Some improvements to version number handling.
This commit is contained in:
parent
726d494ca1
commit
834905abf9
@ -204,7 +204,7 @@ void X264Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdL
|
||||
patterns << new QRegExp("\\bx264 (\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified)
|
||||
void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
|
||||
{
|
||||
int offset = -1;
|
||||
|
||||
@ -215,8 +215,8 @@ void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &p
|
||||
unsigned int temp2 = patterns[0]->cap(3).toUInt(&ok2);
|
||||
if(ok1 && ok2)
|
||||
{
|
||||
coreVers = temp1;
|
||||
revision = temp2;
|
||||
core = temp1;
|
||||
build = temp2;
|
||||
}
|
||||
}
|
||||
else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
|
||||
@ -226,8 +226,8 @@ void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &p
|
||||
unsigned int temp2 = patterns[1]->cap(3).toUInt(&ok2);
|
||||
if(ok1 && ok2)
|
||||
{
|
||||
coreVers = temp1;
|
||||
revision = temp2;
|
||||
core = temp1;
|
||||
build = temp2;
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
@ -240,21 +240,30 @@ void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &p
|
||||
|
||||
QString X264Encoder::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
return tr("x264 revision: %1 (core #%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT)).append(modified ? tr(" - with custom patches!") : QString());
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
QString versionStr = tr("x264 revision: %1 (core #%2)").arg(QString::number(build), QString::number(core));
|
||||
if(modified)
|
||||
{
|
||||
versionStr.append(tr(" - with custom patches!"));
|
||||
}
|
||||
|
||||
return versionStr;
|
||||
}
|
||||
|
||||
bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
const unsigned int ver = (revision / REV_MULT);
|
||||
const unsigned int rev = (revision % REV_MULT);
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
if((rev % REV_MULT) < VERSION_X264_MINIMUM_REV)
|
||||
if(build < VERSION_X264_MINIMUM_REV)
|
||||
{
|
||||
log(tr("\nERROR: Your revision of x264 is too old! Minimum required revision is %1.").arg(QString::number(VERSION_X264_MINIMUM_REV)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ver != VERSION_X264_CURRENT_API)
|
||||
if(core != VERSION_X264_CURRENT_API)
|
||||
{
|
||||
log(tr("\nWARNING: Your x264 binary uses an untested core (API) version, take care!"));
|
||||
log(tr("This application works best with x264 core (API) version %1. Newer versions may work or not.").arg(QString::number(VERSION_X264_CURRENT_API)));
|
||||
|
@ -41,7 +41,7 @@ protected:
|
||||
virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile);
|
||||
|
||||
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
|
||||
|
||||
virtual void runEncodingPass_init(QList<QRegExp*> &patterns);
|
||||
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const int &pass);
|
||||
|
@ -185,7 +185,7 @@ void X265Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdL
|
||||
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<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified)
|
||||
void X265Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
|
||||
{
|
||||
int offset = -1;
|
||||
|
||||
@ -198,9 +198,9 @@ void X265Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &p
|
||||
temp[2] = patterns[0]->cap(3).toUInt(&ok[2]);
|
||||
if(ok[0] && ok[1])
|
||||
{
|
||||
coreVers = (10 * temp[0]) + temp[1];
|
||||
core = (10 * temp[0]) + temp[1];
|
||||
}
|
||||
if(ok[2]) revision = temp[2];
|
||||
if(ok[2]) build = temp[2];
|
||||
}
|
||||
|
||||
if(!line.isEmpty())
|
||||
@ -211,26 +211,26 @@ void X265Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &p
|
||||
|
||||
QString X265Encoder::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
const unsigned int core = revision / REV_MULT;
|
||||
const unsigned int plus = revision % REV_MULT;
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
return tr("x265 version: %1.%2+%3").arg(QString::number(core / 10), QString::number(core % 10), QString::number(plus));
|
||||
return tr("x265 version: %1.%2+%3").arg(QString::number(core / 10), QString::number(core % 10), QString::number(build));
|
||||
}
|
||||
|
||||
bool X265Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
const unsigned int ver = (revision / REV_MULT);
|
||||
const unsigned int rev = (revision % REV_MULT);
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
if((ver < VERSION_X265_MINIMUM_VER) || ((ver == VERSION_X265_MINIMUM_VER) && (rev < VERSION_X265_MINIMUM_REV)))
|
||||
if((core < VERSION_X265_MINIMUM_VER) || ((core == VERSION_X265_MINIMUM_VER) && (build < VERSION_X265_MINIMUM_REV)))
|
||||
{
|
||||
log(tr("\nERROR: Your version of x265 is too old! (Minimum required revision is 0.%1+%2)").arg(QString::number(VERSION_X265_MINIMUM_VER), QString::number(VERSION_X265_MINIMUM_REV)));
|
||||
return false;
|
||||
}
|
||||
else if(ver > VERSION_X265_MINIMUM_VER)
|
||||
else if(core > VERSION_X265_MINIMUM_VER)
|
||||
{
|
||||
log(tr("\nWARNING: Your version of x265 is newer than the latest tested version, take care!"));
|
||||
log(tr("This application works best with x265 version %1. Newer versions may work or not.").arg(QString::number(VERSION_X265_MINIMUM_VER)));
|
||||
log(tr("This application works best with x265 version %1.%2. Newer versions may work or not.").arg(QString::number(VERSION_X265_MINIMUM_VER / 10), QString::number(VERSION_X265_MINIMUM_VER % 10)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -41,7 +41,7 @@ protected:
|
||||
virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile);
|
||||
|
||||
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
|
||||
|
||||
virtual void runEncodingPass_init(QList<QRegExp*> &patterns);
|
||||
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const int &pass);
|
||||
|
@ -76,7 +76,7 @@ void AvisynthSource::checkVersion_init(QList<QRegExp*> &patterns, QStringList &c
|
||||
patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)bm(\\d)\\b", Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void AvisynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified)
|
||||
void AvisynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
|
||||
{
|
||||
int offset = -1;
|
||||
|
||||
@ -87,8 +87,8 @@ void AvisynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*>
|
||||
unsigned int temp2 = patterns[0]->cap(2).toUInt(&ok2);
|
||||
if(ok1 && ok2)
|
||||
{
|
||||
coreVers = temp1;
|
||||
revision = temp2;
|
||||
core = temp1;
|
||||
build = temp2;
|
||||
}
|
||||
log(line);
|
||||
}
|
||||
@ -100,8 +100,8 @@ void AvisynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*>
|
||||
unsigned int temp3 = patterns[1]->cap(3).toUInt(&ok3);
|
||||
if(ok1 && ok2 && ok3)
|
||||
{
|
||||
coreVers = temp1;
|
||||
revision = (temp2 * 10) + (temp3 % 10);
|
||||
core = temp1;
|
||||
build = (temp2 * 10) + (temp3 % 10);
|
||||
}
|
||||
modified = true;
|
||||
log(line);
|
||||
@ -115,12 +115,18 @@ bool AvisynthSource::checkVersion_succeeded(const int &exitCode)
|
||||
|
||||
QString AvisynthSource::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
return tr("Avs2YUV version: %1.%2.%3").arg(QString::number(revision / REV_MULT), QString::number((revision % REV_MULT) / 10),QString::number((revision % REV_MULT) % 10));
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
return tr("Avs2YUV version: %1.%2.%3").arg(QString::number(core), QString::number(build / 10),QString::number(build % 10));
|
||||
}
|
||||
|
||||
bool AvisynthSource::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
if((revision != UINT_MAX) && ((revision % REV_MULT) < VER_X264_AVS2YUV_VER))
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
if((revision != UINT_MAX) && (build < VER_X264_AVS2YUV_VER))
|
||||
{
|
||||
log(tr("\nERROR: Your version of avs2yuv is unsupported (required version: v0.24 BugMaster's mod 2)"));
|
||||
log(tr("You can find the required version at: http://komisar.gin.by/tools/avs2yuv/"));
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
|
||||
virtual bool checkVersion_succeeded(const int &exitCode);
|
||||
|
||||
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
|
@ -74,7 +74,7 @@ void VapoursynthSource::checkVersion_init(QList<QRegExp*> &patterns, QStringList
|
||||
patterns << new QRegExp("\\bAPI\\s+r(\\d+)\\b", Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void VapoursynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified)
|
||||
void VapoursynthSource::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
|
||||
{
|
||||
int offset = -1;
|
||||
|
||||
@ -82,13 +82,13 @@ void VapoursynthSource::checkVersion_parseLine(const QString &line, QList<QRegEx
|
||||
{
|
||||
bool ok = false;
|
||||
unsigned int temp = patterns[1]->cap(1).toUInt(&ok);
|
||||
if(ok) revision = temp;
|
||||
if(ok) build = temp;
|
||||
}
|
||||
else if((offset = patterns[2]->lastIndexIn(line)) >= 0)
|
||||
{
|
||||
bool ok = false;
|
||||
unsigned int temp = patterns[2]->cap(1).toUInt(&ok);
|
||||
if(ok) coreVers = temp;
|
||||
if(ok) core = temp;
|
||||
}
|
||||
|
||||
if(!line.isEmpty())
|
||||
@ -99,12 +99,18 @@ void VapoursynthSource::checkVersion_parseLine(const QString &line, QList<QRegEx
|
||||
|
||||
QString VapoursynthSource::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
return tr("\nVapourSynth version: r%1 (API r%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT));
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
return tr("\nVapourSynth version: r%1 (API r%2)").arg(QString::number(build), QString::number(core));
|
||||
}
|
||||
|
||||
bool VapoursynthSource::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
if((revision % REV_MULT) < VER_X264_VSPIPE_VER)
|
||||
unsigned int core, build;
|
||||
splitRevision(revision, core, build);
|
||||
|
||||
if(build < VER_X264_VSPIPE_VER)
|
||||
{
|
||||
log(tr("\nERROR: Your version of VapourSynth is unsupported (requires version r%1 or newer").arg(QString::number(VER_X264_VSPIPE_VER)));
|
||||
log(tr("You can find the latest VapourSynth version at: http://www.vapoursynth.com/"));
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified);
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
|
||||
|
||||
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
|
||||
virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen);
|
||||
|
@ -31,8 +31,6 @@
|
||||
|
||||
#include "global.h"
|
||||
|
||||
static const unsigned int VAPOURSYNTH_VERSION_MIN = 20;
|
||||
|
||||
QMutex VapourSynthCheckThread::m_vpsLock;
|
||||
QFile *VapourSynthCheckThread::m_vpsExePath = NULL;
|
||||
QFile *VapourSynthCheckThread::m_vpsDllPath = NULL;
|
||||
@ -264,7 +262,7 @@ bool VapourSynthCheckThread::detectVapourSynthPath3(QString &path)
|
||||
if(vapoursynthComplete && m_vpsExePath)
|
||||
{
|
||||
qDebug("VapourSynth detection is running, please stand by...");
|
||||
success = checkVapourSynthVersion(m_vpsExePath->fileName());
|
||||
success = checkVapourSynth(m_vpsExePath->fileName());
|
||||
}
|
||||
|
||||
//Return VapourSynth path
|
||||
@ -276,7 +274,7 @@ bool VapourSynthCheckThread::detectVapourSynthPath3(QString &path)
|
||||
return success;
|
||||
}
|
||||
|
||||
bool VapourSynthCheckThread::checkVapourSynthVersion(const QString vspipePath)
|
||||
bool VapourSynthCheckThread::checkVapourSynth(const QString vspipePath)
|
||||
{
|
||||
QProcess process;
|
||||
QStringList output;
|
||||
@ -335,36 +333,23 @@ bool VapourSynthCheckThread::checkVapourSynthVersion(const QString vspipePath)
|
||||
}
|
||||
|
||||
//Init regular expressions
|
||||
unsigned int vapursynthVersion = 0;
|
||||
bool vapoursynthLogo = false;
|
||||
QRegExp vpsLogo("VapourSynth\\s+Video\\s+Processing\\s+Library");
|
||||
QRegExp vpsCore("Core\\s+r(\\d+)");
|
||||
|
||||
//Check for version info
|
||||
bool vapoursynthLogo = false;
|
||||
for(QStringList::ConstIterator iter = output.constBegin(); iter != output.constEnd(); iter++)
|
||||
{
|
||||
if(vpsLogo.lastIndexIn(*iter) >= 0)
|
||||
{
|
||||
vapoursynthLogo = true;
|
||||
continue;
|
||||
}
|
||||
if(vapoursynthLogo && (vpsCore.lastIndexIn(*iter) >= 0))
|
||||
{
|
||||
bool ok = false;
|
||||
const unsigned int temp = vpsCore.cap(1).toUInt(&ok);
|
||||
if(ok) vapursynthVersion = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Minimum required version found?
|
||||
if(vapoursynthLogo && (vapursynthVersion > 0))
|
||||
if(vapoursynthLogo)
|
||||
{
|
||||
qDebug("VapourSynth version \"Core r%u\" detected.", vapursynthVersion);
|
||||
if(vapursynthVersion < VAPOURSYNTH_VERSION_MIN)
|
||||
{
|
||||
qWarning("VapourSynth version is too old -> disable Vapousynth support!");
|
||||
return false;
|
||||
}
|
||||
qDebug("VapourSynth was detected successfully.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -65,5 +65,5 @@ private:
|
||||
static bool detectVapourSynthPath3(QString &path);
|
||||
|
||||
//Internal functions
|
||||
static bool checkVapourSynthVersion(const QString vspipePath);
|
||||
static bool checkVapourSynth(const QString vspipePath);
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ unsigned int AbstractTool::checkVersion(bool &modified)
|
||||
if(m_preferences->getSkipVersionTest())
|
||||
{
|
||||
log("Warning: Skipping the version check this time!");
|
||||
return (999 * REV_MULT) + (REV_MULT-1);
|
||||
return makeRevision(9999, 9999);
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
@ -140,7 +140,7 @@ unsigned int AbstractTool::checkVersion(bool &modified)
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
return (coreVers * REV_MULT) + (revision % REV_MULT);
|
||||
return makeRevision(coreVers, revision);
|
||||
}
|
||||
|
||||
bool AbstractTool::checkVersion_succeeded(const int &exitCode)
|
||||
@ -223,3 +223,14 @@ QString AbstractTool::stringToHash(const QString &string)
|
||||
|
||||
return QString::fromLatin1(result.toHex().constData());
|
||||
}
|
||||
|
||||
unsigned int AbstractTool::makeRevision(const unsigned int &core, const unsigned int &build)
|
||||
{
|
||||
return ((core & 0x0000FFFF) << 16) | (build & 0x0000FFFF);
|
||||
}
|
||||
|
||||
void AbstractTool::splitRevision(const unsigned int &revision, unsigned int &core, unsigned int &build)
|
||||
{
|
||||
core = (revision & 0xFFFF0000) >> 16;
|
||||
build = (revision & 0x0000FFFF);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified) = 0;
|
||||
virtual QString printVersion(const unsigned int &revision, const bool &modified) = 0;
|
||||
|
||||
static const unsigned int REV_MULT = 10000;
|
||||
//static const unsigned int REV_MULT = 10000;
|
||||
|
||||
signals:
|
||||
void statusChanged(const JobStatus &newStatus);
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
virtual const QString &getBinaryPath(void) = 0;
|
||||
|
||||
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified) = 0;
|
||||
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified) = 0;
|
||||
virtual bool checkVersion_succeeded(const int &exitCode);
|
||||
|
||||
void log(const QString &text) { emit messageLogged(text); }
|
||||
@ -88,6 +88,8 @@ protected:
|
||||
|
||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||
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);
|
||||
|
||||
static QMutex s_mutexStartProcess;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 3
|
||||
#define VER_X264_PATCH 9
|
||||
#define VER_X264_BUILD 865
|
||||
#define VER_X264_BUILD 866
|
||||
|
||||
#define VER_X264_PORTABLE_EDITION (0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user