OSDN Git Service

Removed a lot of old cruft and use MUtils functions where possible.
[x264-launcher/x264-launcher.git] / src / binaries.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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.
9 //
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.
14 //
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.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "binaries.h"
23
24 //Internal
25 #include "global.h"
26 #include "model_sysinfo.h"
27 #include "model_preferences.h"
28 #include "model_options.h"
29
30 //MUtils
31 #include <MUtils/Exception.h>
32
33 /* --- Encooders --- */
34
35 QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel::EncType &encType, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant)
36 {
37         QString baseName, arch, variant;
38
39         //Encoder Type
40         switch(encType)
41         {
42                 case OptionsModel::EncType_X264: baseName = "x264"; break;
43                 case OptionsModel::EncType_X265: baseName = "x265"; break;
44         }
45         
46         //Architecture
47         switch(encArch)
48         {
49                 case OptionsModel::EncArch_x32: arch = "x86"; break;
50                 case OptionsModel::EncArch_x64: arch = "x64"; break;
51         }
52
53         //Encoder Variant
54         switch(encVariant)
55         {
56         case OptionsModel::EncVariant_LoBit:
57                 switch(encType)
58                 {
59                         case OptionsModel::EncType_X264:
60                         case OptionsModel::EncType_X265: variant = "8bit"; break;
61                 }
62                 break;
63         case OptionsModel::EncVariant_HiBit:
64                 switch(encType)
65                 {
66                         case OptionsModel::EncType_X264: variant = "10bit"; break;
67                         case OptionsModel::EncType_X265: variant = "16bit"; break;
68                 }
69                 break;
70         }
71
72         //Sanity check
73         if(baseName.isEmpty() || arch.isEmpty() || variant.isEmpty())
74         {
75                 MUTILS_THROW("Failed to determine the encoder binarty path!");
76         }
77
78         //Return path
79         return QString("%1/toolset/%2/%3_%4_%2.exe").arg(sysinfo->getAppPath(), arch, baseName, variant);
80 }
81
82 QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
83 {
84         return ENC_BINARY(sysinfo, options->encType(), options->encArch(), options->encVariant());
85 }
86
87 /* --- Avisynth --- */
88
89 QString AVS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
90 {
91         return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
92 }
93
94 QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
95 {
96         return AVS_BINARY(sysinfo, preferences->getUseAvisyth64Bit() && sysinfo->hasX64Support());
97 }
98
99 /* --- VapurSynth --- */
100
101 QString VPS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
102 {
103         return QString("%1/vspipe.exe").arg(sysinfo->getVPSPath());
104 }
105
106 QString VPS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
107 {
108         return VPS_BINARY(sysinfo, sysinfo->hasX64Support());
109 }