1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
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.
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.
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.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
27 //Forward declarations
38 ///////////////////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////////////////
63 typedef struct _x264_os_version_t
65 unsigned int versionMajor;
66 unsigned int versionMinor;
69 //comparision operators
70 inline bool operator== (const _x264_os_version_t &rhs) const { return (versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor); }
71 inline bool operator!= (const _x264_os_version_t &rhs) const { return (versionMajor != rhs.versionMajor) || (versionMinor != rhs.versionMinor); }
72 inline bool operator> (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor)); }
73 inline bool operator>= (const _x264_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor)); }
74 inline bool operator< (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)); }
75 inline bool operator<= (const _x264_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor)); }
83 x264_beep_warning = 1,
91 x264_folder_localappdata = 0,
92 x264_folder_programfiles = 2,
93 x264_folder_systemfolder = 3,
94 x264_folder_systroot_dir = 4
98 //Network connection types
101 x264_network_err = 0, /*unknown*/
102 x264_network_non = 1, /*not connected*/
103 x264_network_yes = 2 /*connected*/
107 //Known Windows versions
108 extern const x264_os_version_t x264_winver_win2k;
109 extern const x264_os_version_t x264_winver_winxp;
110 extern const x264_os_version_t x264_winver_xpx64;
111 extern const x264_os_version_t x264_winver_vista;
112 extern const x264_os_version_t x264_winver_win70;
113 extern const x264_os_version_t x264_winver_win80;
114 extern const x264_os_version_t x264_winver_win81;
116 ///////////////////////////////////////////////////////////////////////////////
118 ///////////////////////////////////////////////////////////////////////////////
120 const QStringList &x264_arguments(void);
121 bool x264_beep(int beepType);
122 void x264_blink_window(QWidget *poWindow, unsigned int count, unsigned int delay);
123 bool x264_bring_process_to_front(const unsigned long pid);
124 bool x264_bring_to_front(const QWidget *win);
125 bool x264_change_process_priority(const QProcess *proc, const int priority);
126 bool x264_change_process_priority(const int priority);
127 bool x264_change_process_priority(void *hProcess, const int priority);
128 QDate x264_current_date_safe(void);
129 const QString &x264_data_path(void);
130 size_t x264_dbg_private_bytes(void);
131 x264_cpu_t x264_detect_cpu_features(const QStringList &argv);
132 bool x264_enable_close_button(const QWidget *win, const bool bEnable);
133 void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
134 void x264_finalization(void);
135 void x264_init_console(int argc, char* argv[]);
136 void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
137 bool x264_init_qt(int argc, char* argv[]);
138 bool x264_is_executable(const QString &path);
139 bool x264_is_prerelease(void);
140 const QString &x264_known_folder(x264_known_folder_t folder_id);
141 void x264_message_handler(QtMsgType type, const char *msg);
142 int x264_network_status(void);
143 QString x264_path2ansi(const QString &longPath, bool makeLowercase = false);
144 bool x264_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const wchar_t *alias = NULL);
145 bool x264_portable(void);
146 unsigned int x264_process_id(void);
147 unsigned int x264_process_id(QProcess &process);
148 QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name);
149 unsigned int x264_rand(void);
150 QString x264_rand_str(const bool bLong = false);
151 void x264_seed_rand(void);
152 bool x264_set_thread_execution_state(const bool systemRequired);
153 bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
154 void x264_sleep(const unsigned int delay);
155 bool x264_suspendProcess(const QProcess *proc, const bool suspend);
156 const QString &x264_temp_directory(void);
157 bool x264_user_is_admin(void);
158 const char *x264_version_arch(void);
159 unsigned int x264_version_build(void);
160 const char *x264_version_compiler(void);
161 const QDate &x264_version_date(void);
162 unsigned int x264_version_major(void);
163 unsigned int x264_version_minor(void);
164 const char *x264_version_time(void);
165 unsigned int x264_version_x264_minimum_rev(void);
166 unsigned int x264_version_x264_current_api(void);
167 unsigned int x264_version_x264_avs2yuv_ver(void);
169 ///////////////////////////////////////////////////////////////////////////////
171 ///////////////////////////////////////////////////////////////////////////////
173 #define QWCHAR(STR) reinterpret_cast<const wchar_t*>(STR.utf16())
174 #define QUTF8(STR) ((STR).toUtf8().constData())
175 #define WCHAR2QSTR(STR) (QString::fromUtf16(reinterpret_cast<const unsigned short*>((STR))))
176 #define X264_BOOL(X) ((X) ? "1" : "0")
177 #define X264_DELETE(PTR) if(PTR) { delete PTR; PTR = NULL; }
178 #define X264_DELETE_ARRAY(PTR) if(PTR) { delete [] PTR; PTR = NULL; }
179 #define _X264_MAKE_STRING_(X) #X
180 #define X264_MAKE_STRING(X) _X264_MAKE_STRING_(X)
181 #define X264_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" X264_MAKE_STRING(__LINE__) ") : warning: " TXT))
182 #define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
185 #if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
186 #define X264_DEBUG (1)
188 #define X264_DEBUG (0)
191 //Check for CPU-compatibility options
192 #if !defined(_M_X64) && defined(_MSC_VER) && defined(_M_IX86_FP)
193 #if (_M_IX86_FP != 0)
194 #error We should not enabled SSE or SSE2 in release builds!
198 //Helper macro for throwing exceptions
199 #define THROW(MESSAGE) do \
201 throw std::runtime_error((MESSAGE)); \
204 #define THROW_FMT(FORMAT, ...) do \
206 char _error_msg[512]; \
207 _snprintf_s(_error_msg, 512, _TRUNCATE, (FORMAT), __VA_ARGS__); \
208 throw std::runtime_error(_error_msg); \
214 #define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
216 size_t _privateBytesBefore = x264_dbg_private_bytes(); \
217 RETV = FUNC(__VA_ARGS__); \
218 size_t _privateBytesLeak = (x264_dbg_private_bytes() - _privateBytesBefore) / 1024; \
219 if(_privateBytesLeak > 0) { \
220 x264_dbg_dbg_output_string("\nMemory leak: Lost %u KiloBytes of PrivateUsage memory!\n\n", _privateBytesLeak); \
225 #define X264_MEMORY_CHECK(FUNC, RETV, ...) do \
227 RETV = __noop(__VA_ARGS__); \