OSDN Git Service

More code refactoring: Got rid of the "binaries" class + added a SourceFactory class...
authorlordmulder <mulder2@gmx.de>
Sun, 2 Aug 2015 19:16:36 +0000 (21:16 +0200)
committerlordmulder <mulder2@gmx.de>
Sun, 2 Aug 2015 19:16:36 +0000 (21:16 +0200)
27 files changed:
gui/win_addJob.ui
src/binaries.cpp [deleted file]
src/encoder_abstract.cpp
src/encoder_abstract.h
src/encoder_factory.cpp
src/encoder_factory.h
src/encoder_x264.cpp
src/encoder_x265.cpp
src/source_abstract.cpp
src/source_abstract.h
src/source_avisynth.cpp
src/source_avisynth.h
src/source_factory.cpp [new file with mode: 0644]
src/source_factory.h [moved from src/binaries.h with 61% similarity]
src/source_vapoursynth.cpp
src/source_vapoursynth.h
src/thread_avisynth.cpp
src/thread_binaries.cpp
src/thread_encode.cpp
src/tool_abstract.cpp
src/version.h
src/win_addJob.cpp
src/win_addJob.h
src/win_help.cpp
src/win_main.cpp
x264_launcher_MSVC2013.vcxproj
x264_launcher_MSVC2013.vcxproj.filters

index a3111d7..0fc0e3c 100644 (file)
                <property name="currentIndex">
                 <number>-1</number>
                </property>
-               <item>
-                <property name="text">
-                 <string>x264 (AVC)</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>x265 (HEVC)</string>
-                </property>
-               </item>
               </widget>
              </item>
             </layout>
                <property name="currentIndex">
                 <number>-1</number>
                </property>
-               <item>
-                <property name="text">
-                 <string>32-Bit (x86)</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>64-Bit (x86_64)</string>
-                </property>
-               </item>
               </widget>
              </item>
             </layout>
                <property name="currentIndex">
                 <number>-1</number>
                </property>
-               <item>
-                <property name="text">
-                 <string>8-Bit</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>10-Bit</string>
-                </property>
-               </item>
               </widget>
              </item>
             </layout>
                <property name="currentIndex">
                 <number>-1</number>
                </property>
-               <item>
-                <property name="text">
-                 <string>CRF</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>CQ</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>2-Pass</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>ABR</string>
-                </property>
-               </item>
               </widget>
              </item>
             </layout>
                <property name="currentIndex">
                 <number>-1</number>
                </property>
-               <item>
-                <property name="text">
-                 <string>Ultrafast</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Superfast</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Veryfast</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Faster</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Fast</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Medium</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Slow</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Slower</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Veryslow</string>
-                </property>
-               </item>
-               <item>
-                <property name="text">
-                 <string>Placebo</string>
-                </property>
-               </item>
               </widget>
              </item>
             </layout>
diff --git a/src/binaries.cpp b/src/binaries.cpp
deleted file mode 100644 (file)
index ce8b3cc..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Simple x264 Launcher
-// Copyright (C) 2004-2015 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 "binaries.h"
-
-//Internal
-#include "global.h"
-#include "model_sysinfo.h"
-#include "model_preferences.h"
-#include "model_options.h"
-
-//MUtils
-#include <MUtils/Exception.h>
-
-/* --- Avisynth --- */
-
-QString AVS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
-{
-       return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
-}
-
-QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
-{
-       const bool avs32 = sysinfo->getAvisynth(SysinfoModel::Avisynth_X86);
-       const bool avs64 = sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64);
-       return AVS_BINARY(sysinfo, (avs32 && avs64) ? preferences->getPrefer64BitSource() : avs64);
-}
-
-/* --- VapurSynth --- */
-
-QString VPS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
-{
-       return QString("%1/core%2/vspipe.exe").arg(sysinfo->getVPSPath(), (x64 ? "64" : "32"));
-}
-
-QString VPS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
-{
-       const bool vps32 = sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X86);
-       const bool vps64 = sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X64) && sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64);
-       return VPS_BINARY(sysinfo, (vps32 && vps64) ? preferences->getPrefer64BitSource() : vps64);
-}
-
-/* --- AVS Checker--- */
-
-QString CHK_BINARY(const SysinfoModel *sysinfo, const bool& x64)
-{
-       return QString("%1/toolset/%2/avs_check_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
-}
index d2c001a..e835efb 100644 (file)
@@ -28,7 +28,6 @@
 #include "model_sysinfo.h"
 #include "model_status.h"
 #include "source_abstract.h"
-#include "binaries.h"
 
 //MUtils
 #include <MUtils/Global.h>
index e59ac58..594388c 100644 (file)
@@ -32,10 +32,11 @@ class AbstractEncoderInfo
 {
 public:
        virtual QFlags<OptionsModel::EncVariant> getVariants(void) const = 0;
-       virtual QStringList getProfiles(const int &variant) const = 0;
+       virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const = 0;
        virtual QStringList getTunings(void) const = 0;
+       virtual QStringList getPresets(void) const = 0;
        virtual QStringList supportedOutputFormats(void) const = 0;
-       virtual bool isRCModeSupported(const int rcMode) const = 0;
+       virtual bool isRCModeSupported(const OptionsModel::RCMode &rcMode) const = 0;
        virtual bool isInputTypeSupported(const int format) const = 0;
        virtual QString getBinaryPath(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const = 0;
 };
index c99aee2..5d0d52e 100644 (file)
@@ -49,7 +49,7 @@ AbstractEncoder *EncoderFactory::createEncoder(JobObject *jobObject, const Optio
        return encoder;
 }
 
-const AbstractEncoderInfo& EncoderFactory::getEncoderInfo(const int &encoderType)
+const AbstractEncoderInfo& EncoderFactory::getEncoderInfo(const OptionsModel::EncType &encoderType)
 {
        switch(encoderType)
        {
index bda5472..3f165bc 100644 (file)
@@ -27,7 +27,7 @@ class EncoderFactory
 {
 public:
        static AbstractEncoder *createEncoder(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);
-       static const AbstractEncoderInfo& getEncoderInfo(const int &encoderType);
+       static const AbstractEncoderInfo& getEncoderInfo(const OptionsModel::EncType &encoderType);
 
 private:
        EncoderFactory(void) {/*Disabled*/}
index 5983638..f0a6d8b 100644 (file)
@@ -25,7 +25,6 @@
 #include "global.h"
 #include "model_options.h"
 #include "model_status.h"
-#include "binaries.h"
 #include "mediainfo.h"
 #include "model_sysinfo.h"
 
@@ -101,7 +100,6 @@ public:
        virtual QStringList getTunings(void) const
        {
                QStringList tunings;
-
                tunings << "Film"       << "Animation"   << "Grain";
                tunings << "StillImage" << "PSNR"        << "SSIM";
                tunings << "FastDecode" << "ZeroLatency" << "Touhou";
@@ -109,7 +107,15 @@ public:
                return tunings;
        }
 
-       virtual QStringList getProfiles(const int &variant) const
+       virtual QStringList getPresets(void) const
+       {
+               QStringList presets;
+               presets << "ultrafast" << "superfast" << "veryfast" << "faster"   << "fast";
+               presets << "medium"    << "slow"      << "slower"   << "veryslow" << "placebo";
+               return presets;
+       }
+
+       virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const
        {
                QStringList profiles;
 
@@ -132,7 +138,7 @@ public:
                return extLst;
        }
 
-       virtual bool isRCModeSupported(const int rcMode) const
+       virtual bool isRCModeSupported(const OptionsModel::RCMode &rcMode) const
        {
                switch(rcMode)
                {
index 2851843..3f9842d 100644 (file)
@@ -25,7 +25,6 @@
 #include "global.h"
 #include "model_options.h"
 #include "model_status.h"
-#include "binaries.h"
 #include "mediainfo.h"
 #include "model_sysinfo.h"
 
@@ -106,7 +105,15 @@ public:
                return tunings;
        }
 
-       virtual QStringList getProfiles(const int &variant) const
+       virtual QStringList getPresets(void) const
+       {
+               QStringList presets;
+               presets << "ultrafast" << "superfast" << "veryfast" << "faster"   << "fast";
+               presets << "medium"    << "slow"      << "slower"   << "veryslow" << "placebo";
+               return presets;
+       }
+
+       virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const
        {
                QStringList profiles;
                switch(variant)
@@ -131,7 +138,7 @@ public:
                return extLst;
        }
 
-       virtual bool isRCModeSupported(const int rcMode) const
+       virtual bool isRCModeSupported(const OptionsModel::RCMode &rcMode) const
        {
                switch(rcMode)
                {
index 02396fe..dc6abf3 100644 (file)
@@ -29,6 +29,7 @@
 
 //MUtils
 #include <MUtils/Global.h>
+#include <MUtils/Exception.h>
 
 //Qt
 #include <QProcess>
@@ -201,3 +202,12 @@ bool AbstractSource::createProcess(QProcess &processEncode, QProcess&processInpu
 
        return true;
 }
+
+// ------------------------------------------------------------
+// Source Info
+// ------------------------------------------------------------
+
+const AbstractSourceInfo& AbstractSource::getSourceInfo(void)
+{
+       MUTILS_THROW("[getSourceInfo] This function must be overwritten in sub-classes!");
+}
index 7564a90..978e7d8 100644 (file)
 #pragma once
 
 #include "tool_abstract.h"
+#include "model_options.h"
 
 class QRegExp;
 template<class T> class QList;
 class QProcess;
 
+class AbstractSourceInfo
+{
+public:
+       virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const = 0;
+};
+
 class AbstractSource : public AbstractTool
 {
 public:
@@ -38,6 +45,8 @@ public:
        virtual bool createProcess(QProcess &processEncode, QProcess&processInput);
        virtual void flushProcess(QProcess &processInput) = 0;
 
+       static const AbstractSourceInfo& getSourceInfo(void);
+
 protected:
        virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
        virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) = 0;
index aaebee2..5bcd6ed 100644 (file)
@@ -24,9 +24,6 @@
 #include "source_avisynth.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_AVS2YUV_VER = 243;
 
 // ------------------------------------------------------------
+// Encoder Info
+// ------------------------------------------------------------
+
+class AvisynthSourceInfo : public AbstractSourceInfo
+{
+public:
+       virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const
+       {
+               return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
+       }
+};
+
+static const AvisynthSourceInfo s_avisynthEncoderInfo;
+
+const AbstractSourceInfo &AvisynthSource::getSourceInfo(void)
+{
+       return s_avisynthEncoderInfo;
+}
+
+// ------------------------------------------------------------
 // Constructor & Destructor
 // ------------------------------------------------------------
 
 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*/
 }
@@ -53,7 +68,7 @@ AvisynthSource::~AvisynthSource(void)
 
 QString AvisynthSource::getName(void) const
 {
-       return m_sourceName;
+       return tr("Avisynth (avs)");
 }
 
 // ------------------------------------------------------------
index b5a2809..e336eb6 100644 (file)
@@ -22,6 +22,8 @@
 #pragma once
 
 #include "source_abstract.h"
+#include "model_sysinfo.h"
+#include "model_preferences.h"
 
 class AvisynthSource : public AbstractSource
 {
@@ -37,6 +39,8 @@ public:
 
        virtual void flushProcess(QProcess &processInput);
 
+       static const AbstractSourceInfo& getSourceInfo(void);
+
 protected:
        virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
        virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
@@ -45,9 +49,6 @@ protected:
        virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
        virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen);
 
-       virtual QString getBinaryPath() const { return m_binaryFile; }
+       virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, (m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_preferences->getPrefer64BitSource())); }
        virtual void buildCommandLine(QStringList &cmdLine);
-
-       const QString m_sourceName;
-       const QString m_binaryFile;
 };
diff --git a/src/source_factory.cpp b/src/source_factory.cpp
new file mode 100644 (file)
index 0000000..c0d3b4d
--- /dev/null
@@ -0,0 +1,54 @@
+///////////////////////////////////////////////////////////////////////////////
+// Simple x264 Launcher
+// Copyright (C) 2004-2015 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 "source_factory.h"
+
+//Internal
+#include "source_avisynth.h"
+#include "source_vapoursynth.h"
+
+//MUtils
+#include <MUtils/Exception.h>
+
+AbstractSource *SourceFactory::createSource(const SourceType &type, 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 *source = NULL;
+       switch(type)
+       {
+               case SourceType_AVS: source = new AvisynthSource   (jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile); break;
+               case SourceType_VPS: source = new VapoursynthSource(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile); break;
+               default: MUTILS_THROW("Invalid source type!");
+       }
+       return source;
+}
+
+const AbstractSourceInfo& SourceFactory::getSourceInfo(const SourceType &type)
+{
+       const AbstractSourceInfo *sourceInfo = NULL;
+       switch(type)
+       {
+           case SourceType_AVS: sourceInfo = &AvisynthSource   ::getSourceInfo(); break;
+               case SourceType_VPS: sourceInfo = &VapoursynthSource::getSourceInfo(); break;
+               default: MUTILS_THROW("Invalid source type!");
+       }
+       return (*sourceInfo);
+}
+
similarity index 61%
rename from src/binaries.h
rename to src/source_factory.h
index 3a48037..de8f223 100644 (file)
 // http://www.gnu.org/licenses/gpl-2.0.txt
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "model_options.h"
+#pragma once
 
-class SysinfoModel;
-class PreferencesModel;
+#include "source_abstract.h"
 
-QString AVS_BINARY(const SysinfoModel *sysinfo, const bool &x64);
-QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences);
+class SourceFactory
+{
+public:
+       enum SourceType
+       {
+               SourceType_AVS = 0,
+               SourceType_VPS = 1,
 
-QString VPS_BINARY(const SysinfoModel *sysinfo, const bool& x64);
-QString VPS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences);
+               SourceType_MIN = SourceType_AVS,
+               SourceType_MAX = SourceType_VPS
+       };
 
-QString CHK_BINARY(const SysinfoModel *sysinfo, const bool &x64);
+       static AbstractSource *createSource(const SourceType &type, 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);
+       static const AbstractSourceInfo& getSourceInfo(const SourceType &type);
+
+private:
+       SourceFactory(void) {/*Disabled*/}
+};
index 52b2eba..f49224c 100644 (file)
@@ -24,9 +24,6 @@
 #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_API =  3;
 static const unsigned int VER_X264_VSPIPE_VER = 24;
 
+// ------------------------------------------------------------
+// Encoder Info
+// ------------------------------------------------------------
+
+class VapoursyntSourceInfo : public AbstractSourceInfo
+{
+public:
+       virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const
+       {
+               return QString("%1/core%2/vspipe.exe").arg(sysinfo->getVPSPath(), (x64 ? "64" : "32"));
+       }
+};
+
+static const VapoursyntSourceInfo s_vapoursynthEncoderInfo;
+
+const AbstractSourceInfo &VapoursynthSource::getSourceInfo(void)
+{
+       return s_vapoursynthEncoderInfo;
+}
+
+// ------------------------------------------------------------
+// Constructor & Destructor
+// ------------------------------------------------------------
+
 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))
+       AbstractSource(jobObject, options, sysinfo, preferences, jobStatus, abort, pause, semaphorePause, sourceFile)
 {
        /*Nothing to do here*/
 }
@@ -50,7 +69,7 @@ VapoursynthSource::~VapoursynthSource(void)
 
 QString VapoursynthSource::getName(void) const
 {
-       return m_sourceName;
+       return tr("VapourSynth (vpy)");
 }
 
 // ------------------------------------------------------------
@@ -59,7 +78,7 @@ QString VapoursynthSource::getName(void) const
 
 bool VapoursynthSource::isSourceAvailable()
 {
-       if(!(m_sysinfo->hasVapourSynth() && (!m_sysinfo->getVPSPath().isEmpty()) && QFileInfo(VPS_BINARY(m_sysinfo, m_preferences)).isFile()))
+       if(!(m_sysinfo->hasVapourSynth() && (!m_sysinfo->getVPSPath().isEmpty()) && QFileInfo(getBinaryPath()).isFile()))
        {
                log(tr("\nVPY INPUT REQUIRES VAPOURSYNTH, BUT IT IS *NOT* AVAILABLE !!!"));
                return false;
index caf7216..0d6f05a 100644 (file)
@@ -22,6 +22,8 @@
 #pragma once
 
 #include "source_abstract.h"
+#include "model_sysinfo.h"
+#include "model_preferences.h"
 
 class VapoursynthSource : public AbstractSource
 {
@@ -37,6 +39,8 @@ public:
 
        virtual void flushProcess(QProcess &processInput);
 
+       static const AbstractSourceInfo& getSourceInfo(void);
+
 protected:
        virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
        virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
@@ -44,9 +48,6 @@ protected:
        virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
        virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen);
 
-       virtual QString getBinaryPath() const { return m_binaryFile; }
+       virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, (m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_preferences->getPrefer64BitSource())); }
        virtual void buildCommandLine(QStringList &cmdLine);
-
-       const QString m_sourceName;
-       const QString m_binaryFile;
 };
index 4e70256..b4c583d 100644 (file)
@@ -32,7 +32,6 @@
 //Internal
 #include "global.h"
 #include "model_sysinfo.h"
-#include "binaries.h"
 
 //MUtils
 #include <MUtils/Global.h>
 QMutex AvisynthCheckThread::m_avsLock;
 QScopedPointer<QFile> AvisynthCheckThread::m_avsDllPath[2];
 
+//Helper
 #define BOOLIFY(X) ((X) ? '1' : '0')
 
+//Utility function
+QString AVS_CHECK_BINARY(const SysinfoModel *sysinfo, const bool& x64)
+{
+       return QString("%1/toolset/%2/avs_check_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
+}
+
 class Wow64RedirectionDisabler
 {
 public:
@@ -221,7 +227,7 @@ bool AvisynthCheckThread::checkAvisynth(const SysinfoModel *const sysinfo, QFile
        process.setReadChannel(QProcess::StandardOutput);
 
        //Try to start VSPIPE.EXE
-       process.start(CHK_BINARY(sysinfo, x64), QStringList());
+       process.start(AVS_CHECK_BINARY(sysinfo, x64), QStringList());
        if(!process.waitForStarted())
        {
                qWarning("Failed to launch AVS_CHECK.EXE -> %s", process.errorString().toUtf8().constData());
index cc26b49..ac7a3c1 100644 (file)
@@ -33,8 +33,8 @@
 #include "global.h"
 #include "model_sysinfo.h"
 #include "win_updater.h"
-#include "binaries.h"
 #include "encoder_factory.h"
+#include "source_factory.h"
 
 //MUtils
 #include <MUtils/Global.h>
@@ -48,6 +48,9 @@ QScopedPointer<QFile> BinariesCheckThread::m_binPath[MAX_BINARIES];
 #define NEXT(X) ((*reinterpret_cast<int*>(&(X)))++)
 #define SHFL(X) ((*reinterpret_cast<int*>(&(X))) <<= 1)
 
+//External
+QString AVS_CHECK_BINARY(const SysinfoModel *sysinfo, const bool& x64);
+
 //-------------------------------------
 // External API
 //-------------------------------------
@@ -158,10 +161,10 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
                        }
                }
        }
-       for(OptionsModel::EncArch arch = OptionsModel::EncArch_x86_32; arch <= OptionsModel::EncArch_x86_64; NEXT(arch))
+       for(int i = 0; i < 2; i++)
        {
-               binFiles << AVS_BINARY(sysinfo, arch == OptionsModel::EncArch_x86_64);
-               binFiles << CHK_BINARY(sysinfo, arch == OptionsModel::EncArch_x86_64);
+               binFiles << SourceFactory::getSourceInfo(SourceFactory::SourceType_AVS).getBinaryPath(sysinfo, bool(i));
+               binFiles << AVS_CHECK_BINARY(sysinfo, bool(i));
        }
        for(size_t i = 0; UpdaterDialog::BINARIES[i].name; i++)
        {
index afec867..a18e442 100644 (file)
 #include "model_preferences.h"
 #include "model_sysinfo.h"
 #include "job_object.h"
-#include "binaries.h"
 #include "mediainfo.h"
 
 //Encoders
 #include "encoder_factory.h"
 
 //Source
-#include "source_avisynth.h"
-#include "source_vapoursynth.h"
+#include "source_factory.h"
 
 //MUtils
 #include <MUtils/OSSupport.h>
@@ -139,13 +137,13 @@ EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputF
        case MediaInfo::FILETYPE_AVISYNTH:
                if(m_sysinfo->hasAvisynth())
                {
-                       m_pipedSource = new AvisynthSource   (m_jobObject, m_options, m_sysinfo, m_preferences, m_status, &m_abort, &m_pause, &m_semaphorePaused, m_sourceFileName);
+                       m_pipedSource = SourceFactory::createSource(SourceFactory::SourceType_AVS, m_jobObject, m_options, m_sysinfo, m_preferences, m_status, &m_abort, &m_pause, &m_semaphorePaused, m_sourceFileName);
                }
                break;
        case MediaInfo::FILETYPE_VAPOURSYNTH:
                if(m_sysinfo->hasVapourSynth())
                {
-                       m_pipedSource = new VapoursynthSource(m_jobObject, m_options, m_sysinfo, m_preferences, m_status, &m_abort, &m_pause, &m_semaphorePaused, m_sourceFileName);
+                       m_pipedSource = SourceFactory::createSource(SourceFactory::SourceType_VPS, m_jobObject, m_options, m_sysinfo, m_preferences, m_status, &m_abort, &m_pause, &m_semaphorePaused, m_sourceFileName);
                }
                break;
        }
index f2bbd88..f2f67b9 100644 (file)
@@ -26,7 +26,6 @@
 #include "model_options.h"
 #include "model_preferences.h"
 #include "model_sysinfo.h"
-#include "binaries.h"
 #include "job_object.h"
 
 //MUtils
index 91dcf2a..5b6a322 100644 (file)
@@ -26,7 +26,7 @@
 #define VER_X264_MAJOR 2
 #define VER_X264_MINOR 6
 #define VER_X264_PATCH 0
-#define VER_X264_BUILD 958
+#define VER_X264_BUILD 962
 
 #define VER_X264_PORTABLE_EDITION (0)
 
index 2bc54ee..b0e391b 100644 (file)
        WIDGET->addAction(_action); \
 } 
 
-static void setIndexByData(QComboBox *const box, const int &data)
-{
-       for(int i = 0; i < box->count(); i++)
-       {
-               if(box->itemData(i).toInt() == data)
-               {
-                       box->setCurrentIndex(i);
-                       break;
-               }
-       }
-}
-
 Q_DECLARE_METATYPE(const void*)
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -270,6 +258,20 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *const options, Recentl
        setMinimumSize(size());
        setMaximumHeight(height());
 
+       //Init encoder combobox
+       ui->cbxEncoderType->addItem(tr("x264 (AVC)"), OptionsModel::EncType_X264);
+       ui->cbxEncoderType->addItem(tr("x265 (HEVC)"), OptionsModel::EncType_X265);
+
+       //Init arch combobox
+       ui->cbxEncoderArch->addItem(tr("32-Bit"), OptionsModel::EncArch_x86_32);
+       ui->cbxEncoderArch->addItem(tr("64-Bit"), OptionsModel::EncArch_x86_64);
+
+       //Init rc-mode combobox
+       ui->cbxRateControlMode->addItem(tr("CRF"),    OptionsModel::RCMode_CRF);
+       ui->cbxRateControlMode->addItem(tr("CQ"),     OptionsModel::RCMode_CQ);
+       ui->cbxRateControlMode->addItem(tr("2-Pass"), OptionsModel::RCMode_2Pass);
+       ui->cbxRateControlMode->addItem(tr("ABR"),    OptionsModel::RCMode_ABR);
+
        //Init combobox items
        ui->cbxTuning ->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
        ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));
@@ -464,7 +466,8 @@ void AddJobDialog::dropEvent(QDropEvent *event)
 
 void AddJobDialog::encoderIndexChanged(int index)
 {
-       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
+       const OptionsModel::EncType encType = static_cast<OptionsModel::EncType>(ui->cbxEncoderType->itemData(ui->cbxEncoderType->currentIndex()).toInt());
+       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(encType);
 
        //Update encoder variants
        const QFlags<OptionsModel::EncVariant> variants = encoderInfo.getVariants();
@@ -485,8 +488,23 @@ void AddJobDialog::encoderIndexChanged(int index)
                }
        }
 
+       //Update presets
+       const QStringList presets = encoderInfo.getPresets();
+       if(presets.empty())
+       {
+               ui->cbxPreset->setEnabled(false);
+               ui->cbxPreset->setCurrentIndex(0);
+       }
+       else
+       {
+               ui->cbxPreset->setEnabled(true);
+               ui->cbxPreset->clear();
+               ui->cbxPreset->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
+               ui->cbxPreset->addItems(presets);
+       }
+
        //Update tunings
-       QStringList tunings = encoderInfo.getTunings();
+       const QStringList tunings = encoderInfo.getTunings();
        if(tunings.empty())
        {
                ui->cbxTuning->setEnabled(false);
@@ -505,10 +523,11 @@ void AddJobDialog::encoderIndexChanged(int index)
 
 void AddJobDialog::variantIndexChanged(int index)
 {
-       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
+       const OptionsModel::EncType encType = static_cast<OptionsModel::EncType>(ui->cbxEncoderType->itemData(ui->cbxEncoderType->currentIndex()).toInt());
+       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(encType);
 
        //Update encoder profiles
-       QStringList profiles = encoderInfo.getProfiles(index);
+       const QStringList profiles = encoderInfo.getProfiles(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant->itemData(index).toInt()));
        if(profiles.empty())
        {
                ui->cbxProfile->setEnabled(false);
@@ -562,15 +581,16 @@ void AddJobDialog::accept(void)
        }
 
        //Get encoder info
-       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(ui->cbxEncoderType->currentIndex());
+       const OptionsModel::EncType encType = static_cast<OptionsModel::EncType>(ui->cbxEncoderType->itemData(ui->cbxEncoderType->currentIndex()).toInt());
+       const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(encType);
 
        //Is selected RC mode supported?
-       if(!encoderInfo.isRCModeSupported(ui->cbxRateControlMode->currentIndex()))
+       if(!encoderInfo.isRCModeSupported(static_cast<OptionsModel::RCMode>(ui->cbxRateControlMode->currentIndex())))
        {
                QMessageBox::warning(this, tr("Bad RC Mode!"), tr("<nobr>The selected RC mode is not supported by the selected encoder!</nobr>"));
                for(int i = 0; i < ui->cbxRateControlMode->count(); i++)
                {
-                       if(encoderInfo.isRCModeSupported(i))
+                       if(encoderInfo.isRCModeSupported(static_cast<OptionsModel::RCMode>(i)))
                        {
                                ui->cbxRateControlMode->setCurrentIndex(i);
                                break;
@@ -991,7 +1011,7 @@ void AddJobDialog::loadTemplateList(void)
        }
 }
 
-void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
+void AddJobDialog::updateComboBox(QComboBox *const cbox, const QString &text)
 {
        int index = 0;
        if(QAbstractItemModel *model = cbox->model())
@@ -1008,15 +1028,32 @@ void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
        cbox->setCurrentIndex(index);
 }
 
+void AddJobDialog::updateComboBox(QComboBox *const cbox, const int &data)
+{
+       int index = 0;
+       if(QAbstractItemModel *model = cbox->model())
+       {
+               for(int i = 0; i < cbox->model()->rowCount(); i++)
+               {
+                       if(model->itemData(model->index(i, 0, QModelIndex())).value(Qt::UserRole).toInt() == index)
+                       {
+                               index = i;
+                               break;
+                       }
+               }
+       }
+       cbox->setCurrentIndex(index);
+}
+
 void AddJobDialog::restoreOptions(const OptionsModel *options)
 {
        //Ignore config changes while restoring template!
        m_monitorConfigChanges = false;
 
-       ui->cbxEncoderType     ->setCurrentIndex(options->encType());
-       ui->cbxEncoderArch     ->setCurrentIndex(options->encArch());
-       setIndexByData(ui->cbxEncoderVariant, options->encVariant());
-       ui->cbxRateControlMode -> setCurrentIndex(options->rcMode());
+       updateComboBox(ui->cbxEncoderType,     options->encType());
+       updateComboBox(ui->cbxEncoderArch,     options->encArch());
+       updateComboBox(ui->cbxEncoderVariant,  options->encVariant());
+       updateComboBox(ui->cbxRateControlMode, options->rcMode());
 
        ui->spinQuantizer->setValue(options->quantizer());
        ui->spinBitrate  ->setValue(options->bitrate());
@@ -1028,16 +1065,19 @@ void AddJobDialog::restoreOptions(const OptionsModel *options)
        ui->editCustomX264Params   ->setText(options->customEncParams());
        ui->editCustomAvs2YUVParams->setText(options->customAvs2YUV());
 
+       //Force UI update
+       encoderIndexChanged(ui->cbxEncoderType->currentIndex());
+
        //Make sure we will monitor config changes again!
        m_monitorConfigChanges = true;
 }
 
 void AddJobDialog::saveOptions(OptionsModel *options)
 {
-       options->setEncType(static_cast<OptionsModel::EncType>(ui->cbxEncoderType->currentIndex()));
-       options->setEncArch(static_cast<OptionsModel::EncArch>(ui->cbxEncoderArch->currentIndex()));
-       options->setEncVariant(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant->itemData(ui->cbxEncoderVariant->currentIndex()).toInt()));
-       options->setRCMode(static_cast<OptionsModel::RCMode>(ui->cbxRateControlMode->currentIndex()));
+       options->setEncType   (static_cast<OptionsModel::EncType>   (ui->cbxEncoderType    ->itemData(ui->cbxEncoderType    ->currentIndex()).toInt()));
+       options->setEncArch   (static_cast<OptionsModel::EncArch>   (ui->cbxEncoderArch    ->itemData(ui->cbxEncoderArch    ->currentIndex()).toInt()));
+       options->setEncVariant(static_cast<OptionsModel::EncVariant>(ui->cbxEncoderVariant ->itemData(ui->cbxEncoderVariant ->currentIndex()).toInt()));
+       options->setRCMode    (static_cast<OptionsModel::RCMode>    (ui->cbxRateControlMode->itemData(ui->cbxRateControlMode->currentIndex()).toInt()));
        
        options->setQuantizer(ui->spinQuantizer->value());
        options->setBitrate(ui->spinBitrate->value());
@@ -1094,7 +1134,8 @@ QString AddJobDialog::currentOutputPath(const bool bWithName)
 
 int AddJobDialog::currentOutputIndx(void)
 {
-       if(ui->cbxEncoderType->currentIndex() == OptionsModel::EncType_X265)
+       const OptionsModel::EncType encType = static_cast<OptionsModel::EncType>(ui->cbxEncoderType->itemData(ui->cbxEncoderType->currentIndex()).toInt());
+       if(encType == OptionsModel::EncType_X265)
        {
                return ARRAY_SIZE(X264_FILE_TYPE_FILTERS) - 1;
        }
index 0bb1b05..1ad4a13 100644 (file)
@@ -97,7 +97,8 @@ private:
        void loadTemplateList(void);
        void restoreOptions(const OptionsModel *options);
        void saveOptions(OptionsModel *options);
-       void updateComboBox(QComboBox *cbox, const QString &text);
+       void updateComboBox(QComboBox *const cbox, const QString &text);
+       void updateComboBox(QComboBox *const cbox, const int &data);
 
        QString currentSourcePath(const bool bWithName = false);
        QString currentOutputPath(const bool bWithName = false);
index 8a49034..4dce732 100644 (file)
 //Internal
 #include "global.h"
 #include "model_options.h"
-#include "binaries.h"
+#include "model_sysinfo.h"
+#include "model_preferences.h"
 #include "encoder_factory.h"
+#include "source_factory.h"
 
 //MUtils
 #include <MUtils/Sound.h>
@@ -91,7 +93,7 @@ void HelpDialog::showEvent(QShowEvent *event)
        }
        else
        {
-               m_process->start(AVS_BINARY(m_sysinfo, m_preferences), QStringList());
+               m_process->start(SourceFactory::getSourceInfo(SourceFactory::SourceType_AVS).getBinaryPath(m_sysinfo, m_preferences->getPrefer64BitSource() && m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64)), QStringList());
        }
 
        if(!m_process->waitForStarted())
index 935b9b3..e9ae9fb 100644 (file)
@@ -42,7 +42,6 @@
 #include "win_about.h"
 #include "win_preferences.h"
 #include "win_updater.h"
-#include "binaries.h"
 #include "resource.h"
 
 //MUtils
index 7ce05ad..079f08e 100644 (file)
@@ -285,6 +285,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
     </CustomBuild>
+    <ClInclude Include="src\source_factory.h" />
     <ClInclude Include="tmp\x264_launcher\UIC_win_about.h" />
     <ClInclude Include="tmp\x264_launcher\UIC_win_addJob.h" />
     <ClInclude Include="tmp\x264_launcher\UIC_win_editor.h" />
@@ -349,7 +350,6 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
     </CustomBuild>
     <ClInclude Include="resource.h" />
-    <ClInclude Include="src\binaries.h" />
     <ClInclude Include="src\cli.h" />
     <ClInclude Include="src\encoder_abstract.h" />
     <ClInclude Include="src\encoder_factory.h" />
@@ -426,7 +426,6 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
     </CustomBuild>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="src\binaries.cpp" />
     <ClCompile Include="src\encoder_abstract.cpp" />
     <ClCompile Include="src\encoder_factory.cpp" />
     <ClCompile Include="src\encoder_x264.cpp" />
@@ -441,6 +440,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
     <ClCompile Include="src\model_recently.cpp" />
     <ClCompile Include="src\source_abstract.cpp" />
     <ClCompile Include="src\source_avisynth.cpp" />
+    <ClCompile Include="src\source_factory.cpp" />
     <ClCompile Include="src\source_vapoursynth.cpp" />
     <ClCompile Include="src\thread_avisynth.cpp" />
     <ClCompile Include="src\thread_binaries.cpp" />
index 4c020d1..2aa795a 100644 (file)
@@ -63,9 +63,6 @@
     <ClInclude Include="src\model_sysinfo.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="src\binaries.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="src\encoder_abstract.h">
       <Filter>Header Files</Filter>
     </ClInclude>
     <ClInclude Include="tmp\x264_launcher\UIC_win_updater.h">
       <Filter>Generated Files</Filter>
     </ClInclude>
+    <ClInclude Include="src\source_factory.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\main.cpp">
     <ClCompile Include="src\win_updater.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\binaries.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\encoder_abstract.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="tmp\x264_launcher\MOC_thread_binaries.cpp">
       <Filter>Generated Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\source_factory.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="src\win_main.h">