The list of supported profiles will now be loaded from the EncoderInfo object, depending on the select Encoder *and* Variant.
This commit is contained in:
parent
23dacbaddf
commit
383bf1c0dd
@ -327,6 +327,10 @@ QString AbstractEncoder::sizeToString(qint64 size)
|
||||
return tr("N/A");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// Encoder Info
|
||||
// ------------------------------------------------------------
|
||||
|
||||
const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void)
|
||||
{
|
||||
THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");
|
||||
|
@ -30,7 +30,9 @@ class AbstractSource;
|
||||
class AbstractEncoderInfo
|
||||
{
|
||||
public:
|
||||
virtual QStringList supportedInputFormats (void) const = 0;
|
||||
virtual QString getVariantId(const int &variant) const = 0;
|
||||
virtual QStringList getProfiles(const int &variant) const = 0;
|
||||
virtual QStringList supportedInputFormats(void) const = 0;
|
||||
virtual QStringList supportedOutputFormats(void) const = 0;
|
||||
virtual bool isRCModeSupported(const int rcMode) const = 0;
|
||||
};
|
||||
|
@ -84,6 +84,35 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
|
||||
class X264EncoderInfo : public AbstractEncoderInfo
|
||||
{
|
||||
public:
|
||||
virtual QString getVariantId(const int &variant) const
|
||||
{
|
||||
switch(variant)
|
||||
{
|
||||
case OptionsModel::EncVariant_LoBit:
|
||||
return QString::fromLatin1("8-Bit");
|
||||
case OptionsModel::EncVariant_HiBit:
|
||||
return QString::fromLatin1("10-Bit");
|
||||
default:
|
||||
return QString::fromLatin1("N/A");
|
||||
}
|
||||
}
|
||||
|
||||
virtual QStringList getProfiles(const int &variant) const
|
||||
{
|
||||
QStringList profiles;
|
||||
|
||||
if(variant == OptionsModel::EncVariant_LoBit)
|
||||
{
|
||||
profiles << "Baseline" << "Main" << "High";
|
||||
}
|
||||
if((variant == OptionsModel::EncVariant_LoBit) || (variant == OptionsModel::EncVariant_HiBit))
|
||||
{
|
||||
profiles << "High10" << "High422" << "High444";
|
||||
}
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
virtual QStringList supportedInputFormats(void) const
|
||||
{
|
||||
QStringList extLst;
|
||||
@ -267,11 +296,11 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
|
||||
cmdLine << "--tune" << m_options->tune().toLower();
|
||||
}
|
||||
|
||||
if(m_options->profile().compare("auto", Qt::CaseInsensitive) != 0)
|
||||
if(!m_options->profile().simplified().isEmpty())
|
||||
{
|
||||
if((m_options->encType() == OptionsModel::EncType_X264) && (m_options->encVariant() == OptionsModel::EncVariant_LoBit))
|
||||
if(m_options->profile().simplified().compare(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED), Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
cmdLine << "--profile" << m_options->profile().toLower();
|
||||
cmdLine << "--profile" << m_options->profile().simplified().toLower();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,24 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
|
||||
class X265EncoderInfo : public AbstractEncoderInfo
|
||||
{
|
||||
public:
|
||||
virtual QString getVariantId(const int &variant) const
|
||||
{
|
||||
switch(variant)
|
||||
{
|
||||
case OptionsModel::EncVariant_LoBit:
|
||||
return QString::fromLatin1("8-Bit");
|
||||
case OptionsModel::EncVariant_HiBit:
|
||||
return QString::fromLatin1("16-Bit");
|
||||
default:
|
||||
return QString::fromLatin1("N/A");
|
||||
}
|
||||
}
|
||||
|
||||
virtual QStringList getProfiles(const int &variant) const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
virtual QStringList supportedInputFormats(void) const
|
||||
{
|
||||
QStringList extLst;
|
||||
|
@ -46,6 +46,8 @@ 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::PROFILE_UNRESTRICTED = "<Unrestricted>";
|
||||
|
||||
OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
|
||||
{
|
||||
m_encoderType = EncType_X264;
|
||||
@ -56,9 +58,9 @@ OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
|
||||
m_quantizer = 22;
|
||||
m_preset = "Medium";
|
||||
m_tune = "None";
|
||||
m_profile = "Auto";
|
||||
m_custom_encoder = "";
|
||||
m_custom_avs2yuv = "";
|
||||
m_profile = QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED);
|
||||
m_custom_encoder = QString();
|
||||
m_custom_avs2yuv = QString();
|
||||
}
|
||||
|
||||
OptionsModel::OptionsModel(const OptionsModel &rhs)
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
RCMode_ABR = 3,
|
||||
};
|
||||
|
||||
static const char *const PROFILE_UNRESTRICTED;
|
||||
|
||||
//Getter
|
||||
EncType encType(void) const { return m_encoderType; }
|
||||
EncArch encArch(void) const { return m_encoderArch; }
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 3
|
||||
#define VER_X264_PATCH 5
|
||||
#define VER_X264_BUILD 818
|
||||
#define VER_X264_BUILD 820
|
||||
|
||||
#define VER_X264_PORTABLE_EDITION (0)
|
||||
|
||||
|
@ -244,6 +244,9 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *const options, Recentl
|
||||
setMinimumSize(size());
|
||||
setMaximumHeight(height());
|
||||
|
||||
//Init combobox items
|
||||
ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));
|
||||
|
||||
//Hide optional controls
|
||||
ui->checkBoxApplyToAll->setVisible(false);
|
||||
|
||||
@ -435,24 +438,33 @@ void AddJobDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
void AddJobDialog::encoderIndexChanged(int index)
|
||||
{
|
||||
const bool isX265 = (index > 0);
|
||||
const bool noProf = isX265 || (ui->cbxEncoderVariant->currentIndex() > 0);
|
||||
const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
|
||||
|
||||
ui->cbxEncoderVariant->setItemText(1, isX265 ? tr("16-Bit") : tr("10-Bit"));
|
||||
ui->labelProfile->setEnabled(!noProf);
|
||||
ui->cbxProfile->setEnabled(!noProf);
|
||||
if(noProf) ui->cbxProfile->setCurrentIndex(0);
|
||||
//Update encoder variants
|
||||
ui->cbxEncoderVariant->setItemText(OptionsModel::EncVariant_LoBit, encoderInfo.getVariantId(OptionsModel::EncVariant_LoBit));
|
||||
ui->cbxEncoderVariant->setItemText(OptionsModel::EncVariant_HiBit, encoderInfo.getVariantId(OptionsModel::EncVariant_HiBit));
|
||||
|
||||
variantIndexChanged(ui->cbxEncoderVariant->currentIndex());
|
||||
}
|
||||
|
||||
void AddJobDialog::variantIndexChanged(int index)
|
||||
{
|
||||
const bool noProf = (index > 0) || (ui->cbxEncoderType->currentIndex() > 0);
|
||||
const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
|
||||
|
||||
ui->labelProfile->setEnabled(!noProf);
|
||||
ui->cbxProfile->setEnabled(!noProf);
|
||||
if(noProf) ui->cbxProfile->setCurrentIndex(0);
|
||||
//Update encoder profiles
|
||||
QStringList profiles = encoderInfo.getProfiles(index);
|
||||
if(profiles.empty())
|
||||
{
|
||||
ui->cbxProfile->setEnabled(false);
|
||||
ui->cbxProfile->setCurrentIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->cbxProfile->setEnabled(true);
|
||||
ui->cbxProfile->clear();
|
||||
ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));
|
||||
ui->cbxProfile->addItems(profiles);
|
||||
}
|
||||
|
||||
modeIndexChanged(ui->cbxRateControlMode->currentIndex());
|
||||
}
|
||||
@ -552,7 +564,6 @@ void AddJobDialog::accept(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Is output file extension supported by encoder?
|
||||
const QStringList outputFormats = encoderInfo.supportedOutputFormats();
|
||||
QFileInfo outputFile = QFileInfo(this->outputFile());
|
||||
@ -660,11 +671,6 @@ void AddJobDialog::templateSelected(void)
|
||||
REMOVE_USAFED_ITEM;
|
||||
restoreOptions(options);
|
||||
}
|
||||
|
||||
//Force updates
|
||||
encoderIndexChanged(ui->cbxEncoderType->currentIndex());
|
||||
variantIndexChanged(ui->cbxEncoderVariant->currentIndex());
|
||||
modeIndexChanged(ui->cbxRateControlMode->currentIndex());
|
||||
}
|
||||
|
||||
void AddJobDialog::saveTemplateButtonClicked(void)
|
||||
@ -922,7 +928,7 @@ void AddJobDialog::loadTemplateList(void)
|
||||
|
||||
void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
|
||||
{
|
||||
int index = -1;
|
||||
int index = 0;
|
||||
if(QAbstractItemModel *model = cbox->model())
|
||||
{
|
||||
for(int i = 0; i < cbox->model()->rowCount(); i++)
|
||||
@ -939,12 +945,15 @@ void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
|
||||
|
||||
void AddJobDialog::restoreOptions(const OptionsModel *options)
|
||||
{
|
||||
BLOCK_SIGNALS(true);
|
||||
BLOCK_SIGNALS(false);
|
||||
|
||||
ui->cbxEncoderType->setCurrentIndex(options->encType());
|
||||
ui->cbxEncoderArch->setCurrentIndex(options->encArch());
|
||||
ui->cbxEncoderVariant->setCurrentIndex(options->encVariant());
|
||||
ui->cbxRateControlMode->setCurrentIndex(options->rcMode());
|
||||
|
||||
BLOCK_SIGNALS(true);
|
||||
|
||||
ui->spinQuantizer->setValue(options->quantizer());
|
||||
ui->spinBitrate->setValue(options->bitrate());
|
||||
updateComboBox(ui->cbxPreset, options->preset());
|
||||
@ -962,11 +971,14 @@ void AddJobDialog::saveOptions(OptionsModel *options)
|
||||
options->setEncArch(static_cast<OptionsModel::EncArch>(ui->cbxEncoderArch->currentIndex()));
|
||||
options->setEncVariant(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant->currentIndex()));
|
||||
options->setRCMode(static_cast<OptionsModel::RCMode>(ui->cbxRateControlMode->currentIndex()));
|
||||
|
||||
options->setQuantizer(ui->spinQuantizer->value());
|
||||
options->setBitrate(ui->spinBitrate->value());
|
||||
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->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->setProfile(ui->cbxProfile->model()->data(ui->cbxProfile->model()->index(ui->cbxProfile->currentIndex(), 0)).toString());
|
||||
|
||||
options->setCustomEncParams(ui->editCustomX264Params->hasAcceptableInput() ? ui->editCustomX264Params->text().simplified() : QString());
|
||||
options->setCustomAvs2YUV(ui->editCustomAvs2YUVParams->hasAcceptableInput() ? ui->editCustomAvs2YUVParams->text().simplified() : QString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user