From 726d494ca1370b253beb921ed88880ad63785356 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 5 May 2014 18:20:58 +0200 Subject: [PATCH] Fixed detection of x265 core version 1.0 and higher (old code assumed "0.x" format). --- src/encoder_x265.cpp | 22 +++++++++++++++------- src/thread_encode.cpp | 2 +- src/version.h | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/encoder_x265.cpp b/src/encoder_x265.cpp index 29f4624..cf65ffc 100644 --- a/src/encoder_x265.cpp +++ b/src/encoder_x265.cpp @@ -182,7 +182,7 @@ const QString &X265Encoder::getName(void) void X265Encoder::checkVersion_init(QList &patterns, QStringList &cmdLine) { cmdLine << "--version"; - patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+0\\.(\\d+)\\+(\\d+)-[a-f0-9]+\\b", Qt::CaseInsensitive); + patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\+(\\d+)-[a-f0-9]+\\b", Qt::CaseInsensitive); } void X265Encoder::checkVersion_parseLine(const QString &line, QList &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified) @@ -191,11 +191,16 @@ void X265Encoder::checkVersion_parseLine(const QString &line, QList &p if((offset = patterns[0]->lastIndexIn(line)) >= 0) { - bool ok1 = false, ok2 = false; - unsigned int temp1 = patterns[0]->cap(1).toUInt(&ok1); - unsigned int temp2 = patterns[0]->cap(2).toUInt(&ok2); - if(ok1) coreVers = temp1; - if(ok2) revision = temp2; + bool ok[3] = { false, false, false }; + unsigned int temp[3]; + temp[0] = patterns[0]->cap(1).toUInt(&ok[0]); + temp[1] = patterns[0]->cap(2).toUInt(&ok[1]); + temp[2] = patterns[0]->cap(3).toUInt(&ok[2]); + if(ok[0] && ok[1]) + { + coreVers = (10 * temp[0]) + temp[1]; + } + if(ok[2]) revision = temp[2]; } if(!line.isEmpty()) @@ -206,7 +211,10 @@ void X265Encoder::checkVersion_parseLine(const QString &line, QList &p QString X265Encoder::printVersion(const unsigned int &revision, const bool &modified) { - return tr("x265 version: 0.%1+%2").arg(QString::number(revision / REV_MULT), QString::number(revision % REV_MULT)); + const unsigned int core = revision / REV_MULT; + const unsigned int plus = revision % REV_MULT; + + return tr("x265 version: %1.%2+%3").arg(QString::number(core / 10), QString::number(core % 10), QString::number(plus)); } bool X265Encoder::isVersionSupported(const unsigned int &revision, const bool &modified) diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index 89626b6..20ae23b 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -262,7 +262,7 @@ void EncodeThread::encode(void) log(tr("Preset : %1").arg(m_options->preset())); log(tr("Tuning : %1").arg(m_options->tune())); log(tr("Profile : %1").arg(m_options->profile())); - log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("(None)") : m_options->customEncParams())); + log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("") : m_options->customEncParams())); bool ok = false; unsigned int frames = 0; diff --git a/src/version.h b/src/version.h index 6f65556..e123a4f 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 3 #define VER_X264_PATCH 9 -#define VER_X264_BUILD 864 +#define VER_X264_BUILD 865 #define VER_X264_PORTABLE_EDITION (0)