OSDN Git Service

Bump x264 minimum required version to API-#160 (r2999).
[x264-launcher/x264-launcher.git] / src / source_avisynth.cpp
index eca9005..5453af0 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 
 #include "global.h"
 
+#include <MUtils/Global.h>
+
 #include <QDir>
 #include <QProcess>
 
-static const unsigned int VER_X264_AVS2YUV_VER = 243;
+static const unsigned int VER_X264_AVS2YUV_VER = 246;
 
 // ------------------------------------------------------------
 // Encoder Info
@@ -37,10 +39,21 @@ static const unsigned int VER_X264_AVS2YUV_VER = 243;
 class AvisynthSourceInfo : public AbstractSourceInfo
 {
 public:
-       virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const
+       virtual QString getBinaryPath(const SysinfoModel *const sysinfo, const bool& x64) const
        {
                return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
        }
+
+       virtual QStringList getExtraPaths(const SysinfoModel *const sysinfo, const bool& x64) const
+       {
+               const QString avsPath = sysinfo->getAVSPath();
+               if (!avsPath.isEmpty())
+               {
+               
+                       return QStringList() << QString("%1/%2").arg(avsPath, x64 ? QLatin1String("x64") : QLatin1String("x86"));
+               }
+               return QStringList();
+       }
 };
 
 static const AvisynthSourceInfo s_avisynthEncoderInfo;
@@ -50,6 +63,7 @@ const AbstractSourceInfo &AvisynthSource::getSourceInfo(void)
        return s_avisynthEncoderInfo;
 }
 
+
 // ------------------------------------------------------------
 // Constructor & Destructor
 // ------------------------------------------------------------
@@ -91,7 +105,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 &core, unsigned int &build, bool &modified)
+void AvisynthSource::checkVersion_parseLine(const QString &line, const QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
 {
        int offset = -1;
 
@@ -143,7 +157,7 @@ bool AvisynthSource::isVersionSupported(const unsigned int &revision, const bool
 
        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("\nERROR: Your version of avs2yuv is unsupported (required version: v0.24 BugMaster's mod 6)"));
                log(tr("You can find the required version at: http://komisar.gin.by/tools/avs2yuv/"));
                return false;
        }
@@ -164,54 +178,30 @@ void AvisynthSource::checkSourceProperties_init(QList<QRegExp*> &patterns, QStri
        cmdLine << "-frames" << "1";
        cmdLine << QDir::toNativeSeparators(x264_path2ansi(m_sourceFile, true)) << "NUL";
 
-       patterns << new QRegExp(": (\\d+)x(\\d+), (\\d+) fps, (\\d+) frames");
-       patterns << new QRegExp(": (\\d+)x(\\d+), (\\d+)/(\\d+) fps, (\\d+) frames");
+       patterns << new QRegExp(":\\s+(\\d+)\\s*x\\s*(\\d+)\\s*,\\s+\\w+\\s*,\\s+\\d+-bits\\s*,\\s+\\w+\\s*,\\s+(\\d+)\\s+fps\\s*,\\s+(\\d+)\\s+frames");
+       patterns << new QRegExp(":\\s+(\\d+)\\s*x\\s*(\\d+)\\s*,\\s+\\w+\\s*,\\s+\\d+-bits\\s*,\\s+\\w+\\s*,\\s+(\\d+)\\s*/\\s*(\\d+)\\s+fps\\s*,\\s+(\\d+)\\s+frames");
 }
 
-void AvisynthSource::checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo)
+void AvisynthSource::checkSourceProperties_parseLine(const QString &line, const QList<QRegExp*> &patterns, ClipInfo &clipInfo)
 {
        int offset = -1;
+       quint32 temp[5];
 
        if((offset = patterns[0]->lastIndexIn(line)) >= 0)
        {
-               bool ok[4] = { false, false, false, false };
-               quint32 temp[4];
-               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]);
-               temp[3] = patterns[0]->cap(4).toUInt(&ok[3]);
-               if (ok[0] && ok[1])
+               if (MUtils::regexp_parse_uint32((*patterns[0]), temp, 4))
                {
                        clipInfo.setFrameSize(temp[0], temp[1]);
-               }
-               if (ok[2])
-               {
                        clipInfo.setFrameRate(temp[2], 0);
-               }
-               if (ok[3])
-               {
                        clipInfo.setFrameCount(temp[3]);
                }
        }
        else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
        {
-               bool ok[5] = { false, false, false, false, false };
-               quint32 temp[5];
-               temp[0] = patterns[1]->cap(1).toUInt(&ok[0]);
-               temp[1] = patterns[1]->cap(2).toUInt(&ok[1]);
-               temp[2] = patterns[1]->cap(3).toUInt(&ok[2]);
-               temp[3] = patterns[1]->cap(4).toUInt(&ok[3]);
-               temp[4] = patterns[1]->cap(5).toUInt(&ok[4]);
-               if (ok[0] && ok[1])
+               if (MUtils::regexp_parse_uint32((*patterns[1]), temp, 5))
                {
                        clipInfo.setFrameSize(temp[0], temp[1]);
-               }
-               if (ok[2] && ok[3])
-               {
                        clipInfo.setFrameRate(temp[2], temp[3]);
-               }
-               if (ok[4])
-               {
                        clipInfo.setFrameCount(temp[4]);
                }
        }