buildCommandLine(cmdLine_Encode, (pipedSource != NULL), clipInfo, m_indexFile, pass, passLogFile);
log("Creating encoder process:");
- if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode))
+ if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode, true, getExtraPath()))
{
return false;
}
SYSINFO_MAKE_FLAG(Avisynth)
SYSINFO_MAKE_FLAG(VapourSynth)
+ SYSINFO_MAKE_PATH(AVS)
SYSINFO_MAKE_PATH(VPS)
SYSINFO_MAKE_PATH(App)
checkSourceProperties_init(patterns, cmdLine);
log("Creating process:");
- if(!startProcess(process, getBinaryPath(), cmdLine))
+ if(!startProcess(process, getBinaryPath(), cmdLine, true, getExtraPath()))
{
return false;;
}
buildCommandLine(cmdLine_Input);
log("Creating input process:");
- if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false))
+ if(!startProcess(processInput, getBinaryPath(), cmdLine_Input, false, getExtraPath()))
{
return false;
}
class AbstractSourceInfo
{
public:
- virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const = 0;
+ virtual QString getBinaryPath(const SysinfoModel *const sysinfo, const bool& x64) const = 0;
+ virtual QString getExtraPath(const SysinfoModel *const sysinfo, const bool& x64) const { return QString(); }
};
class AbstractSource : public AbstractTool
#include "global.h"
+#include <MUtils/Global.h>
+
#include <QDir>
#include <QProcess>
class AvisynthSourceInfo : public AbstractSourceInfo
{
public:
- virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const
+ virtual QString getBinaryPath(const SysinfoModel *const sysinfo, const bool& x64) const
{
return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
}
+
+ virtual QString getExtraPath(const SysinfoModel *const sysinfo, const bool& x64) const
+ {
+ const QString avsPath = sysinfo->getAVSPath();
+ if (!avsPath.isEmpty())
+ {
+
+ return QString("%1/%2").arg(avsPath, x64 ? QLatin1String("x64") : QLatin1String("x86"));
+ }
+ return QString();
+ }
};
static const AvisynthSourceInfo s_avisynthEncoderInfo;
return s_avisynthEncoderInfo;
}
+
// ------------------------------------------------------------
// Constructor & Destructor
// ------------------------------------------------------------
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo);
- virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)))); }
+ virtual QString getBinaryPath(void) const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)))); }
+ virtual QString getExtraPath(void) const { return getSourceInfo().getExtraPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)))); }
virtual void buildCommandLine(QStringList &cmdLine);
};
class VapoursyntSourceInfo : public AbstractSourceInfo
{
public:
- virtual QString getBinaryPath(const SysinfoModel *sysinfo, const bool& x64) const
+ virtual QString getBinaryPath(const SysinfoModel *const sysinfo, const bool& x64) const
{
return QString("%1/core%2/vspipe.exe").arg(sysinfo->getVPSPath(), (x64 ? "64" : "32"));
}
#include "thread_avisynth.h"
+//Qt
#include <QLibrary>
#include <QEventLoop>
#include <QTimer>
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
+//Const
+static const bool ENABLE_PORTABLE_AVS = true;
+
//Static
QMutex AvisynthCheckThread::m_avsLock;
QScopedPointer<QFile> AvisynthCheckThread::m_avsDllPath[2];
//Helper
+#define VALID_DIR(STR) ((!(STR).isEmpty()) && QDir((STR)).exists())
#define BOOLIFY(X) ((X) ? '1' : '0')
//Utility function
{
sysinfo->setAvisynth(SysinfoModel::Avisynth_X86, thread.getSuccess() & AVISYNTH_X86);
sysinfo->setAvisynth(SysinfoModel::Avisynth_X64, thread.getSuccess() & AVISYNTH_X64);
+ sysinfo->setAVSPath(thread.getPath());
qDebug("Avisynth support is officially enabled now! [x86=%c, x64=%c]", BOOLIFY(sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)), BOOLIFY(sysinfo->getAvisynth(SysinfoModel::Avisynth_X64)));
}
else
{
m_exception = false;
m_success &= 0;
+ m_basePath.clear();
- detectAvisynthVersion1(m_success, m_sysinfo, &m_exception);
+ detectAvisynthVersion1(m_success, m_basePath, m_sysinfo, &m_exception);
}
-void AvisynthCheckThread::detectAvisynthVersion1(int &success, const SysinfoModel *const sysinfo, volatile bool *exception)
+void AvisynthCheckThread::detectAvisynthVersion1(int &success, QString &basePath, const SysinfoModel *const sysinfo, volatile bool *exception)
{
__try
{
- detectAvisynthVersion2(success, sysinfo, exception);
+ detectAvisynthVersion2(success, basePath, sysinfo, exception);
}
__except(1)
{
}
}
-void AvisynthCheckThread::detectAvisynthVersion2(int &success, const SysinfoModel *const sysinfo, volatile bool *exception)
+void AvisynthCheckThread::detectAvisynthVersion2(int &success, QString &basePath, const SysinfoModel *const sysinfo, volatile bool *exception)
{
try
{
- return detectAvisynthVersion3(success, sysinfo);
+ return detectAvisynthVersion3(success, basePath, sysinfo);
}
catch(...)
{
}
}
-void AvisynthCheckThread::detectAvisynthVersion3(int &success, const SysinfoModel *const sysinfo)
+void AvisynthCheckThread::detectAvisynthVersion3(int &success, QString &basePath, const SysinfoModel *const sysinfo)
{
success &= 0;
QFile *avsPath32;
- if(checkAvisynth(sysinfo, avsPath32, false))
+ if(checkAvisynth(basePath, sysinfo, avsPath32, false))
{
m_avsDllPath[0].reset(avsPath32);
success |= AVISYNTH_X86;
if(sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64))
{
QFile *avsPath64;
- if(checkAvisynth(sysinfo, avsPath64, true))
+ if(checkAvisynth(basePath, sysinfo, avsPath64, true))
{
m_avsDllPath[1].reset(avsPath64);
success |= AVISYNTH_X64;
}
}
-bool AvisynthCheckThread::checkAvisynth(const SysinfoModel *const sysinfo, QFile *&path, const bool &x64)
+bool AvisynthCheckThread::checkAvisynth(QString &basePath, const SysinfoModel *const sysinfo, QFile *&path, const bool &x64)
{
qDebug("Avisynth %s-Bit support is being tested.", x64 ? "64" : "32");
QProcess process;
QStringList output;
+ QString extraPath;
+
+ //Look for "portable" Avisynth version
+ if (ENABLE_PORTABLE_AVS)
+ {
+ const QString avsPortableDir = QString("%1/extra/Avisynth").arg(QCoreApplication::applicationDirPath());
+ if (VALID_DIR(avsPortableDir))
+ {
+ const QString archDir = x64 ? QLatin1String("x64") : QLatin1String("x86");
+ QFileInfo avsDllFile(QString("%1/%2/avisynth.dll").arg(avsPortableDir, archDir)), devilDllFile(QString("%1/%2/devil.dll").arg(avsPortableDir, archDir));
+ if (avsDllFile.exists() && devilDllFile.exists() && avsDllFile.isFile() && devilDllFile.isFile())
+ {
+ qWarning("Adding portable Avisynth to PATH environment variable: %s", MUTILS_UTF8(avsPortableDir));
+ basePath = avsPortableDir;
+ extraPath = QString("%1/%2").arg(avsPortableDir, archDir);
+ }
+ }
+ }
//Setup process object
- process.setWorkingDirectory(QDir::tempPath());
- process.setProcessChannelMode(QProcess::MergedChannels);
- process.setReadChannel(QProcess::StandardOutput);
+ MUtils::init_process(process, QDir::tempPath(), true, extraPath);
//Try to start VSPIPE.EXE
process.start(AVS_CHECK_BINARY(sysinfo, x64), QStringList());
{
MUTILS_DELETE(path);
}
-
qDebug("Avisynth was detected successfully (current version: %u.%02u).", avisynthVersion[0], avisynthVersion[1]);
qDebug("Avisynth DLL path: %s", MUTILS_UTF8(avisynthPath));
return true;
int getSuccess(void) { return m_success; }
bool getException(void) { return m_exception; }
+ QString getPath(void) { return m_basePath; }
typedef enum _AvisynthFlags
{
private:
volatile bool m_exception;
int m_success;
+ QString m_basePath;
const SysinfoModel *const m_sysinfo;
static QMutex m_avsLock;
virtual void run(void);
//Functions
- static void detectAvisynthVersion1(int &success, const SysinfoModel *const sysinfo, volatile bool *exception);
- static void detectAvisynthVersion2(int &success, const SysinfoModel *const sysinfo, volatile bool *exception);
- static void detectAvisynthVersion3(int &success, const SysinfoModel *const sysinfo);
+ static void detectAvisynthVersion1(int &success, QString &basePath, const SysinfoModel *const sysinfo, volatile bool *exception);
+ static void detectAvisynthVersion2(int &success, QString &basePath, const SysinfoModel *const sysinfo, volatile bool *exception);
+ static void detectAvisynthVersion3(int &success, QString &basePath, const SysinfoModel *const sysinfo);
//Internal functions
- static bool checkAvisynth(const SysinfoModel *const sysinfo, QFile *&path, const bool &x64);
+ static bool checkAvisynth(QString &basePath, const SysinfoModel *const sysinfo, QFile *&path, const bool &x64);
};
}
}
-
//Make sure VapourSynth directory does exist
if(vapoursynthPath.isEmpty())
{
return;
}
-
//Validate the VapourSynth installation now!
qDebug("VapourSynth Dir: %s", vapoursynthPath.toUtf8().constData());
for (size_t i = 0; VPS_CORE_DIR[i]; i++)
checkVersion_init(patterns, cmdLine);
log("Creating process:");
- if(!startProcess(process, getBinaryPath(), cmdLine))
+ if(!startProcess(process, getBinaryPath(), cmdLine, true, getExtraPath()))
{
return false;
}
// Process Creation
// ------------------------------------------------------------
-bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels)
+bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels, const QString &extraPath)
{
QMutexLocker lock(&s_mutexStartProcess);
log(commandline2string(program, args) + "\n");
+ log("EXTRAPATH: '" + extraPath + "'\n");
- process.setWorkingDirectory(QDir::tempPath());
-
- if(mergeChannels)
- {
- process.setProcessChannelMode(QProcess::MergedChannels);
- process.setReadChannel(QProcess::StandardOutput);
- }
- else
+ MUtils::init_process(process, QDir::tempPath(), true, extraPath);
+ if(!mergeChannels)
{
process.setProcessChannelMode(QProcess::SeparateChannels);
process.setReadChannel(QProcess::StandardError);
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified) = 0;
virtual QString printVersion(const unsigned int &revision, const bool &modified) = 0;
- //static const unsigned int REV_MULT = 10000;
-
signals:
void statusChanged(const JobStatus &newStatus);
void progressChanged(unsigned int newProgress);
static const unsigned int m_processTimeoutWarning = 24;
virtual QString getBinaryPath(void) const = 0;
+ virtual QString getExtraPath(void) const { return QString(); }
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified) = 0;
void setProgress(unsigned int newProgress) { emit progressChanged(newProgress); }
void setDetails(const QString &text) { emit detailsChanged(text); }
- bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true);
+ bool startProcess(QProcess &process, const QString &program, const QStringList &args, bool mergeChannels = true, const QString &extraPath = QString());
JobObject *const m_jobObject;
const OptionsModel *const m_options;
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 7
#define VER_X264_PATCH 5
-#define VER_X264_BUILD 1045
+#define VER_X264_BUILD 1051
#define VER_X264_PORTABLE_EDITION (0)