From 78f882f1ad2a2dc49671dff3fe34f30bd3f6d2c4 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Fri, 2 Aug 2013 18:09:12 +0200 Subject: [PATCH] Added VapourSynth detection code. --- src/version.h | 2 +- src/win_main.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ src/win_main.h | 3 +++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 3fb8c58..018f749 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 1 #define VER_X264_PATCH 7 -#define VER_X264_BUILD 510 +#define VER_X264_BUILD 519 #define VER_X264_MINIMUM_REV 2339 #define VER_X264_CURRENT_API 135 diff --git a/src/win_main.cpp b/src/win_main.cpp index ced61a4..e2b314a 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -797,6 +797,45 @@ void MainWindow::init(void) qDebug(""); } + //Check for Vapoursynth support + if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive)) + { + qDebug("[Check for VapourSynth support]"); + const QString vapursynthPath = getVapoursynthLocation(); + if(!vapursynthPath.isEmpty()) + { + bool okay = false; + QFile *vpsExePath = new QFile(QString("%1/core/vspipe.exe").arg(vapursynthPath)); + QFile *vpsDllPath = new QFile(QString("%1/core/vapoursynth.dll").arg(vapursynthPath)); + qDebug("VapourSynth EXE: %s", vpsExePath->fileName().toUtf8().constData()); + qDebug("VapourSynth DLL: %s", vpsDllPath->fileName().toUtf8().constData()); + if(vpsExePath->open(QIODevice::ReadOnly) && vpsDllPath->open(QIODevice::ReadOnly)) + { + DWORD binaryType; + if(GetBinaryType(QWCHAR(QDir::toNativeSeparators(vpsExePath->fileName())), &binaryType)) + { + okay = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY); + } + } + if(okay) + { + qDebug("VapourSynth support enabled."); + m_vapoursynthPath = QFileInfo(vpsExePath->fileName()).canonicalFilePath(); + m_toolsList << vpsExePath; + m_toolsList << vpsDllPath; + } + else + { + qDebug("VapourSynth binaries not found -> disable Vapousynth support!"); + X264_DELETE(vpsExePath); + X264_DELETE(vpsDllPath); + int val = QMessageBox::warning(this, tr("VapourSynth Missing"), tr("It appears that VapourSynth is not currently installed on your computer.
Therefore VapourSynth (.vpy) input will not be working at all!

Please download and install VapourSynth (r19 or later) here:
http://www.vapoursynth.com/
").replace("-", "−"), tr("Quit"), tr("Ignore")); + if(val != 1) { close(); qApp->exit(-1); return; } + } + } + qDebug(""); + } + //Check for expiration if(x264_version_date().addMonths(6) < QDate::currentDate()) { @@ -1258,3 +1297,34 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon) WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon); } + +/* + * Read Vapursynth location from registry + */ +QString MainWindow::getVapoursynthLocation(void) +{ + QString vapoursynthPath; + static const wchar_t *VPS_REG_KEY = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VapourSynth_is1"; + HKEY hKey = NULL; + if(RegOpenKey(HKEY_LOCAL_MACHINE, VPS_REG_KEY, &hKey) == ERROR_SUCCESS) + { + const size_t DATA_LEN = 2048; + wchar_t data[DATA_LEN]; + DWORD type = REG_NONE, size = sizeof(wchar_t) * DATA_LEN; + if(RegQueryValueEx(hKey, L"InstallLocation", NULL, &type, ((BYTE*)&data[0]), &size) == ERROR_SUCCESS) + { + if((type == REG_SZ) || (type == REG_EXPAND_SZ)) + { + vapoursynthPath = QDir::fromNativeSeparators(QString::fromUtf16((const ushort*)&data[0])); + while(vapoursynthPath.endsWith("/")) { vapoursynthPath.chop(1); } + qDebug("Vapoursynth location: %s", vapoursynthPath.toUtf8().constData()); + } + } + RegCloseKey(hKey); + } + else + { + qDebug("Vapoursynth registry key not found -> not installed!"); + } + return vapoursynthPath; +} diff --git a/src/win_main.h b/src/win_main.h index 4e69855..938b84c 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -64,6 +64,7 @@ private: PreferencesModel *m_preferences; RecentlyUsed *m_recentlyUsed; + QString m_vapoursynthPath; const x264_cpu_t *const m_cpuFeatures; const QString m_appDir; @@ -77,6 +78,8 @@ private: unsigned int countPendingJobs(void); unsigned int countRunningJobs(void); + static QString getVapoursynthLocation(void); + private slots: void addButtonPressed(); void openActionTriggered();