Improved x264/x265 version check + check supported RC modes.

This commit is contained in:
LoRd_MuldeR 2014-04-15 22:12:02 +02:00
parent d10dfaec1e
commit ca2d532f8b
5 changed files with 64 additions and 12 deletions

View File

@ -32,6 +32,7 @@ class AbstractEncoderInfo
public: public:
virtual QStringList supportedInputFormats (void) const = 0; virtual QStringList supportedInputFormats (void) const = 0;
virtual QStringList supportedOutputFormats(void) const = 0; virtual QStringList supportedOutputFormats(void) const = 0;
virtual bool isRCModeSupported(const int rcMode) const = 0;
}; };
class AbstractEncoder : public AbstractTool class AbstractEncoder : public AbstractTool

View File

@ -30,8 +30,8 @@
#include <QRegExp> #include <QRegExp>
//x264 version info //x264 version info
static const unsigned int X264_VERSION_X264_MINIMUM_REV = 2397; static const unsigned int VERSION_X264_MINIMUM_REV = 2397;
static const unsigned int X264_VERSION_X264_CURRENT_API = 142; static const unsigned int VERSION_X264_CURRENT_API = 142;
// ------------------------------------------------------------ // ------------------------------------------------------------
// Helper Macros // Helper Macros
@ -109,6 +109,20 @@ public:
extLst << "mp4"; extLst << "mp4";
return extLst; return extLst;
} }
virtual bool isRCModeSupported(const int rcMode) const
{
switch(rcMode)
{
case OptionsModel::RCMode_CRF:
case OptionsModel::RCMode_CQ:
case OptionsModel::RCMode_2Pass:
case OptionsModel::RCMode_ABR:
return true;
default:
return false;
}
}
}; };
static const X264EncoderInfo s_x264EncoderInfo; static const X264EncoderInfo s_x264EncoderInfo;
@ -196,16 +210,19 @@ QString X264Encoder::printVersion(const unsigned int &revision, const bool &modi
bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &modified) bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
{ {
if((revision % REV_MULT) < X264_VERSION_X264_MINIMUM_REV) const unsigned int ver = (revision / REV_MULT);
const unsigned int rev = (revision % REV_MULT);
if((rev % REV_MULT) < VERSION_X264_MINIMUM_REV)
{ {
log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %1)").arg(QString::number(X264_VERSION_X264_MINIMUM_REV))); log(tr("\nERROR: Your revision of x264 is too old! Minimum required revision is %1.").arg(QString::number(VERSION_X264_MINIMUM_REV)));
return false; return false;
} }
if((revision / REV_MULT) != X264_VERSION_X264_CURRENT_API) if(ver != VERSION_X264_CURRENT_API)
{ {
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!")); log(tr("\nWARNING: Your x264 binary uses an untested core (API) version, take care!"));
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(X264_VERSION_X264_CURRENT_API))); log(tr("This application works best with x264 core (API) version %1. Newer versions may work or not.").arg(QString::number(VERSION_X264_CURRENT_API)));
} }
return true; return true;

View File

@ -31,8 +31,8 @@
#include <QRegExp> #include <QRegExp>
//x265 version info //x265 version info
static const unsigned int X265_VERSION_X264_MINIMUM_VER = 9; static const unsigned int VERSION_X265_MINIMUM_VER = 9;
static const unsigned int X265_VERSION_X264_MINIMUM_REV = 29; static const unsigned int VERSION_X265_MINIMUM_REV = 29;
// ------------------------------------------------------------ // ------------------------------------------------------------
// Helper Macros // Helper Macros
@ -97,6 +97,20 @@ public:
extLst << "hevc"; extLst << "hevc";
return extLst; return extLst;
} }
virtual bool isRCModeSupported(const int rcMode) const
{
switch(rcMode)
{
case OptionsModel::RCMode_CRF:
case OptionsModel::RCMode_CQ:
case OptionsModel::RCMode_ABR:
return true;
default:
return false;
}
}
}; };
static const X265EncoderInfo s_x265EncoderInfo; static const X265EncoderInfo s_x265EncoderInfo;
@ -171,11 +185,16 @@ bool X265Encoder::isVersionSupported(const unsigned int &revision, const bool &m
const unsigned int ver = (revision / REV_MULT); const unsigned int ver = (revision / REV_MULT);
const unsigned int rev = (revision % REV_MULT); const unsigned int rev = (revision % REV_MULT);
if((ver < X265_VERSION_X264_MINIMUM_VER) || (rev < X265_VERSION_X264_MINIMUM_REV)) if((ver < VERSION_X265_MINIMUM_VER) || ((ver == VERSION_X265_MINIMUM_VER) && (rev < VERSION_X265_MINIMUM_REV)))
{ {
log(tr("\nERROR: Your version of x265 is too old! (Minimum required revision is 0.%1+%2)").arg(QString::number(X265_VERSION_X264_MINIMUM_VER), QString::number(X265_VERSION_X264_MINIMUM_REV))); log(tr("\nERROR: Your version of x265 is too old! (Minimum required revision is 0.%1+%2)").arg(QString::number(VERSION_X265_MINIMUM_VER), QString::number(VERSION_X265_MINIMUM_REV)));
return false; return false;
} }
else if(ver > VERSION_X265_MINIMUM_VER)
{
log(tr("\nWARNING: Your version of x265 is newer than the latest tested version, take care!"));
log(tr("This application works best with x265 version %1. Newer versions may work or not.").arg(QString::number(VERSION_X265_MINIMUM_VER)));
}
return true; return true;
} }

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 3 #define VER_X264_MINOR 3
#define VER_X264_PATCH 5 #define VER_X264_PATCH 5
#define VER_X264_BUILD 813 #define VER_X264_BUILD 815
#define VER_X264_PORTABLE_EDITION (0) #define VER_X264_PORTABLE_EDITION (0)

View File

@ -501,6 +501,21 @@ void AddJobDialog::accept(void)
//Get encoder info //Get encoder info
const AbstractEncoderInfo &encoderInfo = getEncoderInfo(ui->cbxEncoderType->currentIndex()); const AbstractEncoderInfo &encoderInfo = getEncoderInfo(ui->cbxEncoderType->currentIndex());
//Is selected RC mode supported?
if(!encoderInfo.isRCModeSupported(ui->cbxRateControlMode->currentIndex()))
{
QMessageBox::warning(this, tr("Bad RC Mode!"), tr("<nobr>The selected RC mode is not supported by the selected encoder!</nobr>"));
for(int i = 0; i < ui->cbxRateControlMode->count(); i++)
{
if(encoderInfo.isRCModeSupported(i))
{
ui->cbxRateControlMode->setCurrentIndex(i);
break;
}
}
return;
}
//Is the type of the source file supported? (as far as we can tell) //Is the type of the source file supported? (as far as we can tell)
if(sourceFile.suffix().compare("AVS", Qt::CaseInsensitive) == 0) if(sourceFile.suffix().compare("AVS", Qt::CaseInsensitive) == 0)
{ {