Initial multi-encoder support. This will allow adding support for x265 in a future version. Also it makes switching between 32-Bit/64-Bit and 8-Bit/10-Bit x264 binaries more convenient.

This commit is contained in:
LoRd_MuldeR 2014-02-10 21:33:04 +01:00
parent 1dd25db214
commit 5d9c70db03
7 changed files with 307 additions and 133 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>569</width> <width>557</width>
<height>614</height> <height>611</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -29,26 +29,19 @@
<string> Input / Output </string> <string> Input / Output </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <property name="spacing">
<spacer name="verticalSpacer_2"> <number>3</number>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="topMargin">
<size> <number>3</number>
<width>0</width>
<height>0</height>
</size>
</property> </property>
</spacer>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_14"> <layout class="QVBoxLayout" name="verticalLayout_14">
<property name="spacing"> <property name="spacing">
<number>4</number> <number>1</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelSource">
<property name="toolTip"> <property name="toolTip">
<string>Select the source video file. This can be an Avisynth/VapourSynth script or any type of video file supported by FFmpegSource2 (libavformat).</string> <string>Select the source video file. This can be an Avisynth/VapourSynth script or any type of video file supported by FFmpegSource2 (libavformat).</string>
</property> </property>
@ -86,26 +79,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing"> <property name="spacing">
<number>4</number> <number>1</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="labelOutput">
<property name="toolTip"> <property name="toolTip">
<string>Select the output H.264/AVC file. This can be a Matroska (MKV,) MPEG-4 Part-14 (MP4) or &quot;raw&quot; H.264 file.</string> <string>Select the output H.264/AVC file. This can be a Matroska (MKV,) MPEG-4 Part-14 (MP4) or &quot;raw&quot; H.264 file.</string>
</property> </property>
@ -143,19 +123,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -165,10 +132,13 @@
<string> Configuration </string> <string> Configuration </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_15"> <layout class="QVBoxLayout" name="verticalLayout_15">
<property name="topMargin">
<number>3</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="labelTemplate">
<property name="toolTip"> <property name="toolTip">
<string>Here you can load a user-defined template that you have saved before. Use the &quot;Save As&quot; button to save your current configuration to a new template.</string> <string>Here you can load a user-defined template that you have saved before. Use the &quot;Save As&quot; button to save your current configuration to a new template.</string>
</property> </property>
@ -253,21 +223,140 @@
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_10"> <widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string> Encoder Selection </string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="topMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<layout class="QVBoxLayout" name="verticalLayout_16">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="labelEncoderType">
<property name="text">
<string>Encoder:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxEncoderType">
<item>
<property name="text">
<string>x264 (AVC)</string>
</property>
</item>
<item>
<property name="text">
<string>x265 (HEVC)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_15">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType"> <property name="sizeType">
<enum>QSizePolicy::Fixed</enum> <enum>QSizePolicy::Fixed</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>16</width>
<height>4</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="labelEncoderArch">
<property name="text">
<string>Architecture:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxEncoderArch">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>32-Bit (x86)</string>
</property>
</item>
<item>
<property name="text">
<string>64-Bit (x86_64)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="labelEncoderVariant">
<property name="text">
<string>Variant:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbxEncoderVariant">
<item>
<property name="text">
<string>8-Bit</string>
</property>
</item>
<item>
<property name="text">
<string>10-Bit</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy"> <property name="sizePolicy">
@ -280,6 +369,9 @@
<string> Rate Control </string> <string> Rate Control </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>3</number>
</property>
<item> <item>
<spacer name="verticalSpacer_4"> <spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">
@ -297,8 +389,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="labelRCMode">
<property name="toolTip"> <property name="toolTip">
<string>Select the x264 rate-control mode. Use 'CRF' mode to hit a specific level of quality or use '2-Pass' mode to hit a specific file size.</string> <string>Select the x264 rate-control mode. Use 'CRF' mode to hit a specific level of quality or use '2-Pass' mode to hit a specific file size.</string>
</property> </property>
@ -357,8 +452,11 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="labelQuantizer">
<property name="toolTip"> <property name="toolTip">
<string>Select the quantizer or CRF value. Smaller value means better quality, but bigger file. Higher value means smaller file, but lower quality. A value of '0' triggers lossless mode.</string> <string>Select the quantizer or CRF value. Smaller value means better quality, but bigger file. Higher value means smaller file, but lower quality. A value of '0' triggers lossless mode.</string>
</property> </property>
@ -403,8 +501,11 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="labelBitrate">
<property name="toolTip"> <property name="toolTip">
<string>Select the target average(!) bitrate, in kilobit/sec. Higher value means better quality, but bigger file. Lower value means smaller file, but lower quality.</string> <string>Select the target average(!) bitrate, in kilobit/sec. Higher value means better quality, but bigger file. Lower value means smaller file, but lower quality.</string>
</property> </property>
@ -461,6 +562,9 @@
<string> Basic Encoder Options </string> <string> Basic Encoder Options </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<property name="topMargin">
<number>3</number>
</property>
<item> <item>
<spacer name="verticalSpacer_6"> <spacer name="verticalSpacer_6">
<property name="orientation"> <property name="orientation">
@ -478,8 +582,11 @@
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_11"> <layout class="QVBoxLayout" name="verticalLayout_11">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="labelPreset">
<property name="toolTip"> <property name="toolTip">
<string>This option controls the &quot;Speed -vs- Quality&quot; trade-off. Use a slower preset to improve the quality at the same bitrate (file size). Use a faster preset to save encoding time, at the cost of reduced quality.</string> <string>This option controls the &quot;Speed -vs- Quality&quot; trade-off. Use a slower preset to improve the quality at the same bitrate (file size). Use a faster preset to save encoding time, at the cost of reduced quality.</string>
</property> </property>
@ -568,8 +675,11 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="labelTuning">
<property name="toolTip"> <property name="toolTip">
<string>This option tweaks x264 for a specific type of source/content. For real-life footage, CGI and most other stuff, use the &quot;Film&quot; option. For anime/cartoon use the &quot;Animation&quot; option.</string> <string>This option tweaks x264 for a specific type of source/content. For real-life footage, CGI and most other stuff, use the &quot;Film&quot; option. For anime/cartoon use the &quot;Animation&quot; option.</string>
</property> </property>
@ -658,8 +768,11 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
<property name="spacing">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="labelProfile">
<property name="toolTip"> <property name="toolTip">
<string>This option can be used to enforce the restrictions of a specific H.264/AVC Proifle, though it won't force a higher profile than needed. Use &quot;Auto&quot; for an unrestricted encode.</string> <string>This option can be used to enforce the restrictions of a specific H.264/AVC Proifle, though it won't force a higher profile than needed. Use &quot;Auto&quot; for an unrestricted encode.</string>
</property> </property>
@ -745,6 +858,9 @@
<string>Advanced Encoder Options </string> <string>Advanced Encoder Options </string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<property name="topMargin">
<number>3</number>
</property>
<item> <item>
<spacer name="verticalSpacer_8"> <spacer name="verticalSpacer_8">
<property name="orientation"> <property name="orientation">
@ -777,7 +893,7 @@
<string>&lt;nobr&gt;All command&amp;minus;line parameters you enter here will be passed to x264 unmodified and unchecked. Some parameters are forbidden, as they are reserved for the GUI.&lt;br&gt;The following macros can be used:&lt;tt&gt; $(INPUT)&lt;/tt&gt; expands to the current source file path and&lt;tt&gt; $(OUTPUT)&lt;/tt&gt; expands to the current output file path.&lt;/nobr&gt;</string> <string>&lt;nobr&gt;All command&amp;minus;line parameters you enter here will be passed to x264 unmodified and unchecked. Some parameters are forbidden, as they are reserved for the GUI.&lt;br&gt;The following macros can be used:&lt;tt&gt; $(INPUT)&lt;/tt&gt; expands to the current source file path and&lt;tt&gt; $(OUTPUT)&lt;/tt&gt; expands to the current output file path.&lt;/nobr&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Custom x264 Parameters:</string> <string>Custom Encoder Parameters:</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -28,15 +28,38 @@
#include <QStringList> #include <QStringList>
#include <QApplication> #include <QApplication>
#define COMPARE_VAL(OTHER, NAME) ((this->NAME) == (OTHER->NAME))
#define COMPARE_STR(OTHER, NAME) ((this->NAME).compare((model->NAME), Qt::CaseInsensitive) == 0)
#define ASSIGN_FROM(OTHER, NAME) ((this->NAME) = (OTHER.NAME))
OptionsModel::OptionsModel(void) OptionsModel::OptionsModel(void)
{ {
m_encoderType = EncType_X264;
m_encoderArch = EncArch_x32;
m_encoderVariant = EncVariant_LoBit;
m_rcMode = RCMode_CRF; m_rcMode = RCMode_CRF;
m_bitrate = 1200; m_bitrate = 1200;
m_quantizer = 22; m_quantizer = 22;
m_preset = "Medium"; m_preset = "Medium";
m_tune = "None"; m_tune = "None";
m_profile = "Auto"; m_profile = "Auto";
m_custom_x264 = ""; m_custom_encoder = "";
m_custom_avs2yuv = "";
}
OptionsModel::OptionsModel(const OptionsModel &rhs)
{
ASSIGN_FROM(rhs, m_encoderType);
ASSIGN_FROM(rhs, m_encoderArch);
ASSIGN_FROM(rhs, m_encoderVariant);
ASSIGN_FROM(rhs, m_rcMode);
ASSIGN_FROM(rhs, m_bitrate);
ASSIGN_FROM(rhs, m_quantizer);
ASSIGN_FROM(rhs, m_preset);
ASSIGN_FROM(rhs, m_tune);
ASSIGN_FROM(rhs, m_profile);
ASSIGN_FROM(rhs, m_custom_encoder);
ASSIGN_FROM(rhs, m_custom_avs2yuv);
} }
OptionsModel::~OptionsModel(void) OptionsModel::~OptionsModel(void)
@ -69,14 +92,17 @@ bool OptionsModel::equals(OptionsModel *model)
{ {
bool equal = true; bool equal = true;
if(this->m_rcMode != model->m_rcMode) equal = false; equal = equal && COMPARE_VAL(model, m_encoderType);
if(this->m_bitrate!= model->m_bitrate) equal = false; equal = equal && COMPARE_VAL(model, m_encoderArch);
if(this->m_quantizer != model->m_quantizer) equal = false; equal = equal && COMPARE_VAL(model, m_encoderVariant);
if(this->m_preset.compare(model->m_preset, Qt::CaseInsensitive)) equal = false; equal = equal && COMPARE_VAL(model, m_rcMode);
if(this->m_tune.compare(model->m_tune, Qt::CaseInsensitive)) equal = false; equal = equal && COMPARE_VAL(model, m_bitrate);
if(this->m_profile.compare(model->m_profile, Qt::CaseInsensitive)) equal = false; equal = equal && COMPARE_VAL(model, m_quantizer);
if(this->m_custom_x264.compare(model->m_custom_x264, Qt::CaseInsensitive)) equal = false; equal = equal && COMPARE_STR(model, m_preset);
if(this->m_custom_avs2yuv.compare(model->m_custom_avs2yuv, Qt::CaseInsensitive)) equal = false; equal = equal && COMPARE_STR(model, m_tune);
equal = equal && COMPARE_STR(model, m_profile);
equal = equal && COMPARE_STR(model, m_custom_encoder);
equal = equal && COMPARE_STR(model, m_custom_avs2yuv);
return equal; return equal;
} }
@ -94,13 +120,16 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat); QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
settings.beginGroup(templateName); settings.beginGroup(templateName);
settings.setValue("encoder_type", model->m_encoderType);
settings.setValue("encoder_arch", model->m_encoderArch);
settings.setValue("encoder_variant", model->m_encoderVariant);
settings.setValue("rate_control_mode", model->m_rcMode); settings.setValue("rate_control_mode", model->m_rcMode);
settings.setValue("target_bitrate", model->m_bitrate); settings.setValue("target_bitrate", model->m_bitrate);
settings.setValue("target_quantizer", model->m_quantizer); settings.setValue("target_quantizer", model->m_quantizer);
settings.setValue("preset_name", model->m_preset); settings.setValue("preset_name", model->m_preset);
settings.setValue("tuning_name", model->m_tune); settings.setValue("tuning_name", model->m_tune);
settings.setValue("profile_name", model->m_profile); settings.setValue("profile_name", model->m_profile);
settings.setValue("custom_params_x264", model->m_custom_x264); settings.setValue("custom_params_encoder", model->m_custom_encoder);
settings.setValue("custom_params_avs2yuv", model->m_custom_avs2yuv); settings.setValue("custom_params_avs2yuv", model->m_custom_avs2yuv);
settings.endGroup(); settings.endGroup();
@ -129,24 +158,30 @@ bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name)
} }
bool complete = true; bool complete = true;
if(!settings.contains("encoder_type")) complete = false;
if(!settings.contains("encoder_arch")) complete = false;
if(!settings.contains("encoder_variant")) complete = false;
if(!settings.contains("rate_control_mode")) complete = false; if(!settings.contains("rate_control_mode")) complete = false;
if(!settings.contains("target_bitrate")) complete = false; if(!settings.contains("target_bitrate")) complete = false;
if(!settings.contains("target_quantizer")) complete = false; if(!settings.contains("target_quantizer")) complete = false;
if(!settings.contains("preset_name")) complete = false; if(!settings.contains("preset_name")) complete = false;
if(!settings.contains("tuning_name")) complete = false; if(!settings.contains("tuning_name")) complete = false;
if(!settings.contains("profile_name")) complete = false; if(!settings.contains("profile_name")) complete = false;
if(!settings.contains("custom_params_x264")) complete = false; if(!settings.contains("custom_params_encoder")) complete = false;
if(!settings.contains("custom_params_avs2yuv")) complete = false; if(!settings.contains("custom_params_avs2yuv")) complete = false;
if(complete) if(complete)
{ {
model->setEncType(static_cast<OptionsModel::EncType>(settings.value("encoder_type", model->m_encoderType).toInt()));
model->setEncArch(static_cast<OptionsModel::EncArch>(settings.value("encoder_arch", model->m_encoderArch).toInt()));
model->setEncVariant(static_cast<OptionsModel::EncVariant>(settings.value("encoder_variant", model->m_encoderVariant).toInt()));
model->setRCMode(static_cast<OptionsModel::RCMode>(settings.value("rate_control_mode", model->m_rcMode).toInt())); model->setRCMode(static_cast<OptionsModel::RCMode>(settings.value("rate_control_mode", model->m_rcMode).toInt()));
model->setBitrate(settings.value("target_bitrate", model->m_bitrate).toUInt()); model->setBitrate(settings.value("target_bitrate", model->m_bitrate).toUInt());
model->setQuantizer(settings.value("target_quantizer", model->m_quantizer).toDouble()); model->setQuantizer(settings.value("target_quantizer", model->m_quantizer).toDouble());
model->setPreset(settings.value("preset_name", model->m_preset).toString()); model->setPreset(settings.value("preset_name", model->m_preset).toString());
model->setTune(settings.value("tuning_name", model->m_tune).toString()); model->setTune(settings.value("tuning_name", model->m_tune).toString());
model->setProfile(settings.value("profile_name", model->m_profile).toString()); model->setProfile(settings.value("profile_name", model->m_profile).toString());
model->setCustomX264(settings.value("custom_params_x264", model->m_custom_x264).toString()); model->setCustomEncParams(settings.value("custom_params_x264", model->m_custom_encoder).toString());
model->setCustomAvs2YUV(settings.value("custom_params_avs2yuv", model->m_custom_avs2yuv).toString()); model->setCustomAvs2YUV(settings.value("custom_params_avs2yuv", model->m_custom_avs2yuv).toString());
} }

View File

@ -29,8 +29,27 @@ class OptionsModel
{ {
public: public:
OptionsModel(void); OptionsModel(void);
OptionsModel(const OptionsModel &rhs);
~OptionsModel(void); ~OptionsModel(void);
enum EncType
{
EncType_X264 = 0,
EncType_X265 = 1,
};
enum EncArch
{
EncArch_x32 = 0,
EncArch_x64 = 1,
};
enum EncVariant
{
EncVariant_LoBit = 0, // 8-Bit
EncVariant_HiBit = 1, //10-Bit (x264) or 16-Bit (x265)
};
enum RCMode enum RCMode
{ {
RCMode_CRF = 0, RCMode_CRF = 0,
@ -40,23 +59,29 @@ public:
}; };
//Getter //Getter
EncType encType(void) const { return m_encoderType; }
EncArch encArch(void) const { return m_encoderArch; }
EncVariant encVariant(void) const { return m_encoderVariant; }
RCMode rcMode(void) const { return m_rcMode; } RCMode rcMode(void) const { return m_rcMode; }
unsigned int bitrate(void) const { return m_bitrate; } unsigned int bitrate(void) const { return m_bitrate; }
double quantizer(void) const { return m_quantizer; } double quantizer(void) const { return m_quantizer; }
QString preset(void) const { return m_preset; } QString preset(void) const { return m_preset; }
QString tune(void) const { return m_tune; } QString tune(void) const { return m_tune; }
QString profile(void) const { return m_profile; } QString profile(void) const { return m_profile; }
QString customX264(void) const { return m_custom_x264; } QString customEncParams(void) const { return m_custom_encoder; }
QString customAvs2YUV(void) const { return m_custom_avs2yuv; } QString customAvs2YUV(void) const { return m_custom_avs2yuv; }
//Setter //Setter
void setEncType(EncType type) { m_encoderType = qBound(EncType_X264, type, EncType_X265); }
void setEncArch(EncArch arch) { m_encoderArch = qBound(EncArch_x32, arch, EncArch_x64); }
void setEncVariant(EncVariant variant) { m_encoderVariant = qBound(EncVariant_LoBit, variant, EncVariant_HiBit); }
void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); } void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); }
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); } void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); } void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
void setPreset(const QString &preset) { m_preset = preset.trimmed(); } void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
void setTune(const QString &tune) { m_tune = tune.trimmed(); } void setTune(const QString &tune) { m_tune = tune.trimmed(); }
void setProfile(const QString &profile) { m_profile = profile.trimmed(); } void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
void setCustomX264(const QString &custom) { m_custom_x264 = custom.trimmed(); } void setCustomEncParams(const QString &custom) { m_custom_encoder = custom.trimmed(); }
void setCustomAvs2YUV(const QString &custom) { m_custom_avs2yuv = custom.trimmed(); } void setCustomAvs2YUV(const QString &custom) { m_custom_avs2yuv = custom.trimmed(); }
//Stuff //Stuff
@ -71,12 +96,15 @@ public:
static bool deleteTemplate(const QString &name); static bool deleteTemplate(const QString &name);
protected: protected:
EncType m_encoderType;
EncArch m_encoderArch;
EncVariant m_encoderVariant;
RCMode m_rcMode; RCMode m_rcMode;
unsigned int m_bitrate; unsigned int m_bitrate;
double m_quantizer; double m_quantizer;
QString m_preset; QString m_preset;
QString m_tune; QString m_tune;
QString m_profile; QString m_profile;
QString m_custom_x264; QString m_custom_encoder;
QString m_custom_avs2yuv; QString m_custom_avs2yuv;
}; };

View File

@ -249,7 +249,7 @@ void EncodeThread::encode(void)
log(tr("Preset: %1").arg(m_options->preset())); log(tr("Preset: %1").arg(m_options->preset()));
log(tr("Tuning: %1").arg(m_options->tune())); log(tr("Tuning: %1").arg(m_options->tune()));
log(tr("Profile: %1").arg(m_options->profile())); log(tr("Profile: %1").arg(m_options->profile()));
log(tr("Custom: %1").arg(m_options->customX264().isEmpty() ? tr("(None)") : m_options->customX264())); log(tr("Custom: %1").arg(m_options->customEncParams().isEmpty() ? tr("(None)") : m_options->customEncParams()));
log(m_binDir); log(m_binDir);
@ -690,9 +690,9 @@ QStringList EncodeThread::buildCommandLine(bool usePipe, bool use10Bit, unsigned
} }
} }
if(!m_options->customX264().isEmpty()) if(!m_options->customEncParams().isEmpty())
{ {
QStringList customArgs = splitParams(m_options->customX264()); QStringList customArgs = splitParams(m_options->customEncParams());
if(usePipe) if(usePipe)
{ {
QStringList::iterator i = customArgs.begin(); QStringList::iterator i = customArgs.begin();

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 3 #define VER_X264_MINOR 3
#define VER_X264_PATCH 1 #define VER_X264_PATCH 1
#define VER_X264_BUILD 754 #define VER_X264_BUILD 758
#define VER_X264_MINIMUM_REV 2380 #define VER_X264_MINIMUM_REV 2380
#define VER_X264_CURRENT_API 142 #define VER_X264_CURRENT_API 142

View File

@ -76,6 +76,18 @@
WIDGET->addAction(_action); \ WIDGET->addAction(_action); \
} }
static void ENABLE_SIGNALS(Ui::AddJobDialog *ui, const bool &flag)
{
ui->cbxRateControlMode->blockSignals(flag);
ui->spinQuantizer->blockSignals(flag);
ui->spinBitrate->blockSignals(flag);
ui->cbxPreset->blockSignals(flag);
ui->cbxTuning->blockSignals(flag);
ui->cbxProfile->blockSignals(flag);
ui->editCustomX264Params->blockSignals(flag);
ui->editCustomAvs2YUVParams->blockSignals(flag);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Validator // Validator
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -227,8 +239,9 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, RecentlyUsed
//Hide optional controls //Hide optional controls
ui->checkBoxApplyToAll->setVisible(false); ui->checkBoxApplyToAll->setVisible(false);
//Monitor RC mode combobox //Monitor combobox changes
connect(ui->cbxRateControlMode, SIGNAL(currentIndexChanged(int)), this, SLOT(modeIndexChanged(int))); connect(ui->cbxRateControlMode, SIGNAL(currentIndexChanged(int)), this, SLOT(modeIndexChanged(int)));
connect(ui->cbxEncoderType, SIGNAL(currentIndexChanged(int)), this, SLOT(encoderIndexChanged(int)));
//Activate buttons //Activate buttons
connect(ui->buttonBrowseSource, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); connect(ui->buttonBrowseSource, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
@ -407,6 +420,15 @@ void AddJobDialog::dropEvent(QDropEvent *event)
// Slots // Slots
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void AddJobDialog::encoderIndexChanged(int index)
{
const bool isX265 = (index >= 1);
ui->cbxEncoderVariant->setItemText(1, isX265 ? tr("16-Bit") : tr("10-Bit"));
ui->cbxProfile->setEnabled(!isX265);
ui->labelProfile->setEnabled(!isX265);
if(isX265) ui->cbxProfile->setCurrentIndex(0);
}
void AddJobDialog::modeIndexChanged(int index) void AddJobDialog::modeIndexChanged(int index)
{ {
ui->spinQuantizer->setEnabled(index == 0 || index == 1); ui->spinQuantizer->setEnabled(index == 0 || index == 1);
@ -534,6 +556,7 @@ void AddJobDialog::templateSelected(void)
restoreOptions(options); restoreOptions(options);
} }
//Force updates
modeIndexChanged(ui->cbxRateControlMode->currentIndex()); modeIndexChanged(ui->cbxRateControlMode->currentIndex());
} }
@ -725,26 +748,6 @@ QString AddJobDialog::outputFile(void)
return QDir::fromNativeSeparators(ui->editOutput->text()); return QDir::fromNativeSeparators(ui->editOutput->text());
} }
QString AddJobDialog::preset(void)
{
return ui->cbxPreset->itemText(ui->cbxPreset->currentIndex());
}
QString AddJobDialog::tuning(void)
{
return ui->cbxTuning->itemText(ui->cbxTuning->currentIndex());
}
QString AddJobDialog::profile(void)
{
return ui->cbxProfile->itemText(ui->cbxProfile->currentIndex());
}
QString AddJobDialog::params(void)
{
return ui->editCustomX264Params->text().simplified();
}
bool AddJobDialog::runImmediately(void) bool AddJobDialog::runImmediately(void)
{ {
return ui->checkBoxRun->isChecked(); return ui->checkBoxRun->isChecked();
@ -812,26 +815,24 @@ void AddJobDialog::loadTemplateList(void)
void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text) void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
{ {
int index = -1;
if(QAbstractItemModel *model = cbox->model())
{
for(int i = 0; i < cbox->model()->rowCount(); i++) for(int i = 0; i < cbox->model()->rowCount(); i++)
{ {
if(cbox->model()->data(cbox->model()->index(i, 0, QModelIndex())).toString().compare(text, Qt::CaseInsensitive) == 0) if(model->data(model->index(i, 0, QModelIndex())).toString().compare(text, Qt::CaseInsensitive) == 0)
{ {
cbox->setCurrentIndex(i); index = i;
break; break;
} }
} }
}
cbox->setCurrentIndex(index);
} }
void AddJobDialog::restoreOptions(OptionsModel *options) void AddJobDialog::restoreOptions(OptionsModel *options)
{ {
ui->cbxRateControlMode->blockSignals(true); ENABLE_SIGNALS(ui, false);
ui->spinQuantizer->blockSignals(true);
ui->spinBitrate->blockSignals(true);
ui->cbxPreset->blockSignals(true);
ui->cbxTuning->blockSignals(true);
ui->cbxProfile->blockSignals(true);
ui->editCustomX264Params->blockSignals(true);
ui->editCustomAvs2YUVParams->blockSignals(true);
ui->cbxRateControlMode->setCurrentIndex(options->rcMode()); ui->cbxRateControlMode->setCurrentIndex(options->rcMode());
ui->spinQuantizer->setValue(options->quantizer()); ui->spinQuantizer->setValue(options->quantizer());
@ -839,28 +840,24 @@ void AddJobDialog::restoreOptions(OptionsModel *options)
updateComboBox(ui->cbxPreset, options->preset()); updateComboBox(ui->cbxPreset, options->preset());
updateComboBox(ui->cbxTuning, options->tune()); updateComboBox(ui->cbxTuning, options->tune());
updateComboBox(ui->cbxProfile, options->profile()); updateComboBox(ui->cbxProfile, options->profile());
ui->editCustomX264Params->setText(options->customX264()); ui->editCustomX264Params->setText(options->customEncParams());
ui->editCustomAvs2YUVParams->setText(options->customAvs2YUV()); ui->editCustomAvs2YUVParams->setText(options->customAvs2YUV());
ui->cbxRateControlMode->blockSignals(false); ENABLE_SIGNALS(ui, true);
ui->spinQuantizer->blockSignals(false);
ui->spinBitrate->blockSignals(false);
ui->cbxPreset->blockSignals(false);
ui->cbxTuning->blockSignals(false);
ui->cbxProfile->blockSignals(false);
ui->editCustomX264Params->blockSignals(false);
ui->editCustomAvs2YUVParams->blockSignals(false);
} }
void AddJobDialog::saveOptions(OptionsModel *options) void AddJobDialog::saveOptions(OptionsModel *options)
{ {
options->setEncType(static_cast<OptionsModel::EncType>(ui->cbxEncoderArch->currentIndex()));
options->setEncArch(static_cast<OptionsModel::EncArch>(ui->cbxEncoderType->currentIndex()));
options->setEncVariant(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant->currentIndex()));
options->setRCMode(static_cast<OptionsModel::RCMode>(ui->cbxRateControlMode->currentIndex())); options->setRCMode(static_cast<OptionsModel::RCMode>(ui->cbxRateControlMode->currentIndex()));
options->setQuantizer(ui->spinQuantizer->value()); options->setQuantizer(ui->spinQuantizer->value());
options->setBitrate(ui->spinBitrate->value()); options->setBitrate(ui->spinBitrate->value());
options->setPreset(ui->cbxPreset->model()->data(ui->cbxPreset->model()->index(ui->cbxPreset->currentIndex(), 0)).toString()); options->setPreset(ui->cbxPreset->model()->data(ui->cbxPreset->model()->index(ui->cbxPreset->currentIndex(), 0)).toString());
options->setTune(ui->cbxTuning->model()->data(ui->cbxTuning->model()->index(ui->cbxTuning->currentIndex(), 0)).toString()); options->setTune(ui->cbxTuning->model()->data(ui->cbxTuning->model()->index(ui->cbxTuning->currentIndex(), 0)).toString());
options->setProfile(ui->cbxProfile->model()->data(ui->cbxProfile->model()->index(ui->cbxProfile->currentIndex(), 0)).toString()); options->setProfile(ui->cbxProfile->model()->data(ui->cbxProfile->model()->index(ui->cbxProfile->currentIndex(), 0)).toString());
options->setCustomX264(ui->editCustomX264Params->hasAcceptableInput() ? ui->editCustomX264Params->text().simplified() : QString()); options->setCustomEncParams(ui->editCustomX264Params->hasAcceptableInput() ? ui->editCustomX264Params->text().simplified() : QString());
options->setCustomAvs2YUV(ui->editCustomAvs2YUVParams->hasAcceptableInput() ? ui->editCustomAvs2YUVParams->text().simplified() : QString()); options->setCustomAvs2YUV(ui->editCustomAvs2YUVParams->hasAcceptableInput() ? ui->editCustomAvs2YUVParams->text().simplified() : QString());
} }

View File

@ -42,10 +42,7 @@ public:
QString sourceFile(void); QString sourceFile(void);
QString outputFile(void); QString outputFile(void);
QString preset(void);
QString tuning(void);
QString profile(void);
QString params(void);
bool runImmediately(void); bool runImmediately(void);
bool applyToAll(void); bool applyToAll(void);
void setRunImmediately(bool run); void setRunImmediately(bool run);
@ -76,6 +73,7 @@ protected:
virtual void dropEvent(QDropEvent *event); virtual void dropEvent(QDropEvent *event);
private slots: private slots:
void encoderIndexChanged(int index);
void modeIndexChanged(int index); void modeIndexChanged(int index);
void browseButtonClicked(void); void browseButtonClicked(void);
void configurationChanged(void); void configurationChanged(void);