Correctly handle the case when Preset and/or Tune is "UNSPECIFIED".

This commit is contained in:
LoRd_MuldeR 2015-08-02 22:13:14 +02:00
parent e1c33653bb
commit 1123701e6f
5 changed files with 41 additions and 23 deletions

View File

@ -338,21 +338,30 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
cmdLine << "--stats" << QDir::toNativeSeparators(passLogFile);
}
cmdLine << "--preset" << m_options->preset().toLower();
if(!m_options->tune().simplified().isEmpty())
const QString preset = m_options->preset().simplified().toLower();
if(!preset.isEmpty())
{
if(m_options->tune().simplified().compare(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
if(preset.compare(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--tune" << m_options->tune().simplified().toLower();
cmdLine << "--preset" << preset;
}
}
if(!m_options->profile().simplified().isEmpty())
const QString tune = m_options->tune().simplified().toLower();
if(!tune.isEmpty())
{
if(m_options->profile().simplified().compare(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED), Qt::CaseInsensitive) != 0)
if(tune.compare(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--profile" << m_options->profile().simplified().toLower();
cmdLine << "--tune" << tune;
}
}
const QString profile = m_options->profile().simplified().toLower();
if(!profile.isEmpty())
{
if(profile.compare(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--profile" << profile;
}
}

View File

@ -334,21 +334,30 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
cmdLine << "--stats" << QDir::toNativeSeparators(passLogFile);
}
cmdLine << "--preset" << m_options->preset().toLower();
if(!m_options->tune().simplified().isEmpty())
const QString preset = m_options->preset().simplified().toLower();
if(!preset.isEmpty())
{
if(m_options->tune().simplified().compare(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
if(preset.compare(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--tune" << m_options->tune().simplified().toLower();
cmdLine << "--preset" << preset;
}
}
if(!m_options->profile().simplified().isEmpty())
const QString tune = m_options->tune().simplified().toLower();
if(!tune.isEmpty())
{
if(m_options->profile().simplified().compare(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED), Qt::CaseInsensitive) != 0)
if(tune.compare(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--profile" << m_options->profile().simplified().toLower();
cmdLine << "--tune" << tune;
}
}
const QString profile = m_options->profile().simplified().toLower();
if(!profile.isEmpty())
{
if(profile.compare(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED), Qt::CaseInsensitive) != 0)
{
cmdLine << "--profile" << profile;
}
}

View File

@ -51,7 +51,7 @@ static const char *KEY_PROFILE_NAME = "profile_name";
static const char *KEY_CUSTOM_ENCODER = "custom_params_encoder";
static const char *KEY_CUSTOM_AVS2YUV = "custom_params_avs2yuv";
const char *const OptionsModel::TUNING_UNSPECIFIED = "<None>";
const char *const OptionsModel::SETTING_UNSPECIFIED = "<None>";
const char *const OptionsModel::PROFILE_UNRESTRICTED = "<Unrestricted>";
OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
@ -63,7 +63,7 @@ OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
m_bitrate = 1200;
m_quantizer = 22;
m_preset = "Medium";
m_tune = QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED);
m_tune = QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED);
m_profile = QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED);
m_custom_encoder = QString();
m_custom_avs2yuv = QString();
@ -292,6 +292,6 @@ void OptionsModel::fixTemplate(QSettings &settingsFile)
}
if(settingsFile.value(KEY_TUNING_NAME).toString().compare("none", Qt::CaseInsensitive) == 0)
{
settingsFile.setValue(KEY_TUNING_NAME, QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
settingsFile.setValue(KEY_TUNING_NAME, QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED));
}
}

View File

@ -74,7 +74,7 @@ public:
RCMode_MAX = RCMode_ABR,
};
static const char *const TUNING_UNSPECIFIED;
static const char *const SETTING_UNSPECIFIED;
static const char *const PROFILE_UNRESTRICTED;
//Getter

View File

@ -294,7 +294,7 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *const options, Recentl
ui->cbxRateControlMode->addItem(tr("ABR"), OptionsModel::RCMode_ABR);
//Init combobox items
ui->cbxTuning ->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
ui->cbxTuning ->addItem(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED));
ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));
//Hide optional controls
@ -524,7 +524,7 @@ void AddJobDialog::encoderIndexChanged(int index)
{
ui->cbxPreset->setEnabled(true);
ui->cbxPreset->clear();
ui->cbxPreset->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
ui->cbxPreset->addItem(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED));
ui->cbxPreset->addItems(presets);
}
@ -539,7 +539,7 @@ void AddJobDialog::encoderIndexChanged(int index)
{
ui->cbxTuning->setEnabled(true);
ui->cbxTuning->clear();
ui->cbxTuning->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
ui->cbxTuning->addItem(QString::fromLatin1(OptionsModel::SETTING_UNSPECIFIED));
ui->cbxTuning->addItems(tunings);
}