Make "custom" Avs2YUV parameters work again.

This commit is contained in:
LoRd_MuldeR 2015-11-18 20:48:54 +01:00
parent 3a777274cc
commit 1e2b69c6f4
8 changed files with 87 additions and 69 deletions

View File

@ -44,20 +44,6 @@
#include <QThread>
#include <QLocale>
// ------------------------------------------------------------
// Helper Macros
// ------------------------------------------------------------
#define APPEND_AND_CLEAR(LIST, STR) do \
{ \
if(!((STR).isEmpty())) \
{ \
(LIST) << (STR); \
(STR).clear(); \
} \
} \
while(0)
// ------------------------------------------------------------
// Constructor & Destructor
// ------------------------------------------------------------
@ -264,38 +250,6 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
// Utilities
// ------------------------------------------------------------
QStringList AbstractEncoder::splitParams(const QString &params, const QString &sourceFile, const QString &outputFile)
{
QStringList list;
bool ignoreWhitespaces = false;
QString temp;
for(int i = 0; i < params.length(); i++)
{
const QChar c = params.at(i);
if(c == QChar::fromLatin1('"'))
{
ignoreWhitespaces = (!ignoreWhitespaces);
continue;
}
else if((!ignoreWhitespaces) && (c == QChar::fromLatin1(' ')))
{
APPEND_AND_CLEAR(list, temp);
continue;
}
temp.append(c);
}
APPEND_AND_CLEAR(list, temp);
list.replaceInStrings("$(INPUT)", QDir::toNativeSeparators(sourceFile), Qt::CaseInsensitive);
list.replaceInStrings("$(OUTPUT)", QDir::toNativeSeparators(outputFile), Qt::CaseInsensitive);
return list;
}
double AbstractEncoder::estimateSize(const QString &fileName, const double &progress)
{
double estimatedSize = 0.0;

View File

@ -57,7 +57,6 @@ protected:
virtual void runEncodingPass_init(QList<QRegExp*> &patterns) = 0;
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const int &pass, double &last_progress, double &size_estimate) = 0;
static QStringList splitParams(const QString &params, const QString &sourceFile, const QString &outputFile);
static double estimateSize(const QString &fileName, const double &progress);
static QString sizeToString(qint64 size);

View File

@ -38,7 +38,7 @@
//x265 version info
static const unsigned int VERSION_X265_MINIMUM_VER = 18;
static const unsigned int VERSION_X265_MINIMUM_REV = 0;
static const unsigned int VERSION_X265_MINIMUM_REV = 60;
// ------------------------------------------------------------
// Helper Macros

View File

@ -78,30 +78,30 @@ public:
static const char *const PROFILE_UNRESTRICTED;
//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; }
unsigned int bitrate(void) const { return m_bitrate; }
double quantizer(void) const { return m_quantizer; }
QString preset(void) const { return m_preset; }
QString tune(void) const { return m_tune; }
QString profile(void) const { return m_profile; }
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; }
unsigned int bitrate(void) const { return m_bitrate; }
double quantizer(void) const { return m_quantizer; }
QString preset(void) const { return m_preset; }
QString tune(void) const { return m_tune; }
QString profile(void) const { return m_profile; }
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
void setEncType(EncType type) { m_encoderType = qBound(EncType_X264, type, EncType_X265); }
void setEncArch(EncArch arch) { m_encoderArch = qBound(EncArch_x86_32, arch, EncArch_x86_64); }
void setEncVariant(EncVariant variant) { m_encoderVariant = qBound(EncVariant_8Bit, variant, EncVariant_12Bit); }
void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); }
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
void setTune(const QString &tune) { m_tune = tune.trimmed(); }
void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
void setEncType(EncType type) { m_encoderType = qBound(EncType_X264, type, EncType_X265); }
void setEncArch(EncArch arch) { m_encoderArch = qBound(EncArch_x86_32, arch, EncArch_x86_64); }
void setEncVariant(EncVariant variant) { m_encoderVariant = qBound(EncVariant_8Bit, variant, EncVariant_12Bit); }
void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); }
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
void setTune(const QString &tune) { m_tune = tune.trimmed(); }
void setProfile(const QString &profile) { m_profile = profile.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
bool equals(const OptionsModel *model);

View File

@ -156,6 +156,11 @@ bool AvisynthSource::isVersionSupported(const unsigned int &revision, const bool
void AvisynthSource::checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
{
if(!m_options->customAvs2YUV().isEmpty())
{
cmdLine << splitParams(m_options->customAvs2YUV());
}
cmdLine << "-frames" << "1";
cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFile, true)) << "NUL";
@ -217,6 +222,11 @@ void AvisynthSource::checkSourceProperties_parseLine(const QString &line, QList<
void AvisynthSource::buildCommandLine(QStringList &cmdLine)
{
if(!m_options->customAvs2YUV().isEmpty())
{
cmdLine << splitParams(m_options->customAvs2YUV());
}
cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFile, true));
cmdLine << "-";
}

View File

@ -39,6 +39,23 @@
QMutex AbstractTool::s_mutexStartProcess;
// ------------------------------------------------------------
// Helper Macros
// ------------------------------------------------------------
static void APPEND_AND_CLEAR(QStringList &list, QString &str)
{
if(!str.isEmpty())
{
const QString temp = str.trimmed();
if(!temp.isEmpty())
{
list << temp;
}
str.clear();
}
}
// ------------------------------------------------------------
// Constructor & Destructor
// ------------------------------------------------------------
@ -210,6 +227,43 @@ QString AbstractTool::commandline2string(const QString &program, const QStringLi
return commandline;
}
QStringList AbstractTool::splitParams(const QString &params, const QString &sourceFile, const QString &outputFile)
{
QStringList list;
bool ignoreWhitespaces = false;
QString temp;
for(int i = 0; i < params.length(); i++)
{
const QChar c = params.at(i);
if(c == QLatin1Char('"'))
{
ignoreWhitespaces = (!ignoreWhitespaces);
continue;
}
else if((!ignoreWhitespaces) && (c == QChar::fromLatin1(' ')))
{
APPEND_AND_CLEAR(list, temp);
continue;
}
temp.append(c);
}
APPEND_AND_CLEAR(list, temp);
if(!sourceFile.isEmpty())
{
list.replaceInStrings("$(INPUT)", QDir::toNativeSeparators(sourceFile), Qt::CaseInsensitive);
}
if(!outputFile.isEmpty())
{
list.replaceInStrings("$(OUTPUT)", QDir::toNativeSeparators(outputFile), Qt::CaseInsensitive);
}
return list;
}
QString AbstractTool::stringToHash(const QString &string)
{
QByteArray result(10, char(0));

View File

@ -87,6 +87,7 @@ protected:
QSemaphore *const m_semaphorePause;
static QString commandline2string(const QString &program, const QStringList &arguments);
static QStringList splitParams(const QString &params, const QString &sourceFile = QString(), const QString &outputFile = QString());
static QString stringToHash(const QString &string);
static unsigned int makeRevision(const unsigned int &core, const unsigned int &build);
static void splitRevision(const unsigned int &revision, unsigned int &core, unsigned int &build);

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 6
#define VER_X264_PATCH 2
#define VER_X264_BUILD 990
#define VER_X264_BUILD 994
#define VER_X264_PORTABLE_EDITION (0)