From 3f8ed91da3b6ae41b185d70d9e6e89395f317ce1 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 14 May 2012 21:47:47 +0200 Subject: [PATCH] Added an option to save the output file to the same folder where the source is located. Also improved Avisynth detection in case of exception error. --- gui/win_preferences.ui | 42 +++++++++++++++++++++++++++++++++++------ src/version.h | 4 ++-- src/win_addJob.cpp | 5 +++-- src/win_addJob.h | 3 ++- src/win_main.cpp | 18 +++++++++++++----- src/win_main.h | 2 +- src/win_preferences.cpp | 7 +++++++ src/win_preferences.h | 1 + 8 files changed, 65 insertions(+), 17 deletions(-) diff --git a/gui/win_preferences.ui b/gui/win_preferences.ui index f1762b1..498eeac 100644 --- a/gui/win_preferences.ui +++ b/gui/win_preferences.ui @@ -10,7 +10,7 @@ 0 0 379 - 292 + 325 @@ -47,7 +47,7 @@ - + Qt::Horizontal @@ -63,7 +63,7 @@ - + Qt::Horizontal @@ -155,14 +155,14 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. - + - + Shutdown computer as soon as the last job has completed @@ -185,7 +185,7 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. - + Qt::Vertical @@ -288,6 +288,36 @@ Please be aware that this option does NOT have any effect on 32-Bit systems. + + + + Save output to the same folder where the source is located + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + + + diff --git a/src/version.h b/src/version.h index 70309e1..6b994d6 100644 --- a/src/version.h +++ b/src/version.h @@ -21,8 +21,8 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 0 -#define VER_X264_PATCH 4 -#define VER_X264_BUILD 331 +#define VER_X264_PATCH 5 +#define VER_X264_BUILD 340 #define VER_X264_MINIMUM_REV 2189 #define VER_X264_CURRENT_API 124 diff --git a/src/win_addJob.cpp b/src/win_addJob.cpp index 8f9835a..6afbacc 100644 --- a/src/win_addJob.cpp +++ b/src/win_addJob.cpp @@ -185,13 +185,14 @@ public: // Constructor & Destructor /////////////////////////////////////////////////////////////////////////////// -AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding) +AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding, bool saveToSourceFolder) : QDialog(parent), m_defaults(new OptionsModel()), m_options(options), m_x64supported(x64supported), m_use10BitEncoding(use10BitEncoding), + m_saveToSourceFolder(saveToSourceFolder), m_initialDir_src(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))), m_initialDir_out(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))), m_lastFilterIndex(0) @@ -836,7 +837,7 @@ QString AddJobDialog::makeFileFilter(void) void AddJobDialog::generateOutputFileName(const QString &filePath) { QString name = QFileInfo(filePath).completeBaseName(); - QString path = VALID_DIR(m_initialDir_out) ? m_initialDir_out : QFileInfo(filePath).path(); + QString path = m_saveToSourceFolder ? QFileInfo(filePath).canonicalPath() : (VALID_DIR(m_initialDir_out) ? m_initialDir_out : QFileInfo(filePath).path()); QString fext = getFilterExt(m_lastFilterIndex); QString outPath = QString("%1/%2.%3").arg(path, name, fext); diff --git a/src/win_addJob.h b/src/win_addJob.h index 9b2eca7..fdd37d0 100644 --- a/src/win_addJob.h +++ b/src/win_addJob.h @@ -32,7 +32,7 @@ class AddJobDialog : public QDialog, private Ui::AddJobDialog Q_OBJECT public: - AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding); + AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding, bool saveToSourceFolder); ~AddJobDialog(void); QString sourceFile(void); @@ -52,6 +52,7 @@ protected: const bool m_x64supported; const bool m_use10BitEncoding; + const bool m_saveToSourceFolder; QStringList m_types; QString m_initialDir_src; diff --git a/src/win_main.cpp b/src/win_main.cpp index 16065f0..73d946b 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -219,7 +219,7 @@ void MainWindow::addButtonPressed(const QString &filePathIn, const QString &file if(ok) *ok = false; - AddJobDialog *addDialog = new AddJobDialog(this, options ? options : m_options, m_cpuFeatures->x64, m_preferences.use10BitEncoding); + AddJobDialog *addDialog = new AddJobDialog(this, options ? options : m_options, m_cpuFeatures->x64, m_preferences.use10BitEncoding, m_preferences.saveToSourcePath); addDialog->setRunImmediately(countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1)); if(options) addDialog->setWindowTitle(tr("Restart Job")); @@ -777,10 +777,14 @@ void MainWindow::init(void) } if(m_avsLib->load()) { - avisynthVersion = detectAvisynthVersion(m_avsLib); - if(avisynthVersion < 0.0) + DWORD errorCode = 0; + avisynthVersion = detectAvisynthVersion(m_avsLib, &errorCode); + if((avisynthVersion < 0.0) || errorCode) { - int val = QMessageBox::critical(this, tr("Avisynth Error"), tr("A critical error was encountered while checking your Avisynth version!").replace("-", "−"), tr("Quit"), tr("Ignore")); + QString text = tr("A critical error (code: 0x%1) was encountered while checking your Avisynth version.").arg(QString().sprintf("%08X", errorCode)).append("
"); + text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins foler!").append("
"); + text += tr("We suggest to move all .dll and .avsi files out of your Avisynth Plugins folder and try again."); + int val = QMessageBox::critical(this, tr("Avisynth Error"), QString("%1").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore")); if(val != 1) { close(); qApp->exit(-1); return; } } } @@ -1150,9 +1154,10 @@ void MainWindow::updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon /* * Detect Avisynth version */ -double MainWindow::detectAvisynthVersion(QLibrary *avsLib) +double MainWindow::detectAvisynthVersion(QLibrary *avsLib, DWORD *errorCode) { qDebug("detectAvisynthVersion(QLibrary *avsLib)"); + if(errorCode) *errorCode = 0; double version_number = 0.0; EXCEPTION_RECORD exceptionRecord; @@ -1164,6 +1169,8 @@ double MainWindow::detectAvisynthVersion(QLibrary *avsLib) avs_delete_script_environment_func avs_delete_script_environment_ptr = (avs_delete_script_environment_func) avsLib->resolve("avs_delete_script_environment"); avs_release_value_func avs_release_value_ptr = (avs_release_value_func) avsLib->resolve("avs_release_value"); + //volatile int x = 0, y = 0; x = 42 / y; + if((avs_create_script_environment_ptr != NULL) && (avs_invoke_ptr != NULL) && (avs_function_exists_ptr != NULL)) { qDebug("avs_create_script_environment_ptr(AVS_INTERFACE_25)"); @@ -1215,6 +1222,7 @@ double MainWindow::detectAvisynthVersion(QLibrary *avsLib) } __except(exceptionFilter(&exceptionRecord, GetExceptionInformation())) { + if(errorCode) *errorCode = exceptionRecord.ExceptionCode; qWarning("Exception in Avisynth initialization code! (Address: %p, Code: 0x%08x)", exceptionRecord.ExceptionAddress, exceptionRecord.ExceptionCode); version_number = -1.0; } diff --git a/src/win_main.h b/src/win_main.h index 115ecc4..7697f6e 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -69,7 +69,7 @@ private: void updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon); unsigned int countPendingJobs(void); unsigned int countRunningJobs(void); - double detectAvisynthVersion(QLibrary *avsLib); + double detectAvisynthVersion(QLibrary *avsLib, DWORD *errorCode = NULL); private slots: void addButtonPressed(const QString &filePathIn = QString(), const QString &filePathOut = QString(), OptionsModel *options = NULL, int fileNo = -1, int fileTotal = 0, bool *ok = NULL); diff --git a/src/win_preferences.cpp b/src/win_preferences.cpp index 37499ea..8bbf28f 100644 --- a/src/win_preferences.cpp +++ b/src/win_preferences.cpp @@ -48,6 +48,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Preferences *preferences, labelUse64BitAvs2YUV->installEventFilter(this); labelShutdownComputer->installEventFilter(this); labelSaveLogFiles->installEventFilter(this); + labelSaveToSourceFolder->installEventFilter(this); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed())); connect(checkUse10BitEncoding, SIGNAL(toggled(bool)), this, SLOT(use10BitEncodingToggled(bool))); @@ -67,6 +68,7 @@ void PreferencesDialog::showEvent(QShowEvent *event) UPDATE_CHECKBOX(checkShutdownComputer, m_preferences->shutdownComputer); UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit); UPDATE_CHECKBOX(checkSaveLogFiles, m_preferences->saveLogFiles); + UPDATE_CHECKBOX(checkSaveToSourceFolder, m_preferences->saveToSourcePath); checkUse10BitEncoding->blockSignals(true); UPDATE_CHECKBOX(checkUse10BitEncoding, m_preferences->use10BitEncoding); @@ -85,6 +87,7 @@ bool PreferencesDialog::eventFilter(QObject *o, QEvent *e) emulateMouseEvent(o, e, labelUse10BitEncoding, checkUse10BitEncoding); emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV); emulateMouseEvent(o, e, labelSaveLogFiles, checkSaveLogFiles); + emulateMouseEvent(o, e, labelSaveToSourceFolder, checkSaveToSourceFolder); return false; } @@ -115,6 +118,7 @@ void PreferencesDialog::done(int n) m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked(); m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked(); m_preferences->saveLogFiles = checkSaveLogFiles->isChecked(); + m_preferences->saveToSourcePath = checkSaveToSourceFolder->isChecked(); m_preferences->maxRunningJobCount = spinBoxJobCount->value(); savePreferences(m_preferences); @@ -157,6 +161,7 @@ void PreferencesDialog::initPreferences(Preferences *preferences) preferences->use10BitEncoding = false; preferences->useAvisyth64Bit = false; preferences->saveLogFiles = false; + preferences->saveToSourcePath = false; } void PreferencesDialog::loadPreferences(Preferences *preferences) @@ -174,6 +179,7 @@ void PreferencesDialog::loadPreferences(Preferences *preferences) preferences->use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.use10BitEncoding)).toBool(); preferences->useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.useAvisyth64Bit)).toBool(); preferences->saveLogFiles = settings.value("save_log_files", QVariant(defaults.saveLogFiles)).toBool(); + preferences->saveToSourcePath = settings.value("save_to_source_path", QVariant(defaults.saveToSourcePath)).toBool(); } void PreferencesDialog::savePreferences(Preferences *preferences) @@ -188,6 +194,7 @@ void PreferencesDialog::savePreferences(Preferences *preferences) settings.setValue("use_10bit_encoding", preferences->use10BitEncoding); settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit); settings.setValue("save_log_files", preferences->saveLogFiles); + settings.setValue("save_to_source_path", preferences->saveToSourcePath); settings.sync(); } diff --git a/src/win_preferences.h b/src/win_preferences.h index 1d35ec6..6a6c81c 100644 --- a/src/win_preferences.h +++ b/src/win_preferences.h @@ -36,6 +36,7 @@ public: bool use10BitEncoding; bool useAvisyth64Bit; bool saveLogFiles; + bool saveToSourcePath; } Preferences;