Refactored encoder version detection into encoder-specific classes.
This commit is contained in:
parent
b356e28a32
commit
0fa2a16e13
@ -29,6 +29,18 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
AbstractEncoder::AbstractEncoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort)
|
||||
:
|
||||
AbstractTool(jobId, jobObject, options, sysinfo, preferences, abort)
|
||||
{
|
||||
/*Nothing to do here*/
|
||||
}
|
||||
|
||||
AbstractEncoder::~AbstractEncoder(void)
|
||||
{
|
||||
/*Nothing to do here*/
|
||||
}
|
||||
|
||||
unsigned int AbstractEncoder::checkVersion(bool &modified)
|
||||
{
|
||||
if(m_preferences->getSkipVersionTest())
|
||||
@ -38,22 +50,16 @@ unsigned int AbstractEncoder::checkVersion(bool &modified)
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
QStringList cmdLine = QStringList() << "--version";
|
||||
QList<QRegExp*> patterns;
|
||||
QStringList cmdLine;
|
||||
|
||||
//Init encoder-specific values
|
||||
checkVersion_init(patterns, cmdLine);
|
||||
|
||||
log("Creating process:");
|
||||
if(!startProcess(process, ENC_BINARY(m_sysinfo, m_options), cmdLine))
|
||||
{
|
||||
return false;;
|
||||
}
|
||||
|
||||
QRegExp regExpVersion("", Qt::CaseInsensitive);
|
||||
QRegExp regExpVersionMod("\\bx264 (\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
|
||||
|
||||
switch(m_options->encType())
|
||||
{
|
||||
case OptionsModel::EncType_X264: regExpVersion.setPattern("\\bx264\\s(\\d)\\.(\\d+)\\.(\\d+)\\s([a-f0-9]{7})");
|
||||
case OptionsModel::EncType_X265: regExpVersion.setPattern("\\bHEVC\\s+encoder\\s+version\\s+0\\.(\\d+)\\+(\\d+)-[a-f0-9]+\\b");
|
||||
default: throw "Invalid encoder type!";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
@ -87,25 +93,8 @@ unsigned int AbstractEncoder::checkVersion(bool &modified)
|
||||
QList<QByteArray> lines = process.readLine().split('\r');
|
||||
while(!lines.isEmpty())
|
||||
{
|
||||
QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified();
|
||||
int offset = -1;
|
||||
if((offset = regExpVersion.lastIndexIn(text)) >= 0)
|
||||
{
|
||||
bool ok1 = false, ok2 = false;
|
||||
unsigned int temp1 = regExpVersion.cap(2).toUInt(&ok1);
|
||||
unsigned int temp2 = regExpVersion.cap(3).toUInt(&ok2);
|
||||
if(ok1) coreVers = temp1;
|
||||
if(ok2) revision = temp2;
|
||||
}
|
||||
else if((offset = regExpVersionMod.lastIndexIn(text)) >= 0)
|
||||
{
|
||||
bool ok1 = false, ok2 = false;
|
||||
unsigned int temp1 = regExpVersionMod.cap(2).toUInt(&ok1);
|
||||
unsigned int temp2 = regExpVersionMod.cap(3).toUInt(&ok2);
|
||||
if(ok1) coreVers = temp1;
|
||||
if(ok2) revision = temp2;
|
||||
modified = true;
|
||||
}
|
||||
const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified();
|
||||
checkVersion_parseLine(text, patterns, coreVers, revision, modified);
|
||||
if(!text.isEmpty())
|
||||
{
|
||||
log(text);
|
||||
@ -121,6 +110,12 @@ unsigned int AbstractEncoder::checkVersion(bool &modified)
|
||||
process.waitForFinished(-1);
|
||||
}
|
||||
|
||||
while(!patterns.isEmpty())
|
||||
{
|
||||
QRegExp *pattern = patterns.takeFirst();
|
||||
X264_DELETE(pattern);
|
||||
}
|
||||
|
||||
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
|
||||
{
|
||||
if(!(bTimeout || bAborted))
|
||||
|
@ -26,14 +26,19 @@
|
||||
class QRegExp;
|
||||
template<class T> class QList;
|
||||
|
||||
class AbstractEncoder : AbstractTool
|
||||
class AbstractEncoder : public AbstractTool
|
||||
{
|
||||
public:
|
||||
static const unsigned int REV_MULT = 10000;
|
||||
|
||||
AbstractEncoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort);
|
||||
virtual ~AbstractEncoder(void);
|
||||
|
||||
virtual unsigned int checkVersion(bool &modified);
|
||||
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified) = 0;
|
||||
virtual void printVersion(const unsigned int &revision, const bool &modified) = 0;
|
||||
|
||||
protected:
|
||||
virtual void checkVersion_init(QList<QRegExp*> *patterns) = 0;
|
||||
virtual void checkVersion_parseLine(QRegExp *pattern, unsigned int &coreVers, unsigned int &revision, bool &modified) = 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;
|
||||
};
|
||||
|
98
src/encoder_x264.cpp
Normal file
98
src/encoder_x264.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2014 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "encoder_x264.h"
|
||||
|
||||
#include "model_options.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
//x264 version info
|
||||
static const unsigned int X264_VERSION_X264_MINIMUM_REV = 2380;
|
||||
static const unsigned int X264_VERSION_X264_CURRENT_API = 142;
|
||||
|
||||
X264Encoder::X264Encoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort)
|
||||
:
|
||||
AbstractEncoder(jobId, jobObject, options, sysinfo, preferences, abort)
|
||||
{
|
||||
if(options->encType() != OptionsModel::EncType_X264)
|
||||
{
|
||||
throw "Invalid encoder type!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
X264Encoder::~X264Encoder(void)
|
||||
{
|
||||
/*Nothing to do here*/
|
||||
}
|
||||
|
||||
void X264Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
|
||||
{
|
||||
cmdLine << "--version";
|
||||
patterns << new QRegExp("\\bx264\\s(\\d)\\.(\\d+)\\.(\\d+)\\s([a-f0-9]{7})", Qt::CaseInsensitive);
|
||||
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)
|
||||
{
|
||||
int offset = -1;
|
||||
if((offset = patterns[0]->lastIndexIn(line)) >= 0)
|
||||
{
|
||||
bool ok1 = false, ok2 = false;
|
||||
unsigned int temp1 = patterns[0]->cap(2).toUInt(&ok1);
|
||||
unsigned int temp2 = patterns[0]->cap(3).toUInt(&ok2);
|
||||
if(ok1) coreVers = temp1;
|
||||
if(ok2) revision = temp2;
|
||||
}
|
||||
else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
|
||||
{
|
||||
bool ok1 = false, ok2 = false;
|
||||
unsigned int temp1 = patterns[1]->cap(2).toUInt(&ok1);
|
||||
unsigned int temp2 = patterns[1]->cap(3).toUInt(&ok2);
|
||||
if(ok1) coreVers = temp1;
|
||||
if(ok2) revision = temp2;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
void X264Encoder::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT)).append(modified ? tr(" - with custom patches!") : QString()));
|
||||
}
|
||||
|
||||
bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
if((revision % REV_MULT) < X264_VERSION_X264_MINIMUM_REV)
|
||||
{
|
||||
log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %1)").arg(QString::number(X264_VERSION_X264_MINIMUM_REV)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if((revision / REV_MULT) != X264_VERSION_X264_CURRENT_API)
|
||||
{
|
||||
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
|
||||
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(X264_VERSION_X264_CURRENT_API)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
38
src/encoder_x264.h
Normal file
38
src/encoder_x264.h
Normal file
@ -0,0 +1,38 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2014 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "encoder_abstract.h"
|
||||
|
||||
class X264Encoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
X264Encoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort);
|
||||
virtual ~X264Encoder(void);
|
||||
|
||||
virtual void printVersion(const unsigned int &revision, const bool &modified);
|
||||
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);
|
||||
|
||||
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);
|
||||
};
|
84
src/encoder_x265.cpp
Normal file
84
src/encoder_x265.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2014 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "encoder_x265.h"
|
||||
|
||||
#include "model_options.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
|
||||
//x265 version info
|
||||
static const unsigned int X265_VERSION_X264_MINIMUM_VER = 7;
|
||||
static const unsigned int X265_VERSION_X264_MINIMUM_REV = 167;
|
||||
|
||||
X265Encoder::X265Encoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort)
|
||||
:
|
||||
AbstractEncoder(jobId, jobObject, options, sysinfo, preferences, abort)
|
||||
{
|
||||
if(options->encType() != OptionsModel::EncType_X265)
|
||||
{
|
||||
throw "Invalid encoder type!";
|
||||
}
|
||||
}
|
||||
|
||||
X265Encoder::~X265Encoder(void)
|
||||
{
|
||||
/*Nothing to do here*/
|
||||
}
|
||||
|
||||
void X265Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
|
||||
{
|
||||
cmdLine << "--version";
|
||||
patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+0\\.(\\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)
|
||||
{
|
||||
int offset = -1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void X265Encoder::printVersion(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
log(tr("\nx265 version: 0.%1+%2").arg(QString::number(revision / REV_MULT), QString::number(revision % REV_MULT)));
|
||||
}
|
||||
|
||||
bool X265Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
|
||||
{
|
||||
const unsigned int ver = (revision / REV_MULT);
|
||||
const unsigned int rev = (revision % REV_MULT);
|
||||
|
||||
if((ver < X265_VERSION_X264_MINIMUM_VER) || (rev < X265_VERSION_X264_MINIMUM_REV))
|
||||
{
|
||||
log(tr("\nERROR: Your version of x265 is too old! (Minimum required revision is 0.%1+%2)").arg(QString::number(X265_VERSION_X264_MINIMUM_VER), QString::number(X265_VERSION_X264_MINIMUM_REV)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
38
src/encoder_x265.h
Normal file
38
src/encoder_x265.h
Normal file
@ -0,0 +1,38 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2014 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "encoder_abstract.h"
|
||||
|
||||
class X265Encoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
X265Encoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort);
|
||||
virtual ~X265Encoder(void);
|
||||
|
||||
virtual void printVersion(const unsigned int &revision, const bool &modified);
|
||||
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);
|
||||
|
||||
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);
|
||||
};
|
@ -112,8 +112,6 @@ static const struct
|
||||
unsigned int ver_build;
|
||||
const char* ver_date;
|
||||
const char* ver_time;
|
||||
unsigned int ver_x264_minimum_rev;
|
||||
unsigned int ver_x264_current_api;
|
||||
unsigned int ver_x264_avs2yuv_ver;
|
||||
}
|
||||
g_x264_version =
|
||||
@ -124,8 +122,6 @@ g_x264_version =
|
||||
(VER_X264_BUILD),
|
||||
__DATE__,
|
||||
__TIME__,
|
||||
(VER_X264_MINIMUM_REV),
|
||||
(VER_X264_CURRENT_API),
|
||||
(VER_X264_AVS2YUV_VER)
|
||||
};
|
||||
|
||||
@ -763,16 +759,7 @@ const char *x264_version_arch(void)
|
||||
return g_x264_version_arch;
|
||||
}
|
||||
|
||||
unsigned int x264_version_x264_minimum_rev(void)
|
||||
{
|
||||
return g_x264_version.ver_x264_minimum_rev;
|
||||
}
|
||||
|
||||
unsigned int x264_version_x264_current_api(void)
|
||||
{
|
||||
return g_x264_version.ver_x264_current_api;
|
||||
}
|
||||
|
||||
//FIXME: Remove x264_version_x264_avs2yuv_ver!
|
||||
unsigned int x264_version_x264_avs2yuv_ver(void)
|
||||
{
|
||||
return g_x264_version.ver_x264_avs2yuv_ver;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "model_options.h"
|
||||
#include "model_preferences.h"
|
||||
#include "model_sysinfo.h"
|
||||
#include "encoder_x264.h"
|
||||
#include "encoder_x265.h"
|
||||
#include "job_object.h"
|
||||
#include "binaries.h"
|
||||
|
||||
@ -141,12 +143,27 @@ EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputF
|
||||
{
|
||||
m_abort = false;
|
||||
m_pause = false;
|
||||
|
||||
//Create encoder object
|
||||
switch(options->encType())
|
||||
{
|
||||
case OptionsModel::EncType_X264:
|
||||
m_encoder = new X264Encoder(&m_jobId, m_jobObject, m_options, m_sysinfo, m_preferences, &m_abort);
|
||||
break;
|
||||
case OptionsModel::EncType_X265:
|
||||
m_encoder = new X265Encoder(&m_jobId, m_jobObject, m_options, m_sysinfo, m_preferences, &m_abort);
|
||||
break;
|
||||
default:
|
||||
throw "Unknown encoder type encountered!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EncodeThread::~EncodeThread(void)
|
||||
{
|
||||
X264_DELETE(m_options);
|
||||
X264_DELETE(m_encoder);
|
||||
X264_DELETE(m_jobObject);
|
||||
X264_DELETE(m_options);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -223,6 +240,10 @@ void EncodeThread::encode(void)
|
||||
{
|
||||
QDateTime startTime = QDateTime::currentDateTime();
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Print Information
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
//Print some basic info
|
||||
log(tr("Simple x264 Launcher (Build #%1), built %2\n").arg(QString::number(x264_version_build()), x264_version_date().toString(Qt::ISODate)));
|
||||
log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
|
||||
@ -250,12 +271,16 @@ void EncodeThread::encode(void)
|
||||
const int inputType = getInputType(QFileInfo(m_sourceFileName).suffix());
|
||||
const QString indexFile = QString("%1/x264_%2.ffindex").arg(QDir::tempPath(), stringToHash(m_sourceFileName));
|
||||
|
||||
//Checking x264 version
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Check Versions
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
log(tr("\n--- CHECK VERSION ---\n"));
|
||||
unsigned int encoderRevision = UINT_MAX;
|
||||
|
||||
//Check encoder version
|
||||
bool encoderModified = false;
|
||||
ok = ((encoderRevision = checkVersionEncoder(encoderModified)) != UINT_MAX);
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
unsigned int encoderRevision = m_encoder->checkVersion(encoderModified);
|
||||
CHECK_STATUS(m_abort, (ok = (encoderRevision != UINT_MAX)));
|
||||
|
||||
//Checking avs2yuv version
|
||||
unsigned int revision_avs2yuv = UINT_MAX;
|
||||
@ -269,34 +294,17 @@ void EncodeThread::encode(void)
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
|
||||
//Print versions
|
||||
switch(m_options->encType())
|
||||
{
|
||||
case OptionsModel::EncType_X264: log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(encoderRevision % REV_MULT), QString::number(encoderRevision / REV_MULT)).append(encoderModified ? tr(" - with custom patches!") : QString())); break;
|
||||
case OptionsModel::EncType_X265: log(tr("\nx265 version: 0.%1+%2").arg(QString::number(encoderRevision / REV_MULT), QString::number(encoderRevision % REV_MULT))); break;
|
||||
}
|
||||
m_encoder->printVersion(encoderRevision, encoderModified);
|
||||
if(revision_avs2yuv != UINT_MAX)
|
||||
{
|
||||
log(tr("Avs2YUV version: %1.%2.%3").arg(QString::number(revision_avs2yuv / REV_MULT), QString::number((revision_avs2yuv % REV_MULT) / 10),QString::number((revision_avs2yuv % REV_MULT) % 10)));
|
||||
}
|
||||
|
||||
//Is encoder version suppoprted?
|
||||
if(m_options->encType() == OptionsModel::EncType_X264)
|
||||
if(!m_encoder->isVersionSupported(encoderRevision, encoderModified))
|
||||
{
|
||||
if((encoderRevision % REV_MULT) < x264_version_x264_minimum_rev())
|
||||
{
|
||||
log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %2)").arg(QString::number(x264_version_x264_minimum_rev())));
|
||||
setStatus(JobStatus_Failed);
|
||||
return;
|
||||
}
|
||||
if((encoderRevision / REV_MULT) != x264_version_x264_current_api())
|
||||
{
|
||||
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
|
||||
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(x264_version_x264_current_api())));
|
||||
}
|
||||
}
|
||||
else if(m_options->encType() == OptionsModel::EncType_X264)
|
||||
{
|
||||
/*TODO*/
|
||||
setStatus(JobStatus_Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
//Is Avs2YUV version supported?
|
||||
@ -308,6 +316,10 @@ void EncodeThread::encode(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
// Detect Source Info
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
//Detect source info
|
||||
if(inputType != INPUT_NATIVE)
|
||||
{
|
||||
@ -717,11 +729,6 @@ QStringList EncodeThread::buildCommandLine(const bool &usePipe, const unsigned i
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
unsigned int EncodeThread::checkVersionEncoder(bool &modified)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int EncodeThread::checkVersionAvs2yuv(void)
|
||||
{
|
||||
if(!m_sysinfo->hasAVSSupport())
|
||||
|
@ -34,6 +34,7 @@ class PreferencesModel;
|
||||
class OptionsModel;
|
||||
class QProcess;
|
||||
class JobObject;
|
||||
class AbstractEncoder;
|
||||
|
||||
class EncodeThread : public QThread
|
||||
{
|
||||
@ -102,6 +103,9 @@ protected:
|
||||
JobStatus m_status;
|
||||
unsigned int m_progress;
|
||||
|
||||
//Encoder and Source objects
|
||||
AbstractEncoder *m_encoder;
|
||||
|
||||
//Entry point
|
||||
virtual void run(void);
|
||||
virtual void checkedRun(void);
|
||||
@ -110,7 +114,6 @@ protected:
|
||||
void encode(void);
|
||||
bool runEncodingPass(const int &inputType, const unsigned int &frames, const QString &indexFile, const int &pass = 0, const QString &passLogFile = QString());
|
||||
QStringList buildCommandLine(const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass = 0, const QString &passLogFile = QString());
|
||||
unsigned int checkVersionEncoder(bool &modified);
|
||||
unsigned int checkVersionAvs2yuv(void);
|
||||
bool checkVersionVapoursynth(void);
|
||||
bool checkPropertiesAVS(unsigned int &frames);
|
||||
|
@ -34,13 +34,14 @@
|
||||
|
||||
QMutex AbstractTool::s_mutexStartProcess;
|
||||
|
||||
AbstractTool::AbstractTool(volatile bool *abort, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobObject *jobObject)
|
||||
AbstractTool::AbstractTool(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort)
|
||||
:
|
||||
m_abort(abort),
|
||||
m_jobId(jobId),
|
||||
m_jobObject(jobObject),
|
||||
m_options(options),
|
||||
m_sysinfo(sysinfo),
|
||||
m_preferences(preferences),
|
||||
m_jobObject(jobObject)
|
||||
m_abort(abort)
|
||||
{
|
||||
/*nothing to do here*/
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
#include <QMutex>
|
||||
|
||||
class OptionsModel;
|
||||
@ -35,22 +36,23 @@ class AbstractTool : QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AbstractTool(volatile bool *abort, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobObject *jobObject);
|
||||
AbstractTool(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort);
|
||||
virtual ~AbstractTool(void) {/*NOP*/}
|
||||
|
||||
signals:
|
||||
void messageLogged(const QString &text);
|
||||
void messageLogged(const QUuid &jobId, const QString &text);
|
||||
|
||||
protected:
|
||||
void log(const QString &text) { emit messageLogged(text); }
|
||||
inline void log(const QString &text) { emit messageLogged((*m_jobId), text); }
|
||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true);
|
||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||
|
||||
const QUuid *const m_jobId;
|
||||
JobObject *const m_jobObject;
|
||||
const OptionsModel *const m_options;
|
||||
const SysinfoModel *const m_sysinfo;
|
||||
const PreferencesModel *const m_preferences;
|
||||
JobObject *const m_jobObject;
|
||||
|
||||
volatile bool *const m_abort;
|
||||
|
||||
static QMutex s_mutexStartProcess;
|
||||
};
|
||||
|
@ -26,10 +26,8 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 3
|
||||
#define VER_X264_PATCH 2
|
||||
#define VER_X264_BUILD 780
|
||||
#define VER_X264_BUILD 782
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2380
|
||||
#define VER_X264_CURRENT_API 142
|
||||
#define VER_X264_AVS2YUV_VER 242
|
||||
|
||||
#define VER_X264_PORTABLE_EDITION (0)
|
||||
|
@ -297,6 +297,8 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<ClInclude Include="src\checksum.h" />
|
||||
<ClInclude Include="src\cli.h" />
|
||||
<ClInclude Include="src\encoder_abstract.h" />
|
||||
<ClInclude Include="src\encoder_x264.h" />
|
||||
<ClInclude Include="src\encoder_x265.h" />
|
||||
<ClInclude Include="src\global.h" />
|
||||
<CustomBuild Include="src\model_jobList.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
|
||||
@ -372,6 +374,8 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<ClCompile Include="src\checksum.cpp" />
|
||||
<ClCompile Include="src\cli.cpp" />
|
||||
<ClCompile Include="src\encoder_abstract.cpp" />
|
||||
<ClCompile Include="src\encoder_x264.cpp" />
|
||||
<ClCompile Include="src\encoder_x265.cpp" />
|
||||
<ClCompile Include="src\ipc.cpp" />
|
||||
<ClCompile Include="src\job_object.cpp" />
|
||||
<ClCompile Include="src\model_jobList.cpp" />
|
||||
|
@ -90,6 +90,12 @@
|
||||
<ClInclude Include="src\tool_abstract.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\encoder_x264.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\encoder_x265.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
@ -215,6 +221,12 @@
|
||||
<ClCompile Include="src\tool_abstract.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\encoder_x264.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\encoder_x265.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="src\win_main.h">
|
||||
|
Loading…
Reference in New Issue
Block a user