From 675ef7cef57b61736bc669a0f64b67becda1a93c Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 26 Feb 2014 16:08:06 +0100 Subject: [PATCH] Fixed VapourSynth input + some more code re-factoring. --- src/encoder_abstract.cpp | 14 -------------- src/encoder_x264.cpp | 13 +++++++++++++ src/encoder_x264.h | 3 +++ src/encoder_x265.cpp | 13 +++++++++++++ src/encoder_x265.h | 3 +++ src/source_abstract.cpp | 18 ------------------ src/source_avisynth.cpp | 6 ++++++ src/source_avisynth.h | 3 +++ src/source_vapoursynth.cpp | 27 ++++++++++++++++++++++++++- src/source_vapoursynth.h | 3 +++ src/thread_encode.cpp | 22 ++++++++++++---------- src/tool_abstract.cpp | 18 ------------------ src/tool_abstract.h | 24 ++++++++++++++++++++++++ src/version.h | 2 +- 14 files changed, 107 insertions(+), 62 deletions(-) diff --git a/src/encoder_abstract.cpp b/src/encoder_abstract.cpp index 1f07c89..537915f 100644 --- a/src/encoder_abstract.cpp +++ b/src/encoder_abstract.cpp @@ -52,20 +52,6 @@ } \ while(0) -#define PROCESS_PENDING_LINES(PROC, HANDLER, ...) do \ -{ \ - while((PROC).bytesAvailable() > 0) \ - { \ - QList lines = (PROC).readLine().split('\r'); \ - while(!lines.isEmpty()) \ - { \ - const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified(); \ - HANDLER(text, __VA_ARGS__); \ - } \ - } \ -} \ -while(0) - // ------------------------------------------------------------ // Constructor & Destructor // ------------------------------------------------------------ diff --git a/src/encoder_x264.cpp b/src/encoder_x264.cpp index 55f5cf3..ddd7285 100644 --- a/src/encoder_x264.cpp +++ b/src/encoder_x264.cpp @@ -69,6 +69,13 @@ while(0) } \ while(0) +static QString MAKE_NAME(const char *baseName, const OptionsModel *options) +{ + const QString arch = (options->encArch() == OptionsModel::EncArch_x64) ? "x64" : "x86"; + const QString vari = (options->encVariant() == OptionsModel::EncVariant_HiBit ) ? "10-Bit" : "8-Bit"; + return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari); +} + // ------------------------------------------------------------ // Constructor & Destructor // ------------------------------------------------------------ @@ -76,6 +83,7 @@ while(0) X264Encoder::X264Encoder(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, const QString &outputFile) : AbstractEncoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile), + m_encoderName(MAKE_NAME("x264 (H.264/AVC)", m_options)), m_binaryFile(ENC_BINARY(sysinfo, options)) { if(options->encType() != OptionsModel::EncType_X264) @@ -89,6 +97,11 @@ X264Encoder::~X264Encoder(void) /*Nothing to do here*/ } +const QString &X264Encoder::getName(void) +{ + return m_encoderName; +} + // ------------------------------------------------------------ // Check Version // ------------------------------------------------------------ diff --git a/src/encoder_x264.h b/src/encoder_x264.h index 75c5133..ba8a218 100644 --- a/src/encoder_x264.h +++ b/src/encoder_x264.h @@ -29,6 +29,8 @@ public: X264Encoder(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, const QString &outputFile); virtual ~X264Encoder(void); + virtual const QString &getName(void); + virtual void printVersion(const unsigned int &revision, const bool &modified); virtual bool isVersionSupported(const unsigned int &revision, const bool &modified); @@ -42,5 +44,6 @@ protected: virtual void runEncodingPass_init(QList &patterns); virtual void runEncodingPass_parseLine(const QString &line, QList &patterns, const int &pass); + const QString m_encoderName; const QString m_binaryFile; }; diff --git a/src/encoder_x265.cpp b/src/encoder_x265.cpp index 8773dca..f6a54c0 100644 --- a/src/encoder_x265.cpp +++ b/src/encoder_x265.cpp @@ -70,6 +70,13 @@ while(0) } \ while(0) +static QString MAKE_NAME(const char *baseName, const OptionsModel *options) +{ + const QString arch = (options->encArch() == OptionsModel::EncArch_x64) ? "x64" : "x86"; + const QString vari = (options->encVariant() == OptionsModel::EncVariant_HiBit ) ? "16-Bit" : "8-Bit"; + return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari); +} + // ------------------------------------------------------------ // Constructor & Destructor // ------------------------------------------------------------ @@ -77,6 +84,7 @@ while(0) X265Encoder::X265Encoder(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, const QString &outputFile) : AbstractEncoder(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile, outputFile), + m_encoderName(MAKE_NAME("x265 (H.265/HEVC)", m_options)), m_binaryFile(ENC_BINARY(sysinfo, options)) { if(options->encType() != OptionsModel::EncType_X265) @@ -90,6 +98,11 @@ X265Encoder::~X265Encoder(void) /*Nothing to do here*/ } +const QString &X265Encoder::getName(void) +{ + return m_encoderName; +} + // ------------------------------------------------------------ // Check Version // ------------------------------------------------------------ diff --git a/src/encoder_x265.h b/src/encoder_x265.h index c4d21a6..c3422e4 100644 --- a/src/encoder_x265.h +++ b/src/encoder_x265.h @@ -29,6 +29,8 @@ public: X265Encoder(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, const QString &outputFile); virtual ~X265Encoder(void); + virtual const QString &getName(void); + virtual void printVersion(const unsigned int &revision, const bool &modified); virtual bool isVersionSupported(const unsigned int &revision, const bool &modified); @@ -42,5 +44,6 @@ protected: virtual void runEncodingPass_init(QList &patterns); virtual void runEncodingPass_parseLine(const QString &line, QList &patterns, const int &pass); + const QString m_encoderName; const QString m_binaryFile; }; diff --git a/src/source_abstract.cpp b/src/source_abstract.cpp index 52a2b69..a859bb7 100644 --- a/src/source_abstract.cpp +++ b/src/source_abstract.cpp @@ -30,24 +30,6 @@ #include #include -// ------------------------------------------------------------ -// Helper Macros -// ------------------------------------------------------------ - -#define PROCESS_PENDING_LINES(PROC, HANDLER, ...) do \ -{ \ - while((PROC).bytesAvailable() > 0) \ - { \ - QList lines = (PROC).readLine().split('\r'); \ - while(!lines.isEmpty()) \ - { \ - const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified(); \ - HANDLER(text, __VA_ARGS__); \ - } \ - } \ -} \ -while(0) - // ------------------------------------------------------------ // Constructor & Destructor // ------------------------------------------------------------ diff --git a/src/source_avisynth.cpp b/src/source_avisynth.cpp index ddd6cbe..a697a3a 100644 --- a/src/source_avisynth.cpp +++ b/src/source_avisynth.cpp @@ -40,6 +40,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)) { /*Nothing to do here*/ @@ -50,6 +51,11 @@ AvisynthSource::~AvisynthSource(void) /*Nothing to do here*/ } +const QString &AvisynthSource::getName(void) +{ + return m_sourceName; +} + // ------------------------------------------------------------ // Check Version // ------------------------------------------------------------ diff --git a/src/source_avisynth.h b/src/source_avisynth.h index 0d266bc..b9f2638 100644 --- a/src/source_avisynth.h +++ b/src/source_avisynth.h @@ -28,6 +28,8 @@ class AvisynthSource : public AbstractSource 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 const QString &getName(void); virtual bool isSourceAvailable(void); virtual void printVersion(const unsigned int &revision, const bool &modified); @@ -45,5 +47,6 @@ protected: virtual const QString &getBinaryPath() { return m_binaryFile; } virtual void buildCommandLine(QStringList &cmdLine); + const QString m_sourceName; const QString m_binaryFile; }; diff --git a/src/source_vapoursynth.cpp b/src/source_vapoursynth.cpp index 20d1bff..0a085ec 100644 --- a/src/source_vapoursynth.cpp +++ b/src/source_vapoursynth.cpp @@ -36,6 +36,7 @@ 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) : AbstractSource(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile), + m_sourceName("VapourSynth (vpy)"), m_binaryFile(VPS_BINARY(m_sysinfo, m_preferences)) { /*Nothing to do here*/ @@ -46,13 +47,18 @@ VapoursynthSource::~VapoursynthSource(void) /*Nothing to do here*/ } +const QString &VapoursynthSource::getName(void) +{ + return m_sourceName; +} + // ------------------------------------------------------------ // Check Version // ------------------------------------------------------------ bool VapoursynthSource::isSourceAvailable() { - if(!(m_sysinfo->hasVPSSupport() && (!m_sysinfo->getVPSPath().isEmpty()) && QFileInfo(m_sysinfo->getVPSPath()).isFile())) + if(!(m_sysinfo->hasVPSSupport() && (!m_sysinfo->getVPSPath().isEmpty()) && QFileInfo(VPS_BINARY(m_sysinfo, m_preferences)).isFile())) { log(tr("\nVPY INPUT REQUIRES VAPOURSYNTH, BUT IT IS *NOT* AVAILABLE !!!")); return false; @@ -119,6 +125,8 @@ void VapoursynthSource::checkSourceProperties_init(QList &patterns, QS patterns << new QRegExp("\\bFrames:\\s+(\\d+)\\b"); patterns << new QRegExp("\\bWidth:\\s+(\\d+)\\b"); patterns << new QRegExp("\\bHeight:\\s+(\\d+)\\b"); + patterns << new QRegExp("\\bFPS:\\s+(\\d+)\\b"); + patterns << new QRegExp("\\bFPS:\\s+(\\d+)/(\\d+)\\b"); } void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QList &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) @@ -143,6 +151,23 @@ void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QLi unsigned int temp = patterns[2]->cap(1).toUInt(&ok); if(ok) fSizeH = temp; } + if((offset = patterns[3]->lastIndexIn(line)) >= 0) + { + bool ok = false; + unsigned int temp = patterns[3]->cap(1).toUInt(&ok); + if(ok) fpsNom = temp; + } + if((offset = patterns[4]->lastIndexIn(line)) >= 0) + { + bool ok1 = false, ok2 = false; + unsigned int temp1 = patterns[4]->cap(1).toUInt(&ok1); + unsigned int temp2 = patterns[4]->cap(2).toUInt(&ok2); + if(ok1 && ok2) + { + fpsNom = temp1; + fpsDen = temp2; + } + } if(!line.isEmpty()) { diff --git a/src/source_vapoursynth.h b/src/source_vapoursynth.h index b041579..18f43c5 100644 --- a/src/source_vapoursynth.h +++ b/src/source_vapoursynth.h @@ -29,6 +29,8 @@ 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 const QString &getName(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); @@ -45,5 +47,6 @@ protected: virtual const QString &getBinaryPath() { return m_binaryFile; } virtual void buildCommandLine(QStringList &cmdLine); + const QString m_sourceName; const QString m_binaryFile; }; diff --git a/src/thread_encode.cpp b/src/thread_encode.cpp index a2d2c86..7dbb388 100644 --- a/src/thread_encode.cpp +++ b/src/thread_encode.cpp @@ -258,22 +258,24 @@ void EncodeThread::encode(void) //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))); - log(tr("Source file: %1").arg(QDir::toNativeSeparators(m_sourceFileName))); - log(tr("Output file: %1").arg(QDir::toNativeSeparators(m_outputFileName))); + log(tr("Source file : %1").arg(QDir::toNativeSeparators(m_sourceFileName))); + log(tr("Output file : %1").arg(QDir::toNativeSeparators(m_outputFileName))); //Print system info log(tr("\n--- SYSTEMINFO ---\n")); - log(tr("Binary Path: %1").arg(QDir::toNativeSeparators(m_sysinfo->getAppPath()))); - log(tr("Avisynth OK: %1").arg(m_sysinfo->hasAVSSupport() ? tr("Yes") : tr("No"))); - log(tr("VapourSynth: %1").arg(m_sysinfo->hasVPSSupport() ? QDir::toNativeSeparators(m_sysinfo->getVPSPath()) : tr("N/A"))); + log(tr("Binary Path : %1").arg(QDir::toNativeSeparators(m_sysinfo->getAppPath()))); + log(tr("Avisynth : %1").arg(m_sysinfo->hasAVSSupport() ? tr("Yes") : tr("No"))); + log(tr("VapourSynth : %1").arg(m_sysinfo->hasVPSSupport() ? QDir::toNativeSeparators(m_sysinfo->getVPSPath()) : tr("N/A"))); //Print encoder settings log(tr("\n--- SETTINGS ---\n")); - log(tr("RC Mode: %1").arg(OptionsModel::rcMode2String(m_options->rcMode()))); - log(tr("Preset: %1").arg(m_options->preset())); - log(tr("Tuning: %1").arg(m_options->tune())); - log(tr("Profile: %1").arg(m_options->profile())); - log(tr("Custom: %1").arg(m_options->customEncParams().isEmpty() ? tr("(None)") : m_options->customEncParams())); + log(tr("Encoder : %1").arg(m_encoder->getName())); + log(tr("Source : %1").arg(m_pipedSource ? m_pipedSource->getName() : tr("Native"))); + log(tr("RC Mode : %1").arg(OptionsModel::rcMode2String(m_options->rcMode()))); + log(tr("Preset : %1").arg(m_options->preset())); + log(tr("Tuning : %1").arg(m_options->tune())); + log(tr("Profile : %1").arg(m_options->profile())); + log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("(None)") : m_options->customEncParams())); bool ok = false; unsigned int frames = 0; diff --git a/src/tool_abstract.cpp b/src/tool_abstract.cpp index 88c4364..3388297 100644 --- a/src/tool_abstract.cpp +++ b/src/tool_abstract.cpp @@ -35,24 +35,6 @@ QMutex AbstractTool::s_mutexStartProcess; -// ------------------------------------------------------------ -// Helper Macros -// ------------------------------------------------------------ - -#define PROCESS_PENDING_LINES(PROC, HANDLER, ...) do \ -{ \ - while((PROC).bytesAvailable() > 0) \ - { \ - QList lines = (PROC).readLine().split('\r'); \ - while(!lines.isEmpty()) \ - { \ - const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified(); \ - HANDLER(text, __VA_ARGS__); \ - } \ - } \ -} \ -while(0) - // ------------------------------------------------------------ // Constructor & Destructor // ------------------------------------------------------------ diff --git a/src/tool_abstract.h b/src/tool_abstract.h index cbea57e..2904cb8 100644 --- a/src/tool_abstract.h +++ b/src/tool_abstract.h @@ -33,6 +33,10 @@ class QProcess; class QSemaphore; enum JobStatus; +// ------------------------------------------------------------ +// Base Class +// ------------------------------------------------------------ + class AbstractTool : public QObject { Q_OBJECT @@ -41,6 +45,8 @@ public: AbstractTool(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause); virtual ~AbstractTool(void) {/*NOP*/} + virtual const QString &getName(void) = 0; + 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; @@ -85,3 +91,21 @@ protected: static QMutex s_mutexStartProcess; }; + +// ------------------------------------------------------------ +// Helper Macros +// ------------------------------------------------------------ + +#define PROCESS_PENDING_LINES(PROC, HANDLER, ...) do \ +{ \ + while((PROC).bytesAvailable() > 0) \ + { \ + QList lines = (PROC).readLine().split('\r'); \ + while(!lines.isEmpty()) \ + { \ + const QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified(); \ + HANDLER(text, __VA_ARGS__); \ + } \ + } \ +} \ +while(0) diff --git a/src/version.h b/src/version.h index 89a9f97..864dae9 100644 --- a/src/version.h +++ b/src/version.h @@ -26,7 +26,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 3 #define VER_X264_PATCH 3 -#define VER_X264_BUILD 804 +#define VER_X264_BUILD 805 #define VER_X264_PORTABLE_EDITION (0)