2012-01-29 19:14:46 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Simple x264 Launcher
|
2017-01-07 18:48:20 +01:00
|
|
|
// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
|
2012-01-29 19:14:46 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2012-01-31 22:30:21 +01:00
|
|
|
#include <QMap>
|
2012-01-29 19:14:46 +01:00
|
|
|
|
2014-02-15 00:40:15 +01:00
|
|
|
class SysinfoModel;
|
2014-04-18 14:41:20 +02:00
|
|
|
class QSettings;
|
2014-02-15 00:40:15 +01:00
|
|
|
|
2012-01-29 19:14:46 +01:00
|
|
|
class OptionsModel
|
|
|
|
{
|
|
|
|
public:
|
2014-02-15 00:40:15 +01:00
|
|
|
OptionsModel(const SysinfoModel *sysinfo);
|
2014-02-10 21:33:04 +01:00
|
|
|
OptionsModel(const OptionsModel &rhs);
|
2012-01-29 19:14:46 +01:00
|
|
|
~OptionsModel(void);
|
|
|
|
|
2014-02-10 21:33:04 +01:00
|
|
|
enum EncType
|
|
|
|
{
|
2016-05-07 17:39:12 +02:00
|
|
|
EncType_X264 = 0,
|
|
|
|
EncType_X265 = 1,
|
|
|
|
EncType_NVEnc = 2,
|
2015-08-02 19:16:37 +02:00
|
|
|
|
|
|
|
EncType_MIN = EncType_X264,
|
2016-05-07 17:39:12 +02:00
|
|
|
EncType_MAX = EncType_NVEnc,
|
2014-02-10 21:33:04 +01:00
|
|
|
};
|
|
|
|
|
2015-08-02 22:13:14 +02:00
|
|
|
static const char *const SETTING_UNSPECIFIED;
|
2014-04-16 16:05:24 +02:00
|
|
|
static const char *const PROFILE_UNRESTRICTED;
|
|
|
|
|
2012-01-29 19:14:46 +01:00
|
|
|
//Getter
|
2015-11-18 20:48:54 +01:00
|
|
|
EncType encType(void) const { return m_encoderType; }
|
2016-05-08 15:33:09 +02:00
|
|
|
quint32 encArch(void) const { return m_encoderArch; }
|
|
|
|
quint32 encVariant(void) const { return m_encoderVariant; }
|
|
|
|
quint32 rcMode(void) const { return m_rcMode; }
|
2015-11-18 20:48:54 +01:00
|
|
|
unsigned int bitrate(void) const { return m_bitrate; }
|
|
|
|
double quantizer(void) const { return m_quantizer; }
|
|
|
|
QString preset(void) const { return m_preset; }
|
|
|
|
QString tune(void) const { return m_tune; }
|
|
|
|
QString profile(void) const { return m_profile; }
|
2014-02-10 21:33:04 +01:00
|
|
|
QString customEncParams(void) const { return m_custom_encoder; }
|
2015-11-18 20:48:54 +01:00
|
|
|
QString customAvs2YUV(void) const { return m_custom_avs2yuv; }
|
2012-01-29 19:14:46 +01:00
|
|
|
|
|
|
|
//Setter
|
2016-05-08 15:33:09 +02:00
|
|
|
void setEncType(quint32 type) { setEncType(static_cast<EncType>(type)); }
|
2016-05-07 17:39:12 +02:00
|
|
|
void setEncType(EncType type) { m_encoderType = qBound(EncType_MIN, type, EncType_MAX); }
|
2016-05-08 15:33:09 +02:00
|
|
|
void setEncArch(quint32 arch) { m_encoderArch = arch; }
|
|
|
|
void setEncVariant(quint32 variant) { m_encoderVariant = variant; }
|
|
|
|
void setRCMode(quint32 mode) { m_rcMode = mode; }
|
2015-11-18 20:48:54 +01:00
|
|
|
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
|
|
|
|
void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
|
|
|
|
void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
|
|
|
|
void setTune(const QString &tune) { m_tune = tune.trimmed(); }
|
|
|
|
void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
|
2014-02-10 21:33:04 +01:00
|
|
|
void setCustomEncParams(const QString &custom) { m_custom_encoder = custom.trimmed(); }
|
2015-11-18 20:48:54 +01:00
|
|
|
void setCustomAvs2YUV(const QString &custom) { m_custom_avs2yuv = custom.trimmed(); }
|
2012-01-29 19:14:46 +01:00
|
|
|
|
2012-01-31 03:03:17 +01:00
|
|
|
//Stuff
|
2014-02-12 21:36:10 +01:00
|
|
|
bool equals(const OptionsModel *model);
|
2012-01-31 03:03:17 +01:00
|
|
|
|
2012-01-31 22:30:21 +01:00
|
|
|
//Static functions
|
2014-04-18 14:41:20 +02:00
|
|
|
static bool saveTemplate(const OptionsModel *model, const QString &name);
|
2012-02-09 02:06:29 +01:00
|
|
|
static bool loadTemplate(OptionsModel *model, const QString &name);
|
2014-02-15 00:40:15 +01:00
|
|
|
static QMap<QString, OptionsModel*> loadAllTemplates(const SysinfoModel *sysinfo);
|
2012-01-31 22:30:21 +01:00
|
|
|
static bool templateExists(const QString &name);
|
|
|
|
static bool deleteTemplate(const QString &name);
|
2014-04-18 14:41:20 +02:00
|
|
|
static bool saveOptions(const OptionsModel *model, QSettings &settingsFile);
|
|
|
|
static bool loadOptions(OptionsModel *model, QSettings &settingsFile);
|
2012-01-29 19:14:46 +01:00
|
|
|
|
|
|
|
protected:
|
2014-02-10 21:33:04 +01:00
|
|
|
EncType m_encoderType;
|
2016-05-08 15:33:09 +02:00
|
|
|
quint32 m_encoderArch;
|
|
|
|
quint32 m_encoderVariant;
|
|
|
|
quint32 m_rcMode;
|
2012-01-29 19:14:46 +01:00
|
|
|
unsigned int m_bitrate;
|
2012-02-04 15:56:38 +01:00
|
|
|
double m_quantizer;
|
2012-01-29 19:14:46 +01:00
|
|
|
QString m_preset;
|
|
|
|
QString m_tune;
|
|
|
|
QString m_profile;
|
2014-02-10 21:33:04 +01:00
|
|
|
QString m_custom_encoder;
|
2012-02-12 15:58:28 +01:00
|
|
|
QString m_custom_avs2yuv;
|
2014-08-13 15:38:17 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void fixTemplate(QSettings &settingsFile);
|
2012-01-29 19:14:46 +01:00
|
|
|
};
|