2012-01-28 16:40:14 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Simple x264 Launcher
|
2015-01-31 19:56:04 +01:00
|
|
|
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
|
2012-01-28 16:40:14 +01:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-02-07 21:48:25 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-11-06 00:30:27 +01:00
|
|
|
#define _CRT_RAND_S
|
2013-11-03 18:34:20 +01:00
|
|
|
#include <cstdlib>
|
2014-04-16 14:57:32 +02:00
|
|
|
#include <stdexcept>
|
2012-04-30 16:56:01 +02:00
|
|
|
|
2013-11-06 00:30:27 +01:00
|
|
|
//Forward declarations
|
2012-01-28 16:40:14 +01:00
|
|
|
class QString;
|
|
|
|
class QStringList;
|
|
|
|
class QDate;
|
|
|
|
class QTime;
|
|
|
|
class QIcon;
|
|
|
|
class QWidget;
|
|
|
|
class LockedFile;
|
2013-11-03 18:34:20 +01:00
|
|
|
class QProcess;
|
2012-01-28 16:40:14 +01:00
|
|
|
enum QtMsgType;
|
|
|
|
|
2013-11-06 00:30:27 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// TYPE DEFINITIONS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-01-28 16:40:14 +01:00
|
|
|
//Types definitions
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int family;
|
|
|
|
int model;
|
|
|
|
int stepping;
|
|
|
|
int count;
|
|
|
|
bool x64;
|
|
|
|
bool mmx;
|
2012-02-07 03:37:47 +01:00
|
|
|
bool mmx2;
|
2012-01-28 16:40:14 +01:00
|
|
|
bool sse;
|
|
|
|
bool sse2;
|
|
|
|
bool sse3;
|
|
|
|
bool ssse3;
|
|
|
|
char vendor[0x40];
|
|
|
|
char brand[0x40];
|
|
|
|
bool intel;
|
|
|
|
}
|
|
|
|
x264_cpu_t;
|
|
|
|
|
2013-11-03 17:08:02 +01:00
|
|
|
//OS version number
|
|
|
|
typedef struct _x264_os_version_t
|
|
|
|
{
|
|
|
|
unsigned int versionMajor;
|
|
|
|
unsigned int versionMinor;
|
|
|
|
bool overrideFlag;
|
|
|
|
|
|
|
|
//comparision operators
|
|
|
|
inline bool operator== (const _x264_os_version_t &rhs) const { return (versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor); }
|
|
|
|
inline bool operator!= (const _x264_os_version_t &rhs) const { return (versionMajor != rhs.versionMajor) || (versionMinor != rhs.versionMinor); }
|
|
|
|
inline bool operator> (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor)); }
|
|
|
|
inline bool operator>= (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor)); }
|
|
|
|
inline bool operator< (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)); }
|
|
|
|
inline bool operator<= (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor)); }
|
|
|
|
}
|
|
|
|
x264_os_version_t;
|
|
|
|
|
2013-11-03 18:34:20 +01:00
|
|
|
//Beep types
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
x264_beep_info = 0,
|
|
|
|
x264_beep_warning = 1,
|
|
|
|
x264_beep_error = 2
|
|
|
|
}
|
|
|
|
x264_beep_t;
|
|
|
|
|
2013-11-29 18:09:38 +01:00
|
|
|
//Known folders
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
x264_folder_localappdata = 0,
|
|
|
|
x264_folder_programfiles = 2,
|
2013-12-09 22:19:32 +01:00
|
|
|
x264_folder_systemfolder = 3,
|
|
|
|
x264_folder_systroot_dir = 4
|
2013-11-29 18:09:38 +01:00
|
|
|
}
|
|
|
|
x264_known_folder_t;
|
|
|
|
|
2013-12-09 22:19:32 +01:00
|
|
|
//Network connection types
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
x264_network_err = 0, /*unknown*/
|
|
|
|
x264_network_non = 1, /*not connected*/
|
|
|
|
x264_network_yes = 2 /*connected*/
|
|
|
|
}
|
|
|
|
x264_network_t;
|
|
|
|
|
2013-11-03 17:08:02 +01:00
|
|
|
//Known Windows versions
|
2014-11-19 17:20:13 +01:00
|
|
|
extern const x264_os_version_t x264_winver_error; //N/A
|
|
|
|
extern const x264_os_version_t x264_winver_win2k; //2000
|
|
|
|
extern const x264_os_version_t x264_winver_winxp; //XP
|
|
|
|
extern const x264_os_version_t x264_winver_xpx64; //XP_x64
|
|
|
|
extern const x264_os_version_t x264_winver_vista; //Vista
|
|
|
|
extern const x264_os_version_t x264_winver_win70; //7
|
|
|
|
extern const x264_os_version_t x264_winver_win80; //8
|
|
|
|
extern const x264_os_version_t x264_winver_win81; //8.1
|
|
|
|
extern const x264_os_version_t x264_winver_wn100; //10
|
2013-11-03 17:08:02 +01:00
|
|
|
|
2014-04-16 14:57:32 +02:00
|
|
|
//Exception class
|
|
|
|
class X264Exception : public std::runtime_error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
X264Exception(const char *message, ...);
|
|
|
|
virtual const char* what() const { return m_message; }
|
|
|
|
private:
|
|
|
|
static const size_t MAX_MSGLEN = 256;
|
|
|
|
char m_message[MAX_MSGLEN];
|
|
|
|
};
|
|
|
|
|
2013-11-06 00:30:27 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GLOBAL FUNCTIONS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const QStringList &x264_arguments(void);
|
|
|
|
bool x264_beep(int beepType);
|
|
|
|
void x264_blink_window(QWidget *poWindow, unsigned int count, unsigned int delay);
|
2013-12-13 15:25:36 +01:00
|
|
|
bool x264_bring_process_to_front(const unsigned long pid);
|
2013-11-06 00:30:27 +01:00
|
|
|
bool x264_bring_to_front(const QWidget *win);
|
|
|
|
bool x264_change_process_priority(const QProcess *proc, const int priority);
|
|
|
|
bool x264_change_process_priority(const int priority);
|
|
|
|
bool x264_change_process_priority(void *hProcess, const int priority);
|
2013-12-09 22:19:32 +01:00
|
|
|
QDate x264_current_date_safe(void);
|
2012-02-10 18:40:28 +01:00
|
|
|
const QString &x264_data_path(void);
|
2014-04-20 21:23:14 +02:00
|
|
|
void x264_dbg_output_string(const char* format, ...);
|
2013-11-06 00:30:27 +01:00
|
|
|
size_t x264_dbg_private_bytes(void);
|
2014-02-02 15:54:39 +01:00
|
|
|
x264_cpu_t x264_detect_cpu_features(const int argc, char **argv);
|
2013-11-06 00:30:27 +01:00
|
|
|
bool x264_enable_close_button(const QWidget *win, const bool bEnable);
|
2014-04-16 14:57:32 +02:00
|
|
|
void x264_fatal_exit(const wchar_t* exitMessage, const char* errorBoxMessage = NULL);
|
2012-01-28 16:40:14 +01:00
|
|
|
void x264_finalization(void);
|
2014-02-02 15:54:39 +01:00
|
|
|
void x264_init_console(const int argc, char **argv);
|
2013-12-09 22:19:32 +01:00
|
|
|
void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
|
2014-02-01 20:21:24 +01:00
|
|
|
bool x264_init_qt(int &argc, char **argv);
|
2013-11-06 00:30:27 +01:00
|
|
|
bool x264_is_executable(const QString &path);
|
|
|
|
bool x264_is_prerelease(void);
|
2013-11-29 18:09:38 +01:00
|
|
|
const QString &x264_known_folder(x264_known_folder_t folder_id);
|
2013-11-06 00:30:27 +01:00
|
|
|
void x264_message_handler(QtMsgType type, const char *msg);
|
2013-12-09 22:19:32 +01:00
|
|
|
int x264_network_status(void);
|
2013-11-08 14:15:40 +01:00
|
|
|
QString x264_path2ansi(const QString &longPath, bool makeLowercase = false);
|
2013-11-03 18:34:20 +01:00
|
|
|
bool x264_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL);
|
2013-11-06 00:30:27 +01:00
|
|
|
bool x264_portable(void);
|
2013-11-03 18:34:20 +01:00
|
|
|
unsigned int x264_process_id(void);
|
2013-12-13 15:25:36 +01:00
|
|
|
unsigned int x264_process_id(QProcess &process);
|
2013-11-03 18:34:20 +01:00
|
|
|
QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name);
|
2013-12-09 22:19:32 +01:00
|
|
|
unsigned int x264_rand(void);
|
|
|
|
QString x264_rand_str(const bool bLong = false);
|
|
|
|
void x264_seed_rand(void);
|
2013-11-10 23:20:24 +01:00
|
|
|
bool x264_set_thread_execution_state(const bool systemRequired);
|
2013-11-06 00:30:27 +01:00
|
|
|
bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
|
|
|
|
void x264_sleep(const unsigned int delay);
|
|
|
|
bool x264_suspendProcess(const QProcess *proc, const bool suspend);
|
2013-11-29 18:09:38 +01:00
|
|
|
const QString &x264_temp_directory(void);
|
2013-12-16 22:58:52 +01:00
|
|
|
bool x264_user_is_admin(void);
|
2013-11-06 00:30:27 +01:00
|
|
|
const char *x264_version_arch(void);
|
|
|
|
unsigned int x264_version_build(void);
|
|
|
|
const char *x264_version_compiler(void);
|
|
|
|
const QDate &x264_version_date(void);
|
|
|
|
unsigned int x264_version_major(void);
|
|
|
|
unsigned int x264_version_minor(void);
|
|
|
|
const char *x264_version_time(void);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HELPER MACROS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
|
|
|
|
#define QUTF8(STR) ((STR).toUtf8().constData())
|
|
|
|
#define WCHAR2QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
|
|
|
|
#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; }
|
|
|
|
#define _X264_MAKE_STRING_(X) #X
|
|
|
|
#define X264_MAKE_STRING(X) _X264_MAKE_STRING_(X)
|
|
|
|
#define X264_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" X264_MAKE_STRING(__LINE__) ") : warning: " TXT))
|
2014-01-27 20:34:59 +01:00
|
|
|
#define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
|
2013-11-06 00:30:27 +01:00
|
|
|
|
|
|
|
//Debug build
|
|
|
|
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
|
|
|
|
#define X264_DEBUG (1)
|
|
|
|
#else
|
|
|
|
#define X264_DEBUG (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//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
|
|
|
|
|
|
|
|
//Helper macro for throwing exceptions
|
2014-04-16 14:57:32 +02:00
|
|
|
#define THROW(MESSAGE, ...) do \
|
2013-11-06 00:30:27 +01:00
|
|
|
{ \
|
2014-04-16 14:57:32 +02:00
|
|
|
throw X264Exception((MESSAGE), __VA_ARGS__); \
|
2013-11-06 00:30:27 +01:00
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
//Memory check
|
|
|
|
#if X264_DEBUG
|
|
|
|
#define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
|
|
|
|
{ \
|
|
|
|
size_t _privateBytesBefore = x264_dbg_private_bytes(); \
|
|
|
|
RETV = FUNC(__VA_ARGS__); \
|
|
|
|
size_t _privateBytesLeak = (x264_dbg_private_bytes() - _privateBytesBefore) / 1024; \
|
|
|
|
if(_privateBytesLeak > 0) { \
|
2014-04-20 21:23:14 +02:00
|
|
|
x264_dbg_output_string("\nMemory leak: Lost %u KiloBytes of PrivateUsage memory!\n\n", _privateBytesLeak); \
|
2013-11-06 00:30:27 +01:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
#else
|
|
|
|
#define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
|
|
|
|
{ \
|
|
|
|
RETV = __noop(__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
#endif
|