OSDN Git Service

Updated CA certificates file for cURL.
[x264-launcher/x264-launcher.git] / src / encoder_x265.cpp
index 73355fb..e877431 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2021 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
@@ -40,8 +40,8 @@
 #include <QPair>
 
 //x265 version info
-static const unsigned int VERSION_X265_MINIMUM_VER = 23;
-static const unsigned int VERSION_X265_MINIMUM_REV = 28;
+static const unsigned int VERSION_X265_MINIMUM_VER = 35;
+static const unsigned int VERSION_X265_MINIMUM_REV = 20;
 
 // ------------------------------------------------------------
 // Helper Macros
@@ -119,7 +119,7 @@ public:
 
        virtual QStringList getTunings(void) const
        {
-               return QStringList() << "Grain" << "PSNR" << "SSIM" << "FastDecode" << "ZeroLatency";
+               return QStringList() << "Grain" << "PSNR" << "SSIM" << "FastDecode" << "ZeroLatency" << "Animation";
        }
 
        virtual QStringList getPresets(void) const
@@ -160,21 +160,18 @@ public:
 
        virtual QString getBinaryPath(const SysinfoModel *sysinfo, const quint32 &encArch, const quint32 &encVariant) const
        {
-               QString arch, variant;
+               QString arch;
                switch(encArch)
                {
                        case 0: arch = "x86"; break;
                        case 1: arch = "x64"; break;
                        default: MUTILS_THROW("Unknown encoder arch!");
                }
-               switch(encVariant)
+               if((encVariant < 0) || (encVariant > 2))
                {
-                       case 0: variant =  "8bit"; break;
-                       case 1: variant = "10bit"; break;
-                       case 2: variant = "12bit"; break;
-                       default: MUTILS_THROW("Unknown encoder arch!");
+                       MUTILS_THROW("Unknown encoder variant!");
                }
-               return QString("%1/toolset/%2/x265_%3_%2.exe").arg(sysinfo->getAppPath(), arch, variant);
+               return QString("%1/toolset/%2/x265_%2.exe").arg(sysinfo->getAppPath(), arch);
        }
 
        virtual QString getHelpCommand(void) const
@@ -226,31 +223,40 @@ QString X265Encoder::getName(void) const
 void X265Encoder::checkVersion_init(QList<QRegExp*> &patterns, QStringList &cmdLine)
 {
        cmdLine << "--version";
-       patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\+(\\d+)\\b", Qt::CaseInsensitive);
-       patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\b", Qt::CaseInsensitive);
+       patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\+(\\d+)\\b",      Qt::CaseInsensitive);
+       patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\_Au\\+(\\d+)\\b", Qt::CaseInsensitive);
+       patterns << new QRegExp("\\bHEVC\\s+encoder\\s+version\\s+(\\d)\\.(\\d+)\\b",               Qt::CaseInsensitive);
 }
 
 void X265Encoder::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)
+       for (size_t q = 0; q < 2; ++q)
        {
-               unsigned int temp[3];
-               if(MUtils::regexp_parse_uint32(*patterns[0], temp, 3))
+               if ((offset = patterns[q]->lastIndexIn(line)) >= 0)
                {
-                       core  = (10 * temp[0]) + temp[1];
-                       build = temp[2];
+                       unsigned int temp[3];
+                       if (MUtils::regexp_parse_uint32(*patterns[q], temp, 3))
+                       {
+                               core = (10 * temp[0]) + temp[1];
+                               build = temp[2];
+                               break;
+                       }
                }
        }
-       else if((offset = patterns[1]->lastIndexIn(line)) >= 0)
+
+       if ((!core) || (core == UINT_MAX))
        {
-               unsigned int temp[2];
-               if (MUtils::regexp_parse_uint32(*patterns[0], temp, 2))
+               if ((offset = patterns[2]->lastIndexIn(line)) >= 0)
                {
-                       core = (10 * temp[0]) + temp[1];
+                       unsigned int temp[2];
+                       if (MUtils::regexp_parse_uint32(*patterns[2], temp, 2))
+                       {
+                               core = (10 * temp[0]) + temp[1];
+                       }
+                       build = 0;
                }
-               build = 0;
        }
 
        if(!line.isEmpty())
@@ -294,6 +300,22 @@ void X265Encoder::buildCommandLine(QStringList &cmdLine, const bool &usePipe, co
 {
        double crf_int = 0.0, crf_frc = 0.0;
 
+       cmdLine << "-D";
+       switch (m_options->encVariant())
+       {
+       case 0:
+               cmdLine << QString::number(8);
+               break;
+       case 1:
+               cmdLine << QString::number(10);
+               break;
+       case 2:
+               cmdLine << QString::number(12);
+               break;
+       default:
+               MUTILS_THROW("Unknown encoder variant!");
+       }
+
        switch(m_options->rcMode())
        {
        case 0: