OSDN Git Service

Updated copyright year.
[x264-launcher/x264-launcher.git] / src / global.h
index ee918e7..d7c2a24 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2022 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
 // http://www.gnu.org/licenses/gpl-2.0.txt
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "targetver.h"
+#pragma once
 
-//C++ includes
-#include <stdio.h>
-#include <string.h>
-#include <iostream>
-#include <time.h>
+#define _CRT_RAND_S
+#include <cstdlib>
+#include <stdexcept>
 
-//Win32 includes
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
-
-//Debug build
-#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
-       #define X264_DEBUG (1)
-#else
-       #define X264_DEBUG (0)
-#endif
-
-//Memory leack checker
-#if X264_DEBUG
-#define X264_MEMORY_CHECK(CMD) \
-{ \
-       SIZE_T _privateBytesBefore = x264_dbg_private_bytes(); \
-       CMD; \
-       SIZE_T _privateBytesLeak = (x264_dbg_private_bytes() - _privateBytesBefore) / 1024; \
-       if(_privateBytesLeak > 10) { \
-               qWarning("Memory leak: Lost %u KiloBytes.", _privateBytesLeak); \
-       } \
-}
-#else
-#define X264_MEMORY_CHECK(CMD) CMD
-#endif
-
-//Helper macros
-#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
-#define X264_BOOL(X) ((X) ? "1" : "0")
-#define X264_DELETE(PTR) if(PTR) { delete PTR; PTR = NULL; }
-#define X264_DELETE_ARRAY(PTR) if(PTR) { delete [] PTR; PTR = NULL; }
-
-//Declarations
+//Forward declarations
 class QString;
 class QStringList;
 class QDate;
@@ -67,42 +33,31 @@ class QTime;
 class QIcon;
 class QWidget;
 class LockedFile;
-enum QtMsgType;
+class QProcess;
+
+///////////////////////////////////////////////////////////////////////////////
+// GLOBAL FUNCTIONS
+///////////////////////////////////////////////////////////////////////////////
 
-//Types definitions
-typedef struct
-{
-       int family;
-       int model;
-       int stepping;
-       int count;
-       bool x64;
-       bool mmx;
-       bool mmx2;
-       bool sse;
-       bool sse2;
-       bool sse3;
-       bool ssse3;
-       char vendor[0x40];
-       char brand[0x40];
-       bool intel;
-}
-x264_cpu_t;
+//Utility functions
+const QString &x264_data_path(void);
+QString x264_path2ansi(const QString &longPath, bool makeLowercase = false);
+bool x264_set_thread_execution_state(const bool systemRequired);
 
-//Functions
-LONG WINAPI x264_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo);
-void x264_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
-void x264_message_handler(QtMsgType type, const char *msg);
+//Version getters
 unsigned int x264_version_major(void);
 unsigned int x264_version_minor(void);
-const QDate &x264_version_date(void);
-bool x264_is_prerelease(void);
-const char *x264_version_time(void);
-const char *x264_version_compiler(void);
-const char *x264_version_arch(void);
-void x264_init_console(int argc, char* argv[]);
-bool x264_init_qt(int argc, char* argv[]);
-x264_cpu_t x264_detect_cpu_features(int argc, char **argv);
-bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
-SIZE_T x264_dbg_private_bytes(void);
-void x264_finalization(void);
+unsigned int x264_version_build(void);
+bool         x264_is_prerelease(void);
+bool         x264_is_portable  (void);
+
+///////////////////////////////////////////////////////////////////////////////
+// HELPER MACROS
+///////////////////////////////////////////////////////////////////////////////
+
+//Check for CPU-compatibility options
+#if !defined(_M_X64) && defined(_MSC_VER) && defined(_M_IX86_FP)
+       #if (_M_IX86_FP != 0)
+               #error We should not enabled SSE or SSE2 in release builds!
+       #endif
+#endif