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.

This commit is contained in:
LoRd_MuldeR 2012-05-14 21:47:47 +02:00
parent 1fcc296bda
commit 3f8ed91da3
8 changed files with 65 additions and 17 deletions

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>379</width> <width>379</width>
<height>292</height> <height>325</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -47,7 +47,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" rowspan="10"> <item row="1" column="0" rowspan="12">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -63,7 +63,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="6" rowspan="10"> <item row="1" column="6" rowspan="12">
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -155,14 +155,14 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="10" column="1"> <item row="12" column="1">
<widget class="QCheckBox" name="checkShutdownComputer"> <widget class="QCheckBox" name="checkShutdownComputer">
<property name="text"> <property name="text">
<string notr="true"/> <string notr="true"/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="2" colspan="4"> <item row="12" column="2" colspan="4">
<widget class="QLabel" name="labelShutdownComputer"> <widget class="QLabel" name="labelShutdownComputer">
<property name="text"> <property name="text">
<string>Shutdown computer as soon as the last job has completed</string> <string>Shutdown computer as soon as the last job has completed</string>
@ -185,7 +185,7 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="11" column="1" colspan="5"> <item row="13" column="1" colspan="5">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -288,6 +288,36 @@ Please be aware that this option does NOT have any effect on 32-Bit systems.</st
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="10" column="2" colspan="4">
<widget class="QLabel" name="labelSaveToSourceFolder">
<property name="text">
<string>Save output to the same folder where the source is located</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="5">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="checkSaveToSourceFolder">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -21,8 +21,8 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 0 #define VER_X264_MINOR 0
#define VER_X264_PATCH 4 #define VER_X264_PATCH 5
#define VER_X264_BUILD 331 #define VER_X264_BUILD 340
#define VER_X264_MINIMUM_REV 2189 #define VER_X264_MINIMUM_REV 2189
#define VER_X264_CURRENT_API 124 #define VER_X264_CURRENT_API 124

View File

@ -185,13 +185,14 @@ public:
// Constructor & Destructor // 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), QDialog(parent),
m_defaults(new OptionsModel()), m_defaults(new OptionsModel()),
m_options(options), m_options(options),
m_x64supported(x64supported), m_x64supported(x64supported),
m_use10BitEncoding(use10BitEncoding), m_use10BitEncoding(use10BitEncoding),
m_saveToSourceFolder(saveToSourceFolder),
m_initialDir_src(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))), m_initialDir_src(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))),
m_initialDir_out(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))), m_initialDir_out(QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation))),
m_lastFilterIndex(0) m_lastFilterIndex(0)
@ -836,7 +837,7 @@ QString AddJobDialog::makeFileFilter(void)
void AddJobDialog::generateOutputFileName(const QString &filePath) void AddJobDialog::generateOutputFileName(const QString &filePath)
{ {
QString name = QFileInfo(filePath).completeBaseName(); 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 fext = getFilterExt(m_lastFilterIndex);
QString outPath = QString("%1/%2.%3").arg(path, name, fext); QString outPath = QString("%1/%2.%3").arg(path, name, fext);

View File

@ -32,7 +32,7 @@ class AddJobDialog : public QDialog, private Ui::AddJobDialog
Q_OBJECT Q_OBJECT
public: public:
AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding); AddJobDialog(QWidget *parent, OptionsModel *options, bool x64supported, bool use10BitEncoding, bool saveToSourceFolder);
~AddJobDialog(void); ~AddJobDialog(void);
QString sourceFile(void); QString sourceFile(void);
@ -52,6 +52,7 @@ protected:
const bool m_x64supported; const bool m_x64supported;
const bool m_use10BitEncoding; const bool m_use10BitEncoding;
const bool m_saveToSourceFolder;
QStringList m_types; QStringList m_types;
QString m_initialDir_src; QString m_initialDir_src;

View File

@ -219,7 +219,7 @@ void MainWindow::addButtonPressed(const QString &filePathIn, const QString &file
if(ok) *ok = false; 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)); addDialog->setRunImmediately(countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
if(options) addDialog->setWindowTitle(tr("Restart Job")); if(options) addDialog->setWindowTitle(tr("Restart Job"));
@ -777,10 +777,14 @@ void MainWindow::init(void)
} }
if(m_avsLib->load()) if(m_avsLib->load())
{ {
avisynthVersion = detectAvisynthVersion(m_avsLib); DWORD errorCode = 0;
if(avisynthVersion < 0.0) avisynthVersion = detectAvisynthVersion(m_avsLib, &errorCode);
if((avisynthVersion < 0.0) || errorCode)
{ {
int val = QMessageBox::critical(this, tr("Avisynth Error"), tr("<nobr>A critical error was encountered while checking your Avisynth version!</nobr>").replace("-", "&minus;"), 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("<br>");
text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins foler!").append("<br>");
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("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
if(val != 1) { close(); qApp->exit(-1); return; } if(val != 1) { close(); qApp->exit(-1); return; }
} }
} }
@ -1150,9 +1154,10 @@ void MainWindow::updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon
/* /*
* Detect Avisynth version * Detect Avisynth version
*/ */
double MainWindow::detectAvisynthVersion(QLibrary *avsLib) double MainWindow::detectAvisynthVersion(QLibrary *avsLib, DWORD *errorCode)
{ {
qDebug("detectAvisynthVersion(QLibrary *avsLib)"); qDebug("detectAvisynthVersion(QLibrary *avsLib)");
if(errorCode) *errorCode = 0;
double version_number = 0.0; double version_number = 0.0;
EXCEPTION_RECORD exceptionRecord; 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_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"); 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)) 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)"); qDebug("avs_create_script_environment_ptr(AVS_INTERFACE_25)");
@ -1215,6 +1222,7 @@ double MainWindow::detectAvisynthVersion(QLibrary *avsLib)
} }
__except(exceptionFilter(&exceptionRecord, GetExceptionInformation())) __except(exceptionFilter(&exceptionRecord, GetExceptionInformation()))
{ {
if(errorCode) *errorCode = exceptionRecord.ExceptionCode;
qWarning("Exception in Avisynth initialization code! (Address: %p, Code: 0x%08x)", exceptionRecord.ExceptionAddress, exceptionRecord.ExceptionCode); qWarning("Exception in Avisynth initialization code! (Address: %p, Code: 0x%08x)", exceptionRecord.ExceptionAddress, exceptionRecord.ExceptionCode);
version_number = -1.0; version_number = -1.0;
} }

View File

@ -69,7 +69,7 @@ private:
void updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon); void updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon);
unsigned int countPendingJobs(void); unsigned int countPendingJobs(void);
unsigned int countRunningJobs(void); unsigned int countRunningJobs(void);
double detectAvisynthVersion(QLibrary *avsLib); double detectAvisynthVersion(QLibrary *avsLib, DWORD *errorCode = NULL);
private slots: private slots:
void addButtonPressed(const QString &filePathIn = QString(), const QString &filePathOut = QString(), OptionsModel *options = NULL, int fileNo = -1, int fileTotal = 0, bool *ok = NULL); void addButtonPressed(const QString &filePathIn = QString(), const QString &filePathOut = QString(), OptionsModel *options = NULL, int fileNo = -1, int fileTotal = 0, bool *ok = NULL);

View File

@ -48,6 +48,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Preferences *preferences,
labelUse64BitAvs2YUV->installEventFilter(this); labelUse64BitAvs2YUV->installEventFilter(this);
labelShutdownComputer->installEventFilter(this); labelShutdownComputer->installEventFilter(this);
labelSaveLogFiles->installEventFilter(this); labelSaveLogFiles->installEventFilter(this);
labelSaveToSourceFolder->installEventFilter(this);
connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed())); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed()));
connect(checkUse10BitEncoding, SIGNAL(toggled(bool)), this, SLOT(use10BitEncodingToggled(bool))); 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(checkShutdownComputer, m_preferences->shutdownComputer);
UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit); UPDATE_CHECKBOX(checkUse64BitAvs2YUV, m_preferences->useAvisyth64Bit);
UPDATE_CHECKBOX(checkSaveLogFiles, m_preferences->saveLogFiles); UPDATE_CHECKBOX(checkSaveLogFiles, m_preferences->saveLogFiles);
UPDATE_CHECKBOX(checkSaveToSourceFolder, m_preferences->saveToSourcePath);
checkUse10BitEncoding->blockSignals(true); checkUse10BitEncoding->blockSignals(true);
UPDATE_CHECKBOX(checkUse10BitEncoding, m_preferences->use10BitEncoding); 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, labelUse10BitEncoding, checkUse10BitEncoding);
emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV); emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV);
emulateMouseEvent(o, e, labelSaveLogFiles, checkSaveLogFiles); emulateMouseEvent(o, e, labelSaveLogFiles, checkSaveLogFiles);
emulateMouseEvent(o, e, labelSaveToSourceFolder, checkSaveToSourceFolder);
return false; return false;
} }
@ -115,6 +118,7 @@ void PreferencesDialog::done(int n)
m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked(); m_preferences->use10BitEncoding = checkUse10BitEncoding->isChecked();
m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked(); m_preferences->useAvisyth64Bit = checkUse64BitAvs2YUV->isChecked();
m_preferences->saveLogFiles = checkSaveLogFiles->isChecked(); m_preferences->saveLogFiles = checkSaveLogFiles->isChecked();
m_preferences->saveToSourcePath = checkSaveToSourceFolder->isChecked();
m_preferences->maxRunningJobCount = spinBoxJobCount->value(); m_preferences->maxRunningJobCount = spinBoxJobCount->value();
savePreferences(m_preferences); savePreferences(m_preferences);
@ -157,6 +161,7 @@ void PreferencesDialog::initPreferences(Preferences *preferences)
preferences->use10BitEncoding = false; preferences->use10BitEncoding = false;
preferences->useAvisyth64Bit = false; preferences->useAvisyth64Bit = false;
preferences->saveLogFiles = false; preferences->saveLogFiles = false;
preferences->saveToSourcePath = false;
} }
void PreferencesDialog::loadPreferences(Preferences *preferences) 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->use10BitEncoding = settings.value("use_10bit_encoding", QVariant(defaults.use10BitEncoding)).toBool();
preferences->useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.useAvisyth64Bit)).toBool(); preferences->useAvisyth64Bit = settings.value("use_64bit_avisynth", QVariant(defaults.useAvisyth64Bit)).toBool();
preferences->saveLogFiles = settings.value("save_log_files", QVariant(defaults.saveLogFiles)).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) void PreferencesDialog::savePreferences(Preferences *preferences)
@ -188,6 +194,7 @@ void PreferencesDialog::savePreferences(Preferences *preferences)
settings.setValue("use_10bit_encoding", preferences->use10BitEncoding); settings.setValue("use_10bit_encoding", preferences->use10BitEncoding);
settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit); settings.setValue("use_64bit_avisynth", preferences->useAvisyth64Bit);
settings.setValue("save_log_files", preferences->saveLogFiles); settings.setValue("save_log_files", preferences->saveLogFiles);
settings.setValue("save_to_source_path", preferences->saveToSourcePath);
settings.sync(); settings.sync();
} }

View File

@ -36,6 +36,7 @@ public:
bool use10BitEncoding; bool use10BitEncoding;
bool useAvisyth64Bit; bool useAvisyth64Bit;
bool saveLogFiles; bool saveLogFiles;
bool saveToSourcePath;
} }
Preferences; Preferences;