1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "encoder_x264.h"
24 #include "model_options.h"
26 #include <QStringList>
30 static const unsigned int X264_VERSION_X264_MINIMUM_REV = 2380;
31 static const unsigned int X264_VERSION_X264_CURRENT_API = 142;
33 X264Encoder::X264Encoder(const QUuid *jobId, JobObject *jobObject, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences, volatile bool *abort)
35 AbstractEncoder(jobId, jobObject, options, sysinfo, preferences, abort)
37 if(options->encType() != OptionsModel::EncType_X264)
39 throw "Invalid encoder type!";
44 X264Encoder::~X264Encoder(void)
46 /*Nothing to do here*/
49 void X264Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
51 cmdLine << "--version";
52 patterns << new QRegExp("\\bx264\\s(\\d)\\.(\\d+)\\.(\\d+)\\s([a-f0-9]{7})", Qt::CaseInsensitive);
53 patterns << new QRegExp("\\bx264 (\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
56 void X264Encoder::checkVersion_parseLine(const QString &line, QList<QRegExp*> &patterns, unsigned int &coreVers, unsigned int &revision, bool &modified)
59 if((offset = patterns[0]->lastIndexIn(line)) >= 0)
61 bool ok1 = false, ok2 = false;
62 unsigned int temp1 = patterns[0]->cap(2).toUInt(&ok1);
63 unsigned int temp2 = patterns[0]->cap(3).toUInt(&ok2);
64 if(ok1) coreVers = temp1;
65 if(ok2) revision = temp2;
67 else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
69 bool ok1 = false, ok2 = false;
70 unsigned int temp1 = patterns[1]->cap(2).toUInt(&ok1);
71 unsigned int temp2 = patterns[1]->cap(3).toUInt(&ok2);
72 if(ok1) coreVers = temp1;
73 if(ok2) revision = temp2;
78 void X264Encoder::printVersion(const unsigned int &revision, const bool &modified)
80 log(tr("\nx264 revision: %1 (core #%2)").arg(QString::number(revision % REV_MULT), QString::number(revision / REV_MULT)).append(modified ? tr(" - with custom patches!") : QString()));
83 bool X264Encoder::isVersionSupported(const unsigned int &revision, const bool &modified)
85 if((revision % REV_MULT) < X264_VERSION_X264_MINIMUM_REV)
87 log(tr("\nERROR: Your revision of x264 is too old! (Minimum required revision is %1)").arg(QString::number(X264_VERSION_X264_MINIMUM_REV)));
91 if((revision / REV_MULT) != X264_VERSION_X264_CURRENT_API)
93 log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
94 log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(X264_VERSION_X264_CURRENT_API)));