OSDN Git Service

The list of supported profiles will now be loaded from the EncoderInfo object, depend...
[x264-launcher/x264-launcher.git] / src / model_options.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 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 <QObject>
25 #include <QString>
26 #include <QMap>
27
28 class SysinfoModel;
29
30 class OptionsModel
31 {
32 public:
33         OptionsModel(const SysinfoModel *sysinfo);
34         OptionsModel(const OptionsModel &rhs);
35         ~OptionsModel(void);
36
37         enum EncType
38         {
39                 EncType_X264 = 0,
40                 EncType_X265 = 1,
41         };
42
43         enum EncArch
44         {
45                 EncArch_x32 = 0,
46                 EncArch_x64 = 1
47         };
48
49         enum EncVariant
50         {
51                 EncVariant_LoBit = 0, // 8-Bit
52                 EncVariant_HiBit = 1, //10-Bit (x264) or 16-Bit (x265)
53         };
54
55         enum RCMode
56         {
57                 RCMode_CRF = 0,
58                 RCMode_CQ = 1,
59                 RCMode_2Pass = 2,
60                 RCMode_ABR = 3,
61         };
62
63         static const char *const PROFILE_UNRESTRICTED;
64
65         //Getter
66         EncType encType(void) const { return m_encoderType; }
67         EncArch encArch(void) const { return m_encoderArch; }
68         EncVariant encVariant(void) const { return m_encoderVariant; }
69         RCMode rcMode(void) const { return m_rcMode; }
70         unsigned int bitrate(void) const { return m_bitrate; }
71         double quantizer(void) const { return m_quantizer; }
72         QString preset(void) const { return m_preset; }
73         QString tune(void) const { return m_tune; }
74         QString profile(void) const { return m_profile; }
75         QString customEncParams(void) const { return m_custom_encoder; }
76         QString customAvs2YUV(void) const { return m_custom_avs2yuv; }
77
78         //Setter
79         void setEncType(EncType type) { m_encoderType = qBound(EncType_X264, type, EncType_X265); }
80         void setEncArch(EncArch arch) { m_encoderArch = qBound(EncArch_x32, arch, EncArch_x64); }
81         void setEncVariant(EncVariant variant) { m_encoderVariant = qBound(EncVariant_LoBit, variant, EncVariant_HiBit); }
82         void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); }
83         void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
84         void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
85         void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
86         void setTune(const QString &tune) { m_tune = tune.trimmed(); }
87         void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
88         void setCustomEncParams(const QString &custom) { m_custom_encoder = custom.trimmed(); }
89         void setCustomAvs2YUV(const QString &custom) { m_custom_avs2yuv = custom.trimmed(); }
90
91         //Stuff
92         bool equals(const OptionsModel *model);
93
94         //Static functions
95         static QString rcMode2String(RCMode mode);
96         static bool saveTemplate(OptionsModel *model, const QString &name);
97         static bool loadTemplate(OptionsModel *model, const QString &name);
98         static QMap<QString, OptionsModel*> loadAllTemplates(const SysinfoModel *sysinfo);
99         static bool templateExists(const QString &name);
100         static bool deleteTemplate(const QString &name);
101
102 protected:
103         EncType m_encoderType;
104         EncArch m_encoderArch;
105         EncVariant m_encoderVariant;
106         RCMode m_rcMode;
107         unsigned int m_bitrate;
108         double m_quantizer;
109         QString m_preset;
110         QString m_tune;
111         QString m_profile;
112         QString m_custom_encoder;
113         QString m_custom_avs2yuv;
114 };