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:
LoRd_MuldeR 2014-04-16 16:05:24 +02:00
parent 23dacbaddf
commit 383bf1c0dd
8 changed files with 106 additions and 37 deletions

View File

@ -327,6 +327,10 @@ QString AbstractEncoder::sizeToString(qint64 size)
return tr("N/A"); return tr("N/A");
} }
// ------------------------------------------------------------
// Encoder Info
// ------------------------------------------------------------
const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void) const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void)
{ {
THROW("[getEncoderInfo] This function must be overwritten in sub-classes!"); THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");

View File

@ -30,7 +30,9 @@ class AbstractSource;
class AbstractEncoderInfo class AbstractEncoderInfo
{ {
public: 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 QStringList supportedOutputFormats(void) const = 0;
virtual bool isRCModeSupported(const int rcMode) const = 0; virtual bool isRCModeSupported(const int rcMode) const = 0;
}; };

View File

@ -84,6 +84,35 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
class X264EncoderInfo : public AbstractEncoderInfo class X264EncoderInfo : public AbstractEncoderInfo
{ {
public: 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 virtual QStringList supportedInputFormats(void) const
{ {
QStringList extLst; QStringList extLst;
@ -267,11 +296,11 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
cmdLine << "--tune" << m_options->tune().toLower(); 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();
} }
} }

View File

@ -84,6 +84,24 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
class X265EncoderInfo : public AbstractEncoderInfo class X265EncoderInfo : public AbstractEncoderInfo
{ {
public: 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 virtual QStringList supportedInputFormats(void) const
{ {
QStringList extLst; QStringList extLst;

View File

@ -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_ENCODER = "custom_params_encoder";
static const char *KEY_CUSTOM_AVS2YUV = "custom_params_avs2yuv"; static const char *KEY_CUSTOM_AVS2YUV = "custom_params_avs2yuv";
const char *const OptionsModel::PROFILE_UNRESTRICTED = "<Unrestricted>";
OptionsModel::OptionsModel(const SysinfoModel *sysinfo) OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
{ {
m_encoderType = EncType_X264; m_encoderType = EncType_X264;
@ -56,9 +58,9 @@ OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
m_quantizer = 22; m_quantizer = 22;
m_preset = "Medium"; m_preset = "Medium";
m_tune = "None"; m_tune = "None";
m_profile = "Auto"; m_profile = QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED);
m_custom_encoder = ""; m_custom_encoder = QString();
m_custom_avs2yuv = ""; m_custom_avs2yuv = QString();
} }
OptionsModel::OptionsModel(const OptionsModel &rhs) OptionsModel::OptionsModel(const OptionsModel &rhs)

View File

@ -60,6 +60,8 @@ public:
RCMode_ABR = 3, RCMode_ABR = 3,
}; };
static const char *const PROFILE_UNRESTRICTED;
//Getter //Getter
EncType encType(void) const { return m_encoderType; } EncType encType(void) const { return m_encoderType; }
EncArch encArch(void) const { return m_encoderArch; } EncArch encArch(void) const { return m_encoderArch; }

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 5 #define VER_X264_PATCH 5
#define VER_X264_BUILD 818 #define VER_X264_BUILD 820
#define VER_X264_PORTABLE_EDITION (0) #define VER_X264_PORTABLE_EDITION (0)

View File

@ -244,6 +244,9 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *const options, Recentl
setMinimumSize(size()); setMinimumSize(size());
setMaximumHeight(height()); setMaximumHeight(height());
//Init combobox items
ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));
//Hide optional controls //Hide optional controls
ui->checkBoxApplyToAll->setVisible(false); ui->checkBoxApplyToAll->setVisible(false);
@ -435,24 +438,33 @@ void AddJobDialog::dropEvent(QDropEvent *event)
void AddJobDialog::encoderIndexChanged(int index) void AddJobDialog::encoderIndexChanged(int index)
{ {
const bool isX265 = (index > 0); const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
const bool noProf = isX265 || (ui->cbxEncoderVariant->currentIndex() > 0);
ui->cbxEncoderVariant->setItemText(1, isX265 ? tr("16-Bit") : tr("10-Bit")); //Update encoder variants
ui->labelProfile->setEnabled(!noProf); ui->cbxEncoderVariant->setItemText(OptionsModel::EncVariant_LoBit, encoderInfo.getVariantId(OptionsModel::EncVariant_LoBit));
ui->cbxProfile->setEnabled(!noProf); ui->cbxEncoderVariant->setItemText(OptionsModel::EncVariant_HiBit, encoderInfo.getVariantId(OptionsModel::EncVariant_HiBit));
if(noProf) ui->cbxProfile->setCurrentIndex(0);
variantIndexChanged(ui->cbxEncoderVariant->currentIndex()); variantIndexChanged(ui->cbxEncoderVariant->currentIndex());
} }
void AddJobDialog::variantIndexChanged(int index) 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); //Update encoder profiles
ui->cbxProfile->setEnabled(!noProf); QStringList profiles = encoderInfo.getProfiles(index);
if(noProf) ui->cbxProfile->setCurrentIndex(0); 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()); modeIndexChanged(ui->cbxRateControlMode->currentIndex());
} }
@ -552,7 +564,6 @@ void AddJobDialog::accept(void)
} }
} }
//Is output file extension supported by encoder? //Is output file extension supported by encoder?
const QStringList outputFormats = encoderInfo.supportedOutputFormats(); const QStringList outputFormats = encoderInfo.supportedOutputFormats();
QFileInfo outputFile = QFileInfo(this->outputFile()); QFileInfo outputFile = QFileInfo(this->outputFile());
@ -660,11 +671,6 @@ void AddJobDialog::templateSelected(void)
REMOVE_USAFED_ITEM; REMOVE_USAFED_ITEM;
restoreOptions(options); restoreOptions(options);
} }
//Force updates
encoderIndexChanged(ui->cbxEncoderType->currentIndex());
variantIndexChanged(ui->cbxEncoderVariant->currentIndex());
modeIndexChanged(ui->cbxRateControlMode->currentIndex());
} }
void AddJobDialog::saveTemplateButtonClicked(void) void AddJobDialog::saveTemplateButtonClicked(void)
@ -922,7 +928,7 @@ void AddJobDialog::loadTemplateList(void)
void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text) void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
{ {
int index = -1; int index = 0;
if(QAbstractItemModel *model = cbox->model()) if(QAbstractItemModel *model = cbox->model())
{ {
for(int i = 0; i < cbox->model()->rowCount(); i++) 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) void AddJobDialog::restoreOptions(const OptionsModel *options)
{ {
BLOCK_SIGNALS(true); BLOCK_SIGNALS(false);
ui->cbxEncoderType->setCurrentIndex(options->encType()); ui->cbxEncoderType->setCurrentIndex(options->encType());
ui->cbxEncoderArch->setCurrentIndex(options->encArch()); ui->cbxEncoderArch->setCurrentIndex(options->encArch());
ui->cbxEncoderVariant->setCurrentIndex(options->encVariant()); ui->cbxEncoderVariant->setCurrentIndex(options->encVariant());
ui->cbxRateControlMode->setCurrentIndex(options->rcMode()); ui->cbxRateControlMode->setCurrentIndex(options->rcMode());
BLOCK_SIGNALS(true);
ui->spinQuantizer->setValue(options->quantizer()); ui->spinQuantizer->setValue(options->quantizer());
ui->spinBitrate->setValue(options->bitrate()); ui->spinBitrate->setValue(options->bitrate());
updateComboBox(ui->cbxPreset, options->preset()); updateComboBox(ui->cbxPreset, options->preset());
@ -962,11 +971,14 @@ void AddJobDialog::saveOptions(OptionsModel *options)
options->setEncArch(static_cast<OptionsModel::EncArch>(ui->cbxEncoderArch->currentIndex())); options->setEncArch(static_cast<OptionsModel::EncArch>(ui->cbxEncoderArch->currentIndex()));
options->setEncVariant(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant->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->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->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->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());
} }