Some refactoring to allow supporting multiple encoders in the encode thread (far from being complete though).
This commit is contained in:
parent
52eb860a9c
commit
b356e28a32
140
src/encoder_abstract.cpp
Normal file
140
src/encoder_abstract.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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_abstract.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "model_options.h"
|
||||
#include "model_preferences.h"
|
||||
#include "model_sysinfo.h"
|
||||
#include "binaries.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
unsigned int AbstractEncoder::checkVersion(bool &modified)
|
||||
{
|
||||
if(m_preferences->getSkipVersionTest())
|
||||
{
|
||||
log("Warning: Skipping encoder version check this time!");
|
||||
return (999 * REV_MULT) + (REV_MULT-1);
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
QStringList cmdLine = QStringList() << "--version";
|
||||
|
||||
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!";
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
|
||||
unsigned int revision = UINT_MAX;
|
||||
unsigned int coreVers = UINT_MAX;
|
||||
modified = false;
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
if(m_abort)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
break;
|
||||
}
|
||||
if(!process.waitForReadyRead())
|
||||
{
|
||||
if(process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("encoder process timed out <-- killing!");
|
||||
log("\nPROCESS TIMEOUT !!!");
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if(!text.isEmpty())
|
||||
{
|
||||
log(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.waitForFinished();
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
process.kill();
|
||||
process.waitForFinished(-1);
|
||||
}
|
||||
|
||||
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
|
||||
{
|
||||
if(!(bTimeout || bAborted))
|
||||
{
|
||||
log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode())));
|
||||
}
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
if((revision == UINT_MAX) || (coreVers == UINT_MAX))
|
||||
{
|
||||
log(tr("\nFAILED TO DETERMINE ENCODER VERSION !!!"));
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
return (coreVers * REV_MULT) + (revision % REV_MULT);
|
||||
}
|
39
src/encoder_abstract.h
Normal file
39
src/encoder_abstract.h
Normal file
@ -0,0 +1,39 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 "tool_abstract.h"
|
||||
|
||||
class QRegExp;
|
||||
template<class T> class QList;
|
||||
|
||||
class AbstractEncoder : AbstractTool
|
||||
{
|
||||
public:
|
||||
static const unsigned int REV_MULT = 10000;
|
||||
|
||||
virtual unsigned int checkVersion(bool &modified);
|
||||
|
||||
protected:
|
||||
virtual void checkVersion_init(QList<QRegExp*> *patterns) = 0;
|
||||
virtual void checkVersion_parseLine(QRegExp *pattern, unsigned int &coreVers, unsigned int &revision, bool &modified) = 0;
|
||||
};
|
@ -122,7 +122,6 @@ while(0)
|
||||
/*
|
||||
* Static vars
|
||||
*/
|
||||
static const unsigned int REV_MULT = 10000;
|
||||
static const char *VPS_TEST_FILE = "import vapoursynth as vs\ncore = vs.get_core()\nv = core.std.BlankClip()\nv.set_output()\n";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -253,41 +252,54 @@ void EncodeThread::encode(void)
|
||||
|
||||
//Checking x264 version
|
||||
log(tr("\n--- CHECK VERSION ---\n"));
|
||||
unsigned int revision_x264 = UINT_MAX;
|
||||
bool x264_modified = false;
|
||||
ok = ((revision_x264 = checkVersionX264(x264_modified)) != UINT_MAX);
|
||||
unsigned int encoderRevision = UINT_MAX;
|
||||
bool encoderModified = false;
|
||||
ok = ((encoderRevision = checkVersionEncoder(encoderModified)) != UINT_MAX);
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
|
||||
//Checking avs2yuv version
|
||||
unsigned int revision_avs2yuv = UINT_MAX;
|
||||
switch(inputType)
|
||||
{
|
||||
case INPUT_AVISYN:
|
||||
ok = ((revision_avs2yuv = checkVersionAvs2yuv()) != UINT_MAX);
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
break;
|
||||
case INPUT_VAPOUR:
|
||||
ok = checkVersionVapoursynth();
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
break;
|
||||
case INPUT_NATIVE: break;
|
||||
case INPUT_AVISYN: ok = ((revision_avs2yuv = checkVersionAvs2yuv()) != UINT_MAX); break;
|
||||
case INPUT_VAPOUR: ok = checkVersionVapoursynth(); break;
|
||||
default: throw "Invalid input type!";
|
||||
}
|
||||
CHECK_STATUS(m_abort, ok);
|
||||
|
||||
//Print versions
|
||||
log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(revision_x264 % REV_MULT), QString::number(revision_x264 / REV_MULT)).append(x264_modified ? tr(" - with custom patches!") : QString()));
|
||||
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)));
|
||||
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;
|
||||
}
|
||||
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 x264 revision supported?
|
||||
if((revision_x264 % REV_MULT) < x264_version_x264_minimum_rev())
|
||||
//Is encoder version suppoprted?
|
||||
if(m_options->encType() == OptionsModel::EncType_X264)
|
||||
{
|
||||
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_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())));
|
||||
}
|
||||
}
|
||||
if((revision_x264 / REV_MULT) != x264_version_x264_current_api())
|
||||
else if(m_options->encType() == OptionsModel::EncType_X264)
|
||||
{
|
||||
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())));
|
||||
/*TODO*/
|
||||
}
|
||||
|
||||
//Is Avs2YUV version supported?
|
||||
if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != x264_version_x264_avs2yuv_ver()))
|
||||
{
|
||||
log(tr("\nERROR: Your version of avs2yuv is unsupported (Required version: v0.24 BugMaster's mod 2)"));
|
||||
@ -705,107 +717,9 @@ QStringList EncodeThread::buildCommandLine(const bool &usePipe, const unsigned i
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
unsigned int EncodeThread::checkVersionX264(bool &modified)
|
||||
unsigned int EncodeThread::checkVersionEncoder(bool &modified)
|
||||
{
|
||||
if(m_preferences->getSkipVersionTest())
|
||||
{
|
||||
log("Warning: Skipping x264 version check this time!");
|
||||
return (999 * REV_MULT) + (9999 % REV_MULT);
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
QStringList cmdLine = QStringList() << "--version";
|
||||
|
||||
log("Creating process:");
|
||||
if(!startProcess(process, ENC_BINARY(m_sysinfo, m_options), cmdLine))
|
||||
{
|
||||
return false;;
|
||||
}
|
||||
|
||||
QRegExp regExpVersion("\\bx264\\s(\\d)\\.(\\d+)\\.(\\d+)\\s([a-f0-9]{7})", Qt::CaseInsensitive);
|
||||
QRegExp regExpVersionMod("\\bx264 (\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
|
||||
unsigned int revision = UINT_MAX;
|
||||
unsigned int coreVers = UINT_MAX;
|
||||
modified = false;
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
if(m_abort)
|
||||
{
|
||||
process.kill();
|
||||
bAborted = true;
|
||||
break;
|
||||
}
|
||||
if(!process.waitForReadyRead())
|
||||
{
|
||||
if(process.state() == QProcess::Running)
|
||||
{
|
||||
process.kill();
|
||||
qWarning("x264 process timed out <-- killing!");
|
||||
log("\nPROCESS TIMEOUT !!!");
|
||||
bTimeout = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(process.bytesAvailable() > 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
if(!text.isEmpty())
|
||||
{
|
||||
log(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.waitForFinished();
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
process.kill();
|
||||
process.waitForFinished(-1);
|
||||
}
|
||||
|
||||
if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
|
||||
{
|
||||
if(!(bTimeout || bAborted))
|
||||
{
|
||||
log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode())));
|
||||
}
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
if((revision == UINT_MAX) || (coreVers == UINT_MAX))
|
||||
{
|
||||
log(tr("\nFAILED TO DETERMINE X264 VERSION !!!"));
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
return (coreVers * REV_MULT) + (revision % REV_MULT);
|
||||
}
|
||||
|
||||
unsigned int EncodeThread::checkVersionAvs2yuv(void)
|
||||
@ -1368,55 +1282,6 @@ QString EncodeThread::stringToHash(const QString &string)
|
||||
return QString::fromLatin1(result.toHex().constData());
|
||||
}
|
||||
|
||||
bool EncodeThread::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels)
|
||||
{
|
||||
QMutexLocker lock(&m_mutex_startProcess);
|
||||
log(commandline2string(program, args) + "\n");
|
||||
|
||||
process.setWorkingDirectory(QDir::tempPath());
|
||||
|
||||
if(mergeChannels)
|
||||
{
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
}
|
||||
else
|
||||
{
|
||||
process.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
process.setReadChannel(QProcess::StandardError);
|
||||
}
|
||||
|
||||
process.start(program, args);
|
||||
|
||||
if(process.waitForStarted())
|
||||
{
|
||||
m_jobObject->addProcessToJob(&process);
|
||||
x264_change_process_priority(&process, m_preferences->getProcessPriority());
|
||||
lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
log("Process creation has failed :-(");
|
||||
QString errorMsg= process.errorString().trimmed();
|
||||
if(!errorMsg.isEmpty()) log(errorMsg);
|
||||
|
||||
process.kill();
|
||||
process.waitForFinished(-1);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString EncodeThread::commandline2string(const QString &program, const QStringList &arguments)
|
||||
{
|
||||
QString commandline = (program.contains(' ') ? QString("\"%1\"").arg(program) : program);
|
||||
|
||||
for(int i = 0; i < arguments.count(); i++)
|
||||
{
|
||||
commandline += (arguments.at(i).contains(' ') ? QString(" \"%1\"").arg(arguments.at(i)) : QString(" %1").arg(arguments.at(i)));
|
||||
}
|
||||
|
||||
return commandline;
|
||||
}
|
||||
|
||||
QStringList EncodeThread::splitParams(const QString ¶ms)
|
||||
{
|
||||
QStringList list;
|
||||
|
@ -110,7 +110,7 @@ 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 checkVersionX264(bool &modified);
|
||||
unsigned int checkVersionEncoder(bool &modified);
|
||||
unsigned int checkVersionAvs2yuv(void);
|
||||
bool checkVersionVapoursynth(void);
|
||||
bool checkPropertiesAVS(unsigned int &frames);
|
||||
@ -121,12 +121,10 @@ protected:
|
||||
inline void setStatus(JobStatus newStatus);
|
||||
inline void setProgress(unsigned int newProgress);
|
||||
inline void setDetails(const QString &text);
|
||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true);
|
||||
QStringList splitParams(const QString ¶ms);
|
||||
qint64 estimateSize(int progress);
|
||||
|
||||
//Static functions
|
||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||
static QString sizeToString(qint64 size);
|
||||
static int getInputType(const QString &fileExt);
|
||||
static QString stringToHash(const QString &string);
|
||||
|
95
src/tool_abstract.cpp
Normal file
95
src/tool_abstract.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 "tool_abstract.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "model_options.h"
|
||||
#include "model_preferences.h"
|
||||
#include "model_sysinfo.h"
|
||||
#include "binaries.h"
|
||||
#include "job_object.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QMutexLocker>
|
||||
#include <QDir>
|
||||
|
||||
QMutex AbstractTool::s_mutexStartProcess;
|
||||
|
||||
AbstractTool::AbstractTool(volatile bool *abort, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobObject *jobObject)
|
||||
:
|
||||
m_abort(abort),
|
||||
m_options(options),
|
||||
m_sysinfo(sysinfo),
|
||||
m_preferences(preferences),
|
||||
m_jobObject(jobObject)
|
||||
{
|
||||
/*nothing to do here*/
|
||||
}
|
||||
|
||||
bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels)
|
||||
{
|
||||
QMutexLocker lock(&s_mutexStartProcess);
|
||||
log(commandline2string(program, args) + "\n");
|
||||
|
||||
process.setWorkingDirectory(QDir::tempPath());
|
||||
|
||||
if(mergeChannels)
|
||||
{
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
}
|
||||
else
|
||||
{
|
||||
process.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
process.setReadChannel(QProcess::StandardError);
|
||||
}
|
||||
|
||||
process.start(program, args);
|
||||
|
||||
if(process.waitForStarted())
|
||||
{
|
||||
m_jobObject->addProcessToJob(&process);
|
||||
x264_change_process_priority(&process, m_preferences->getProcessPriority());
|
||||
lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
log("Process creation has failed :-(");
|
||||
QString errorMsg= process.errorString().trimmed();
|
||||
if(!errorMsg.isEmpty()) log(errorMsg);
|
||||
|
||||
process.kill();
|
||||
process.waitForFinished(-1);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString AbstractTool::commandline2string(const QString &program, const QStringList &arguments)
|
||||
{
|
||||
QString commandline = (program.contains(' ') ? QString("\"%1\"").arg(program) : program);
|
||||
|
||||
for(int i = 0; i < arguments.count(); i++)
|
||||
{
|
||||
commandline += (arguments.at(i).contains(' ') ? QString(" \"%1\"").arg(arguments.at(i)) : QString(" %1").arg(arguments.at(i)));
|
||||
}
|
||||
|
||||
return commandline;
|
||||
}
|
56
src/tool_abstract.h
Normal file
56
src/tool_abstract.h
Normal file
@ -0,0 +1,56 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <QObject>
|
||||
#include <QMutex>
|
||||
|
||||
class OptionsModel;
|
||||
class SysinfoModel;
|
||||
class PreferencesModel;
|
||||
class JobObject;
|
||||
class QProcess;
|
||||
|
||||
class AbstractTool : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AbstractTool(volatile bool *abort, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobObject *jobObject);
|
||||
virtual ~AbstractTool(void) {/*NOP*/}
|
||||
|
||||
signals:
|
||||
void messageLogged(const QString &text);
|
||||
|
||||
protected:
|
||||
void log(const QString &text) { emit messageLogged(text); }
|
||||
bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true);
|
||||
static QString commandline2string(const QString &program, const QStringList &arguments);
|
||||
|
||||
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;
|
||||
};
|
@ -25,8 +25,8 @@
|
||||
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 3
|
||||
#define VER_X264_PATCH 1
|
||||
#define VER_X264_BUILD 779
|
||||
#define VER_X264_PATCH 2
|
||||
#define VER_X264_BUILD 780
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2380
|
||||
#define VER_X264_CURRENT_API 142
|
||||
|
@ -512,7 +512,7 @@ void AddJobDialog::accept(void)
|
||||
}
|
||||
}
|
||||
|
||||
//Is output file extension supported by encoder
|
||||
//Is output file extension supported by encoder?
|
||||
QFileInfo outputFile = QFileInfo(this->outputFile());
|
||||
if((outputFile.suffix().compare("264", Qt::CaseInsensitive) == 0) && (ui->cbxEncoderType->currentIndex() == OptionsModel::EncType_X265))
|
||||
{
|
||||
|
@ -296,6 +296,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<ClInclude Include="src\binaries.h" />
|
||||
<ClInclude Include="src\checksum.h" />
|
||||
<ClInclude Include="src\cli.h" />
|
||||
<ClInclude Include="src\encoder_abstract.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>
|
||||
@ -353,6 +354,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="src\tool_abstract.h" />
|
||||
<ClInclude Include="src\version.h" />
|
||||
<CustomBuild Include="src\win_main.h">
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
|
||||
@ -369,6 +371,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<ClCompile Include="src\binaries.cpp" />
|
||||
<ClCompile Include="src\checksum.cpp" />
|
||||
<ClCompile Include="src\cli.cpp" />
|
||||
<ClCompile Include="src\encoder_abstract.cpp" />
|
||||
<ClCompile Include="src\ipc.cpp" />
|
||||
<ClCompile Include="src\job_object.cpp" />
|
||||
<ClCompile Include="src\model_jobList.cpp" />
|
||||
@ -383,6 +386,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
<ClCompile Include="src\thread_updater.cpp" />
|
||||
<ClCompile Include="src\thread_vapoursynth.cpp" />
|
||||
<ClCompile Include="src\tool_abstract.cpp" />
|
||||
<ClCompile Include="src\win_addJob.cpp" />
|
||||
<ClCompile Include="src\win_editor.cpp" />
|
||||
<ClCompile Include="src\win_help.cpp" />
|
||||
|
@ -84,6 +84,12 @@
|
||||
<ClInclude Include="src\binaries.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\encoder_abstract.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\tool_abstract.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
@ -203,6 +209,12 @@
|
||||
<ClCompile Include="src\binaries.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\encoder_abstract.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\tool_abstract.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="src\win_main.h">
|
||||
|
Loading…
Reference in New Issue
Block a user