Refactored VapourSynth detection code into a separate thread, similar to Avisynth.

This commit is contained in:
LoRd_MuldeR 2013-08-07 15:34:02 +02:00
parent 9635f092f6
commit 3766369c49
12 changed files with 415 additions and 115 deletions

BIN
res/images/python.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -40,6 +40,7 @@
<file>buttons/x264.png</file> <file>buttons/x264.png</file>
<file>images/avisynth.png</file> <file>images/avisynth.png</file>
<file>images/movie.png</file> <file>images/movie.png</file>
<file>images/python.png</file>
<file>images/update.png</file> <file>images/update.png</file>
<file>images/x264.png</file> <file>images/x264.png</file>
</qresource> </qresource>

View File

@ -33,16 +33,9 @@
QMutex AvisynthCheckThread::m_avsLock; QMutex AvisynthCheckThread::m_avsLock;
QLibrary *AvisynthCheckThread::m_avsLib = NULL; QLibrary *AvisynthCheckThread::m_avsLib = NULL;
AvisynthCheckThread::AvisynthCheckThread(void) //-------------------------------------
{ // External API
m_success = false; //-------------------------------------
m_exception = false;
m_version = 0.0;
}
AvisynthCheckThread::~AvisynthCheckThread(void)
{
}
int AvisynthCheckThread::detect(volatile double *version) int AvisynthCheckThread::detect(volatile double *version)
{ {
@ -103,12 +96,29 @@ void AvisynthCheckThread::unload(void)
{ {
m_avsLib->unload(); m_avsLib->unload();
} }
X264_DELETE(m_avsLib);
} }
X264_DELETE(m_avsLib);
}
//-------------------------------------
// Thread class
//-------------------------------------
AvisynthCheckThread::AvisynthCheckThread(void)
{
m_success = false;
m_exception = false;
m_version = 0.0;
}
AvisynthCheckThread::~AvisynthCheckThread(void)
{
} }
void AvisynthCheckThread::run(void) void AvisynthCheckThread::run(void)
{ {
m_exception = m_success = false;
m_success = detectAvisynthVersion1(&m_version, &m_exception); m_success = detectAvisynthVersion1(&m_version, &m_exception);
} }

View File

@ -31,12 +31,13 @@ class AvisynthCheckThread : public QThread
Q_OBJECT Q_OBJECT
public: public:
AvisynthCheckThread(void);
~AvisynthCheckThread(void);
static int detect(volatile double *version); static int detect(volatile double *version);
static void unload(void); static void unload(void);
protected:
AvisynthCheckThread(void);
~AvisynthCheckThread(void);
bool getSuccess(void) { return m_success; } bool getSuccess(void) { return m_success; }
bool getException(void) { return m_exception; } bool getException(void) { return m_exception; }
double getVersion(void) { return m_version; } double getVersion(void) { return m_version; }

View File

@ -94,7 +94,7 @@ while(0)
#define AVS2_BINARY(BIN_DIR, IS_X64) (QString("%1/%2/avs2yuv_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86"))) #define AVS2_BINARY(BIN_DIR, IS_X64) (QString("%1/%2/avs2yuv_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86")))
#define X264_BINARY(BIN_DIR, IS_10BIT, IS_X64) (QString("%1/%2/x264_%3_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86"), ((IS_10BIT) ? "10bit" : "8bit"))) #define X264_BINARY(BIN_DIR, IS_10BIT, IS_X64) (QString("%1/%2/x264_%3_%2.exe").arg((BIN_DIR), ((IS_X64) ? "x64" : "x86"), ((IS_10BIT) ? "10bit" : "8bit")))
#define VPSP_BINARY(VPS_DIR) (QString("%1/vspipe.exe").arg((VPS_DIR))) #define VPSP_BINARY(VPS_DIR) (QString("%1/core/vspipe.exe").arg((VPS_DIR)))
/* /*
* Static vars * Static vars
@ -217,6 +217,8 @@ void EncodeThread::encode(void)
log(tr("Source file: %1").arg(QDir::toNativeSeparators(m_sourceFileName))); log(tr("Source file: %1").arg(QDir::toNativeSeparators(m_sourceFileName)));
log(tr("Output file: %1").arg(QDir::toNativeSeparators(m_outputFileName))); log(tr("Output file: %1").arg(QDir::toNativeSeparators(m_outputFileName)));
log(tr("VPS Path: %1").arg(m_vpsDir));
//Print encoder settings //Print encoder settings
log(tr("\n--- SETTINGS ---\n")); log(tr("\n--- SETTINGS ---\n"));
log(tr("RC Mode: %1").arg(OptionsModel::rcMode2String(m_options->rcMode()))); log(tr("RC Mode: %1").arg(OptionsModel::rcMode2String(m_options->rcMode())));

261
src/thread_vapoursynth.cpp Normal file
View File

@ -0,0 +1,261 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2013 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 "thread_vapoursynth.h"
#include <QLibrary>
#include <QEventLoop>
#include <QTimer>
#include <QMutexLocker>
#include <QApplication>
#include <QDir>
#include "global.h"
#include "avisynth_c.h"
QMutex VapourSynthCheckThread::m_vpsLock;
QFile *VapourSynthCheckThread::m_vpsExePath = NULL;
QFile *VapourSynthCheckThread::m_vpsDllPath = NULL;
QLibrary *VapourSynthCheckThread::m_vpsLib = NULL;
//-------------------------------------
// External API
//-------------------------------------
int VapourSynthCheckThread::detect(QString &path)
{
path.clear();
QMutexLocker lock(&m_vpsLock);
QEventLoop loop;
VapourSynthCheckThread thread;
QTimer timer;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
connect(&thread, SIGNAL(finished()), &loop, SLOT(quit()));
connect(&thread, SIGNAL(terminated()), &loop, SLOT(quit()));
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
thread.start();
timer.start(8000);
qDebug("VapourSynth thread has been created, please wait...");
loop.exec(QEventLoop::ExcludeUserInputEvents);
qDebug("VapourSynth thread finished.");
QApplication::restoreOverrideCursor();
if(!thread.wait(1000))
{
qWarning("VapourSynth thread encountered timeout -> probably deadlock!");
thread.terminate();
thread.wait();
return -1;
}
if(thread.getException())
{
qWarning("VapourSynth thread encountered an exception !!!");
return -1;
}
if(thread.getSuccess())
{
path = thread.getPath();
qDebug("VapourSynth check completed successfully.");
return 1;
}
qWarning("VapourSynth thread failed to detect installation!");
return 0;
}
void VapourSynthCheckThread::unload(void)
{
QMutexLocker lock(&m_vpsLock);
if(m_vpsLib)
{
if(m_vpsLib->isLoaded())
{
m_vpsLib->unload();
}
}
if(m_vpsExePath)
{
if (m_vpsExePath->isOpen())
{
m_vpsExePath->close();
}
}
if(m_vpsDllPath)
{
if(m_vpsDllPath->isOpen())
{
m_vpsDllPath->close();
}
}
X264_DELETE(m_vpsExePath);
X264_DELETE(m_vpsDllPath);
X264_DELETE(m_vpsLib);
}
//-------------------------------------
// Thread class
//-------------------------------------
VapourSynthCheckThread::VapourSynthCheckThread(void)
{
m_success = false;
m_exception = false;
m_vpsPath.clear();
}
VapourSynthCheckThread::~VapourSynthCheckThread(void)
{
}
void VapourSynthCheckThread::run(void)
{
m_exception = m_success = false;
m_success = detectVapourSynthPath1(m_vpsPath, &m_exception);
}
bool VapourSynthCheckThread::detectVapourSynthPath1(QString &path, volatile bool *exception)
{
__try
{
return detectVapourSynthPath2(path, exception);
}
__except(1)
{
*exception = true;
qWarning("Unhandled exception error in VapourSynth thread !!!");
return false;
}
}
bool VapourSynthCheckThread::detectVapourSynthPath2(QString &path, volatile bool *exception)
{
try
{
return detectVapourSynthPath3(path);
}
catch(...)
{
*exception = true;
qWarning("VapourSynth initializdation raised an C++ exception!");
return false;
}
}
bool VapourSynthCheckThread::detectVapourSynthPath3(QString &path)
{
bool success = false;
X264_DELETE(m_vpsExePath);
X264_DELETE(m_vpsDllPath);
path.clear();
static const wchar_t *VPS_REG_KEY = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VapourSynth_is1";
//Determine the VapourSynth install path from registry
QString vapoursynthPath; 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());
}
}
if(vapoursynthPath.isEmpty())
{
qWarning("Vapoursynth install location entry not found -> not installed!");
}
RegCloseKey(hKey);
}
else
{
qWarning("Vapoursynth registry key not found -> not installed!");
}
//Make sure that 'vapoursynth.dll' and 'vspipe.exe' are available
bool vapoursynthComplete = false;
if(!vapoursynthPath.isEmpty())
{
m_vpsExePath = new QFile(QString("%1/core/vspipe.exe").arg(vapoursynthPath));
m_vpsDllPath = new QFile(QString("%1/core/vapoursynth.dll").arg(vapoursynthPath));
qDebug("VapourSynth EXE: %s", m_vpsExePath->fileName().toUtf8().constData());
qDebug("VapourSynth DLL: %s", m_vpsDllPath->fileName().toUtf8().constData());
if(m_vpsExePath->open(QIODevice::ReadOnly) && m_vpsDllPath->open(QIODevice::ReadOnly))
{
DWORD binaryType;
if(GetBinaryType(QWCHAR(QDir::toNativeSeparators(m_vpsExePath->fileName())), &binaryType))
{
vapoursynthComplete = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY);
}
}
if(!vapoursynthComplete)
{
qWarning("VapourSynth installation incomplete -> disable Vapousynth support!");
}
}
//Make sure 'vsscript.dll' can be loaded successfully
if(vapoursynthComplete)
{
if(!m_vpsLib)
{
m_vpsLib = new QLibrary("vsscript.dll");
}
if(m_vpsLib->isLoaded() || m_vpsLib->load())
{
static const char *VSSCRIPT_ENTRY = "_vsscript_init@0";
qDebug("VapourSynth scripting library loaded.");
if(!(success = (m_vpsLib->resolve(VSSCRIPT_ENTRY) != NULL)))
{
qWarning("Entrypoint '%s' not found in VSSCRIPT.DLL !!!", VSSCRIPT_ENTRY);
}
}
else
{
qWarning("Failed to load VSSCRIPT.DLL !!!");
}
}
//Return VapourSynth path
if(success)
{
path = vapoursynthPath;
}
return success;
}

66
src/thread_vapoursynth.h Normal file
View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2013 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
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QThread>
#include <QMutex>
class QLibrary;
class QFile;
class VapourSynthCheckThread : public QThread
{
Q_OBJECT
public:
static int detect(QString &path);
static void unload(void);
protected:
VapourSynthCheckThread(void);
~VapourSynthCheckThread(void);
bool getSuccess(void) { return m_success; }
bool getException(void) { return m_exception; }
QString getPath(void) { return m_vpsPath; }
private slots:
void start(Priority priority = InheritPriority) { QThread::start(priority); }
private:
volatile bool m_exception;
volatile bool m_success;
QString m_vpsPath;
static QMutex m_vpsLock;
static QFile *m_vpsExePath;
static QFile *m_vpsDllPath;
static QLibrary *m_vpsLib;
//Entry point
virtual void run(void);
//Functions
static bool detectVapourSynthPath1(QString &path, volatile bool *exception);
static bool detectVapourSynthPath2(QString &path, volatile bool *exception);
static bool detectVapourSynthPath3(QString &path);
};

View File

@ -21,8 +21,8 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 1 #define VER_X264_MINOR 1
#define VER_X264_PATCH 8 #define VER_X264_PATCH 9
#define VER_X264_BUILD 537 #define VER_X264_BUILD 548
#define VER_X264_MINIMUM_REV 2339 #define VER_X264_MINIMUM_REV 2339
#define VER_X264_CURRENT_API 135 #define VER_X264_CURRENT_API 135

View File

@ -26,6 +26,7 @@
#include "model_preferences.h" #include "model_preferences.h"
#include "model_recently.h" #include "model_recently.h"
#include "thread_avisynth.h" #include "thread_avisynth.h"
#include "thread_vapoursynth.h"
#include "thread_ipc.h" #include "thread_ipc.h"
#include "thread_encode.h" #include "thread_encode.h"
#include "taskbar7.h" #include "taskbar7.h"
@ -56,6 +57,7 @@ const char *tpl_last = "<LAST_USED>";
#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
#define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
#define LINK(URL) "<a href=\"" URL "\">" URL "</a>"
static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; } static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; }
@ -212,9 +214,10 @@ MainWindow::~MainWindow(void)
} }
X264_DELETE(m_ipcThread); X264_DELETE(m_ipcThread);
AvisynthCheckThread::unload();
X264_DELETE(m_preferences); X264_DELETE(m_preferences);
X264_DELETE(m_recentlyUsed); X264_DELETE(m_recentlyUsed);
VapourSynthCheckThread::unload();
AvisynthCheckThread::unload();
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -456,6 +459,7 @@ void MainWindow::showAbout(void)
aboutBox.setText(text.replace("-", "&minus;")); aboutBox.setText(text.replace("-", "&minus;"));
aboutBox.addButton(tr("About x264"), QMessageBox::NoRole); aboutBox.addButton(tr("About x264"), QMessageBox::NoRole);
aboutBox.addButton(tr("About AVS"), QMessageBox::NoRole); aboutBox.addButton(tr("About AVS"), QMessageBox::NoRole);
aboutBox.addButton(tr("About VPY"), QMessageBox::NoRole);
aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole); aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole);
aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole)); aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole));
@ -501,6 +505,24 @@ void MainWindow::showAbout(void)
} }
break; break;
case 2: case 2:
{
QString text2;
text2 += tr("<nobr><tt>VapourSynth - application for video manipulation based on Python.<br>");
text2 += tr("Copyright (c) 2012 Fredrik Mellbin.<br>");
text2 += tr("Released under the terms of the GNU Lesser General Public.<br><br>");
text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://www.vapoursynth.com/");
text2 += tr("Read the <a href=\"%1\">documentation</a> to get started and use the <a href=\"%2\">support forum</a> for help!<br></tt></nobr>").arg("http://www.vapoursynth.com/doc/", "http://forum.doom9.org/showthread.php?t=165771");
QMessageBox x264Box(this);
x264Box.setIconPixmap(QIcon(":/images/python.png").pixmap(48,48));
x264Box.setWindowTitle(tr("About VapourSynth"));
x264Box.setText(text2.replace("-", "&minus;"));
x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
MessageBeep(MB_ICONINFORMATION);
x264Box.exec();
}
break;
case 3:
QMessageBox::aboutQt(this); QMessageBox::aboutQt(this);
break; break;
default: default:
@ -799,7 +821,7 @@ void MainWindow::init(void)
} }
if((!result) || (avisynthVersion < 2.5)) if((!result) || (avisynthVersion < 2.5))
{ {
int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!<br><br>Please download and install Avisynth:<br><a href=\"http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/\">http://sourceforge.net/projects/avisynth2/files/AviSynth 2.5/</a></nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore")); int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!<br><br>Please download and install Avisynth:<br>" LINK("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/") "</nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
if(val != 1) { close(); qApp->exit(-1); return; } if(val != 1) { close(); qApp->exit(-1); return; }
} }
qDebug(""); qDebug("");
@ -808,29 +830,21 @@ void MainWindow::init(void)
//Check for Vapoursynth support //Check for Vapoursynth support
if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive)) if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive))
{ {
qDebug("[Check for VapourSynth support]"); qDebug("[Check for Vapoursynth support]");
const QString vapursynthPath = getVapoursynthLocation(); volatile double avisynthVersion = 0.0;
if(!vapursynthPath.isEmpty()) const int result = VapourSynthCheckThread::detect(m_vapoursynthPath);
if(result < 0)
{ {
QFile *vpsExePath = new QFile(QString("%1/core/vspipe.exe").arg(vapursynthPath)); QString text = tr("A critical error was encountered while checking your Vapoursynth installation.").append("<br>");
QFile *vpsDllPath = new QFile(QString("%1/core/vapoursynth.dll").arg(vapursynthPath)); text += tr("This is most likely caused by an erroneous Vapoursynth Plugin, please try to clean your Filters folder!").append("<br>");
qDebug("VapourSynth EXE: %s", vpsExePath->fileName().toUtf8().constData()); text += tr("We suggest to move all .dll files out of your Vapoursynth Filters folder and try again.");
qDebug("VapourSynth DLL: %s", vpsDllPath->fileName().toUtf8().constData()); int val = QMessageBox::critical(this, tr("Vapoursynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
if(checkVapourSynth(vpsExePath, vpsDllPath)) if(val != 1) { close(); qApp->exit(-1); return; }
{ }
qDebug("VapourSynth support enabled."); if((!result) || (m_vapoursynthPath.isEmpty()))
m_vapoursynthPath = QFileInfo(vpsExePath->fileName()).canonicalPath(); {
m_toolsList << vpsExePath; int val = QMessageBox::warning(this, tr("Vapoursynth Missing"), tr("<nobr>It appears that Vapoursynth is <b>not</b> currently installed on your computer.<br>Therefore Vapoursynth (.vpy) input will <b>not</b> be working at all!<br><br>Please download and install Vapoursynth R19 or later:<br>" LINK("http://www.vapoursynth.com/") "</nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
m_toolsList << vpsDllPath; if(val != 1) { close(); qApp->exit(-1); return; }
}
else
{
qDebug("VapourSynth not avilable -> disable Vapousynth support!");
X264_DELETE(vpsExePath);
X264_DELETE(vpsDllPath);
int val = QMessageBox::warning(this, tr("VapourSynth Missing"), tr("<nobr>It appears that VapourSynth is <b>not</b> currently installed on your computer.<br>Therefore VapourSynth (.vpy) input will <b>not</b> be working at all!<br><br>Please download and install VapourSynth (r19 or later) here:<br><a href=\"http://www.vapoursynth.com/\">http://www.vapoursynth.com/</a></nobr>").replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
if(val != 1) { close(); qApp->exit(-1); return; }
}
} }
qDebug(""); qDebug("");
} }
@ -1298,74 +1312,3 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &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
{
qWarning("Vapoursynth registry key not found -> not installed!");
}
return vapoursynthPath;
}
bool MainWindow::checkVapourSynth(QFile *vpsExePath, QFile *vpsDllPath)
{
bool okay = false;
static const char *VSSCRIPT_ENTRY = "_vsscript_init@0";
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 binaries found -> load VSSCRIPT.DLL");
QLibrary vspLibrary("vsscript.dll");
if(okay = vspLibrary.load())
{
if(!(okay = (vspLibrary.resolve(VSSCRIPT_ENTRY) != NULL)))
{
qWarning("Entrypoint '%s' not found in VSSCRIPT.DLL !!!", VSSCRIPT_ENTRY);
}
}
else
{
qWarning("Failed to load VSSCRIPT.DLL !!!");
}
}
else
{
qWarning("VapourSynth binaries could not be found !!!");
}
return okay;
}

View File

@ -81,9 +81,6 @@ private:
unsigned int countPendingJobs(void); unsigned int countPendingJobs(void);
unsigned int countRunningJobs(void); unsigned int countRunningJobs(void);
static QString getVapoursynthLocation(void);
static bool checkVapourSynth(QFile *vpsExePath, QFile *vpsDllPath);
private slots: private slots:
void addButtonPressed(); void addButtonPressed();
void openActionTriggered(); void openActionTriggered();

View File

@ -304,6 +304,14 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild> </CustomBuild>
<CustomBuild Include="src\thread_vapoursynth.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MOC "$(SolutionDir)tmp\moc\moc_%(Filename).cpp"</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MOC "$(SolutionDir)tmp\moc\moc_%(Filename).cpp"</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
<ClInclude Include="src\version.h" /> <ClInclude Include="src\version.h" />
<CustomBuild Include="src\win_main.h"> <CustomBuild Include="src\win_main.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)"</Command>
@ -330,6 +338,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
<ClCompile Include="src\global.cpp" /> <ClCompile Include="src\global.cpp" />
<ClCompile Include="src\main.cpp" /> <ClCompile Include="src\main.cpp" />
<ClCompile Include="src\thread_ipc.cpp" /> <ClCompile Include="src\thread_ipc.cpp" />
<ClCompile Include="src\thread_vapoursynth.cpp" />
<ClCompile Include="src\win_addJob.cpp" /> <ClCompile Include="src\win_addJob.cpp" />
<ClCompile Include="src\win_editor.cpp" /> <ClCompile Include="src\win_editor.cpp" />
<ClCompile Include="src\win_help.cpp" /> <ClCompile Include="src\win_help.cpp" />
@ -340,6 +349,7 @@ copy /Y "$(QTDIR)\plugins\imageformats\qgif4.dll" "$(TargetDir)\imageformats"
<ClCompile Include="tmp\moc\moc_thread_avisynth.cpp" /> <ClCompile Include="tmp\moc\moc_thread_avisynth.cpp" />
<ClCompile Include="tmp\moc\moc_thread_encode.cpp" /> <ClCompile Include="tmp\moc\moc_thread_encode.cpp" />
<ClCompile Include="tmp\moc\moc_thread_ipc.cpp" /> <ClCompile Include="tmp\moc\moc_thread_ipc.cpp" />
<ClCompile Include="tmp\moc\moc_thread_vapoursynth.cpp" />
<ClCompile Include="tmp\moc\moc_win_addJob.cpp" /> <ClCompile Include="tmp\moc\moc_win_addJob.cpp" />
<ClCompile Include="tmp\moc\moc_win_editor.cpp" /> <ClCompile Include="tmp\moc\moc_win_editor.cpp" />
<ClCompile Include="tmp\moc\moc_win_help.cpp" /> <ClCompile Include="tmp\moc\moc_win_help.cpp" />

View File

@ -57,6 +57,9 @@
<ClInclude Include="src\model_status.h"> <ClInclude Include="src\model_status.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\thread_vapoursynth.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\main.cpp"> <ClCompile Include="src\main.cpp">
@ -143,6 +146,12 @@
<ClCompile Include="src\model_recently.cpp"> <ClCompile Include="src\model_recently.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\thread_vapoursynth.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tmp\moc\moc_thread_vapoursynth.cpp">
<Filter>Generated Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="src\win_main.h"> <CustomBuild Include="src\win_main.h">