///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
-// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 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
#include "model_status.h"
#include "mediainfo.h"
#include "model_sysinfo.h"
+#include "model_clipInfo.h"
//MUtils
+#include <MUtils/Global.h>
#include <MUtils/Exception.h>
//Qt
#include <QPair>
//x264 version info
-static const unsigned int VERSION_X264_MINIMUM_REV = 2668;
-static const unsigned int VERSION_X264_CURRENT_API = 148;
+static const unsigned int VERSION_X264_MINIMUM_REV = 3049;
+static const unsigned int VERSION_X264_CURRENT_API = 163;
// ------------------------------------------------------------
// Helper Macros
case 1: arch = "x64"; break;
default: MUTILS_THROW("Unknown encoder arch!");
}
- switch(encVariant)
+ if ((encVariant < 0) || (encVariant > 1))
{
- case 0: variant = "8bit"; break;
- case 1: variant = "10bit"; break;
- default: MUTILS_THROW("Unknown encoder variant!");
+ 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_%2.exe").arg(sysinfo->getAppPath(), arch);
+ }
+
+ virtual QString getHelpCommand(void) const
+ {
+ return "--fullhelp";
}
};
patterns << new QRegExp("\\bx264\\s+(\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
}
-void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
+void X264Encoder::checkVersion_parseLine(const QString &line, const QList<QRegExp*> &patterns, unsigned int &core, unsigned int &build, bool &modified)
{
- int offset = -1;
-
- if((offset = patterns[0]->lastIndexIn(line)) >= 0)
+ if(patterns[0]->lastIndexIn(line) >= 0)
{
- bool ok1 = false, ok2 = false;
- unsigned int temp1 = patterns[0]->cap(2).toUInt(&ok1);
- unsigned int temp2 = patterns[0]->cap(3).toUInt(&ok2);
- if(ok1 && ok2 && (temp1 > 0) && (temp2 > 0))
+ unsigned int temp[3];
+ if(MUtils::regexp_parse_uint32(*patterns[0], temp, 3))
{
- core = temp1;
- build = temp2;
+ core = temp[1];
+ build = temp[2];
}
}
- else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
+ else if(patterns[1]->lastIndexIn(line) >= 0)
{
- bool ok1 = false, ok2 = false;
- unsigned int temp1 = patterns[1]->cap(2).toUInt(&ok1);
- unsigned int temp2 = patterns[1]->cap(3).toUInt(&ok2);
- if(ok1 && ok2 && (temp1 > 0) && (temp2 > 0))
+ unsigned int temp[3];
+ if (MUtils::regexp_parse_uint32(*patterns[1], temp, 3))
{
- core = temp1;
- build = temp2;
+ core = temp[1];
+ build = temp[2];
}
modified = true;
}
// 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;
- switch(m_options->rcMode())
+ cmdLine << "--output-depth";
+ switch (m_options->encVariant())
{
case 0:
- cmdLine << "--qp" << QString::number(qRound(m_options->quantizer()));
+ cmdLine << QString::number(8);
break;
case 1:
+ cmdLine << QString::number(10);
+ break;
+ default:
+ MUTILS_THROW("Unknown encoder variant!");
+ }
+
+ switch(m_options->rcMode())
+ {
+ case 0:
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)));
break;
+ case 1:
+ cmdLine << "--qp" << QString::number(qRound(m_options->quantizer()));
+ break;
case 2:
case 3:
cmdLine << "--bitrate" << QString::number(m_options->bitrate());
if(usePipe)
{
- if(frames < 1) MUTILS_THROW("Frames not set!");
- cmdLine << "--frames" << QString::number(frames);
+ if (clipInfo.getFrameCount() < 1)
+ {
+ MUTILS_THROW("Frames not set!");
+ }
+ cmdLine << "--frames" << QString::number(clipInfo.getFrameCount());
cmdLine << "--demuxer" << "y4m";
cmdLine << "--stdin" << "y4m" << "-";
}
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, const QList<QRegExp*> &patterns, const ClipInfo &clipInfo, const int &pass, double &last_progress, double &size_estimate)
{
int offset = -1;
if((offset = patterns[0]->lastIndexIn(line)) >= 0)