diff --git a/src/encoder_abstract.cpp b/src/encoder_abstract.cpp index e835efb..5799624 100644 --- a/src/encoder_abstract.cpp +++ b/src/encoder_abstract.cpp @@ -44,20 +44,6 @@ #include #include -// ------------------------------------------------------------ -// 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 ¶ms, 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; diff --git a/src/encoder_abstract.h b/src/encoder_abstract.h index 594388c..818c382 100644 --- a/src/encoder_abstract.h +++ b/src/encoder_abstract.h @@ -57,7 +57,6 @@ protected: virtual void runEncodingPass_init(QList &patterns) = 0; virtual void runEncodingPass_parseLine(const QString &line, QList &patterns, const int &pass, double &last_progress, double &size_estimate) = 0; - static QStringList splitParams(const QString ¶ms, const QString &sourceFile, const QString &outputFile); static double estimateSize(const QString &fileName, const double &progress); static QString sizeToString(qint64 size); diff --git a/src/encoder_x265.cpp b/src/encoder_x265.cpp index 34300c3..4f00b58 100644 --- a/src/encoder_x265.cpp +++ b/src/encoder_x265.cpp @@ -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 diff --git a/src/model_options.h b/src/model_options.h index 1fe30bd..faa416a 100644 --- a/src/model_options.h +++ b/src/model_options.h @@ -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); diff --git a/src/source_avisynth.cpp b/src/source_avisynth.cpp index 5bcd6ed..a561267 100644 --- a/src/source_avisynth.cpp +++ b/src/source_avisynth.cpp @@ -156,6 +156,11 @@ bool AvisynthSource::isVersionSupported(const unsigned int &revision, const bool void AvisynthSource::checkSourceProperties_init(QList &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 << "-"; } diff --git a/src/tool_abstract.cpp b/src/tool_abstract.cpp index f2f67b9..0787cdc 100644 --- a/src/tool_abstract.cpp +++ b/src/tool_abstract.cpp @@ -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 ¶ms, 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)); diff --git a/src/tool_abstract.h b/src/tool_abstract.h index 6ef7d3b..ecc1692 100644 --- a/src/tool_abstract.h +++ b/src/tool_abstract.h @@ -87,6 +87,7 @@ protected: QSemaphore *const m_semaphorePause; static QString commandline2string(const QString &program, const QStringList &arguments); + static QStringList splitParams(const QString ¶ms, 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); diff --git a/src/version.h b/src/version.h index b37dfb8..1437246 100644 --- a/src/version.h +++ b/src/version.h @@ -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)