Check the Avs2YUV version + improve custom parameters editor.

This commit is contained in:
LoRd_MuldeR 2012-01-31 20:28:40 +01:00
parent a78ae8f7cd
commit 932610e822
9 changed files with 266 additions and 37 deletions

View File

@ -695,6 +695,69 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelNotification">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Invalid parameter entered!</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_6"> <spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
@ -763,7 +826,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="editCustomParams"/> <widget class="QLineEdit" name="editCustomParams">
<property name="placeholderText">
<string>You can enter custom command-line options here...</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -211,6 +211,9 @@
</disabled> </disabled>
</palette> </palette>
</property> </property>
<property name="cursor">
<cursorShape>WhatsThisCursor</cursorShape>
</property>
<property name="text"> <property name="text">
<string>(Version)</string> <string>(Version)</string>
</property> </property>

View File

@ -150,8 +150,47 @@ void EncodeThread::encode(void)
bool ok = false; bool ok = false;
unsigned int frames = 0; unsigned int frames = 0;
//Use Avisynth?
const bool usePipe = (QFileInfo(m_sourceFileName).suffix().compare("avs", Qt::CaseInsensitive) == 0);
//Checking x264 version
log(tr("\n--- CHECK VERSION ---\n"));
unsigned int revision_x264 = UINT_MAX;
ok = ((revision_x264 = checkVersionX264(m_x64)) != UINT_MAX);
CHECK_STATUS(m_abort, ok);
//Checking avs2yuv version
unsigned int revision_avs2yuv = UINT_MAX;
if(usePipe)
{
ok = ((revision_avs2yuv = checkVersionAvs2yuv()) != UINT_MAX);
CHECK_STATUS(m_abort, ok);
}
//Print versions
log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(revision_x264 % REV_MULT), QString::number(revision_x264 / REV_MULT)));
if(revision_avs2yuv != UINT_MAX) log(tr("Avs2YUV version: %1.%2.%3").arg(QString::number(revision_avs2yuv / REV_MULT), QString::number((revision_avs2yuv % REV_MULT) / 10),QString::number((revision_avs2yuv % REV_MULT) % 10)));
//Is x264 revision supported?
if((revision_x264 % REV_MULT) < VER_X264_MINIMUM_REV)
{
log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %2)").arg(QString::number(VER_X264_MINIMUM_REV)));
setStatus(JobStatus_Failed);
return;
}
if((revision_x264 / REV_MULT) != VER_X264_CURRENT_API)
{
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(VER_X264_CURRENT_API)));
}
if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != 242))
{
log(tr("\nERROR: Your version of avs2yuv is unsupported (Required version is v0.24bm2)"));
setStatus(JobStatus_Failed);
return;
}
//Detect source info //Detect source info
bool usePipe = (QFileInfo(m_sourceFileName).suffix().compare("avs", Qt::CaseInsensitive) == 0);
if(usePipe) if(usePipe)
{ {
log(tr("\n--- AVS INFO ---\n")); log(tr("\n--- AVS INFO ---\n"));
@ -159,26 +198,6 @@ void EncodeThread::encode(void)
CHECK_STATUS(m_abort, ok); CHECK_STATUS(m_abort, ok);
} }
//Checking version
log(tr("\n--- X264 VERSION ---\n"));
unsigned int revision;
ok = ((revision = checkVersion(m_x64)) != UINT_MAX);
CHECK_STATUS(m_abort, ok);
//Is revision supported?
log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT)));
if((revision % REV_MULT) < VER_X264_MINIMUM_REV)
{
log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %2)").arg(QString::number(VER_X264_MINIMUM_REV)));
setStatus(JobStatus_Failed);
return;
}
if((revision / REV_MULT) != VER_X264_CURRENT_API)
{
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(VER_X264_CURRENT_API)));
}
//Run encoding passes //Run encoding passes
if(m_options->rcMode() == OptionsModel::RCMode_2Pass) if(m_options->rcMode() == OptionsModel::RCMode_2Pass)
{ {
@ -423,7 +442,7 @@ QStringList EncodeThread::buildCommandLine(bool usePipe, unsigned int frames, in
return cmdLine; return cmdLine;
} }
unsigned int EncodeThread::checkVersion(bool x64) unsigned int EncodeThread::checkVersionX264(bool x64)
{ {
QProcess process; QProcess process;
QStringList cmdLine = QStringList() << "--version"; QStringList cmdLine = QStringList() << "--version";
@ -506,7 +525,98 @@ unsigned int EncodeThread::checkVersion(bool x64)
return UINT_MAX; return UINT_MAX;
} }
return (coreVers * REV_MULT) + revision; return (coreVers * REV_MULT) + (revision % REV_MULT);
}
unsigned int EncodeThread::checkVersionAvs2yuv(void)
{
QProcess process;
log("\nCreating process:");
if(!startProcess(process, QString("%1/avs2yuv.exe").arg(m_binDir), QStringList()))
{
return false;;
}
QRegExp regExpVersion("Avs2YUV (\\d+).(\\d+)bm(\\d)");
bool bTimeout = false;
bool bAborted = false;
unsigned int ver_maj = UINT_MAX;
unsigned int ver_min = UINT_MAX;
unsigned int ver_bld = UINT_MAX;
while(process.state() != QProcess::NotRunning)
{
if(m_abort)
{
process.kill();
bAborted = true;
break;
}
if(!process.waitForReadyRead(m_processTimeoutInterval))
{
if(process.state() == QProcess::Running)
{
process.kill();
qWarning("Avs2YUV process timed out <-- killing!");
log("\nPROCESS TIMEOUT !!!");
bTimeout = true;
break;
}
}
while(process.bytesAvailable() > 0)
{
QList<QByteArray> lines = process.readLine().split('\r');
while(!lines.isEmpty())
{
QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified();
int offset = -1;
if((ver_maj == UINT_MAX) || (ver_min == UINT_MAX) || (ver_bld == UINT_MAX))
{
if(!text.isEmpty())
{
log(text);
}
}
if((offset = regExpVersion.lastIndexIn(text)) >= 0)
{
bool ok1 = false, ok2 = false, ok3 = false;
unsigned int temp1 = regExpVersion.cap(1).toUInt(&ok1);
unsigned int temp2 = regExpVersion.cap(2).toUInt(&ok2);
unsigned int temp3 = regExpVersion.cap(3).toUInt(&ok3);
if(ok1) ver_maj = temp1;
if(ok2) ver_min = temp2;
if(ok3) ver_bld = temp3;
}
}
}
}
process.waitForFinished();
if(process.state() != QProcess::NotRunning)
{
process.kill();
process.waitForFinished(-1);
}
if(bTimeout || bAborted || ((process.exitCode() != EXIT_SUCCESS) && (process.exitCode() != 2)))
{
if(!(bTimeout || bAborted))
{
log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode())));
}
return UINT_MAX;
}
if((ver_maj == UINT_MAX) || (ver_min == UINT_MAX) || (ver_bld == UINT_MAX))
{
log(tr("\nFAILED TO DETERMINE AVS2YUV VERSION !!!"));
return UINT_MAX;
}
return (ver_maj * REV_MULT) + ((ver_min % REV_MULT) * 10) + (ver_bld % 10);
} }
bool EncodeThread::checkProperties(unsigned int &frames) bool EncodeThread::checkProperties(unsigned int &frames)

View File

@ -86,7 +86,8 @@ protected:
void encode(void); void encode(void);
bool runEncodingPass(bool x64, bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString()); bool runEncodingPass(bool x64, bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString());
QStringList buildCommandLine(bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString()); QStringList buildCommandLine(bool usePipe, unsigned int frames, int pass = 0, const QString &passLogFile = QString());
unsigned int checkVersion(bool x64); unsigned int checkVersionX264(bool x64);
unsigned int checkVersionAvs2yuv(void);
bool checkProperties(unsigned int &frames); bool checkProperties(unsigned int &frames);
//Auxiallary Stuff //Auxiallary Stuff

View File

@ -54,21 +54,42 @@ g_filters[] =
class StringValidator : public QValidator class StringValidator : public QValidator
{ {
public:
StringValidator(QLabel *notifier) : m_notifier(notifier) { m_notifier->hide(); }
virtual State validate(QString &input, int &pos) const virtual State validate(QString &input, int &pos) const
{ {
bool invalid = input.simplified().compare(input) && input.simplified().append(" ").compare(input) && bool invalid = false;
input.simplified().prepend(" ").compare(input) && input.simplified().append(" ").prepend(" ").compare(input);
invalid = invalid || (input.contains(" -B") || input.startsWith("-B"));
invalid = invalid || (input.contains(" -o") || input.startsWith("-o"));
invalid = invalid || (input.contains(" -h") || input.startsWith("-h"));
invalid = invalid || (input.contains(" -p") || input.startsWith("-p"));
if(!invalid) invalid = invalid || input.contains("--fps", Qt::CaseInsensitive);
invalid = invalid || input.contains("--frames", Qt::CaseInsensitive);
invalid = invalid || input.contains("--preset", Qt::CaseInsensitive);
invalid = invalid || input.contains("--tune", Qt::CaseInsensitive);
invalid = invalid || input.contains("--profile", Qt::CaseInsensitive);
invalid = invalid || input.contains("--stdin", Qt::CaseInsensitive);
invalid = invalid || input.contains("--crf", Qt::CaseInsensitive);
invalid = invalid || input.contains("--bitrate", Qt::CaseInsensitive);
invalid = invalid || input.contains("--qp", Qt::CaseInsensitive);
invalid = invalid || input.contains("--pass", Qt::CaseInsensitive);
invalid = invalid || input.contains("--stats", Qt::CaseInsensitive);
invalid = invalid || input.contains("--output", Qt::CaseInsensitive);
invalid = invalid || input.contains("--help", Qt::CaseInsensitive);
if(invalid)
{ {
invalid = invalid || input.contains("--fps"); MessageBeep(MB_ICONWARNING);
invalid = invalid || input.contains("--frames"); if(m_notifier->isHidden())
invalid = invalid || input.contains("--preset"); {
invalid = invalid || input.contains("--tune"); m_notifier->show();
invalid = invalid || input.contains("--profile"); QTimer::singleShot(1000, m_notifier, SLOT(hide()));
}
} }
if(invalid) MessageBeep(MB_ICONWARNING);
return invalid ? QValidator::Invalid : QValidator::Acceptable; return invalid ? QValidator::Invalid : QValidator::Acceptable;
} }
@ -76,6 +97,9 @@ class StringValidator : public QValidator
{ {
input = input.simplified(); input = input.simplified();
} }
protected:
QLabel *const m_notifier;
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -107,7 +131,8 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options)
connect(buttonBrowseOutput, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); connect(buttonBrowseOutput, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
//Setup validator //Setup validator
editCustomParams->setValidator(new StringValidator()); editCustomParams->installEventFilter(this);
editCustomParams->setValidator(new StringValidator(labelNotification));
editCustomParams->clear(); editCustomParams->clear();
//Install event filter //Install event filter
@ -153,7 +178,10 @@ bool AddJobDialog::eventFilter(QObject *o, QEvent *e)
if((o == labelHelpScreen) && (e->type() == QEvent::MouseButtonPress)) if((o == labelHelpScreen) && (e->type() == QEvent::MouseButtonPress))
{ {
QMessageBox::information(this, tr("Not yet"), tr("Not implemented yet. Please use the '?' menu for now!")); QMessageBox::information(this, tr("Not yet"), tr("Not implemented yet. Please use the '?' menu for now!"));
return true; }
else if((o == editCustomParams) && (e->type() == QEvent::FocusOut))
{
editCustomParams->setText(editCustomParams->text().simplified());
} }
return false; return false;
} }

View File

@ -66,9 +66,11 @@ MainWindow::MainWindow(bool x64supported)
//Update title //Update title
labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time()))); labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
labelBuildDate->installEventFilter(this);
setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_x64supported ? "64-Bit" : "32-Bit")); setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_x64supported ? "64-Bit" : "32-Bit"));
if(PRE_RELEASE) setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle())); if(PRE_RELEASE) setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle()));
//Create model //Create model
m_jobList = new JobListModel(); m_jobList = new JobListModel();
connect(m_jobList, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(jobChangedData(QModelIndex, QModelIndex))); connect(m_jobList, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(jobChangedData(QModelIndex, QModelIndex)));
@ -398,6 +400,16 @@ void MainWindow::resizeEvent(QResizeEvent *e)
updateLabel(); updateLabel();
} }
bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
if((o == labelBuildDate) && (e->type() == QEvent::MouseButtonPress))
{
QTimer::singleShot(0, this, SLOT(showAbout()));
return true;
}
return false;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Private functions // Private functions
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -40,6 +40,7 @@ protected:
virtual void closeEvent(QCloseEvent *e); virtual void closeEvent(QCloseEvent *e);
virtual void showEvent(QShowEvent *e); virtual void showEvent(QShowEvent *e);
virtual void resizeEvent(QResizeEvent *e); virtual void resizeEvent(QResizeEvent *e);
virtual bool eventFilter(QObject *o, QEvent *e);
private: private:
bool m_firstShow; bool m_firstShow;

View File

@ -107,6 +107,13 @@
<Message> <Message>
</Message> </Message>
</PreLinkEvent> </PreLinkEvent>
<PostBuildEvent>
<Command>rmdir /S /Q "$(SolutionDir)bin\$(Configuration)\toolset"
mkdir "$(SolutionDir)bin\$(Configuration)\toolset"
copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\toolset"
</Command>
<Message>Copy Toolset</Message>
</PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="gui\win_main.ui"> <CustomBuild Include="gui\win_main.ui">

View File

@ -55,7 +55,7 @@ echo !insertmacro SECTION_END >> "%NSIS_FILE%"
"%NSIS_PATH%\makensis.exe" "%NSIS_FILE%" "%NSIS_PATH%\makensis.exe" "%NSIS_FILE%"
if not "%ERRORLEVEL%"=="0" goto BuildError if not "%ERRORLEVEL%"=="0" goto BuildError
del "%NSIS_FILE%" del "%NSIS_FILE%"
del /Q /S "%PACK_PATH%\*.*" rmdir /Q /S "%PACK_PATH%"
REM /////////////////////////////////////////////////////////////////////////// REM ///////////////////////////////////////////////////////////////////////////
echo. echo.
echo Build completed. echo Build completed.