OSDN Git Service

Removed a lot of old cruft and use MUtils functions where possible.
[x264-launcher/x264-launcher.git] / src / binaries.cpp
index 10916d7..66993f3 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2015 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 "binaries.h"
 
+//Internal
+#include "global.h"
 #include "model_sysinfo.h"
 #include "model_preferences.h"
 #include "model_options.h"
 
-QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
+//MUtils
+#include <MUtils/Exception.h>
+
+/* --- Encooders --- */
+
+QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel::EncType &encType, const OptionsModel::EncArch &encArch, const OptionsModel::EncVariant &encVariant)
 {
        QString baseName, arch, variant;
 
        //Encoder Type
-       switch(options->encType())
+       switch(encType)
        {
                case OptionsModel::EncType_X264: baseName = "x264"; break;
                case OptionsModel::EncType_X265: baseName = "x265"; break;
        }
        
        //Architecture
-       switch(options->encArch())
+       switch(encArch)
        {
                case OptionsModel::EncArch_x32: arch = "x86"; break;
                case OptionsModel::EncArch_x64: arch = "x64"; break;
        }
 
        //Encoder Variant
-       switch(options->encVariant())
+       switch(encVariant)
        {
        case OptionsModel::EncVariant_LoBit:
-               switch(options->encType())
+               switch(encType)
                {
                        case OptionsModel::EncType_X264:
                        case OptionsModel::EncType_X265: variant = "8bit"; break;
                }
                break;
        case OptionsModel::EncVariant_HiBit:
-               switch(options->encType())
+               switch(encType)
                {
                        case OptionsModel::EncType_X264: variant = "10bit"; break;
                        case OptionsModel::EncType_X265: variant = "16bit"; break;
@@ -65,14 +72,38 @@ QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
        //Sanity check
        if(baseName.isEmpty() || arch.isEmpty() || variant.isEmpty())
        {
-               throw "Failed to determine the encoder binarty path!";
+               MUTILS_THROW("Failed to determine the encoder binarty path!");
        }
 
        //Return path
        return QString("%1/toolset/%2/%3_%4_%2.exe").arg(sysinfo->getAppPath(), arch, baseName, variant);
 }
 
+QString ENC_BINARY(const SysinfoModel *sysinfo, const OptionsModel *options)
+{
+       return ENC_BINARY(sysinfo, options->encType(), options->encArch(), options->encVariant());
+}
+
+/* --- Avisynth --- */
+
+QString AVS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
+{
+       return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), (x64 ? "x64": "x86"));
+}
+
 QString AVS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
 {
-       return QString("%1/toolset/%2/avs2yuv_%2.exe").arg(sysinfo->getAppPath(), preferences->useAvisyth64Bit() ? "x64": "x86");
+       return AVS_BINARY(sysinfo, preferences->getUseAvisyth64Bit() && sysinfo->hasX64Support());
+}
+
+/* --- VapurSynth --- */
+
+QString VPS_BINARY(const SysinfoModel *sysinfo, const bool& x64)
+{
+       return QString("%1/vspipe.exe").arg(sysinfo->getVPSPath());
+}
+
+QString VPS_BINARY(const SysinfoModel *sysinfo, const PreferencesModel *preferences)
+{
+       return VPS_BINARY(sysinfo, sysinfo->hasX64Support());
 }