Each encoder now can return an AbstractEncoderInfo object, which contains the supported I/O formats. Use this info the AddJob dialog.

This commit is contained in:
LoRd_MuldeR 2014-04-11 15:33:02 +02:00
parent d24ceaab78
commit 057336d162
9 changed files with 135 additions and 18 deletions

View File

@ -27,6 +27,13 @@ class QRegExp;
template<class T> class QList; template<class T> class QList;
class AbstractSource; class AbstractSource;
class AbstractEncoderInfo
{
public:
virtual QStringList supportedInputFormats (void) const = 0;
virtual QStringList supportedOutputFormats(void) const = 0;
};
class AbstractEncoder : public AbstractTool class AbstractEncoder : public AbstractTool
{ {
public: public:
@ -34,6 +41,7 @@ public:
virtual ~AbstractEncoder(void); virtual ~AbstractEncoder(void);
virtual bool runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const unsigned int &frames, const int &pass = 0, const QString &passLogFile = QString()); virtual bool runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const unsigned int &frames, const int &pass = 0, const QString &passLogFile = QString());
static const AbstractEncoderInfo& getEncoderInfo(void);
protected: protected:
virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile) = 0; virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile) = 0;

View File

@ -76,6 +76,48 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari); return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari);
} }
// ------------------------------------------------------------
// Encoder Info
// ------------------------------------------------------------
class X264EncoderInfo : public AbstractEncoderInfo
{
public:
virtual QStringList supportedInputFormats(void) const
{
QStringList extLst;
extLst << "avi";
extLst << "mp4";
extLst << "mkv";
extLst << "flv";
extLst << "mpg";
extLst << "m2v";
extLst << "m2ts";
extLst << "ts";
extLst << "wmv";
extLst << "ogm";
extLst << "vob";
extLst << "y4m";
return extLst;
}
virtual QStringList supportedOutputFormats(void) const
{
QStringList extLst;
extLst << "264";
extLst << "mkv";
extLst << "mp4";
return extLst;
}
};
static const X264EncoderInfo s_x264EncoderInfo;
const AbstractEncoderInfo &X264Encoder::getEncoderInfo(void)
{
return s_x264EncoderInfo;
}
// ------------------------------------------------------------ // ------------------------------------------------------------
// Constructor & Destructor // Constructor & Destructor
// ------------------------------------------------------------ // ------------------------------------------------------------

View File

@ -34,6 +34,8 @@ public:
virtual QString printVersion(const unsigned int &revision, const bool &modified); virtual QString printVersion(const unsigned int &revision, const bool &modified);
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified); virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);
static const AbstractEncoderInfo& getEncoderInfo(void);
protected: protected:
virtual const QString &getBinaryPath() { return m_binaryFile; } virtual const QString &getBinaryPath() { return m_binaryFile; }
virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile); virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile);

View File

@ -77,6 +77,35 @@ static QString MAKE_NAME(const char *baseName, const OptionsModel *options)
return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari); return QString("%1, %2, %3").arg(QString::fromLatin1(baseName), arch, vari);
} }
// ------------------------------------------------------------
// Encoder Info
// ------------------------------------------------------------
class X265EncoderInfo : public AbstractEncoderInfo
{
public:
virtual QStringList supportedInputFormats(void) const
{
QStringList extLst;
extLst << "y4m";
return extLst;
}
virtual QStringList supportedOutputFormats(void) const
{
QStringList extLst;
extLst << "hevc";
return extLst;
}
};
static const X265EncoderInfo s_x265EncoderInfo;
const AbstractEncoderInfo &X265Encoder::getEncoderInfo(void)
{
return s_x265EncoderInfo;
}
// ------------------------------------------------------------ // ------------------------------------------------------------
// Constructor & Destructor // Constructor & Destructor
// ------------------------------------------------------------ // ------------------------------------------------------------

View File

@ -34,6 +34,8 @@ public:
virtual QString printVersion(const unsigned int &revision, const bool &modified); virtual QString printVersion(const unsigned int &revision, const bool &modified);
virtual bool isVersionSupported(const unsigned int &revision, const bool &modified); virtual bool isVersionSupported(const unsigned int &revision, const bool &modified);
static const AbstractEncoderInfo& getEncoderInfo(void);
protected: protected:
virtual const QString &getBinaryPath() { return m_binaryFile; } virtual const QString &getBinaryPath() { return m_binaryFile; }
virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile); virtual void buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile);

View File

@ -33,7 +33,7 @@ X264_FILE_TYPE_FILTERS[] =
{ "mkv", "Matroska Files" }, { "mkv", "Matroska Files" },
{ "mp4", "MPEG-4 Part 14 Container" }, { "mp4", "MPEG-4 Part 14 Container" },
{ "264", "AVC/H.264 Elementary Stream"}, { "264", "AVC/H.264 Elementary Stream"},
{ "hevc", "HEVC/H.264 Elementary Stream"}, { "hevc", "HEVC/H.265 Elementary Stream"},
}; };
class RecentlyUsed class RecentlyUsed

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 4 #define VER_X264_PATCH 4
#define VER_X264_BUILD 811 #define VER_X264_BUILD 812
#define VER_X264_PORTABLE_EDITION (0) #define VER_X264_PORTABLE_EDITION (0)

View File

@ -27,6 +27,8 @@
#include "model_preferences.h" #include "model_preferences.h"
#include "model_sysinfo.h" #include "model_sysinfo.h"
#include "model_recently.h" #include "model_recently.h"
#include "encoder_x264.h"
#include "encoder_x265.h"
#include "win_help.h" #include "win_help.h"
#include "win_editor.h" #include "win_editor.h"
@ -496,34 +498,50 @@ void AddJobDialog::accept(void)
return; return;
} }
//Is the type of source supported? (as far as we can tell) //Get encoder info
if((sourceFile.suffix().compare("AVS", Qt::CaseInsensitive) == 0) && (!m_sysinfo->hasAVSSupport())) const AbstractEncoderInfo &encoderInfo = getEncoderInfo(ui->cbxEncoderType->currentIndex());
//Is the type of the source file supported? (as far as we can tell)
if(sourceFile.suffix().compare("AVS", Qt::CaseInsensitive) == 0)
{ {
if(QMessageBox::warning(this, tr("Avisynth unsupported!"), tr("<nobr>An Avisynth script was selected as input, although Avisynth is <b>not</b> available!</nobr>"), tr("Abort"), tr("Ingnore (at your own risk!)")) != 1) if(!m_sysinfo->hasAVSSupport())
{ {
return; if(QMessageBox::warning(this, tr("Avisynth unsupported!"), tr("<nobr>An Avisynth script was selected as input, although Avisynth is <b>not</b> available!</nobr>"), tr("Abort"), tr("Ingnore (at your own risk!)")) != 1)
{
return;
}
} }
} }
else if(((sourceFile.suffix().compare("VPY", Qt::CaseInsensitive) == 0) || (sourceFile.suffix().compare("PY", Qt::CaseInsensitive) == 0)) && (!m_sysinfo->hasVPSSupport())) else if((sourceFile.suffix().compare("VPY", Qt::CaseInsensitive) == 0) || (sourceFile.suffix().compare("PY", Qt::CaseInsensitive) == 0))
{ {
if(QMessageBox::warning(this, tr("VapurSynth unsupported!"), tr("<nobr>A VapourSynth script was selected as input, although VapourSynth is <b>not/<b> available!</nobr>"), tr("Abort"), tr("Ingnore (at your own risk!)")) != 1) if(!m_sysinfo->hasVPSSupport())
{ {
return; if(QMessageBox::warning(this, tr("VapurSynth unsupported!"), tr("<nobr>A VapourSynth script was selected as input, although VapourSynth is <b>not/<b> available!</nobr>"), tr("Abort"), tr("Ingnore (at your own risk!)")) != 1)
{
return;
}
}
}
else
{
const QStringList inputFormats = encoderInfo.supportedInputFormats();
if(!inputFormats.contains(sourceFile.suffix(), Qt::CaseInsensitive))
{
if(QMessageBox::warning(this, tr("Unsupported input format"), tr("<nobr>The selected encoder does <b>not</b> support the selected input format!</nobr>"), tr("Abort"), tr("Ingnore (at your own risk!)")) != 1)
{
return;
}
} }
} }
//Is output file extension supported by encoder? //Is output file extension supported by encoder?
const QStringList outputFormats = encoderInfo.supportedOutputFormats();
QFileInfo outputFile = QFileInfo(this->outputFile()); QFileInfo outputFile = QFileInfo(this->outputFile());
if((outputFile.suffix().compare("264", Qt::CaseInsensitive) == 0) && (ui->cbxEncoderType->currentIndex() == OptionsModel::EncType_X265)) if(!outputFormats.contains(outputFile.suffix(), Qt::CaseInsensitive))
{ {
QMessageBox::warning(this, tr("H.264 unsupported!"), tr("<nobr>Sorry, x265 cannot output H.264/AVC files!</nobr>")); QMessageBox::warning(this, tr("Unsupported output format"), tr("<nobr>Sorry, the selected encoder does not support the selected output format!</nobr>"));
ui->editOutput->setText(QString("%1/%2.hevc").arg(outputFile.absolutePath(), outputFile.completeBaseName())); ui->editOutput->setText(QDir::toNativeSeparators(QString("%1/%2.%3").arg(outputFile.absolutePath(), outputFile.completeBaseName(), outputFormats.first())));
return;
}
else if((outputFile.suffix().compare("HEVC", Qt::CaseInsensitive) == 0) && (ui->cbxEncoderType->currentIndex() == OptionsModel::EncType_X264))
{
QMessageBox::warning(this, tr("H.264 unsupported!"), tr("<nobr>Sorry, x264 cannot output H.265/HEVC files!</nobr>"));
ui->editOutput->setText(QString("%1/%2.264").arg(outputFile.absolutePath(), outputFile.completeBaseName()));
return; return;
} }
@ -1120,3 +1138,17 @@ QString AddJobDialog::getInputFilterLst(void)
filters << QString("All files (*.*)"); filters << QString("All files (*.*)");
return filters.join(";;"); return filters.join(";;");
} }
const AbstractEncoderInfo& AddJobDialog::getEncoderInfo(const int &encoder)
{
switch(encoder)
{
case OptionsModel::EncType_X264:
return X264Encoder::getEncoderInfo();
case OptionsModel::EncType_X265:
return X265Encoder::getEncoderInfo();
break;
default:
THROW("Unsupported encoder type!");
}
}

View File

@ -27,6 +27,7 @@ class OptionsModel;
class RecentlyUsed; class RecentlyUsed;
class SysinfoModel; class SysinfoModel;
class PreferencesModel; class PreferencesModel;
class AbstractEncoderInfo;
class QComboBox; class QComboBox;
namespace Ui namespace Ui
@ -59,6 +60,7 @@ public:
static QString AddJobDialog::getFilterStr(const int filterIndex); static QString AddJobDialog::getFilterStr(const int filterIndex);
static QString getFilterLst(void); static QString getFilterLst(void);
static QString getInputFilterLst(void); static QString getInputFilterLst(void);
const AbstractEncoderInfo& getEncoderInfo(const int &encoder);
protected: protected:
OptionsModel *const m_options; OptionsModel *const m_options;