Cleaned up VapourSynth detection code + detect "portable" VapourSynth if available.

This commit is contained in:
LoRd_MuldeR 2016-09-27 21:04:35 +02:00
parent f7f950191f
commit f35f2635a3
3 changed files with 77 additions and 52 deletions

View File

@ -103,6 +103,10 @@ Simple x264/x265 Launcher can be run in a "portable" mode. This may be helpful,
***Note:*** Regardless of whether you enable the *portable* mode or not, the Simple x264/x265 Launcher application is **always** "portable", in the sense that the program is fully self-contained. It does *not* require any "external" libraries or frameworks to be installed on the computer. The only exceptions here are Avisynth and VapourSynth, which have to be installed *separately*, if they are needed. The *sole* purpose of the *portable* mode is to control where the configuration files will be stored. There is **no** such thing as a separate "portable" version of Simple x264/x265 Launcher. ***Note:*** Regardless of whether you enable the *portable* mode or not, the Simple x264/x265 Launcher application is **always** "portable", in the sense that the program is fully self-contained. It does *not* require any "external" libraries or frameworks to be installed on the computer. The only exceptions here are Avisynth and VapourSynth, which have to be installed *separately*, if they are needed. The *sole* purpose of the *portable* mode is to control where the configuration files will be stored. There is **no** such thing as a separate "portable" version of Simple x264/x265 Launcher.
## VapourSynth Portable
There now is a "portable" edition **VapourSynth** available, which *Simple x264/x265 Launcher* can use. For this purpose, download the "portable" edition VapourSynth an *extract* it into the sub-directory `extra\VaporSynth` inside of the Simple x264/x265 Launcher "main" directory (i.e. where the `x264_launcher.exe` file is located). More specifically, the *32-Bit* version of VapourSynth needs to go into the `extra\VaporSynth\core32` sub-directory and the *64-Bit* version of VapourSynth needs to go into the `extra\VaporSynth\core64` sub-directory.
# Updating Your Encoder Binaries # # Updating Your Encoder Binaries #

View File

@ -41,6 +41,9 @@
//CRT //CRT
#include <cassert> #include <cassert>
//Const
static const bool ENABLE_PORTABLE_VPS = true;
//Static //Static
QMutex VapourSynthCheckThread::m_vpsLock; QMutex VapourSynthCheckThread::m_vpsLock;
QScopedPointer<QFile> VapourSynthCheckThread::m_vpsExePath[2]; QScopedPointer<QFile> VapourSynthCheckThread::m_vpsExePath[2];
@ -48,6 +51,7 @@ QScopedPointer<QFile> VapourSynthCheckThread::m_vpsDllPath[2];
#define VALID_DIR(STR) ((!(STR).isEmpty()) && QDir((STR)).exists()) #define VALID_DIR(STR) ((!(STR).isEmpty()) && QDir((STR)).exists())
#define BOOLIFY(X) ((X) ? '1' : '0') #define BOOLIFY(X) ((X) ? '1' : '0')
#define VPS_BITNESS(X) (((X) + 1U) * 32U)
static inline QString &cleanDir(QString &path) static inline QString &cleanDir(QString &path)
{ {
@ -174,6 +178,18 @@ void VapourSynthCheckThread::detectVapourSynthPath3(int &success, QString &path)
success &= 0; success &= 0;
path.clear(); path.clear();
static const char *VPS_CORE_DIR[] =
{
"core32",
"core64",
NULL
};
static const int VPS_BIT_FLAG[] =
{
VAPOURSYNTH_X86,
VAPOURSYNTH_X64,
NULL
};
static const char *VPS_REG_KEYS[] = static const char *VPS_REG_KEYS[] =
{ {
"SOFTWARE\\VapourSynth", "SOFTWARE\\VapourSynth",
@ -194,8 +210,29 @@ void VapourSynthCheckThread::detectVapourSynthPath3(int &success, QString &path)
MUtils::Registry::scope_wow_x64 MUtils::Registry::scope_wow_x64
}; };
//Read VapourSynth path from registry
QString vapoursynthPath; QString vapoursynthPath;
//Look for "portable" VapourSynth version
if (ENABLE_PORTABLE_VPS)
{
const QString vpsPortableDir = QString("%1/extra/VapourSynth").arg(QCoreApplication::applicationDirPath());
if (VALID_DIR(vpsPortableDir))
{
for (size_t i = 0; VPS_CORE_DIR[i]; i++)
{
const QFileInfo vpsPortableDll = QFileInfo(QString("%1/%2/VapourSynth.dll").arg(vpsPortableDir, QString::fromLatin1(VPS_CORE_DIR[i])));
if (vpsPortableDll.exists() && vpsPortableDll.isFile())
{
vapoursynthPath = vpsPortableDir;
break;
}
}
}
}
//Read VapourSynth path from registry
if (vapoursynthPath.isEmpty())
{
for (size_t i = 0; VPS_REG_KEYS[i]; i++) for (size_t i = 0; VPS_REG_KEYS[i]; i++)
{ {
for (size_t j = 0; VPS_REG_NAME[j]; j++) for (size_t j = 0; VPS_REG_NAME[j]; j++)
@ -223,56 +260,40 @@ void VapourSynthCheckThread::detectVapourSynthPath3(int &success, QString &path)
break; break;
} }
} }
}
//Make sure VapourSynth does exist
if(!VALID_DIR(vapoursynthPath)) //Make sure VapourSynth directory does exist
if(vapoursynthPath.isEmpty())
{ {
qWarning("VapourSynth install path not found -> disable VapouSynth support!"); qWarning("VapourSynth install path not found -> disable VapouSynth support!");
return; return;
} }
//Validate the VapourSynth installation now!
qDebug("VapourSynth Dir: %s", vapoursynthPath.toUtf8().constData()); qDebug("VapourSynth Dir: %s", vapoursynthPath.toUtf8().constData());
for (size_t i = 0; VPS_CORE_DIR[i]; i++)
//Look for 32-Bit edition of VapourSynth first
QFile *vpsExeFile32, *vpsDllFile32;
if(isVapourSynthComplete(QString("%1/core32").arg(vapoursynthPath), vpsExeFile32, vpsDllFile32))
{ {
if(vpsExeFile32 && checkVapourSynth(vpsExeFile32->fileName())) QFile *vpsExeFile, *vpsDllFile;
if (isVapourSynthComplete(QString("%1/%2").arg(vapoursynthPath, QString::fromLatin1(VPS_CORE_DIR[i])), vpsExeFile, vpsDllFile))
{ {
success |= VAPOURSYNTH_X86; if (vpsExeFile && checkVapourSynth(vpsExeFile->fileName()))
qDebug("VapourSynth 32-Bit edition found!"); {
m_vpsExePath[0].reset(vpsExeFile32); success |= VPS_BIT_FLAG[i];
m_vpsDllPath[0].reset(vpsDllFile32); qDebug("VapourSynth %u-Bit edition found!", VPS_BITNESS(i));
m_vpsExePath[i].reset(vpsExeFile);
m_vpsDllPath[i].reset(vpsDllFile);
} }
else else
{ {
qWarning("VapourSynth 32-Bit edition was found, but version check has failed!"); qWarning("VapourSynth %u-Bit edition was found, but version check has failed!", VPS_BITNESS(i));
} }
} }
else else
{ {
qDebug("VapourSynth 32-Bit edition *not* found!"); qDebug("VapourSynth %u-Bit edition *not* found!", VPS_BITNESS(i));
} }
//Look for 64-Bit edition of VapourSynth next
QFile *vpsExeFile64, *vpsDllFile64;
if(isVapourSynthComplete(QString("%1/core64").arg(vapoursynthPath), vpsExeFile64, vpsDllFile64))
{
if(vpsExeFile64 && checkVapourSynth(vpsExeFile64->fileName()))
{
success |= VAPOURSYNTH_X64;
qDebug("VapourSynth 64-Bit edition found!");
m_vpsExePath[1].reset(vpsExeFile64);
m_vpsDllPath[1].reset(vpsDllFile64);
}
else
{
qWarning("VapourSynth 64-Bit edition was found, but version check has failed!");
}
}
else
{
qDebug("VapourSynth 64-Bit edition *not* found!");
} }
//Return VapourSynth path //Return VapourSynth path

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 7 #define VER_X264_MINOR 7
#define VER_X264_PATCH 5 #define VER_X264_PATCH 5
#define VER_X264_BUILD 1042 #define VER_X264_BUILD 1043
#define VER_X264_PORTABLE_EDITION (0) #define VER_X264_PORTABLE_EDITION (0)