OSDN Git Service

Some re-design of AbstractEncoderInfo to allow more flexible encoder variants and...
[x264-launcher/x264-launcher.git] / src / model_options.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 <QObject>
25 #include <QString>
26 #include <QMap>
27
28 class SysinfoModel;
29 class QSettings;
30
31 class OptionsModel
32 {
33 public:
34         OptionsModel(const SysinfoModel *sysinfo);
35         OptionsModel(const OptionsModel &rhs);
36         ~OptionsModel(void);
37
38         enum EncType
39         {
40                 EncType_X264  = 0,
41                 EncType_X265  = 1,
42                 EncType_NVEnc = 2,
43
44                 EncType_MIN  = EncType_X264,
45                 EncType_MAX  = EncType_NVEnc,
46         };
47
48         static const char *const SETTING_UNSPECIFIED;
49         static const char *const PROFILE_UNRESTRICTED;
50
51         //Getter
52         EncType encType(void)         const { return m_encoderType; }
53         quint32 encArch(void)         const { return m_encoderArch; }
54         quint32 encVariant(void)      const { return m_encoderVariant; }
55         quint32 rcMode(void)          const { return m_rcMode; }
56         unsigned int bitrate(void)    const { return m_bitrate; }
57         double quantizer(void)        const { return m_quantizer; }
58         QString preset(void)          const { return m_preset; }
59         QString tune(void)            const { return m_tune; }
60         QString profile(void)         const { return m_profile; }
61         QString customEncParams(void) const { return m_custom_encoder; }
62         QString customAvs2YUV(void)   const { return m_custom_avs2yuv; }
63
64         //Setter
65         void setEncType(quint32 type)                  { setEncType(static_cast<EncType>(type)); }
66         void setEncType(EncType type)                  { m_encoderType = qBound(EncType_MIN, type, EncType_MAX); }
67         void setEncArch(quint32 arch)                  { m_encoderArch = arch; }
68         void setEncVariant(quint32 variant)            { m_encoderVariant = variant; }
69         void setRCMode(quint32 mode)                   { m_rcMode = mode; }
70         void setBitrate(unsigned int bitrate)          { m_bitrate = qBound(10U, bitrate, 800000U); }
71         void setQuantizer(double quantizer)            { m_quantizer = qBound(0.0, quantizer, 52.0); }
72         void setPreset(const QString &preset)          { m_preset = preset.trimmed(); }
73         void setTune(const QString &tune)              { m_tune = tune.trimmed(); }
74         void setProfile(const QString &profile)        { m_profile = profile.trimmed(); }
75         void setCustomEncParams(const QString &custom) { m_custom_encoder = custom.trimmed(); }
76         void setCustomAvs2YUV(const QString &custom)   { m_custom_avs2yuv = custom.trimmed(); }
77
78         //Stuff
79         bool equals(const OptionsModel *model);
80
81         //Static functions
82         static bool saveTemplate(const OptionsModel *model, const QString &name);
83         static bool loadTemplate(OptionsModel *model, const QString &name);
84         static QMap<QString, OptionsModel*> loadAllTemplates(const SysinfoModel *sysinfo);
85         static bool templateExists(const QString &name);
86         static bool deleteTemplate(const QString &name);
87         static bool saveOptions(const OptionsModel *model, QSettings &settingsFile);
88         static bool loadOptions(OptionsModel *model, QSettings &settingsFile);
89
90 protected:
91         EncType m_encoderType;
92         quint32 m_encoderArch;
93         quint32 m_encoderVariant;
94         quint32 m_rcMode;
95         unsigned int m_bitrate;
96         double m_quantizer;
97         QString m_preset;
98         QString m_tune;
99         QString m_profile;
100         QString m_custom_encoder;
101         QString m_custom_avs2yuv;
102
103 private:
104         static void fixTemplate(QSettings &settingsFile);
105 };