Implemented ClipInfo class + various fixes.

This commit is contained in:
LoRd_MuldeR 2016-05-08 18:33:48 +02:00
parent cf723f7f26
commit 8a8889f51a
20 changed files with 253 additions and 95 deletions

View File

@ -67,7 +67,7 @@ AbstractEncoder::~AbstractEncoder(void)
// Encoding Functions // Encoding Functions
// ------------------------------------------------------------ // ------------------------------------------------------------
bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const unsigned int &frames, const int &pass, const QString &passLogFile) bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const ClipInfo &clipInfo, const int &pass, const QString &passLogFile)
{ {
QProcess processEncode, processInput; QProcess processEncode, processInput;
@ -77,7 +77,7 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
} }
QStringList cmdLine_Encode; QStringList cmdLine_Encode;
buildCommandLine(cmdLine_Encode, (pipedSource != NULL), frames, m_indexFile, pass, passLogFile); buildCommandLine(cmdLine_Encode, (pipedSource != NULL), clipInfo, m_indexFile, pass, passLogFile);
log("Creating encoder process:"); log("Creating encoder process:");
if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode)) if(!startProcess(processEncode, getBinaryPath(), cmdLine_Encode))
@ -164,12 +164,12 @@ bool AbstractEncoder::runEncodingPass(AbstractSource* pipedSource, const QString
} }
//Process all output //Process all output
PROCESS_PENDING_LINES(processEncode, runEncodingPass_parseLine, patterns, frames, pass, last_progress, size_estimate); PROCESS_PENDING_LINES(processEncode, runEncodingPass_parseLine, patterns, clipInfo, pass, last_progress, size_estimate);
} }
if(!(bTimeout || bAborted)) if(!(bTimeout || bAborted))
{ {
PROCESS_PENDING_LINES(processEncode, runEncodingPass_parseLine, patterns, frames, pass, last_progress, size_estimate); PROCESS_PENDING_LINES(processEncode, runEncodingPass_parseLine, patterns, clipInfo, pass, last_progress, size_estimate);
} }
processEncode.waitForFinished(5000); processEncode.waitForFinished(5000);

View File

@ -28,6 +28,7 @@ class QRegExp;
template<class T> class QList; template<class T> class QList;
template <class T1, class T2> struct QPair; template <class T1, class T2> struct QPair;
class AbstractSource; class AbstractSource;
class ClipInfo;
class AbstractEncoderInfo class AbstractEncoderInfo
{ {
@ -77,15 +78,15 @@ public:
AbstractEncoder(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile, const QString &outputFile); AbstractEncoder(JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, JobStatus &jobStatus, volatile bool *abort, volatile bool *pause, QSemaphore *semaphorePause, const QString &sourceFile, const QString &outputFile);
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 ClipInfo &clipInfo, const int &pass = 0, const QString &passLogFile = QString());
virtual const AbstractEncoderInfo& getEncoderInfo(void) const = 0; virtual const AbstractEncoderInfo& getEncoderInfo(void) const = 0;
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 ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile) = 0;
virtual void runEncodingPass_init(QList<QRegExp*> &patterns) = 0; virtual void runEncodingPass_init(QList<QRegExp*> &patterns) = 0;
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate) = 0; virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate) = 0;
static double estimateSize(const QString &fileName, const double &progress); static double estimateSize(const QString &fileName, const double &progress);
static QString sizeToString(qint64 size); static QString sizeToString(qint64 size);

View File

@ -27,6 +27,7 @@
#include "model_status.h" #include "model_status.h"
#include "mediainfo.h" #include "mediainfo.h"
#include "model_sysinfo.h" #include "model_sysinfo.h"
#include "model_clipInfo.h"
//MUtils //MUtils
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
@ -39,7 +40,7 @@
//x265 version info //x265 version info
static const unsigned int VERSION_NVENCC_MINIMUM_VER = 206; static const unsigned int VERSION_NVENCC_MINIMUM_VER = 206;
static const unsigned int VERSION_NVENCC_MINIMUM_API = 60; static const unsigned int VERSION_NVENCC_MINIMUM_API = 60;
// ------------------------------------------------------------ // ------------------------------------------------------------
// Helper Macros // Helper Macros
@ -49,10 +50,11 @@ static const unsigned int VERSION_NVENCC_MINIMUM_API = 60;
{ \ { \
bool ok = false; \ bool ok = false; \
unsigned int progressFrames = (X)->cap(1).toUInt(&ok); \ unsigned int progressFrames = (X)->cap(1).toUInt(&ok); \
double progress = 0.0; \
setStatus(JobStatus_Running); \ setStatus(JobStatus_Running); \
if(ok && (totalFrames > 0) && (totalFrames != UINT_MAX)) \ if(ok && (clipInfo.getFrameCount() > 0)) \
{ \ { \
const double progress = (double(progressFrames) / double(totalFrames)); \ progress = (double(progressFrames) / double(clipInfo.getFrameCount())); \
if(!qFuzzyCompare(progress, last_progress)) \ if(!qFuzzyCompare(progress, last_progress)) \
{ \ { \
setProgress(floor(progress * 100.0)); \ setProgress(floor(progress * 100.0)); \
@ -60,7 +62,7 @@ static const unsigned int VERSION_NVENCC_MINIMUM_API = 60;
last_progress = progress; \ last_progress = progress; \
} \ } \
} \ } \
setDetails(tr("%1, est. file size %2").arg(line.mid(offset).trimmed(), sizeToString(qRound64(size_estimate)))); \ setDetails(tr("[%1] %2, est. file size %3").arg(QString().sprintf("%.1f%%", 100.0 * progress), line.mid(offset).trimmed(), sizeToString(qRound64(size_estimate)))); \
} \ } \
while(0) while(0)
@ -314,7 +316,7 @@ bool NVEncEncoder::isVersionSupported(const unsigned int &revision, const bool &
// Encoding Functions // Encoding Functions
// ------------------------------------------------------------ // ------------------------------------------------------------
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 ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile)
{ {
switch (m_options->encVariant()) switch (m_options->encVariant())
{ {
@ -386,16 +388,21 @@ void NVEncEncoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, c
void NVEncEncoder::runEncodingPass_init(QList<QRegExp*> &patterns) void NVEncEncoder::runEncodingPass_init(QList<QRegExp*> &patterns)
{ {
patterns << new QRegExp("^(\\d+) frames:"); //regExpFrameCnt patterns << new QRegExp("^(\\d+) frames:");
patterns << new QRegExp("Selected\\s+codec\\s+is\\s+not\\s+supported", Qt::CaseInsensitive);
} }
void NVEncEncoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate) void NVEncEncoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate)
{ {
int offset = -1; int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0) if((offset = patterns[0]->lastIndexIn(line)) >= 0)
{ {
NVENCC_UPDATE_PROGRESS(patterns[0]); NVENCC_UPDATE_PROGRESS(patterns[0]);
} }
else if ((offset = patterns[1]->lastIndexIn(line)) >= 0)
{
log(QString("YOUR HARDWARE DOES *NOT* SUPPORT THE '%1' CODEC !!!\n").arg(s_nvencEncoderInfo.variantToString(m_options->encVariant())));
}
else if(!line.isEmpty()) else if(!line.isEmpty())
{ {
log(line); log(line);

View File

@ -39,12 +39,12 @@ public:
protected: protected:
virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); } virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); }
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 ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile);
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine); virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified); virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
virtual bool checkVersion_succeeded(const int &exitCode); virtual bool checkVersion_succeeded(const int &exitCode);
virtual void runEncodingPass_init(QList<QRegExp*> &patterns); virtual void runEncodingPass_init(QList<QRegExp*> &patterns);
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate); virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate);
}; };

View File

@ -27,6 +27,7 @@
#include "model_status.h" #include "model_status.h"
#include "mediainfo.h" #include "mediainfo.h"
#include "model_sysinfo.h" #include "model_sysinfo.h"
#include "model_clipInfo.h"
//MUtils //MUtils
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
@ -299,7 +300,7 @@ bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &m
// Encoding Functions // Encoding Functions
// ------------------------------------------------------------ // ------------------------------------------------------------
void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile) void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile)
{ {
double crf_int = 0.0, crf_frc = 0.0; double crf_int = 0.0, crf_frc = 0.0;
@ -374,8 +375,11 @@ void X264Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
if(usePipe) if(usePipe)
{ {
if(frames < 1) MUTILS_THROW("Frames not set!"); if (clipInfo.getFrameCount() < 1)
cmdLine << "--frames" << QString::number(frames); {
MUTILS_THROW("Frames not set!");
}
cmdLine << "--frames" << QString::number(clipInfo.getFrameCount());
cmdLine << "--demuxer" << "y4m"; cmdLine << "--demuxer" << "y4m";
cmdLine << "--stdin" << "y4m" << "-"; cmdLine << "--stdin" << "y4m" << "-";
} }
@ -394,7 +398,7 @@ void X264Encoder::runEncodingPass_init(QList<QRegExp*> &patterns)
patterns << new QRegExp("\\[\\s*(\\d+)\\.(\\d+)%\\]\\s+(\\d+)/(\\d+)\\s(\\d+).(\\d+)\\s(\\d+).(\\d+)\\s+(\\d+):(\\d+):(\\d+)\\s+(\\d+):(\\d+):(\\d+)"); //regExpModified patterns << new QRegExp("\\[\\s*(\\d+)\\.(\\d+)%\\]\\s+(\\d+)/(\\d+)\\s(\\d+).(\\d+)\\s(\\d+).(\\d+)\\s+(\\d+):(\\d+):(\\d+)\\s+(\\d+):(\\d+):(\\d+)"); //regExpModified
} }
void X264Encoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate) void X264Encoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate)
{ {
int offset = -1; int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0) if((offset = patterns[0]->lastIndexIn(line)) >= 0)

View File

@ -39,12 +39,12 @@ public:
protected: protected:
virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); } virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); }
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 ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile);
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine); virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified); virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
virtual void runEncodingPass_init(QList<QRegExp*> &patterns); virtual void runEncodingPass_init(QList<QRegExp*> &patterns);
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate); virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate);
}; };

View File

@ -27,6 +27,7 @@
#include "model_status.h" #include "model_status.h"
#include "mediainfo.h" #include "mediainfo.h"
#include "model_sysinfo.h" #include "model_sysinfo.h"
#include "model_clipInfo.h"
//MUtils //MUtils
#include <MUtils/Exception.h> #include <MUtils/Exception.h>
@ -290,7 +291,7 @@ bool X265Encoder::isVersionSupported(const unsigned int &revision, const bool &m
// Encoding Functions // Encoding Functions
// ------------------------------------------------------------ // ------------------------------------------------------------
void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const unsigned int &frames, const QString &indexFile, const int &pass, const QString &passLogFile) void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, const ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile)
{ {
double crf_int = 0.0, crf_frc = 0.0; double crf_int = 0.0, crf_frc = 0.0;
@ -366,8 +367,11 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
if(usePipe) if(usePipe)
{ {
if(frames < 1) MUTILS_THROW("Frames not set!"); if (clipInfo.getFrameCount() < 1)
cmdLine << "--frames" << QString::number(frames); {
MUTILS_THROW("Frames not set!");
}
cmdLine << "--frames" << QString::number(clipInfo.getFrameCount());
cmdLine << "--y4m" << "-"; cmdLine << "--y4m" << "-";
} }
else else
@ -384,7 +388,7 @@ void X265Encoder::runEncodingPass_init(QList<QRegExp*> &patterns)
patterns << new QRegExp("\\[\\s*(\\d+)\\.(\\d+)%\\]\\s+(\\d+)/(\\d+)\\s(\\d+).(\\d+)\\s(\\d+).(\\d+)\\s+(\\d+):(\\d+):(\\d+)\\s+(\\d+):(\\d+):(\\d+)"); //regExpModified patterns << new QRegExp("\\[\\s*(\\d+)\\.(\\d+)%\\]\\s+(\\d+)/(\\d+)\\s(\\d+).(\\d+)\\s(\\d+).(\\d+)\\s+(\\d+):(\\d+):(\\d+)\\s+(\\d+):(\\d+):(\\d+)"); //regExpModified
} }
void X265Encoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate) void X265Encoder::runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate)
{ {
int offset = -1; int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0) if((offset = patterns[0]->lastIndexIn(line)) >= 0)

View File

@ -39,11 +39,11 @@ public:
protected: protected:
virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); } virtual QString getBinaryPath() const { return getEncoderInfo().getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()); }
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 ClipInfo &clipInfo, const QString &indexFile, const int &pass, const QString &passLogFile);
virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine); virtual void checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified); virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
virtual void runEncodingPass_init(QList<QRegExp*> &patterns); virtual void runEncodingPass_init(QList<QRegExp*> &patterns);
virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const unsigned int &totalFrames, const int &pass, double &last_progress, double &size_estimate); virtual void runEncodingPass_parseLine(const QString &line, QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate);
}; };

72
src/model_clipInfo.cpp Normal file
View File

@ -0,0 +1,72 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "model_clipInfo.h"
#include <QPair>
ClipInfo::ClipInfo(const quint32 &count, const quint32 &width, const quint32 &height, const quint32 &numerator, const quint32 &denominator)
{
m_frameCount = count;
m_frameSize_wid = width;
m_frameSize_hei = height;
m_frameRate_num = numerator;
m_frameRate_den = denominator;
}
void ClipInfo::reset(void)
{
m_frameCount = m_frameSize_wid = m_frameSize_hei = m_frameRate_num = m_frameRate_den = 0;
}
const quint32 &ClipInfo::getFrameCount(void) const
{
return m_frameCount;
}
QPair<quint32, quint32> ClipInfo::getFrameSize(void) const
{
return qMakePair(m_frameSize_wid, m_frameSize_hei);
}
QPair<quint32, quint32> ClipInfo::getFrameRate(void) const
{
return qMakePair(m_frameRate_num, m_frameRate_den);
}
void ClipInfo::setFrameCount(const quint32 &count)
{
m_frameCount = count;
}
void ClipInfo::setFrameSize(const quint32 &width, const quint32 &height)
{
m_frameSize_wid = width;
m_frameSize_hei = height;
}
void ClipInfo::setFrameRate(const quint32 &numerator, const quint32 &denominator)
{
m_frameRate_num = numerator;
m_frameRate_den = denominator;
}

48
src/model_clipInfo.h Normal file
View File

@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <qglobal.h>
template <class T1, class T2> struct QPair;
class ClipInfo
{
public:
ClipInfo(const quint32 &count = 0, const quint32 &width = 0, const quint32 &height = 0, const quint32 &numerator = 0, const quint32 &denominator = 0);
const quint32 &getFrameCount(void) const;
QPair<quint32, quint32> getFrameSize(void) const;
QPair<quint32, quint32> getFrameRate(void) const;
void setFrameCount(const quint32 &count);
void setFrameSize(const quint32 &width, const quint32 &height);
void setFrameRate(const quint32 &numerator, const quint32 &denominator);
void reset(void);
protected:
quint32 m_frameCount;
quint32 m_frameSize_wid;
quint32 m_frameSize_hei;
quint32 m_frameRate_num;
quint32 m_frameRate_den;
};

View File

@ -247,7 +247,8 @@ QModelIndex JobListModel::insertJob(EncodeThread *thread)
} }
const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(thread->options()->encType()); const AbstractEncoderInfo &encoderInfo = EncoderFactory::getEncoderInfo(thread->options()->encType());
QString config = encoderInfo.getName(); const QStringList encoderNameParts = encoderInfo.getName().simplified().split(' ', QString::SkipEmptyParts);
QString config = encoderNameParts.isEmpty() ? encoderInfo.getName() : encoderNameParts.first();
switch(encoderInfo.rcModeToType(thread->options()->rcMode())) switch(encoderInfo.rcModeToType(thread->options()->rcMode()))
{ {
case AbstractEncoderInfo::RC_TYPE_QUANTIZER: case AbstractEncoderInfo::RC_TYPE_QUANTIZER:
@ -260,7 +261,7 @@ QModelIndex JobListModel::insertJob(EncodeThread *thread)
} }
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

@ -35,6 +35,7 @@
#include <QProcess> #include <QProcess>
#include <QTextCodec> #include <QTextCodec>
#include <QDir> #include <QDir>
#include <QPair>
// ------------------------------------------------------------ // ------------------------------------------------------------
// Constructor & Destructor // Constructor & Destructor
@ -57,7 +58,7 @@ AbstractSource::~AbstractSource(void)
// Check Source Properties // Check Source Properties
// ------------------------------------------------------------ // ------------------------------------------------------------
bool AbstractSource::checkSourceProperties(unsigned int &frames) bool AbstractSource::checkSourceProperties(ClipInfo &clipInfo)
{ {
QStringList cmdLine; QStringList cmdLine;
QList<QRegExp*> patterns; QList<QRegExp*> patterns;
@ -75,14 +76,9 @@ bool AbstractSource::checkSourceProperties(unsigned int &frames)
bool bTimeout = false; bool bTimeout = false;
bool bAborted = false; bool bAborted = false;
frames = 0;
unsigned int fpsNom = 0;
unsigned int fpsDen = 0;
unsigned int fSizeW = 0;
unsigned int fSizeH = 0;
clipInfo.reset();
unsigned int waitCounter = 0; unsigned int waitCounter = 0;
while(process.state() != QProcess::NotRunning) while(process.state() != QProcess::NotRunning)
@ -119,12 +115,12 @@ bool AbstractSource::checkSourceProperties(unsigned int &frames)
} }
waitCounter = 0; waitCounter = 0;
PROCESS_PENDING_LINES(process, checkSourceProperties_parseLine, patterns, frames, fSizeW, fSizeH, fpsNom, fpsDen); PROCESS_PENDING_LINES(process, checkSourceProperties_parseLine, patterns, clipInfo);
} }
if(!(bTimeout || bAborted)) if(!(bTimeout || bAborted))
{ {
PROCESS_PENDING_LINES(process, checkSourceProperties_parseLine, patterns, frames, fSizeW, fSizeH, fpsNom, fpsDen); PROCESS_PENDING_LINES(process, checkSourceProperties_parseLine, patterns, clipInfo);
} }
process.waitForFinished(); process.waitForFinished();
@ -155,31 +151,31 @@ bool AbstractSource::checkSourceProperties(unsigned int &frames)
return false; return false;
} }
if(frames == 0) if(clipInfo.getFrameCount() < 1)
{ {
log(tr("\nFAILED TO DETERMINE AVS PROPERTIES !!!")); log(tr("\nFAILED TO DETERMINE CLIP PROPERTIES !!!"));
return false; return false;
} }
log(""); log("");
if((fSizeW > 0) && (fSizeH > 0)) const QPair<quint32, quint32> frameSize = clipInfo.getFrameSize();
if((frameSize.first > 0) && (frameSize.second > 0))
{ {
log(tr("Resolution: %1x%2").arg(QString::number(fSizeW), QString::number(fSizeH))); log(tr("Resolution: %1 x %2").arg(QString::number(frameSize.first), QString::number(frameSize.second)));
}
if((fpsNom > 0) && (fpsDen > 0))
{
log(tr("Frame Rate: %1/%2").arg(QString::number(fpsNom), QString::number(fpsDen)));
}
if((fpsNom > 0) && (fpsDen == 0))
{
log(tr("Frame Rate: %1").arg(QString::number(fpsNom)));
}
if(frames > 0)
{
log(tr("No. Frames: %1").arg(QString::number(frames)));
} }
const QPair<quint32, quint32> frameRate = clipInfo.getFrameRate();
if((frameRate.first > 0) && (frameRate.second > 0))
{
log(tr("Frame Rate: %1/%2").arg(QString::number(frameRate.first), QString::number(frameRate.second)));
}
else if(frameRate.first > 0)
{
log(tr("Frame Rate: %1").arg(QString::number(frameRate.first)));
}
log(tr("No. Frames: %1").arg(QString::number(clipInfo.getFrameCount())));
return true; return true;
} }

View File

@ -23,6 +23,7 @@
#include "tool_abstract.h" #include "tool_abstract.h"
#include "model_options.h" #include "model_options.h"
#include "model_clipInfo.h"
class QRegExp; class QRegExp;
template<class T> class QList; template<class T> class QList;
@ -41,7 +42,7 @@ public:
virtual ~AbstractSource(void); virtual ~AbstractSource(void);
virtual bool isSourceAvailable(void) = 0; virtual bool isSourceAvailable(void) = 0;
virtual bool checkSourceProperties(unsigned int &frames); virtual bool checkSourceProperties(ClipInfo &clipInfo);
virtual bool createProcess(QProcess &processEncode, QProcess&processInput); virtual bool createProcess(QProcess &processEncode, QProcess&processInput);
virtual void flushProcess(QProcess &processInput) = 0; virtual void flushProcess(QProcess &processInput) = 0;
@ -49,7 +50,7 @@ public:
protected: protected:
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0; virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine) = 0;
virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) = 0; virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo) = 0;
virtual void buildCommandLine(QStringList &cmdLine) = 0; virtual void buildCommandLine(QStringList &cmdLine) = 0;

View File

@ -168,37 +168,52 @@ void AvisynthSource::checkSourceProperties_init(QList<QRegExp*> &patterns, QStri
patterns << new QRegExp(": (\\d+)x(\\d+), (\\d+)/(\\d+) fps, (\\d+) frames"); patterns << new QRegExp(": (\\d+)x(\\d+), (\\d+)/(\\d+) fps, (\\d+) frames");
} }
void AvisynthSource::checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) void AvisynthSource::checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo)
{ {
int offset = -1; int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0) if((offset = patterns[0]->lastIndexIn(line)) >= 0)
{ {
bool ok1 = false, ok2 = false; bool ok[4] = { false, false, false, false };
bool ok3 = false, ok4 = false; quint32 temp[4];
unsigned int temp1 = patterns[0]->cap(1).toUInt(&ok1); temp[0] = patterns[0]->cap(1).toUInt(&ok[0]);
unsigned int temp2 = patterns[0]->cap(2).toUInt(&ok2); temp[1] = patterns[0]->cap(2).toUInt(&ok[1]);
unsigned int temp3 = patterns[0]->cap(3).toUInt(&ok3); temp[2] = patterns[0]->cap(3).toUInt(&ok[2]);
unsigned int temp4 = patterns[0]->cap(4).toUInt(&ok4); temp[3] = patterns[0]->cap(4).toUInt(&ok[3]);
if(ok1) fSizeW = temp1; if (ok[0] && ok[1])
if(ok2) fSizeH = temp2; {
if(ok3) fpsNom = temp3; clipInfo.setFrameSize(temp[0], temp[1]);
if(ok4) frames = temp4; }
if (ok[2])
{
clipInfo.setFrameRate(temp[2], 0);
}
if (ok[3])
{
clipInfo.setFrameCount(temp[3]);
}
} }
else if((offset = patterns[1]->lastIndexIn(line)) >= 0) else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
{ {
bool ok1 = false, ok2 = false; bool ok[5] = { false, false, false, false, false };
bool ok3 = false, ok4 = false, ok5 = false; quint32 temp[5];
unsigned int temp1 = patterns[1]->cap(1).toUInt(&ok1); temp[0] = patterns[1]->cap(1).toUInt(&ok[0]);
unsigned int temp2 = patterns[1]->cap(2).toUInt(&ok2); temp[1] = patterns[1]->cap(2).toUInt(&ok[1]);
unsigned int temp3 = patterns[1]->cap(3).toUInt(&ok3); temp[2] = patterns[1]->cap(3).toUInt(&ok[2]);
unsigned int temp4 = patterns[1]->cap(4).toUInt(&ok4); temp[3] = patterns[1]->cap(4).toUInt(&ok[3]);
unsigned int temp5 = patterns[1]->cap(5).toUInt(&ok5); temp[4] = patterns[1]->cap(5).toUInt(&ok[4]);
if(ok1) fSizeW = temp1; if (ok[0] && ok[1])
if(ok2) fSizeH = temp2; {
if(ok3) fpsNom = temp3; clipInfo.setFrameSize(temp[0], temp[1]);
if(ok4) fpsDen = temp4; }
if(ok5) frames = temp5; if (ok[2] && ok[3])
{
clipInfo.setFrameRate(temp[2], temp[3]);
}
if (ok[4])
{
clipInfo.setFrameCount(temp[4]);
}
} }
if(!line.isEmpty()) if(!line.isEmpty())

View File

@ -47,7 +47,7 @@ protected:
virtual bool checkVersion_succeeded(const int &exitCode); virtual bool checkVersion_succeeded(const int &exitCode);
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine); virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen); virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo);
virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)))); } virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getAvisynth(SysinfoModel::Avisynth_X86)))); }
virtual void buildCommandLine(QStringList &cmdLine); virtual void buildCommandLine(QStringList &cmdLine);

View File

@ -27,6 +27,7 @@
#include <QDir> #include <QDir>
#include <QProcess> #include <QProcess>
#include <QPair>
static const unsigned int VER_X264_VSPIPE_API = 3; static const unsigned int VER_X264_VSPIPE_API = 3;
static const unsigned int VER_X264_VSPIPE_VER = 24; static const unsigned int VER_X264_VSPIPE_VER = 24;
@ -170,7 +171,7 @@ void VapoursynthSource::checkSourceProperties_init(QList<QRegExp*> &patterns, QS
patterns << new QRegExp("\\bFPS:\\s+(\\d+)/(\\d+)\\b"); patterns << new QRegExp("\\bFPS:\\s+(\\d+)/(\\d+)\\b");
} }
void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen) void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo)
{ {
int offset = -1; int offset = -1;
@ -178,25 +179,25 @@ void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QLi
{ {
bool ok = false; bool ok = false;
unsigned int temp = patterns[0]->cap(1).toUInt(&ok); unsigned int temp = patterns[0]->cap(1).toUInt(&ok);
if(ok) frames = temp; if(ok) clipInfo.setFrameCount(temp);
} }
if((offset = patterns[1]->lastIndexIn(line)) >= 0) if((offset = patterns[1]->lastIndexIn(line)) >= 0)
{ {
bool ok = false; bool ok = false;
unsigned int temp =patterns[1]->cap(1).toUInt(&ok); unsigned int temp =patterns[1]->cap(1).toUInt(&ok);
if(ok) fSizeW = temp; if(ok) clipInfo.setFrameSize(temp, clipInfo.getFrameSize().second);
} }
if((offset = patterns[2]->lastIndexIn(line)) >= 0) if((offset = patterns[2]->lastIndexIn(line)) >= 0)
{ {
bool ok = false; bool ok = false;
unsigned int temp = patterns[2]->cap(1).toUInt(&ok); unsigned int temp = patterns[2]->cap(1).toUInt(&ok);
if(ok) fSizeH = temp; if(ok) clipInfo.setFrameSize(clipInfo.getFrameSize().first, temp);
} }
if((offset = patterns[3]->lastIndexIn(line)) >= 0) if((offset = patterns[3]->lastIndexIn(line)) >= 0)
{ {
bool ok = false; bool ok = false;
unsigned int temp = patterns[3]->cap(1).toUInt(&ok); unsigned int temp = patterns[3]->cap(1).toUInt(&ok);
if(ok) fpsNom = temp; if(ok) clipInfo.setFrameRate(temp, 0);
} }
if((offset = patterns[4]->lastIndexIn(line)) >= 0) if((offset = patterns[4]->lastIndexIn(line)) >= 0)
{ {
@ -205,8 +206,7 @@ void VapoursynthSource::checkSourceProperties_parseLine(const QString &line, QLi
unsigned int temp2 = patterns[4]->cap(2).toUInt(&ok2); unsigned int temp2 = patterns[4]->cap(2).toUInt(&ok2);
if(ok1 && ok2) if(ok1 && ok2)
{ {
fpsNom = temp1; clipInfo.setFrameRate(temp1, temp2);
fpsDen = temp2;
} }
} }

View File

@ -46,7 +46,7 @@ protected:
virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified); virtual void checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified);
virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine); virtual void checkSourceProperties_init(QList<QRegExp*> &patterns, QStringList &cmdLine);
virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &frames, unsigned int &fSizeW, unsigned int &fSizeH, unsigned int &fpsNom, unsigned int &fpsDen); virtual void checkSourceProperties_parseLine(const QString &line, QList<QRegExp*> &patterns, ClipInfo &clipInfo);
virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X86)))); } virtual QString getBinaryPath() const { return getSourceInfo().getBinaryPath(m_sysinfo, m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64) && m_sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X64) && (m_preferences->getPrefer64BitSource() || (!m_sysinfo->getVapourSynth(SysinfoModel::VapourSynth_X86)))); }
virtual void buildCommandLine(QStringList &cmdLine); virtual void buildCommandLine(QStringList &cmdLine);

View File

@ -26,6 +26,7 @@
#include "model_options.h" #include "model_options.h"
#include "model_preferences.h" #include "model_preferences.h"
#include "model_sysinfo.h" #include "model_sysinfo.h"
#include "model_clipInfo.h"
#include "job_object.h" #include "job_object.h"
#include "mediainfo.h" #include "mediainfo.h"
@ -267,7 +268,7 @@ void EncodeThread::encode(void)
log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("<None>") : m_options->customEncParams())); log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("<None>") : m_options->customEncParams()));
bool ok = false; bool ok = false;
unsigned int frames = 0; ClipInfo clipInfo;
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Check Versions // Check Versions
@ -317,7 +318,7 @@ void EncodeThread::encode(void)
if(m_pipedSource) if(m_pipedSource)
{ {
log(tr("\n--- GET SOURCE INFO ---\n")); log(tr("\n--- GET SOURCE INFO ---\n"));
ok = m_pipedSource->checkSourceProperties(frames); ok = m_pipedSource->checkSourceProperties(clipInfo);
CHECK_STATUS(m_abort, ok); CHECK_STATUS(m_abort, ok);
} }
@ -331,17 +332,17 @@ void EncodeThread::encode(void)
const QString passLogFile = getPasslogFile(m_outputFileName); const QString passLogFile = getPasslogFile(m_outputFileName);
log(tr("\n--- ENCODING PASS #1 ---\n")); log(tr("\n--- ENCODING PASS #1 ---\n"));
ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames, 1, passLogFile); ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo, 1, passLogFile);
CHECK_STATUS(m_abort, ok); CHECK_STATUS(m_abort, ok);
log(tr("\n--- ENCODING PASS #2 ---\n")); log(tr("\n--- ENCODING PASS #2 ---\n"));
ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames, 2, passLogFile); ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo, 2, passLogFile);
CHECK_STATUS(m_abort, ok); CHECK_STATUS(m_abort, ok);
} }
else else
{ {
log(tr("\n--- ENCODING VIDEO ---\n")); log(tr("\n--- ENCODING VIDEO ---\n"));
ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames); ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo);
CHECK_STATUS(m_abort, ok); CHECK_STATUS(m_abort, ok);
} }

View File

@ -288,6 +288,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\$(ProjectName)\MOC_%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild> </CustomBuild>
<ClInclude Include="src\encoder_nvenc.h" /> <ClInclude Include="src\encoder_nvenc.h" />
<ClInclude Include="src\model_clipInfo.h" />
<ClInclude Include="src\source_factory.h" /> <ClInclude Include="src\source_factory.h" />
<ClInclude Include="tmp\x264_launcher\UIC_win_about.h" /> <ClInclude Include="tmp\x264_launcher\UIC_win_about.h" />
<ClInclude Include="tmp\x264_launcher\UIC_win_addJob.h" /> <ClInclude Include="tmp\x264_launcher\UIC_win_addJob.h" />
@ -437,6 +438,7 @@ copy /Y "$(ProjectDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\plugins\im
<ClCompile Include="src\job_object.cpp" /> <ClCompile Include="src\job_object.cpp" />
<ClCompile Include="src\input_filter.cpp" /> <ClCompile Include="src\input_filter.cpp" />
<ClCompile Include="src\mediainfo.cpp" /> <ClCompile Include="src\mediainfo.cpp" />
<ClCompile Include="src\model_clipInfo.cpp" />
<ClCompile Include="src\model_jobList.cpp" /> <ClCompile Include="src\model_jobList.cpp" />
<ClCompile Include="src\model_logFile.cpp" /> <ClCompile Include="src\model_logFile.cpp" />
<ClCompile Include="src\model_options.cpp" /> <ClCompile Include="src\model_options.cpp" />

View File

@ -114,6 +114,9 @@
<ClInclude Include="src\encoder_nvenc.h"> <ClInclude Include="src\encoder_nvenc.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\model_clipInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\main.cpp"> <ClCompile Include="src\main.cpp">
@ -272,6 +275,9 @@
<ClCompile Include="src\encoder_nvenc.cpp"> <ClCompile Include="src\encoder_nvenc.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\model_clipInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="src\win_main.h"> <CustomBuild Include="src\win_main.h">