Removed dependency on CLIParser from "global" functions.

This commit is contained in:
LoRd_MuldeR 2014-02-02 15:54:39 +01:00
parent 02b61aa490
commit 2d2e5f193b
5 changed files with 50 additions and 42 deletions

View File

@ -28,6 +28,8 @@
// Pre-defined commands // Pre-defined commands
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define MAKE_ARG(X,Y,Z) { "--"X, (Y), (Z) }
static struct static struct
{ {
const char *longName; const char *longName;
@ -36,22 +38,22 @@ static struct
} }
s_parameters[] = s_parameters[] =
{ {
{ "add", 1, CLI_PARAM_ADD_FILE }, MAKE_ARG( "add", 1, CLI_PARAM_ADD_FILE ),
{ "add-file", 1, CLI_PARAM_ADD_FILE }, MAKE_ARG( "add-file", 1, CLI_PARAM_ADD_FILE ),
{ "add-job", 3, CLI_PARAM_ADD_JOB }, MAKE_ARG( "add-job", 3, CLI_PARAM_ADD_JOB ),
{ "force-start", 0, CLI_PARAM_FORCE_START }, MAKE_ARG( "force-start", 0, CLI_PARAM_FORCE_START ),
{ "no-force-start", 0, CLI_PARAM_NO_FORCE_START }, MAKE_ARG( "no-force-start", 0, CLI_PARAM_NO_FORCE_START ),
{ "force-enqueue", 0, CLI_PARAM_FORCE_ENQUEUE }, MAKE_ARG( "force-enqueue", 0, CLI_PARAM_FORCE_ENQUEUE ),
{ "no-force-enqueue", 0, CLI_PARAM_NO_FORCE_ENQUEUE }, MAKE_ARG( "no-force-enqueue", 0, CLI_PARAM_NO_FORCE_ENQUEUE ),
{ "skip-avisynth-check", 0, CLI_PARAM_SKIP_AVS_CHECK }, MAKE_ARG( "skip-avisynth-check", 0, CLI_PARAM_SKIP_AVS_CHECK ),
{ "skip-vapoursynth-check", 0, CLI_PARAM_SKIP_VPS_CHECK }, MAKE_ARG( "skip-vapoursynth-check", 0, CLI_PARAM_SKIP_VPS_CHECK ),
{ "force-cpu-no-64bit", 0, CLI_PARAM_FORCE_CPU_NO_X64 }, MAKE_ARG( "no-deadlock-detection", 0, CLI_PARAM_NO_DEADLOCK ),
{ "force-cpu-no-64bit", 0, CLI_PARAM_FORCE_CPU_NO_SSE }, MAKE_ARG( "no-style", 0, CLI_PARAM_NO_GUI_STYLE ),
{ "force-cpu-no-64bit", 0, CLI_PARAM_FORCE_CPU_NO_INT }, MAKE_ARG( "console", 0, CLI_PARAM_OTHER ),
{ "no-deadlock-detection", 0, CLI_PARAM_NO_DEADLOCK }, MAKE_ARG( "no-console", 0, CLI_PARAM_OTHER ),
{ "console", 0, CLI_PARAM_DEBUG_CONSOLE }, MAKE_ARG( "force-cpu-no-64bit", 0, CLI_PARAM_OTHER ),
{ "no-console", 0, CLI_PARAM_NO_DEBUG_CONSOLE }, MAKE_ARG( "force-cpu-no-sse", 0, CLI_PARAM_OTHER ),
{ "no-style", 0, CLI_PARAM_NO_GUI_STYLE }, MAKE_ARG( "force-cpu-no-intel", 0, CLI_PARAM_OTHER ),
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@ -85,7 +87,7 @@ bool CLIParser::nextOption(int &identifier, QStringList *options)
const QString current = *(m_iter++); const QString current = *(m_iter++);
for(size_t i = 0; s_parameters[i].longName != NULL; i++) for(size_t i = 0; s_parameters[i].longName != NULL; i++)
{ {
if(X264_STRCMP(current, QString("--%1").arg(QString::fromLatin1(s_parameters[i].longName)))) if(X264_STRCMP(current, QString::fromLatin1(s_parameters[i].longName)))
{ {
numOpts = s_parameters[i].optionCount; numOpts = s_parameters[i].optionCount;
identifier = s_parameters[i].identifier; identifier = s_parameters[i].identifier;

View File

@ -36,13 +36,9 @@ static const int CLI_PARAM_NO_FORCE_ENQUEUE = 5;
static const int CLI_PARAM_SKIP_AVS_CHECK = 6; static const int CLI_PARAM_SKIP_AVS_CHECK = 6;
static const int CLI_PARAM_SKIP_VPS_CHECK = 7; static const int CLI_PARAM_SKIP_VPS_CHECK = 7;
static const int CLI_PARAM_SKIP_X264_CHECK = 8; static const int CLI_PARAM_SKIP_X264_CHECK = 8;
static const int CLI_PARAM_FORCE_CPU_NO_X64 = 9; static const int CLI_PARAM_NO_DEADLOCK = 9;
static const int CLI_PARAM_FORCE_CPU_NO_SSE = 10; static const int CLI_PARAM_NO_GUI_STYLE = 10;
static const int CLI_PARAM_FORCE_CPU_NO_INT = 11; static const int CLI_PARAM_OTHER = 42;
static const int CLI_PARAM_NO_DEADLOCK = 12;
static const int CLI_PARAM_DEBUG_CONSOLE = 13;
static const int CLI_PARAM_NO_DEBUG_CONSOLE = 14;
static const int CLI_PARAM_NO_GUI_STYLE = 15;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// CLI Parser // CLI Parser

View File

@ -19,7 +19,9 @@
// http://www.gnu.org/licenses/gpl-2.0.txt // http://www.gnu.org/licenses/gpl-2.0.txt
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//x264 includes
#include "global.h" #include "global.h"
#include "targetver.h"
//Windows includes //Windows includes
#define NOMINMAX #define NOMINMAX
@ -40,10 +42,6 @@
//VLD //VLD
#include <vld.h> #include <vld.h>
//x264 includes
#include "targetver.h"
#include "cli.h"
//Version //Version
#define ENABLE_X264_VERSION_INCLUDE #define ENABLE_X264_VERSION_INCLUDE
#include "version.h" #include "version.h"
@ -222,6 +220,17 @@ while(0)
} \ } \
while(0) while(0)
//Check for CLI flag
static inline bool _CHECK_FLAG(const int argc, char **argv, const char *flag)
{
for(int i = 1; i < argc; i++)
{
if(_stricmp(argv[i], flag) == 0) return true;
}
return false;
}
#define CHECK_FLAG(FLAG) _CHECK_FLAG(argc, argv, "--" FLAG)
#define X264_ZERO_MEMORY(X) SecureZeroMemory(&X, sizeof(X)) #define X264_ZERO_MEMORY(X) SecureZeroMemory(&X, sizeof(X))
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -654,7 +663,7 @@ void x264_message_handler(QtMsgType type, const char *msg)
/* /*
* Initialize the console * Initialize the console
*/ */
void x264_init_console(const QStringList &argv) void x264_init_console(const int argc, char **argv)
{ {
bool enableConsole = x264_is_prerelease() || (X264_DEBUG); bool enableConsole = x264_is_prerelease() || (X264_DEBUG);
@ -679,8 +688,9 @@ void x264_init_console(const QStringList &argv)
if(!X264_DEBUG) if(!X264_DEBUG)
{ {
if(CLIParser::checkFlag(CLI_PARAM_DEBUG_CONSOLE, argv)) enableConsole = true;
if(CLIParser::checkFlag(CLI_PARAM_NO_DEBUG_CONSOLE, argv)) enableConsole = false; if(CHECK_FLAG("console")) enableConsole = true;
if(CHECK_FLAG("no-console")) enableConsole = false;
} }
if(enableConsole) if(enableConsole)
@ -922,7 +932,7 @@ extern "C"
/* /*
* Detect CPU features * Detect CPU features
*/ */
x264_cpu_t x264_detect_cpu_features(const QStringList &argv) x264_cpu_t x264_detect_cpu_features(const int argc, char **argv)
{ {
typedef BOOL (WINAPI *IsWow64ProcessFun)(__in HANDLE hProcess, __out PBOOL Wow64Process); typedef BOOL (WINAPI *IsWow64ProcessFun)(__in HANDLE hProcess, __out PBOOL Wow64Process);
@ -1019,9 +1029,9 @@ x264_cpu_t x264_detect_cpu_features(const QStringList &argv)
} }
bool flag = false; bool flag = false;
if(CLIParser::checkFlag(CLI_PARAM_FORCE_CPU_NO_X64, argv)) { flag = true; features.x64 = false; } if(CHECK_FLAG("force-cpu-no-64bit")) { flag = true; features.x64 = false; }
if(CLIParser::checkFlag(CLI_PARAM_FORCE_CPU_NO_SSE, argv)) { flag = true; features.sse = features.sse2 = features.sse3 = features.ssse3 = false; } if(CHECK_FLAG("force-cpu-no-sse")) { flag = true; features.sse = features.sse2 = features.sse3 = features.ssse3 = false; }
if(CLIParser::checkFlag(CLI_PARAM_FORCE_CPU_NO_INT, argv)) { flag = true; features.intel = false; } if(CHECK_FLAG("force-cpu-no-intel")) { flag = true; features.intel = false; }
if(flag) qWarning("CPU flags overwritten by user-defined parameters. Take care!\n"); if(flag) qWarning("CPU flags overwritten by user-defined parameters. Take care!\n");
return features; return features;

View File

@ -128,11 +128,11 @@ bool x264_change_process_priority(void *hProcess, const int priority);
QDate x264_current_date_safe(void); QDate x264_current_date_safe(void);
const QString &x264_data_path(void); const QString &x264_data_path(void);
size_t x264_dbg_private_bytes(void); size_t x264_dbg_private_bytes(void);
x264_cpu_t x264_detect_cpu_features(const QStringList &argv); x264_cpu_t x264_detect_cpu_features(const int argc, char **argv);
bool x264_enable_close_button(const QWidget *win, const bool bEnable); bool x264_enable_close_button(const QWidget *win, const bool bEnable);
void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL); void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
void x264_finalization(void); void x264_finalization(void);
void x264_init_console(const QStringList &argv); void x264_init_console(const int argc, char **argv);
void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true); void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
bool x264_init_qt(int &argc, char **argv); bool x264_init_qt(int &argc, char **argv);
bool x264_is_executable(const QString &path); bool x264_is_executable(const QString &path);

View File

@ -44,11 +44,8 @@ void handleMultipleInstances(const QStringList &args, IPC *ipc);
static int x264_main(int argc, char* argv[]) static int x264_main(int argc, char* argv[])
{ {
//Get CLI arguments
const QStringList &arguments = x264_arguments();
//Init console //Init console
x264_init_console(arguments); x264_init_console(argc, argv);
//Print version info //Print version info
qDebug("Simple x264 Launcher v%u.%02u.%u - use 64-Bit x264 with 32-Bit Avisynth", x264_version_major(), x264_version_minor(), x264_version_build()); qDebug("Simple x264 Launcher v%u.%02u.%u - use 64-Bit x264 with 32-Bit Avisynth", x264_version_major(), x264_version_minor(), x264_version_build());
@ -69,13 +66,16 @@ static int x264_main(int argc, char* argv[])
} }
//Detect CPU capabilities //Detect CPU capabilities
const x264_cpu_t cpuFeatures = x264_detect_cpu_features(arguments); const x264_cpu_t cpuFeatures = x264_detect_cpu_features(argc, argv);
qDebug(" CPU vendor id : %s (Intel: %s)", cpuFeatures.vendor, X264_BOOL(cpuFeatures.intel)); qDebug(" CPU vendor id : %s (Intel: %s)", cpuFeatures.vendor, X264_BOOL(cpuFeatures.intel));
qDebug("CPU brand string : %s", cpuFeatures.brand); qDebug("CPU brand string : %s", cpuFeatures.brand);
qDebug(" CPU signature : Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); qDebug(" CPU signature : Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping);
qDebug("CPU capabilities : MMX=%s, MMXEXT=%s, SSE=%s, SSE2=%s, SSE3=%s, SSSE3=%s, X64=%s", X264_BOOL(cpuFeatures.mmx), X264_BOOL(cpuFeatures.mmx2), X264_BOOL(cpuFeatures.sse), X264_BOOL(cpuFeatures.sse2), X264_BOOL(cpuFeatures.sse3), X264_BOOL(cpuFeatures.ssse3), X264_BOOL(cpuFeatures.x64)); qDebug("CPU capabilities : MMX=%s, MMXEXT=%s, SSE=%s, SSE2=%s, SSE3=%s, SSSE3=%s, X64=%s", X264_BOOL(cpuFeatures.mmx), X264_BOOL(cpuFeatures.mmx2), X264_BOOL(cpuFeatures.sse), X264_BOOL(cpuFeatures.sse2), X264_BOOL(cpuFeatures.sse3), X264_BOOL(cpuFeatures.ssse3), X264_BOOL(cpuFeatures.x64));
qDebug(" Number of CPU's : %d\n", cpuFeatures.count); qDebug(" Number of CPU's : %d\n", cpuFeatures.count);
//Get CLI arguments
const QStringList &arguments = x264_arguments();
//Initialize the IPC handler class //Initialize the IPC handler class
bool firstInstance = false; bool firstInstance = false;
IPC *ipc = new IPC(); IPC *ipc = new IPC();