OSDN Git Service

Happy new year 2014!
[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 OptionsModel
29 {
30 public:
31         OptionsModel(void);
32         ~OptionsModel(void);
33
34         enum RCMode
35         {
36                 RCMode_CRF = 0,
37                 RCMode_CQ = 1,
38                 RCMode_2Pass = 2,
39                 RCMode_ABR = 3,
40         };
41
42         //Getter
43         RCMode rcMode(void) const { return m_rcMode; }
44         unsigned int bitrate(void) const { return m_bitrate; }
45         double quantizer(void) const { return m_quantizer; }
46         QString preset(void) const { return m_preset; }
47         QString tune(void) const { return m_tune; }
48         QString profile(void) const { return m_profile; }
49         QString customX264(void) const { return m_custom_x264; }
50         QString customAvs2YUV(void) const { return m_custom_avs2yuv; }
51
52         //Setter
53         void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); }
54         void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
55         void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
56         void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
57         void setTune(const QString &tune) { m_tune = tune.trimmed(); }
58         void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
59         void setCustomX264(const QString &custom) { m_custom_x264 = custom.trimmed(); }
60         void setCustomAvs2YUV(const QString &custom) { m_custom_avs2yuv = custom.trimmed(); }
61
62         //Stuff
63         bool equals(OptionsModel *model);
64
65         //Static functions
66         static QString rcMode2String(RCMode mode);
67         static bool saveTemplate(OptionsModel *model, const QString &name);
68         static bool loadTemplate(OptionsModel *model, const QString &name);
69         static QMap<QString, OptionsModel*> loadAllTemplates(void);
70         static bool templateExists(const QString &name);
71         static bool deleteTemplate(const QString &name);
72
73 protected:
74         RCMode m_rcMode;
75         unsigned int m_bitrate;
76         double m_quantizer;
77         QString m_preset;
78         QString m_tune;
79         QString m_profile;
80         QString m_custom_x264;
81         QString m_custom_avs2yuv;
82 };