OSDN Git Service

75d42f4d79f1789547022fc7de72078d23a39579
[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 #include "global.h"
25 #include "model_sysinfo.h"
26 #include "model_preferences.h"
27 #include "model_options.h"
28
29 /* --- Encooders --- */
30
31 QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel::EncType &encType, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant)
32 {
33         QString baseName, arch, variant;
34
35         //Encoder Type
36         switch(encType)
37         {
38                 case OptionsModel::EncType_X264: baseName = "x264"; break;
39                 case OptionsModel::EncType_X265: baseName = "x265"; break;
40         }
41         
42         //Architecture
43         switch(encArch)
44         {
45                 case OptionsModel::EncArch_x32: arch = "x86"; break;
46                 case OptionsModel::EncArch_x64: arch = "x64"; break;
47         }
48
49         //Encoder Variant
50         switch(encVariant)
51         {
52         case OptionsModel::EncVariant_LoBit:
53                 switch(encType)
54                 {
55                         case OptionsModel::EncType_X264:
56                         case OptionsModel::EncType_X265: variant = "8bit"; break;
57                 }
58                 break;
59         case OptionsModel::EncVariant_HiBit:
60                 switch(encType)
61                 {
62                         case OptionsModel::EncType_X264: variant = "10bit"; break;
63                         case OptionsModel::EncType_X265: variant = "16bit"; break;
64                 }
65                 break;
66         }
67
68         //Sanity check
69         if(baseName.isEmpty() || arch.isEmpty() || variant.isEmpty())
70         {
71                 THROW("Failed to determine the encoder binarty path!");
72         }
73
74         //Return path
75         return QString("%1/toolset/%2/%3_%4_%2.exe").arg(sysinfo->getAppPath(), arch, baseName, variant);
76 }
77
78 QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
79 {
80         return ENC_BINARY(sysinfo, options->encType(), options->encArch(), options->encVariant());
81 }
82
83 /* --- Avisynth --- */
84
85 QString AVS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
86 {
87         return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
88 }
89
90 QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
91 {
92         return AVS_BINARY(sysinfo, preferences->getUseAvisyth64Bit() && sysinfo->hasX64Support());
93 }
94
95 /* --- VapurSynth --- */
96
97 QString VPS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
98 {
99         return QString("%1/vspipe.exe").arg(sysinfo->getVPSPath());
100 }
101
102 QString VPS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
103 {
104         return VPS_BINARY(sysinfo, sysinfo->hasX64Support());
105 }