Properly verify custom Avs2YUV parameters. Also improved color-space info in the ReadMe file.

This commit is contained in:
LoRd_MuldeR 2012-02-13 00:04:39 +01:00
parent e316c3cd37
commit 5046a80d56
5 changed files with 205 additions and 45 deletions

View File

@ -126,14 +126,20 @@ i.e. YUV data with 4:2:0 chroma subsampling and 8-Bit precision.
Usually this is exactly what you want/need. If, however, your Avisynth
script outputs image data with a higher chroma resolution, e.g. YUY2
(4:2:2), then the conversion to YV12 (4:2:0) will discard some of the
information. In that case, if you want/need to keep the full chroma
information. In that case, and if you want/need to keep the full chroma
resolution of your Avisynth script's output, you will have to pass the
"-csp" switch to Avs2YUV as a custom parameter! Use "-csp I422" for
YUV 4:2:2 (YV16) and use "-csp I444" for YUV 4:4:4 (YV24). Note,
however, that Avisynth 2.5 did NOT support YV16/YV24, so you need to
use Avisynth 2.6 or Avs2YUV will fail! Also be aware that x264 itself
will convert any YV16 or YV24 input back to YV12, if you don't pass the
suitable "--csp-output i422/i444" switch as a custom parameter to x264!
YUV 4:2:2 (YV16) and use "-csp I444" for YUV 4:4:4 (YV24). Please note
that Avs2YUV can NOT pass through the "packed" YUY2 format. Thus it has
to be converted to the "planar" YV16 format. As both, YUY2 and YV16,
are YUV 4:2:2 formats, converting from YUY2 to YV16 is a lossless
operation. Note, however, that Avisynth 2.5 did NOT support YV16/YV24,
so you need to use Avisynth 2.6; otherwise Avs2YUV will fail to do the
conversion! Also be aware that the x264 encoder itself will convert any
YV16 or YV24 input back to the YV12 format, if you don't pass the
suitable "--output-csp i422/i444" switch to x264 as a custom parameter!
In short, to encode YUY2 from Avisynth, you have to pass "-csp I422" to
Avs2YUV and "--output-csp i422" to x264 to avoid 4:2:0 downsampling.
9. Command-line Syntax

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>611</height>
<height>614</height>
</rect>
</property>
<property name="windowTitle">
@ -767,6 +767,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_10">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>All command-line parameters you enter here will be passed to x264 unmodified and unchecked. Some parameters are forbidden, as they are reserved for the GUI.</string>
</property>
@ -789,7 +795,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="iconNotification">
<widget class="QLabel" name="iconNotificationX264">
<property name="toolTip">
<string>Your custom parameters will be ignored entirely, if you don't fix them!</string>
</property>
@ -818,7 +824,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="labelNotification">
<widget class="QLabel" name="labelNotificationX264">
<property name="palette">
<palette>
<active>
@ -941,7 +947,7 @@
</layout>
</item>
<item>
<widget class="QLineEdit" name="editCustomParams">
<widget class="QLineEdit" name="editCustomX264Params">
<property name="font">
<font>
<family>Lucida Console</family>
@ -955,15 +961,126 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>3</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_11">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Custom Avs2YUV Parameters:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="iconNotificationAvs2YUV">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../res/resources.qrc">:/buttons/error.png</pixmap>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>6</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelNotificationAvs2YUV">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Invalid parameter entered!</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
@ -1156,7 +1273,7 @@
<tabstop>cbxPreset</tabstop>
<tabstop>cbxTuning</tabstop>
<tabstop>cbxProfile</tabstop>
<tabstop>editCustomParams</tabstop>
<tabstop>editCustomX264Params</tabstop>
<tabstop>checkBoxRun</tabstop>
<tabstop>buttonAccept</tabstop>
<tabstop>buttonCancel</tabstop>

View File

@ -22,7 +22,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 0
#define VER_X264_PATCH 1
#define VER_X264_BUILD 135
#define VER_X264_BUILD 146
#define VER_X264_MINIMUM_REV 2146
#define VER_X264_CURRENT_API 120

View File

@ -69,20 +69,7 @@ public:
m_icon->hide();
}
virtual State validate(QString &input, int &pos) const
{
static const char* p[] = {"B", "o", "h", "p", "q", "fps", "frames", "preset", "tune", "profile",
"stdin", "crf", "bitrate", "qp", "pass", "stats", "output", "help","quiet", NULL};
bool invalid = false;
for(size_t i = 0; p[i] && (!invalid); i++)
{
invalid = invalid || checkParam(input, QString::fromLatin1(p[i]));
}
return invalid ? QValidator::Intermediate : QValidator::Acceptable;
}
virtual State validate(QString &input, int &pos) const = 0;
virtual void fixup(QString &input) const
{
@ -92,17 +79,18 @@ public:
protected:
QLabel *const m_notifier, *const m_icon;
bool checkParam(const QString &input, const QString &param) const
bool checkParam(const QString &input, const QString &param, const bool doubleMinus) const
{
static const char c[20] = {' ', '*', '?', '<', '>', '/', '\\', '"', '\'', '!', '+', '#', '&', '%', '=', ',', ';', '.', '´', '`'};
const QString prefix = doubleMinus ? QLatin1String("--") : QLatin1String("-");
bool flag = false;
if(param.length() > 1)
{
flag = flag || input.endsWith(QString("--%1").arg(param), Qt::CaseInsensitive);
flag = flag || input.endsWith(QString("%1%2").arg(prefix, param), Qt::CaseInsensitive);
for(size_t i = 0; i < sizeof(c); i++)
{
flag = flag || input.contains(QString("--%1%2").arg(param, QChar::fromLatin1(c[i])), Qt::CaseInsensitive);
flag = flag || input.contains(QString("%1%2%3").arg(prefix, param, QChar::fromLatin1(c[i])), Qt::CaseInsensitive);
}
}
else
@ -117,7 +105,7 @@ protected:
{
if(m_notifier)
{
m_notifier->setText(tr("Invalid parameter: %1").arg((param.length() > 1) ? QString("--%1").arg(param) : QString("-%1").arg(param)));
m_notifier->setText(tr("Invalid parameter: %1").arg((param.length() > 1) ? QString("%1%2").arg(prefix, param) : QString("-%1").arg(param)));
if(m_notifier->isHidden()) m_notifier->show();
if(m_icon) { if(m_icon->isHidden()) m_icon->show(); }
}
@ -134,6 +122,47 @@ protected:
}
};
class StringValidatorX264 : public StringValidator
{
public:
StringValidatorX264(QLabel *notifier, QLabel *icon) : StringValidator(notifier, icon) {}
virtual State validate(QString &input, int &pos) const
{
static const char* p[] = {"B", "o", "h", "p", "q", "fps", "frames", "preset", "tune", "profile",
"stdin", "crf", "bitrate", "qp", "pass", "stats", "output", "help","quiet", NULL};
bool invalid = false;
for(size_t i = 0; p[i] && (!invalid); i++)
{
invalid = invalid || checkParam(input, QString::fromLatin1(p[i]), true);
}
return invalid ? QValidator::Intermediate : QValidator::Acceptable;
}
};
class StringValidatorAvs2YUV : public StringValidator
{
public:
StringValidatorAvs2YUV(QLabel *notifier, QLabel *icon) : StringValidator(notifier, icon) {}
virtual State validate(QString &input, int &pos) const
{
static const char* p[] = {"o", "frames", "seek", "raw", "hfyu", NULL};
bool invalid = false;
for(size_t i = 0; p[i] && (!invalid); i++)
{
invalid = invalid || checkParam(input, QString::fromLatin1(p[i]), false);
}
return invalid ? QValidator::Intermediate : QValidator::Acceptable;
}
};
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
///////////////////////////////////////////////////////////////////////////////
@ -169,9 +198,12 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64suppo
connect(buttonDeleteTemplate, SIGNAL(clicked()), this, SLOT(deleteTemplateButtonClicked()));
//Setup validator
editCustomParams->installEventFilter(this);
editCustomParams->setValidator(new StringValidator(labelNotification, iconNotification));
editCustomParams->clear();
editCustomX264Params->installEventFilter(this);
editCustomX264Params->setValidator(new StringValidatorX264(labelNotificationX264, iconNotificationX264));
editCustomX264Params->clear();
editCustomAvs2YUVParams->installEventFilter(this);
editCustomAvs2YUVParams->setValidator(new StringValidatorAvs2YUV(labelNotificationAvs2YUV, iconNotificationAvs2YUV));
editCustomAvs2YUVParams->clear();
//Install event filter
labelHelpScreenX264->installEventFilter(this);
@ -184,7 +216,8 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64suppo
connect(cbxPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
connect(cbxTuning, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
connect(cbxProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
connect(editCustomParams, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));
connect(editCustomX264Params, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));
connect(editCustomAvs2YUVParams, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));
//Setup template selector
loadTemplateList();
@ -232,8 +265,10 @@ void AddJobDialog::showEvent(QShowEvent *event)
buttonAccept->setFocus();
}
labelNotification->hide();
iconNotification->hide();
labelNotificationX264->hide();
iconNotificationX264->hide();
labelNotificationAvs2YUV->hide();
iconNotificationAvs2YUV->hide();
}
bool AddJobDialog::eventFilter(QObject *o, QEvent *e)
@ -250,9 +285,9 @@ bool AddJobDialog::eventFilter(QObject *o, QEvent *e)
helpScreen->exec();
X264_DELETE(helpScreen);
}
else if((o == editCustomParams) && (e->type() == QEvent::FocusOut))
else if((o == editCustomX264Params) && (e->type() == QEvent::FocusOut))
{
editCustomParams->setText(editCustomParams->text().simplified());
editCustomX264Params->setText(editCustomX264Params->text().simplified());
}
else if((o == editCustomAvs2YUVParams) && (e->type() == QEvent::FocusOut))
{
@ -353,7 +388,7 @@ void AddJobDialog::accept(void)
QMessageBox::warning(this, tr("Not a File!"), tr("<nobr>Selected output file does not appear to be a valid file!</nobr>"));
return;
}
if(!editCustomParams->hasAcceptableInput())
if(!editCustomX264Params->hasAcceptableInput())
{
int ret = QMessageBox::warning(this, tr("Invalid Params"), tr("<nobr>Your custom parameters are invalid and will be discarded!</nobr>"), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
if(ret != QMessageBox::Ignore) return;
@ -662,7 +697,8 @@ void AddJobDialog::restoreOptions(OptionsModel *options)
cbxPreset->blockSignals(true);
cbxTuning->blockSignals(true);
cbxProfile->blockSignals(true);
editCustomParams->blockSignals(true);
editCustomX264Params->blockSignals(true);
editCustomAvs2YUVParams->blockSignals(true);
cbxRateControlMode->setCurrentIndex(options->rcMode());
spinQuantizer->setValue(options->quantizer());
@ -670,7 +706,7 @@ void AddJobDialog::restoreOptions(OptionsModel *options)
updateComboBox(cbxPreset, options->preset());
updateComboBox(cbxTuning, options->tune());
updateComboBox(cbxProfile, options->profile());
editCustomParams->setText(options->customX264());
editCustomX264Params->setText(options->customX264());
editCustomAvs2YUVParams->setText(options->customAvs2YUV());
cbxRateControlMode->blockSignals(false);
@ -679,7 +715,8 @@ void AddJobDialog::restoreOptions(OptionsModel *options)
cbxPreset->blockSignals(false);
cbxTuning->blockSignals(false);
cbxProfile->blockSignals(false);
editCustomParams->blockSignals(false);
editCustomX264Params->blockSignals(false);
editCustomAvs2YUVParams->blockSignals(false);
}
void AddJobDialog::saveOptions(OptionsModel *options)
@ -690,8 +727,8 @@ void AddJobDialog::saveOptions(OptionsModel *options)
options->setPreset(cbxPreset->model()->data(cbxPreset->model()->index(cbxPreset->currentIndex(), 0)).toString());
options->setTune(cbxTuning->model()->data(cbxTuning->model()->index(cbxTuning->currentIndex(), 0)).toString());
options->setProfile(cbxProfile->model()->data(cbxProfile->model()->index(cbxProfile->currentIndex(), 0)).toString());
options->setCustomX264(editCustomParams->hasAcceptableInput() ? editCustomParams->text().simplified() : QString());
options->setCustomAvs2YUV(editCustomAvs2YUVParams->text().simplified());
options->setCustomX264(editCustomX264Params->hasAcceptableInput() ? editCustomX264Params->text().simplified() : QString());
options->setCustomAvs2YUV(editCustomAvs2YUVParams->hasAcceptableInput() ? editCustomAvs2YUVParams->text().simplified() : QString());
}
QString AddJobDialog::makeFileFilter(void)

View File

@ -40,7 +40,7 @@ public:
QString preset(void) { return cbxPreset->itemText(cbxPreset->currentIndex()); }
QString tuning(void) { return cbxTuning->itemText(cbxTuning->currentIndex()); }
QString profile(void) { return cbxProfile->itemText(cbxProfile->currentIndex()); }
QString params(void) { return editCustomParams->text().simplified(); }
QString params(void) { return editCustomX264Params->text().simplified(); }
bool runImmediately(void) { return checkBoxRun->isChecked(); }
void setRunImmediately(bool run) { checkBoxRun->setChecked(run); }
void setSourceFile(const QString &path) { editSource->setText(QDir::toNativeSeparators(path)); }