X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fsource_avisynth.cpp;h=06dc9c15da433e50d946fc08dcc239ecda1b446a;hb=2050a079c586f6a99e628117efb0f50d040839c3;hp=a697a3a5fdcaf30a19155b185d1576abc6175cfa;hpb=675ef7cef57b61736bc669a0f64b67becda1a93c;p=x264-launcher%2Fx264-launcher.git diff --git a/src/source_avisynth.cpp b/src/source_avisynth.cpp index a697a3a..06dc9c1 100644 --- a/src/source_avisynth.cpp +++ b/src/source_avisynth.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Simple x264 Launcher -// Copyright (C) 2004-2014 LoRd_MuldeR +// Copyright (C) 2004-2019 LoRd_MuldeR // // 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 @@ -24,14 +24,45 @@ #include "source_avisynth.h" #include "global.h" -#include "model_sysinfo.h" -#include "model_preferences.h" -#include "binaries.h" + +#include #include #include -static const unsigned int VER_X264_AVS2YUV_VER = 242; +static const unsigned int VER_X264_AVS2YUV_VER = 246; + +// ------------------------------------------------------------ +// Encoder Info +// ------------------------------------------------------------ + +class AvisynthSourceInfo : public AbstractSourceInfo +{ +public: + 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; + +const AbstractSourceInfo &AvisynthSource::getSourceInfo(void) +{ + return s_avisynthEncoderInfo; +} + // ------------------------------------------------------------ // Constructor & Destructor @@ -39,9 +70,7 @@ static const unsigned int VER_X264_AVS2YUV_VER = 242; AvisynthSource::AvisynthSource(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile) : - AbstractSource(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile), - m_sourceName("Avisynth (avs)"), - m_binaryFile(AVS_BINARY(m_sysinfo, m_preferences)) + AbstractSource(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile) { /*Nothing to do here*/ } @@ -51,9 +80,9 @@ AvisynthSource::~AvisynthSource(void) /*Nothing to do here*/ } -const QString &AvisynthSource::getName(void) +QString AvisynthSource::getName(void) const { - return m_sourceName; + return tr("Avisynth (avs)"); } // ------------------------------------------------------------ @@ -62,7 +91,7 @@ const QString &AvisynthSource::getName(void) bool AvisynthSource::isSourceAvailable() { - if(!(m_sysinfo->hasAVSSupport())) + if(!(m_sysinfo->hasAvisynth())) { log(tr("\nAVS INPUT REQUIRES AVISYNTH, BUT IT IS *NOT* AVAILABLE !!!")); return false; @@ -76,7 +105,7 @@ void AvisynthSource::checkVersion_init(QList &patterns, QStringList &c patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)bm(\\d)\\b", Qt::CaseInsensitive); } -void AvisynthSource::checkVersion_parseLine(const QString &line, QList &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified) +void AvisynthSource::checkVersion_parseLine(const QString &line, const QList &patterns, unsigned int &core, unsigned int &build, bool &modified) { int offset = -1; @@ -87,9 +116,10 @@ void AvisynthSource::checkVersion_parseLine(const QString &line, QList unsigned int temp2 = patterns[0]->cap(2).toUInt(&ok2); if(ok1 && ok2) { - coreVers = temp1; - revision = temp2; + core = temp1; + build = temp2; } + log(line); } else if((offset = patterns[1]->lastIndexIn(line)) >= 0) { @@ -99,10 +129,11 @@ void AvisynthSource::checkVersion_parseLine(const QString &line, QList 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); } } @@ -111,16 +142,22 @@ bool AvisynthSource::checkVersion_succeeded(const int &exitCode) return (exitCode == EXIT_SUCCESS) || (exitCode == 2); } -void AvisynthSource::printVersion(const unsigned int &revision, const bool &modified) +QString AvisynthSource::printVersion(const unsigned int &revision, const bool &modified) { - log(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("\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; } @@ -133,46 +170,40 @@ 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"; - 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 &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) +void AvisynthSource::checkSourceProperties_parseLine(const QString &line, const QList &patterns, ClipInfo &clipInfo) { - qWarning("parseLine \"%1\"", line.toUtf8().constData()); - int offset = -1; + quint32 temp[5]; if((offset = patterns[0]->lastIndexIn(line)) >= 0) { - bool ok1 = false, ok2 = false; - bool ok3 = false, ok4 = false; - unsigned int temp1 = patterns[0]->cap(1).toUInt(&ok1); - unsigned int temp2 = patterns[0]->cap(2).toUInt(&ok2); - unsigned int temp3 = patterns[0]->cap(3).toUInt(&ok3); - unsigned int temp4 = patterns[0]->cap(4).toUInt(&ok4); - if(ok1) fSizeW = temp1; - if(ok2) fSizeH = temp2; - if(ok3) fpsNom = temp3; - if(ok4) frames = temp4; + if (MUtils::regexp_parse_uint32((*patterns[0]), temp, 4)) + { + clipInfo.setFrameSize(temp[0], temp[1]); + clipInfo.setFrameRate(temp[2], 0); + clipInfo.setFrameCount(temp[3]); + } } else if((offset = patterns[1]->lastIndexIn(line)) >= 0) { - bool ok1 = false, ok2 = false; - bool ok3 = false, ok4 = false, ok5 = false; - unsigned int temp1 = patterns[1]->cap(1).toUInt(&ok1); - unsigned int temp2 = patterns[1]->cap(2).toUInt(&ok2); - unsigned int temp3 = patterns[1]->cap(3).toUInt(&ok3); - unsigned int temp4 = patterns[1]->cap(4).toUInt(&ok4); - unsigned int temp5 = patterns[1]->cap(5).toUInt(&ok5); - if(ok1) fSizeW = temp1; - if(ok2) fSizeH = temp2; - if(ok3) fpsNom = temp3; - if(ok4) fpsDen = temp4; - if(ok5) frames = temp5; + if (MUtils::regexp_parse_uint32((*patterns[1]), temp, 5)) + { + clipInfo.setFrameSize(temp[0], temp[1]); + clipInfo.setFrameRate(temp[2], temp[3]); + clipInfo.setFrameCount(temp[4]); + } } if(!line.isEmpty()) @@ -182,7 +213,7 @@ void AvisynthSource::checkSourceProperties_parseLine(const QString &line, QList< if(line.contains("failed to load avisynth.dll", Qt::CaseInsensitive)) { - log(tr("\nWarning: It seems that %1-Bit Avisynth is not currently installed !!!").arg(m_preferences->getUseAvisyth64Bit() ? "64" : "32")); + log(tr("\nWarning: It seems that Avisynth is not currently installed/available !!!")); } if(line.contains(QRegExp("couldn't convert input clip to (YV16|YV24)", Qt::CaseInsensitive))) { @@ -196,6 +227,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 << "-"; }