OSDN Git Service

Bump version.
[x264-launcher/x264-launcher.git] / src / encoder_abstract.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 //////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 #include "tool_abstract.h"
25 #include "model_options.h"
26
27 class QRegExp;
28 template<class T> class QList;
29 template <class T1, class T2> struct QPair;
30 class AbstractSource;
31 class ClipInfo;
32
33 class AbstractEncoderInfo
34 {
35 public:
36         typedef enum _RCType
37         {
38                 RC_TYPE_QUANTIZER = 0,
39                 RC_TYPE_RATE_KBPS = 1,
40                 RC_TYPE_MULTIPASS = 2
41         }
42         RCType;
43
44         typedef enum _ArchBit
45         {
46                 ARCH_TYPE_X86 = 0,
47                 ARCH_TYPE_X64 = 1,
48         }
49         ArchBit;
50
51         typedef QPair<QString, RCType>  RCMode;
52         typedef QPair<QString, ArchBit> ArchId;
53
54         virtual QString       getName(void) const = 0;
55         virtual QString       getFullName(const quint32 &encArch, const quint32 &encVariant) const;
56         virtual QList<ArchId> getArchitectures(void) const = 0;
57         virtual QStringList   getVariants(void) const = 0;
58         virtual QList<RCMode> getRCModes(void) const = 0;
59         virtual QStringList   getProfiles(const quint32 &variant) const = 0;
60         virtual QStringList   getTunings(void) const = 0;
61         virtual QStringList   getPresets(void) const = 0;
62         virtual QStringList   supportedOutputFormats(void) const = 0;
63         virtual bool          isInputTypeSupported(const int format) const = 0;
64         virtual QString       getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const = 0;
65         virtual QStringList   getDependencies(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const;
66         virtual QString       getHelpCommand(void) const = 0;
67
68         //Utilities
69         QString archToString   (const quint32 &index) const;
70         ArchBit archToType     (const quint32 &index) const;
71         QString variantToString(const quint32 &index) const;
72         QString rcModeToString (const quint32 &index) const;
73         RCType  rcModeToType   (const quint32 &index) const;
74 };
75
76 class AbstractEncoder : public AbstractTool
77 {
78 public:
79         AbstractEncoder(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile, const QString &outputFile);
80         virtual ~AbstractEncoder(void);
81
82         virtual bool runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const ClipInfo &clipInfo, const int &pass = 0, const QString &passLogFile = QString());
83         
84         virtual const AbstractEncoderInfo& getEncoderInfo(void) const = 0;
85
86 protected:
87         virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile) = 0;
88
89         virtual void runEncodingPass_init(QList<QRegExp*> &patterns) = 0;
90         virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate) = 0;
91
92         static double estimateSize(const QString &fileName, const double &progress);
93         static QString sizeToString(qint64 size);
94
95         const QString &m_sourceFile;
96         const QString &m_outputFile;
97         const QString m_indexFile;
98 };