Implemented VSPipe version detection + various fixes.

This commit is contained in:
LoRd_MuldeR 2014-02-25 22:44:39 +01:00
parent 38e7dbae56
commit 155f66c061
8 changed files with 69 additions and 45 deletions

View File

@ -33,6 +33,7 @@ public:
AbstractSource(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);
virtual ~AbstractSource(void);
virtual bool isSourceAvailable(void) = 0;
virtual bool checkSourceProperties(unsigned int &frames);
virtual bool createProcess(QProcess &processEncode, QProcess&processInput);
virtual void flushProcess(QProcess &processInput) = 0;

View File

@ -24,6 +24,7 @@
#include "source_avisynth.h"
#include "global.h"
#include "model_sysinfo.h"
#include "model_preferences.h"
#include "binaries.h"
@ -45,11 +46,21 @@ AvisynthSource::~AvisynthSource(void)
/*Nothing to do here*/
}
bool AvisynthSource::isSourceAvailable()
{
if(!(m_sysinfo->hasAVSSupport()))
{
log(tr("\nAVS INPUT REQUIRES AVISYNTH, BUT IT IS *NOT* AVAILABLE !!!"));
return false;
}
return true;
}
void AvisynthSource::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
{
cmdLine << "--version";
patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)bm(\\d)\\b", Qt::CaseInsensitive);
patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)\\b", Qt::CaseInsensitive);
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)

View File

@ -29,6 +29,7 @@ public:
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);
virtual ~AvisynthSource(void);
virtual bool isSourceAvailable(void);
virtual void printVersion(const unsigned int &revision, const bool &modified);
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);

View File

@ -24,13 +24,14 @@
#include "source_vapoursynth.h"
#include "global.h"
#include "model_sysinfo.h"
#include "model_preferences.h"
#include "binaries.h"
#include <QDir>
#include <QProcess>
static const unsigned int VER_X264_VSPIPE_VER = 242;
static const unsigned int VER_X264_VSPIPE_VER = 22;
VapoursynthSource::VapoursynthSource(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)
:
@ -45,46 +46,52 @@ VapoursynthSource::~VapoursynthSource(void)
/*Nothing to do here*/
}
bool VapoursynthSource::isSourceAvailable()
{
if(!(m_sysinfo->hasVPSSupport() && (!m_sysinfo->getVPSPath().isEmpty()) && QFileInfo(m_sysinfo->getVPSPath()).isFile()))
{
log(tr("\nVPY INPUT REQUIRES VAPOURSYNTH, BUT IT IS *NOT* AVAILABLE !!!"));
return false;
}
return true;
}
void VapoursynthSource::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
{
cmdLine << "--version";
patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)bm(\\d)\\b", Qt::CaseInsensitive);
patterns << new QRegExp("\\bAvs2YUV (\\d+).(\\d+)\\b", Qt::CaseInsensitive);
cmdLine << "-version";
patterns << new QRegExp("\\bVapourSynth\\b", Qt::CaseInsensitive);
patterns << new QRegExp("\\bCore\\s+r(\\d+)\\b", Qt::CaseInsensitive);
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)
{
int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0)
if((offset = patterns[1]->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;
bool ok = false;
unsigned int temp = patterns[1]->cap(1).toUInt(&ok);
if(ok) revision = temp;
}
else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
else if((offset = patterns[2]->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;
bool ok = false;
unsigned int temp = patterns[2]->cap(1).toUInt(&ok);
if(ok) coreVers = temp;
}
}
void VapoursynthSource::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)));
log(tr("VapourSynth version: r%1 (API r%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT)));
}
bool VapoursynthSource::isVersionSupported(const unsigned int &revision, const bool &modified)
{
if((revision != UINT_MAX) && ((revision % REV_MULT) != VER_X264_VSPIPE_VER))
if((revision % REV_MULT) < VER_X264_VSPIPE_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/"));
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/"));
return false;
}
return true;

View File

@ -29,6 +29,7 @@ public:
VapoursynthSource(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);
virtual ~VapoursynthSource(void);
virtual bool isSourceAvailable(void);
virtual void printVersion(const unsigned int &revision, const bool &modified);
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);

View File

@ -94,6 +94,18 @@ private:
} \
while(0)
#define CONNECT(OBJ) do \
{ \
if((OBJ)) \
{ \
connect((OBJ), SIGNAL(statusChanged(JobStatus)), this, SLOT(setStatus(JobStatus)), Qt::DirectConnection); \
connect((OBJ), SIGNAL(progressChanged(unsigned int)), this, SLOT(setProgress(unsigned int)), Qt::DirectConnection); \
connect((OBJ), SIGNAL(detailsChanged(QString)), this, SLOT(setDetails(QString)), Qt::DirectConnection); \
connect((OBJ), SIGNAL(messageLogged(QString)), this, SLOT(log(QString)), Qt::DirectConnection); \
} \
} \
while(0)
/*
* Input types
*/
@ -154,17 +166,8 @@ EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputF
}
//Establish connections
connect(m_encoder, SIGNAL(statusChanged(JobStatus)), this, SIGNAL(setStatus(QString)), Qt::DirectConnection);
connect(m_encoder, SIGNAL(progressChanged(unsigned int)), this, SIGNAL(setProgress(QString)), Qt::DirectConnection);
connect(m_encoder, SIGNAL(messageLogged(QString)), this, SIGNAL(log(QString)), Qt::DirectConnection);
connect(m_encoder, SIGNAL(detailsChanged(QString)), this, SIGNAL(setDetails(QString)), Qt::DirectConnection);
if(m_pipedSource)
{
connect(m_pipedSource, SIGNAL(statusChanged(JobStatus)), this, SIGNAL(setStatus(QString)), Qt::DirectConnection);
connect(m_pipedSource, SIGNAL(progressChanged(unsigned int)), this, SIGNAL(setProgress(QString)), Qt::DirectConnection);
connect(m_pipedSource, SIGNAL(messageLogged(QString)), this, SIGNAL(log(QString)), Qt::DirectConnection);
connect(m_pipedSource, SIGNAL(detailsChanged(QString)), this, SIGNAL(setDetails(QString)), Qt::DirectConnection);
}
CONNECT(m_encoder);
CONNECT(m_pipedSource);
}
EncodeThread::~EncodeThread(void)
@ -290,14 +293,13 @@ void EncodeThread::encode(void)
m_encoder->printVersion(encoderRevision, encoderModified);
//Is encoder version suppoprted?
if(!m_encoder->isVersionSupported(encoderRevision, encoderModified))
{
setStatus(JobStatus_Failed);
return;
}
CHECK_STATUS(m_abort, (ok = m_encoder->isVersionSupported(encoderRevision, encoderModified)));
if(m_pipedSource)
{
//Is source type available?
CHECK_STATUS(m_abort, (ok = m_pipedSource->isSourceAvailable()));
//Checking source version
bool sourceModified = false;
const unsigned int sourceRevision = m_pipedSource->checkVersion(sourceModified);
@ -307,11 +309,7 @@ void EncodeThread::encode(void)
m_pipedSource->printVersion(sourceModified, sourceModified);
//Is source version supported?
if(!m_pipedSource->isVersionSupported(sourceRevision, sourceModified))
{
setStatus(JobStatus_Failed);
return;
}
CHECK_STATUS(m_abort, (ok = m_pipedSource->isVersionSupported(sourceRevision, sourceModified)));
}
// -----------------------------------------------------------------------------------
@ -402,7 +400,11 @@ void EncodeThread::setProgress(const unsigned int &newProgress)
void EncodeThread::setDetails(const QString &text)
{
if((!text.isEmpty()) && (m_details.compare(text) != 0))
{
emit detailsChanged(m_jobId, text);
m_details = text;
}
}
int EncodeThread::getInputType(const QString &fileExt)

View File

@ -92,6 +92,7 @@ protected:
//Internal status values
JobStatus m_status;
unsigned int m_progress;
QString m_details;
//Encoder and Source objects
AbstractEncoder *m_encoder;

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 3
#define VER_X264_PATCH 2
#define VER_X264_BUILD 791
#define VER_X264_BUILD 793
#define VER_X264_PORTABLE_EDITION (0)