Some re-design of AbstractEncoderInfo to allow more flexible encoder variants and RC modes.

This commit is contained in:
LoRd_MuldeR 2016-05-08 15:33:09 +02:00
parent b5637c3f0b
commit 36ecf72d93
10 changed files with 292 additions and 310 deletions

View File

@ -293,12 +293,47 @@ QString AbstractEncoder::sizeToString(qint64 size)
// Encoder Info // Encoder Info
// ------------------------------------------------------------ // ------------------------------------------------------------
template <class T>
static T getElementAt(const QList<T> &list, const quint32 &index)
{
if (index >= quint32(list.count()))
{
MUTILS_THROW("Index is out of bounds!");
}
return list[index];
}
const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void) const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void)
{ {
MUTILS_THROW("[getEncoderInfo] This function must be overwritten in sub-classes!"); MUTILS_THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");
} }
QStringList AbstractEncoderInfo::getDependencies(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const QStringList AbstractEncoderInfo::getDependencies(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
{ {
return QStringList(); return QStringList();
} }
QString AbstractEncoderInfo::getFullName(const quint32 &encArch, const quint32 &encVariant) const
{
return QString("%1, %2, %3").arg(getName(), archToString(encArch), variantToString(encVariant));
}
QString AbstractEncoderInfo::archToString(const quint32 &index) const
{
return getElementAt(getArchitectures(), index);
}
QString AbstractEncoderInfo::variantToString(const quint32 &index) const
{
return getElementAt(getVariants(), index);
}
QString AbstractEncoderInfo::rcModeToString(const quint32 &index) const
{
return getElementAt(getRCModes(), index).first;
}
AbstractEncoderInfo::RCType AbstractEncoderInfo::rcModeToType(const quint32 &index) const
{
return getElementAt(getRCModes(), index).second;
}

View File

@ -17,7 +17,7 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// http://www.gnu.org/licenses/gpl-2.0.txt // http://www.gnu.org/licenses/gpl-2.0.txt
/////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
@ -26,20 +26,40 @@
class QRegExp; class QRegExp;
template<class T> class QList; template<class T> class QList;
template <class T1, class T2> struct QPair;
class AbstractSource; class AbstractSource;
class AbstractEncoderInfo class AbstractEncoderInfo
{ {
public: public:
virtual QFlags<OptionsModel::EncVariant> getVariants(void) const = 0; typedef enum _RCType
virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const = 0; {
virtual QStringList getTunings(void) const = 0; RC_TYPE_QUANTIZER = 0,
virtual QStringList getPresets(void) const = 0; RC_TYPE_RATE_KBPS = 1,
virtual QStringList supportedOutputFormats(void) const = 0; RC_TYPE_MULTIPASS = 2
virtual bool isRCModeSupported(const OptionsModel::RCMode &rcMode) const = 0; }
virtual bool isInputTypeSupported(const int format) const = 0; RCType;
virtual QString getBinaryPath(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const = 0;
virtual QStringList getDependencies(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const; typedef QPair<QString, RCType> RCMode;
virtual QString getName(void) const = 0;
virtual QString getFullName(const quint32 &encArch, const quint32 &encVariant) const;
virtual QStringList getArchitectures(void) const = 0;
virtual QStringList getVariants(void) const = 0;
virtual QList<RCMode> getRCModes(void) const = 0;
virtual QStringList getProfiles(const quint32 &variant) const = 0;
virtual QStringList getTunings(void) const = 0;
virtual QStringList getPresets(void) const = 0;
virtual QStringList supportedOutputFormats(void) const = 0;
virtual bool isInputTypeSupported(const int format) const = 0;
virtual QString getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const = 0;
virtual QStringList getDependencies(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const;
//Utilities
QString archToString (const quint32 &index) const;
QString variantToString(const quint32 &index) const;
QString rcModeToString (const quint32 &index) const;
RCType rcModeToType (const quint32 &index) const;
}; };
class AbstractEncoder : public AbstractTool class AbstractEncoder : public AbstractTool

View File

@ -35,6 +35,7 @@
#include <QStringList> #include <QStringList>
#include <QDir> #include <QDir>
#include <QRegExp> #include <QRegExp>
#include <QPair>
//x265 version info //x265 version info
static const unsigned int VERSION_NVENCC_MINIMUM_VER = 206; static const unsigned int VERSION_NVENCC_MINIMUM_VER = 206;
@ -88,11 +89,28 @@ while(0)
class NVEncEncoderInfo : public AbstractEncoderInfo class NVEncEncoderInfo : public AbstractEncoderInfo
{ {
public: public:
virtual QFlags<OptionsModel::EncVariant> getVariants(void) const virtual QString getName(void) const
{ {
QFlags<OptionsModel::EncVariant> variants; return "NVEncC";
variants |= OptionsModel::EncVariant_8Bit; }
return variants;
virtual QStringList getArchitectures(void) const
{
return QStringList() << "32-Bit (x86)" << "64-Bit (x64)";
}
virtual QStringList getVariants(void) const
{
return QStringList() << "AVC" << "HEVC";
}
virtual QList<RCMode> getRCModes(void) const
{
return QList<RCMode>()
<< qMakePair(QString("CQP"), RC_TYPE_QUANTIZER)
<< qMakePair(QString("VBR"), RC_TYPE_RATE_KBPS)
<< qMakePair(QString("VBR2"), RC_TYPE_RATE_KBPS)
<< qMakePair(QString("CBR"), RC_TYPE_RATE_KBPS);
} }
virtual QStringList getTunings(void) const virtual QStringList getTunings(void) const
@ -105,14 +123,14 @@ public:
return QStringList(); return QStringList();
} }
virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const virtual QStringList getProfiles(const quint32 &variant) const
{ {
QStringList profiles; QStringList profiles;
switch(variant) switch(variant)
{ {
case OptionsModel::EncVariant_8Bit: case 0: profiles << "baseline" << "main" << "high"; break;
profiles << "baseline" << "main" << "high"; case 1: profiles << "main"; break;
break; default: MUTILS_THROW("Unknown encoder variant!");
} }
return profiles; return profiles;
} }
@ -124,18 +142,6 @@ public:
return extLst; return extLst;
} }
virtual bool isRCModeSupported(const OptionsModel::RCMode &rcMode) const
{
switch(rcMode)
{
case OptionsModel::RCMode_CQ:
case OptionsModel::RCMode_ABR:
return true;
default:
return false;
}
}
virtual bool isInputTypeSupported(const int format) const virtual bool isInputTypeSupported(const int format) const
{ {
switch(format) switch(format)
@ -147,52 +153,54 @@ public:
} }
} }
virtual QString getBinaryPath(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const virtual QString getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
{ {
QString arch, variant; QString arch;
switch(encArch) switch(encArch)
{ {
case OptionsModel::EncArch_x86_32: arch = "x86"; break; case 0: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break; case 1: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder arch!");
} }
switch(encVariant) switch(encVariant)
{ {
case OptionsModel::EncVariant_8Bit: variant = "8bit"; break; case 0: break;
default: MUTILS_THROW("Unknown encoder arch!"); case 1: break;
default: MUTILS_THROW("Unknown encoder variant!");
} }
return QString("%1/toolset/%2/nvencc_%2.exe").arg(sysinfo->getAppPath(), arch); return QString("%1/toolset/%2/nvencc_%2.exe").arg(sysinfo->getAppPath(), arch);
} }
virtual QStringList getDependencies(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const virtual QStringList getDependencies(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
{ {
QString arch, variant; QString arch;
switch (encArch) switch (encArch)
{ {
case OptionsModel::EncArch_x86_32: arch = "x86"; break; case 0: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break; case 1: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder arch!");
} }
switch (encVariant) switch (encVariant)
{ {
case OptionsModel::EncVariant_8Bit: variant = "8bit"; break; case 0: break;
default: MUTILS_THROW("Unknown encoder arch!"); case 1: break;
default: MUTILS_THROW("Unknown encoder variant!");
} }
QStringList dependencies; return QStringList()
dependencies << QString("%1/toolset/%2/avcodec-57.dll" ).arg(sysinfo->getAppPath(), arch); << QString("%1/toolset/%2/avcodec-57.dll" ).arg(sysinfo->getAppPath(), arch)
dependencies << QString("%1/toolset/%2/avfilter-6.dll" ).arg(sysinfo->getAppPath(), arch); << QString("%1/toolset/%2/avfilter-6.dll" ).arg(sysinfo->getAppPath(), arch)
dependencies << QString("%1/toolset/%2/avformat-57.dll" ).arg(sysinfo->getAppPath(), arch); << QString("%1/toolset/%2/avformat-57.dll" ).arg(sysinfo->getAppPath(), arch)
dependencies << QString("%1/toolset/%2/avutil-55.dll" ).arg(sysinfo->getAppPath(), arch); << QString("%1/toolset/%2/avutil-55.dll" ).arg(sysinfo->getAppPath(), arch)
dependencies << QString("%1/toolset/%2/swresample-2.dll").arg(sysinfo->getAppPath(), arch); << QString("%1/toolset/%2/swresample-2.dll").arg(sysinfo->getAppPath(), arch);
return dependencies;
} }
}; };
static const NVEncEncoderInfo s_x265EncoderInfo; static const NVEncEncoderInfo s_nvencEncoderInfo;
const AbstractEncoderInfo &NVEncEncoder::getEncoderInfo(void) const AbstractEncoderInfo &NVEncEncoder::getEncoderInfo(void)
{ {
return s_x265EncoderInfo; return s_nvencEncoderInfo;
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -216,19 +224,7 @@ NVEncEncoder::~NVEncEncoder(void)
QString NVEncEncoder::getName(void) const QString NVEncEncoder::getName(void) const
{ {
QString arch, variant; return s_nvencEncoderInfo.getFullName(m_options->encArch(), m_options->encVariant());
switch(m_options->encArch())
{
case OptionsModel::EncArch_x86_32: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
switch(m_options->encVariant())
{
case OptionsModel::EncVariant_8Bit: variant = "8-Bit"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
return QString("NVEncC, %1, %2").arg(arch, variant);
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -313,19 +309,34 @@ bool NVEncEncoder::isVersionSupported(const unsigned int &revision, const bool &
void NVEncEncoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile) void NVEncEncoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile)
{ {
double crf_int = 0.0, crf_frc = 0.0; switch (m_options->encVariant())
{
case 0:
cmdLine << "--codec" << "avc";
break;
case 1:
cmdLine << "--codec" << "hevc";
break;
default:
MUTILS_THROW("Bad encoder variant !!!");
}
switch(m_options->rcMode()) switch(m_options->rcMode())
{ {
case OptionsModel::RCMode_ABR: case 0:
cmdLine << "--cqp" << QString::number(qRound(m_options->quantizer()));
break;
case 1:
cmdLine << "--vbr" << QString::number(m_options->bitrate()); cmdLine << "--vbr" << QString::number(m_options->bitrate());
break; break;
case OptionsModel::RCMode_CQ: case 2:
cmdLine << "--cqp" << QString::number(qRound(m_options->quantizer())); cmdLine << "--vbr2" << QString::number(m_options->bitrate());
break;
case 3:
cmdLine << "--cbr" << QString::number(m_options->bitrate());
break; break;
default: default:
MUTILS_THROW("Bad rate-control mode !!!"); MUTILS_THROW("Bad rate-control mode !!!");
break;
} }
const QString profile = m_options->profile().simplified().toLower(); const QString profile = m_options->profile().simplified().toLower();

View File

@ -35,6 +35,7 @@
#include <QStringList> #include <QStringList>
#include <QDir> #include <QDir>
#include <QRegExp> #include <QRegExp>
#include <QPair>
//x264 version info //x264 version info
static const unsigned int VERSION_X264_MINIMUM_REV = 2668; static const unsigned int VERSION_X264_MINIMUM_REV = 2668;
@ -89,67 +90,60 @@ while(0)
class X264EncoderInfo : public AbstractEncoderInfo class X264EncoderInfo : public AbstractEncoderInfo
{ {
public: public:
virtual QFlags<OptionsModel::EncVariant> getVariants(void) const virtual QString getName(void) const
{ {
QFlags<OptionsModel::EncVariant> variants; return "x264 (AVC/H.264)";
variants |= OptionsModel::EncVariant_8Bit; }
variants |= OptionsModel::EncVariant_10Bit;
return variants; virtual QStringList getArchitectures(void) const
{
return QStringList() << "32-Bit (x86)" << "64-Bit (x64)";
}
virtual QStringList getVariants(void) const
{
return QStringList() << "8-Bit" << "10-Bit";
}
virtual QList<RCMode> getRCModes(void) const
{
return QList<RCMode>()
<< qMakePair(QString("CRF"), RC_TYPE_QUANTIZER)
<< qMakePair(QString("CQ"), RC_TYPE_QUANTIZER)
<< qMakePair(QString("2-Pass"), RC_TYPE_MULTIPASS)
<< qMakePair(QString("ABR"), RC_TYPE_RATE_KBPS);
} }
virtual QStringList getTunings(void) const virtual QStringList getTunings(void) const
{ {
QStringList tunings; return QStringList()
tunings << "Film" << "Animation" << "Grain"; << "Film" << "Animation" << "Grain"
tunings << "StillImage" << "PSNR" << "SSIM"; << "StillImage" << "PSNR" << "SSIM"
tunings << "FastDecode" << "ZeroLatency" << "Touhou"; << "FastDecode" << "ZeroLatency" << "Touhou";
return tunings;
} }
virtual QStringList getPresets(void) const virtual QStringList getPresets(void) const
{ {
QStringList presets; return QStringList()
presets << "ultrafast" << "superfast" << "veryfast" << "faster" << "fast"; << "ultrafast" << "superfast" << "veryfast" << "faster" << "fast"
presets << "medium" << "slow" << "slower" << "veryslow" << "placebo"; << "medium" << "slow" << "slower" << "veryslow" << "placebo";
return presets;
} }
virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const virtual QStringList getProfiles(const quint32 &variant) const
{ {
QStringList profiles; QStringList profiles;
switch(variant)
if(variant == OptionsModel::EncVariant_8Bit)
{ {
profiles << "Baseline" << "Main" << "High"; case 0: profiles << "Baseline" << "Main" << "High"; break;
case 1: profiles << "High10" << "High422" << "High444"; break;
default: MUTILS_THROW("Unknown encoder variant!");
} }
if((variant == OptionsModel::EncVariant_8Bit) || (variant == OptionsModel::EncVariant_10Bit))
{
profiles << "High10" << "High422" << "High444";
}
return profiles; return profiles;
} }
virtual QStringList supportedOutputFormats(void) const virtual QStringList supportedOutputFormats(void) const
{ {
QStringList extLst; return QStringList() << "264" << "mkv" << "mp4";
extLst << "264" << "mkv" << "mp4";
return extLst;
}
virtual bool isRCModeSupported(const OptionsModel::RCMode &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;
}
} }
virtual bool isInputTypeSupported(const int format) const virtual bool isInputTypeSupported(const int format) const
@ -165,20 +159,20 @@ public:
} }
} }
virtual QString getBinaryPath(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const virtual QString getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
{ {
QString arch, variant; QString arch, variant;
switch(encArch) switch(encArch)
{ {
case OptionsModel::EncArch_x86_32: arch = "x86"; break; case 0: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break; case 1: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder arch!");
} }
switch(encVariant) switch(encVariant)
{ {
case OptionsModel::EncVariant_8Bit: variant = "8bit"; break; case 0: variant = "8bit"; break;
case OptionsModel::EncVariant_10Bit: variant = "10bit"; break; case 1: variant = "10bit"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder variant!");
} }
return QString("%1/toolset/%2/x264_%3_%2.exe").arg(sysinfo->getAppPath(), arch, variant); return QString("%1/toolset/%2/x264_%3_%2.exe").arg(sysinfo->getAppPath(), arch, variant);
} }
@ -212,20 +206,7 @@ X264Encoder::~X264Encoder(void)
QString X264Encoder::getName(void) const QString X264Encoder::getName(void) const
{ {
QString arch, variant; return s_x264EncoderInfo.getFullName(m_options->encArch(), m_options->encVariant());
switch(m_options->encArch())
{
case OptionsModel::EncArch_x86_32: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
switch(m_options->encVariant())
{
case OptionsModel::EncVariant_8Bit: variant = "8-Bit"; break;
case OptionsModel::EncVariant_10Bit: variant = "10-Bit"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
return QString("x264 (H.264/AVC), %1, %2").arg(arch, variant);
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -317,15 +298,15 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
switch(m_options->rcMode()) switch(m_options->rcMode())
{ {
case OptionsModel::RCMode_CQ: case 0:
cmdLine << "--qp" << QString::number(qRound(m_options->quantizer())); cmdLine << "--qp" << QString::number(qRound(m_options->quantizer()));
break; break;
case OptionsModel::RCMode_CRF: case 1:
crf_frc = modf(m_options->quantizer(), &crf_int); crf_frc = modf(m_options->quantizer(), &crf_int);
cmdLine << "--crf" << QString("%1.%2").arg(QString::number(qRound(crf_int)), QString::number(qRound(crf_frc * 10.0))); cmdLine << "--crf" << QString("%1.%2").arg(QString::number(qRound(crf_int)), QString::number(qRound(crf_frc * 10.0)));
break; break;
case OptionsModel::RCMode_2Pass: case 2:
case OptionsModel::RCMode_ABR: case 3:
cmdLine << "--bitrate" << QString::number(m_options->bitrate()); cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break; break;
default: default:

View File

@ -35,6 +35,7 @@
#include <QStringList> #include <QStringList>
#include <QDir> #include <QDir>
#include <QRegExp> #include <QRegExp>
#include <QPair>
//x265 version info //x265 version info
static const unsigned int VERSION_X265_MINIMUM_VER = 19; static const unsigned int VERSION_X265_MINIMUM_VER = 19;
@ -89,67 +90,57 @@ while(0)
class X265EncoderInfo : public AbstractEncoderInfo class X265EncoderInfo : public AbstractEncoderInfo
{ {
public: public:
virtual QFlags<OptionsModel::EncVariant> getVariants(void) const virtual QString getName(void) const
{ {
QFlags<OptionsModel::EncVariant> variants; return "x265 (HEVC/H.265)";
variants |= OptionsModel::EncVariant_8Bit; }
variants |= OptionsModel::EncVariant_10Bit;
variants |= OptionsModel::EncVariant_12Bit; virtual QStringList getArchitectures(void) const
return variants; {
return QStringList() << "32-Bit (x86)" << "64-Bit (x64)";
}
virtual QStringList getVariants(void) const
{
return QStringList() << "8-Bit" << "10-Bit" << "12-Bit";
}
virtual QList<RCMode> getRCModes(void) const
{
return QList<RCMode>()
<< qMakePair(QString("CRF"), RC_TYPE_QUANTIZER)
<< qMakePair(QString("CQ"), RC_TYPE_QUANTIZER)
<< qMakePair(QString("2-Pass"), RC_TYPE_MULTIPASS)
<< qMakePair(QString("ABR"), RC_TYPE_RATE_KBPS);
} }
virtual QStringList getTunings(void) const virtual QStringList getTunings(void) const
{ {
QStringList tunings; return QStringList() << "Grain" << "PSNR" << "SSIM" << "FastDecode" << "ZeroLatency";
tunings << "Grain" << "PSNR" << "SSIM" << "FastDecode" << "ZeroLatency";
return tunings;
} }
virtual QStringList getPresets(void) const virtual QStringList getPresets(void) const
{ {
QStringList presets; return QStringList()
presets << "ultrafast" << "superfast" << "veryfast" << "faster" << "fast"; << "ultrafast" << "superfast" << "veryfast" << "faster" << "fast"
presets << "medium" << "slow" << "slower" << "veryslow" << "placebo"; << "medium" << "slow" << "slower" << "veryslow" << "placebo";
return presets;
} }
virtual QStringList getProfiles(const OptionsModel::EncVariant &variant) const virtual QStringList getProfiles(const quint32 &variant) const
{ {
QStringList profiles; QStringList profiles;
switch(variant) switch(variant)
{ {
case OptionsModel::EncVariant_8Bit: case 0: profiles << "main" << "main-intra" << "mainstillpicture" << "main444-8" << "main444-intra" << "main444-stillpicture"; break;
profiles << "main" << "main-intra" << "mainstillpicture" << "main444-8" << "main444-intra" << "main444-stillpicture"; case 1: profiles << "main10" << "main10-intra" << "main422-10" << "main422-10-intra" << "main444-10" << "main444-10-intra"; break;
break; case 2: profiles << "main12" << "main12-intra" << "main422-12" << "main422-12-intra" << "main444-12" << "main444-12-intra"; break;
case OptionsModel::EncVariant_10Bit: default: MUTILS_THROW("Unknown encoder variant!");
profiles << "main10" << "main10-intra" << "main422-10" << "main422-10-intra" << "main444-10" << "main444-10-intra";
break;
case OptionsModel::EncVariant_12Bit:
profiles << "main12" << "main12-intra" << "main422-12" << "main422-12-intra" << "main444-12" << "main444-12-intra";
break;
} }
return profiles; return profiles;
} }
virtual QStringList supportedOutputFormats(void) const virtual QStringList supportedOutputFormats(void) const
{ {
QStringList extLst; return QStringList() << "hevc";
extLst << "hevc";
return extLst;
}
virtual bool isRCModeSupported(const OptionsModel::RCMode &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;
}
} }
virtual bool isInputTypeSupported(const int format) const virtual bool isInputTypeSupported(const int format) const
@ -163,20 +154,20 @@ public:
} }
} }
virtual QString getBinaryPath(const SysinfoModel *sysinfo, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant) const virtual QString getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
{ {
QString arch, variant; QString arch, variant;
switch(encArch) switch(encArch)
{ {
case OptionsModel::EncArch_x86_32: arch = "x86"; break; case 0: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break; case 1: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder arch!");
} }
switch(encVariant) switch(encVariant)
{ {
case OptionsModel::EncVariant_8Bit: variant = "8bit"; break; case 0: variant = "8bit"; break;
case OptionsModel::EncVariant_10Bit: variant = "10bit"; break; case 1: variant = "10bit"; break;
case OptionsModel::EncVariant_12Bit: variant = "12bit"; break; case 2: variant = "12bit"; break;
default: MUTILS_THROW("Unknown encoder arch!"); default: MUTILS_THROW("Unknown encoder arch!");
} }
return QString("%1/toolset/%2/x265_%3_%2.exe").arg(sysinfo->getAppPath(), arch, variant); return QString("%1/toolset/%2/x265_%3_%2.exe").arg(sysinfo->getAppPath(), arch, variant);
@ -211,21 +202,7 @@ X265Encoder::~X265Encoder(void)
QString X265Encoder::getName(void) const QString X265Encoder::getName(void) const
{ {
QString arch, variant; return s_x265EncoderInfo.getFullName(m_options->encArch(), m_options->encVariant());
switch(m_options->encArch())
{
case OptionsModel::EncArch_x86_32: arch = "x86"; break;
case OptionsModel::EncArch_x86_64: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
switch(m_options->encVariant())
{
case OptionsModel::EncVariant_8Bit: variant = "8-Bit"; break;
case OptionsModel::EncVariant_10Bit: variant = "10-Bit"; break;
case OptionsModel::EncVariant_12Bit: variant = "12-Bit"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
return QString("x265 (H.265/HEVC), %1, %2").arg(arch, variant);
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -312,15 +289,15 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
switch(m_options->rcMode()) switch(m_options->rcMode())
{ {
case OptionsModel::RCMode_CQ: case 0:
cmdLine << "--qp" << QString::number(qRound(m_options->quantizer())); cmdLine << "--qp" << QString::number(qRound(m_options->quantizer()));
break; break;
case OptionsModel::RCMode_CRF: case 1:
crf_frc = modf(m_options->quantizer(), &crf_int); crf_frc = modf(m_options->quantizer(), &crf_int);
cmdLine << "--crf" << QString("%1.%2").arg(QString::number(qRound(crf_int)), QString::number(qRound(crf_frc * 10.0))); cmdLine << "--crf" << QString("%1.%2").arg(QString::number(qRound(crf_int)), QString::number(qRound(crf_frc * 10.0)));
break; break;
case OptionsModel::RCMode_2Pass: case 2:
case OptionsModel::RCMode_ABR: case 3:
cmdLine << "--bitrate" << QString::number(m_options->bitrate()); cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break; break;
default: default:

View File

@ -23,6 +23,7 @@
#include "global.h" #include "global.h"
#include "model_jobList.h" #include "model_jobList.h"
#include "thread_encode.h" #include "thread_encode.h"
#include "encoder_factory.h"
#include "model_options.h" #include "model_options.h"
#include "model_preferences.h" #include "model_preferences.h"
#include "resource.h" #include "resource.h"
@ -245,24 +246,21 @@ QModelIndex JobListModel::insertJob(EncodeThread *thread)
return QModelIndex(); return QModelIndex();
} }
QString config = QLatin1String("N/A"); const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(thread->options()->encType());
switch(thread->options()->encType()) QString config = encoderInfo.getName();
switch(encoderInfo.rcModeToType(thread->options()->rcMode()))
{ {
case OptionsModel::EncType_X264: config = QLatin1String("x264"); break; case AbstractEncoderInfo::RC_TYPE_QUANTIZER:
case OptionsModel::EncType_X265: config = QLatin1String("x265"); break; config.append(QString(", %1@%2").arg(encoderInfo.rcModeToString(thread->options()->rcMode()), QString::number(qRound(thread->options()->quantizer()))));
} break;
case AbstractEncoderInfo::RC_TYPE_RATE_KBPS:
switch(thread->options()->rcMode()) case AbstractEncoderInfo::RC_TYPE_MULTIPASS:
{ config.append(QString(", %1@%2").arg(encoderInfo.rcModeToString(thread->options()->rcMode()), QString::number(thread->options()->bitrate())));
case OptionsModel::RCMode_CRF: config.append(QString(" CRF@%1") .arg(QString::number(thread->options()->quantizer()))); break; break;
case OptionsModel::RCMode_CQ: config.append(QString(" CQ@%1") .arg(QString::number(qRound(thread->options()->quantizer())))); break;
case OptionsModel::RCMode_2Pass: config.append(QString(" 2Pass@%1").arg(QString::number(thread->options()->bitrate()))); break;
case OptionsModel::RCMode_ABR: config.append(QString(" ABR@%1") .arg(QString::number(thread->options()->bitrate()))); break;
} }
int n = 2; int n = 2;
QString jobName = QString("%1 (%2)").arg(QFileInfo(thread->sourceFileName()).completeBaseName().simplified(), config); QString jobName = QString("%1 (%2)").arg(QFileInfo(thread->sourceFileName()).completeBaseName().simplified(), config);
forever forever
{ {
bool unique = true; bool unique = true;

View File

@ -57,9 +57,9 @@ const char *const OptionsModel::PROFILE_UNRESTRICTED = "<Unrestricted>";
OptionsModel::OptionsModel(const SysinfoModel *sysinfo) OptionsModel::OptionsModel(const SysinfoModel *sysinfo)
{ {
m_encoderType = EncType_X264; m_encoderType = EncType_X264;
m_encoderArch = sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) ? EncArch_x86_64 : EncArch_x86_32; m_encoderArch = sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) ? 0 : 1;
m_encoderVariant = EncVariant_8Bit; m_encoderVariant = 0;
m_rcMode = RCMode_CRF; m_rcMode = 0;
m_bitrate = 1200; m_bitrate = 1200;
m_quantizer = 22; m_quantizer = 22;
m_preset = "Medium"; m_preset = "Medium";
@ -88,28 +88,6 @@ OptionsModel::~OptionsModel(void)
{ {
} }
QString OptionsModel::rcMode2String(RCMode mode)
{
switch(mode)
{
case RCMode_CRF:
return QObject::tr("CRF");
break;
case RCMode_CQ:
return QObject::tr("CQ");
break;
case RCMode_2Pass:
return QObject::tr("2-Pass");
break;
case RCMode_ABR:
return QObject::tr("ABR");
break;
default:
return QString();
break;
}
}
bool OptionsModel::equals(const OptionsModel *model) bool OptionsModel::equals(const OptionsModel *model)
{ {
bool equal = true; bool equal = true;
@ -251,17 +229,17 @@ bool OptionsModel::loadOptions(OptionsModel *model, QSettings &settingsFile)
if(complete) if(complete)
{ {
model->setEncType (static_cast<OptionsModel::EncType> (settingsFile.value(KEY_ENCODER_TYPE, model->m_encoderType) .toInt())); model->setEncType (settingsFile.value(KEY_ENCODER_TYPE, model->m_encoderType) .toInt());
model->setEncArch (static_cast<OptionsModel::EncArch> (settingsFile.value(KEY_ENCODER_ARCH, model->m_encoderArch) .toInt())); model->setEncArch (settingsFile.value(KEY_ENCODER_ARCH, model->m_encoderArch) .toInt());
model->setEncVariant (static_cast<OptionsModel::EncVariant>(settingsFile.value(KEY_ENCODER_VARIANT, model->m_encoderVariant).toInt())); model->setEncVariant (settingsFile.value(KEY_ENCODER_VARIANT, model->m_encoderVariant).toInt());
model->setRCMode (static_cast<OptionsModel::RCMode> (settingsFile.value(KEY_RATECTRL_MODE, model->m_rcMode) .toInt())); model->setRCMode (settingsFile.value(KEY_RATECTRL_MODE, model->m_rcMode) .toInt());
model->setBitrate (settingsFile.value(KEY_TARGET_BITRATE, model->m_bitrate) .toUInt() ); model->setBitrate (settingsFile.value(KEY_TARGET_BITRATE, model->m_bitrate) .toUInt());
model->setQuantizer (settingsFile.value(KEY_TARGET_QUANT, model->m_quantizer) .toDouble()); model->setQuantizer (settingsFile.value(KEY_TARGET_QUANT, model->m_quantizer) .toDouble());
model->setPreset (settingsFile.value(KEY_PRESET_NAME, model->m_preset) .toString()); model->setPreset (settingsFile.value(KEY_PRESET_NAME, model->m_preset) .toString());
model->setTune (settingsFile.value(KEY_TUNING_NAME, model->m_tune) .toString()); model->setTune (settingsFile.value(KEY_TUNING_NAME, model->m_tune) .toString());
model->setProfile (settingsFile.value(KEY_PROFILE_NAME, model->m_profile) .toString()); model->setProfile (settingsFile.value(KEY_PROFILE_NAME, model->m_profile) .toString());
model->setCustomEncParams(settingsFile.value(KEY_CUSTOM_ENCODER, model->m_custom_encoder).toString()); model->setCustomEncParams(settingsFile.value(KEY_CUSTOM_ENCODER, model->m_custom_encoder).toString());
model->setCustomAvs2YUV (settingsFile.value(KEY_CUSTOM_AVS2YUV, model->m_custom_avs2yuv).toString()); model->setCustomAvs2YUV (settingsFile.value(KEY_CUSTOM_AVS2YUV, model->m_custom_avs2yuv).toString());
} }
return complete; return complete;
@ -271,9 +249,9 @@ void OptionsModel::fixTemplate(QSettings &settingsFile)
{ {
if(!(settingsFile.contains(KEY_ENCODER_TYPE) || settingsFile.contains(KEY_ENCODER_ARCH) || settingsFile.contains(KEY_ENCODER_VARIANT))) if(!(settingsFile.contains(KEY_ENCODER_TYPE) || settingsFile.contains(KEY_ENCODER_ARCH) || settingsFile.contains(KEY_ENCODER_VARIANT)))
{ {
settingsFile.setValue(KEY_ENCODER_TYPE, OptionsModel::EncType_X264); settingsFile.setValue(KEY_ENCODER_TYPE, 0);
settingsFile.setValue(KEY_ENCODER_ARCH, OptionsModel::EncArch_x86_32); settingsFile.setValue(KEY_ENCODER_ARCH, 0);
settingsFile.setValue(KEY_ENCODER_VARIANT, OptionsModel::EncVariant_8Bit); settingsFile.setValue(KEY_ENCODER_VARIANT, 0);
} }
static const char *legacyKey[] = { "custom_params", "custom_params_x264", NULL }; static const char *legacyKey[] = { "custom_params", "custom_params_x264", NULL };

View File

@ -45,44 +45,14 @@ public:
EncType_MAX = EncType_NVEnc, EncType_MAX = EncType_NVEnc,
}; };
enum EncArch
{
EncArch_x86_32 = 0,
EncArch_x86_64 = 1,
EncArch_MIN = EncArch_x86_32,
EncArch_MAX = EncArch_x86_64
};
enum EncVariant
{
EncVariant_8Bit = 1,
EncVariant_10Bit = 2,
EncVariant_12Bit = 4,
EncVariant_MIN = EncVariant_8Bit,
EncVariant_MAX = EncVariant_12Bit
};
enum RCMode
{
RCMode_CRF = 0,
RCMode_CQ = 1,
RCMode_2Pass = 2,
RCMode_ABR = 3,
RCMode_MIN = RCMode_CRF,
RCMode_MAX = RCMode_ABR,
};
static const char *const SETTING_UNSPECIFIED; static const char *const SETTING_UNSPECIFIED;
static const char *const PROFILE_UNRESTRICTED; static const char *const PROFILE_UNRESTRICTED;
//Getter //Getter
EncType encType(void) const { return m_encoderType; } EncType encType(void) const { return m_encoderType; }
EncArch encArch(void) const { return m_encoderArch; } quint32 encArch(void) const { return m_encoderArch; }
EncVariant encVariant(void) const { return m_encoderVariant; } quint32 encVariant(void) const { return m_encoderVariant; }
RCMode rcMode(void) const { return m_rcMode; } quint32 rcMode(void) const { return m_rcMode; }
unsigned int bitrate(void) const { return m_bitrate; } unsigned int bitrate(void) const { return m_bitrate; }
double quantizer(void) const { return m_quantizer; } double quantizer(void) const { return m_quantizer; }
QString preset(void) const { return m_preset; } QString preset(void) const { return m_preset; }
@ -92,10 +62,11 @@ public:
QString customAvs2YUV(void) const { return m_custom_avs2yuv; } QString customAvs2YUV(void) const { return m_custom_avs2yuv; }
//Setter //Setter
void setEncType(quint32 type) { setEncType(static_cast<EncType>(type)); }
void setEncType(EncType type) { m_encoderType = qBound(EncType_MIN, type, EncType_MAX); } void setEncType(EncType type) { m_encoderType = qBound(EncType_MIN, type, EncType_MAX); }
void setEncArch(EncArch arch) { m_encoderArch = qBound(EncArch_MIN, arch, EncArch_MAX); } void setEncArch(quint32 arch) { m_encoderArch = arch; }
void setEncVariant(EncVariant variant) { m_encoderVariant = qBound(EncVariant_MIN, variant, EncVariant_MAX); } void setEncVariant(quint32 variant) { m_encoderVariant = variant; }
void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CRF, mode, RCMode_ABR); } void setRCMode(quint32 mode) { m_rcMode = mode; }
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); } void setBitrate(unsigned int bitrate) { m_bitrate = qBound(10U, bitrate, 800000U); }
void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); } void setQuantizer(double quantizer) { m_quantizer = qBound(0.0, quantizer, 52.0); }
void setPreset(const QString &preset) { m_preset = preset.trimmed(); } void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
@ -108,7 +79,6 @@ public:
bool equals(const OptionsModel *model); bool equals(const OptionsModel *model);
//Static functions //Static functions
static QString rcMode2String(RCMode mode);
static bool saveTemplate(const OptionsModel *model, const QString &name); static bool saveTemplate(const OptionsModel *model, const QString &name);
static bool loadTemplate(OptionsModel *model, const QString &name); static bool loadTemplate(OptionsModel *model, const QString &name);
static QMap<QString, OptionsModel*> loadAllTemplates(const SysinfoModel *sysinfo); static QMap<QString, OptionsModel*> loadAllTemplates(const SysinfoModel *sysinfo);
@ -119,9 +89,9 @@ public:
protected: protected:
EncType m_encoderType; EncType m_encoderType;
EncArch m_encoderArch; quint32 m_encoderArch;
EncVariant m_encoderVariant; quint32 m_encoderVariant;
RCMode m_rcMode; quint32 m_rcMode;
unsigned int m_bitrate; unsigned int m_bitrate;
double m_quantizer; double m_quantizer;
QString m_preset; QString m_preset;

View File

@ -24,6 +24,7 @@
#include <QLibrary> #include <QLibrary>
#include <QEventLoop> #include <QEventLoop>
#include <QTimer> #include <QTimer>
#include <QSet>
#include <QMutexLocker> #include <QMutexLocker>
#include <QApplication> #include <QApplication>
#include <QProcess> #include <QProcess>
@ -150,23 +151,22 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
for(OptionsModel::EncType encdr = OptionsModel::EncType_MIN; encdr <= OptionsModel::EncType_MAX; NEXT(encdr)) for(OptionsModel::EncType encdr = OptionsModel::EncType_MIN; encdr <= OptionsModel::EncType_MAX; NEXT(encdr))
{ {
const AbstractEncoderInfo &encInfo = EncoderFactory::getEncoderInfo(encdr); const AbstractEncoderInfo &encInfo = EncoderFactory::getEncoderInfo(encdr);
const QFlags<OptionsModel::EncVariant> variants = encInfo.getVariants(); const QStringList archs = encInfo.getArchitectures(), variants = encInfo.getVariants();
for(OptionsModel::EncArch arch = OptionsModel::EncArch_x86_32; arch <= OptionsModel::EncArch_x86_64; NEXT(arch)) QSet<QString> dependencySet;
for (quint32 archIdx = 0; archIdx < quint32(archs.count()); ++archIdx)
{ {
for(OptionsModel::EncVariant varnt = OptionsModel::EncVariant_MIN; varnt <= OptionsModel::EncVariant_MAX; SHFL(varnt)) for (quint32 varntIdx = 0; varntIdx < quint32(variants.count()); ++varntIdx)
{ {
if(variants.testFlag(varnt)) const QStringList dependencies = encInfo.getDependencies(sysinfo, archIdx, varntIdx);
for (QStringList::ConstIterator iter = dependencies.constBegin(); iter != dependencies.constEnd(); iter++)
{ {
binFiles << qMakePair(encInfo.getBinaryPath(sysinfo, arch, varnt), false); if (!dependencySet.contains(*iter))
const QStringList dependencies = encInfo.getDependencies(sysinfo, arch, varnt);
if (!dependencies.empty())
{ {
for (QStringList::ConstIterator iter = dependencies.constBegin(); iter != dependencies.constEnd(); iter++) dependencySet << (*iter);
{ binFiles << qMakePair(*iter, true);
binFiles << qMakePair(*iter, true);
}
} }
} }
binFiles << qMakePair(encInfo.getBinaryPath(sysinfo, archIdx, varntIdx), false);
} }
} }
} }
@ -192,11 +192,23 @@ void BinariesCheckThread::checkBinaries3(volatile bool &success, const SysinfoMo
if(file->open(QIODevice::ReadOnly)) if(file->open(QIODevice::ReadOnly))
{ {
if(!(iter->second || MUtils::OS::is_executable_file(file->fileName()))) if(!iter->second)
{ {
success = false; if (!MUtils::OS::is_executable_file(file->fileName()))
qWarning("Required tool does NOT look like a valid Win32/Win64 binary:\n%s\n", MUTILS_UTF8(file->fileName())); {
return; success = false;
qWarning("Required tool does NOT look like a valid Win32/Win64 binary:\n%s\n", MUTILS_UTF8(file->fileName()));
return;
}
}
else
{
if (!MUtils::OS::is_library_file(file->fileName()))
{
success = false;
qWarning("Required tool does NOT look like a valid Win32/Win64 library:\n%s\n", MUTILS_UTF8(file->fileName()));
return;
}
} }
if(currentFile < MAX_BINARIES) if(currentFile < MAX_BINARIES)
{ {

View File

@ -260,7 +260,7 @@ void EncodeThread::encode(void)
log(tr("\n--- SETTINGS ---\n")); log(tr("\n--- SETTINGS ---\n"));
log(tr("Encoder : %1").arg(m_encoder->getName())); log(tr("Encoder : %1").arg(m_encoder->getName()));
log(tr("Source : %1").arg(m_pipedSource ? m_pipedSource->getName() : tr("Native"))); log(tr("Source : %1").arg(m_pipedSource ? m_pipedSource->getName() : tr("Native")));
log(tr("RC Mode : %1").arg(OptionsModel::rcMode2String(m_options->rcMode()))); log(tr("RC Mode : %1").arg(m_encoder->getEncoderInfo().rcModeToString(m_options->rcMode())));
log(tr("Preset : %1").arg(m_options->preset())); log(tr("Preset : %1").arg(m_options->preset()));
log(tr("Tuning : %1").arg(m_options->tune())); log(tr("Tuning : %1").arg(m_options->tune()));
log(tr("Profile : %1").arg(m_options->profile())); log(tr("Profile : %1").arg(m_options->profile()));
@ -326,7 +326,7 @@ void EncodeThread::encode(void)
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
//Run encoding passes //Run encoding passes
if(m_options->rcMode() == OptionsModel::RCMode_2Pass) if(m_encoder->getEncoderInfo().rcModeToType(m_options->rcMode()) == AbstractEncoderInfo::RC_TYPE_MULTIPASS)
{ {
const QString passLogFile = getPasslogFile(m_outputFileName); const QString passLogFile = getPasslogFile(m_outputFileName);