From b83d33f7b3cd2f740f535aea6d9e36b93c43bd66 Mon Sep 17 00:00:00 2001 From: Git User Date: Sat, 28 Jan 2012 16:40:14 +0100 Subject: [PATCH] Initial commit. --- License.txt | 342 ++++++++++++++ ReadMe.txt | 19 + gui/win_main.ui | 31 ++ res/icons/movie.ico | Bin 0 -> 25214 bytes res/resources.qrc | 6 + src/global.cpp | 826 ++++++++++++++++++++++++++++++++++ src/global.h | 105 +++++ src/main.cpp | 152 +++++++ src/targetver.h | 8 + src/version.h | 23 + src/win_main.cpp | 38 ++ src/win_main.h | 33 ++ x264_launcher.sln | 20 + x264_launcher.vcxproj | 137 ++++++ x264_launcher.vcxproj.filters | 65 +++ 15 files changed, 1805 insertions(+) create mode 100644 License.txt create mode 100644 ReadMe.txt create mode 100644 gui/win_main.ui create mode 100644 res/icons/movie.ico create mode 100644 res/resources.qrc create mode 100644 src/global.cpp create mode 100644 src/global.h create mode 100644 src/main.cpp create mode 100644 src/targetver.h create mode 100644 src/version.h create mode 100644 src/win_main.cpp create mode 100644 src/win_main.h create mode 100644 x264_launcher.sln create mode 100644 x264_launcher.vcxproj create mode 100644 x264_launcher.vcxproj.filters diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..ecef765 --- /dev/null +++ b/License.txt @@ -0,0 +1,342 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..bb78553 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,19 @@ + + Simple x264 Launcher - use 64-Bit x264 with 32-Bit Avisynth + Copyright (C) 2004-2012 LoRd_MuldeR + + 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 diff --git a/gui/win_main.ui b/gui/win_main.ui new file mode 100644 index 0000000..2a74dd4 --- /dev/null +++ b/gui/win_main.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + Simple x264 Launcher + + + + + + 0 + 0 + 800 + 21 + + + + + + + + diff --git a/res/icons/movie.ico b/res/icons/movie.ico new file mode 100644 index 0000000000000000000000000000000000000000..88400e35c29d52a32517d87c9545d1297688df0f GIT binary patch literal 25214 zcmeHv2Uu1|x9*~T^r|Q#ML_|~5A}B>fv7iDfim2GIVFxSrhP`1|Fk(z%6r!L> zG>Ij#CTfgWqNv0YOAwTG-?iZ*YD{9z`TukO=iW2Vv)JF>d-lwlnKf%x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mode 100644 index 0000000..e0f275c --- /dev/null +++ b/src/global.cpp @@ -0,0 +1,826 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#include "global.h" +#include "version.h" + +//Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//CRT includes +#include +#include +#include +#include + +//Debug only includes +#if X264_DEBUG +#include +#endif + +//Global vars +static bool g_x264_console_attached = false; +static QMutex g_x264_message_mutex; +static const DWORD g_main_thread_id = GetCurrentThreadId(); +static FILE *g_x264_log_file = NULL; +static QDate g_x264_version_date; + +//Const +static const char *g_x264_months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; +static const char *g_x264_imageformats[] = {"png", "jpg", "gif", "ico", "svg", NULL}; + +//Build version +static const struct +{ + unsigned int ver_major; + unsigned int ver_minor; + const char* ver_date; + const char* ver_time; +} +g_x264_version = +{ + VER_X264_MAJOR, + VER_X264_MINOR, + __DATE__, + __TIME__ +}; + +//Compiler detection +//The following code was borrowed from MPC-HC project: http://mpc-hc.sf.net/ +#if defined(__INTEL_COMPILER) + #if (__INTEL_COMPILER >= 1200) + static const char *g_x264_version_compiler = "ICL 12.x"; + #elif (__INTEL_COMPILER >= 1100) + static const char *g_x264_version_compiler = = "ICL 11.x"; + #elif (__INTEL_COMPILER >= 1000) + static const char *g_x264_version_compiler = = "ICL 10.x"; + #else + #error Compiler is not supported! + #endif +#elif defined(_MSC_VER) + #if (_MSC_VER == 1600) + #if (_MSC_FULL_VER >= 160040219) + static const char *g_x264_version_compiler = "MSVC 2010-SP1"; + #else + static const char *g_x264_version_compiler = "MSVC 2010"; + #endif + #elif (_MSC_VER == 1500) + #if (_MSC_FULL_VER >= 150030729) + static const char *g_x264_version_compiler = "MSVC 2008-SP1"; + #else + static const char *g_x264_version_compiler = "MSVC 2008"; + #endif + #else + #error Compiler is not supported! + #endif + + // Note: /arch:SSE and /arch:SSE2 are only available for the x86 platform + #if !defined(_M_X64) && defined(_M_IX86_FP) + #if (_M_IX86_FP == 1) + x264_COMPILER_WARNING("SSE instruction set is enabled!") + #elif (_M_IX86_FP == 2) + x264_COMPILER_WARNING("SSE2 instruction set is enabled!") + #endif + #endif +#else + #error Compiler is not supported! +#endif + +//Architecture detection +#if defined(_M_X64) + static const char *g_x264_version_arch = "x64"; +#elif defined(_M_IX86) + static const char *g_x264_version_arch = "x86"; +#else + #error Architecture is not supported! +#endif + +/* + * Global exception handler + */ +LONG WINAPI x264_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo) +{ + if(GetCurrentThreadId() != g_main_thread_id) + { + HANDLE mainThread = OpenThread(THREAD_TERMINATE, FALSE, g_main_thread_id); + if(mainThread) TerminateThread(mainThread, ULONG_MAX); + } + + FatalAppExit(0, L"Unhandeled exception handler invoked, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + return LONG_MAX; +} + +/* + * Invalid parameters handler + */ +void x264_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t) +{ + if(GetCurrentThreadId() != g_main_thread_id) + { + HANDLE mainThread = OpenThread(THREAD_TERMINATE, FALSE, g_main_thread_id); + if(mainThread) TerminateThread(mainThread, ULONG_MAX); + } + + FatalAppExit(0, L"Invalid parameter handler invoked, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); +} + +/* + * Change console text color + */ +static void x264_console_color(FILE* file, WORD attributes) +{ + const HANDLE hConsole = (HANDLE)(_get_osfhandle(_fileno(file))); + if((hConsole != NULL) && (hConsole != INVALID_HANDLE_VALUE)) + { + SetConsoleTextAttribute(hConsole, attributes); + } +} + +/* + * Qt message handler + */ +void x264_message_handler(QtMsgType type, const char *msg) +{ + static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n"; + + QMutexLocker lock(&g_x264_message_mutex); + + if(g_x264_log_file) + { + static char prefix[] = "DWCF"; + int index = qBound(0, static_cast(type), 3); + unsigned int timestamp = static_cast(_time64(NULL) % 3600I64); + QString str = QString::fromUtf8(msg).trimmed().replace('\n', '\t'); + fprintf(g_x264_log_file, "[%c][%04u] %s\r\n", prefix[index], timestamp, str.toUtf8().constData()); + fflush(g_x264_log_file); + } + + if(g_x264_console_attached) + { + UINT oldOutputCP = GetConsoleOutputCP(); + if(oldOutputCP != CP_UTF8) SetConsoleOutputCP(CP_UTF8); + + switch(type) + { + case QtCriticalMsg: + case QtFatalMsg: + fflush(stdout); + fflush(stderr); + x264_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY); + fprintf(stderr, GURU_MEDITATION); + fprintf(stderr, "%s\n", msg); + fflush(stderr); + break; + case QtWarningMsg: + x264_console_color(stderr, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); + fprintf(stderr, "%s\n", msg); + fflush(stderr); + break; + default: + x264_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); + fprintf(stderr, "%s\n", msg); + fflush(stderr); + break; + } + + x264_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); + if(oldOutputCP != CP_UTF8) SetConsoleOutputCP(oldOutputCP); + } + else + { + QString temp("[LameXP][%1] %2"); + + switch(type) + { + case QtCriticalMsg: + case QtFatalMsg: + temp = temp.arg("C", QString::fromUtf8(msg)); + break; + case QtWarningMsg: + temp = temp.arg("W", QString::fromUtf8(msg)); + break; + default: + temp = temp.arg("I", QString::fromUtf8(msg)); + break; + } + + temp.replace("\n", "\t").append("\n"); + OutputDebugStringA(temp.toLatin1().constData()); + } + + if(type == QtCriticalMsg || type == QtFatalMsg) + { + lock.unlock(); + MessageBoxW(NULL, QWCHAR(QString::fromUtf8(msg)), L"LameXP - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL); + FatalAppExit(0, L"The application has encountered a critical error and will exit now!"); + TerminateProcess(GetCurrentProcess(), -1); + } +} + +/* + * Initialize the console + */ +void x264_init_console(int argc, char* argv[]) +{ + bool enableConsole = true; //x264_version_demo(); + + if(_environ) + { + wchar_t *logfile = NULL; + size_t logfile_len = 0; + if(!_wdupenv_s(&logfile, &logfile_len, L"X264_LAUNCHER_LOGFILE")) + { + if(logfile && (logfile_len > 0)) + { + FILE *temp = NULL; + if(!_wfopen_s(&temp, logfile, L"wb")) + { + fprintf(temp, "%c%c%c", 0xEF, 0xBB, 0xBF); + g_x264_log_file = temp; + } + free(logfile); + } + } + } + + if(!X264_DEBUG) + { + for(int i = 0; i < argc; i++) + { + if(!_stricmp(argv[i], "--console")) + { + enableConsole = true; + } + else if(!_stricmp(argv[i], "--no-console")) + { + enableConsole = false; + } + } + } + + if(enableConsole) + { + if(!g_x264_console_attached) + { + if(AllocConsole() != FALSE) + { + SetConsoleCtrlHandler(NULL, TRUE); + SetConsoleTitle(L"Simple x264 Launcher | Debug Console"); + SetConsoleOutputCP(CP_UTF8); + g_x264_console_attached = true; + } + } + + if(g_x264_console_attached) + { + //------------------------------------------------------------------- + //See: http://support.microsoft.com/default.aspx?scid=kb;en-us;105305 + //------------------------------------------------------------------- + const int flags = _O_WRONLY | _O_U8TEXT; + int hCrtStdOut = _open_osfhandle((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE), flags); + int hCrtStdErr = _open_osfhandle((intptr_t) GetStdHandle(STD_ERROR_HANDLE), flags); + FILE *hfStdOut = (hCrtStdOut >= 0) ? _fdopen(hCrtStdOut, "wb") : NULL; + FILE *hfStdErr = (hCrtStdErr >= 0) ? _fdopen(hCrtStdErr, "wb") : NULL; + if(hfStdOut) { *stdout = *hfStdOut; std::cout.rdbuf(new std::filebuf(hfStdOut)); } + if(hfStdErr) { *stderr = *hfStdErr; std::cerr.rdbuf(new std::filebuf(hfStdErr)); } + } + + HWND hwndConsole = GetConsoleWindow(); + + if((hwndConsole != NULL) && (hwndConsole != INVALID_HANDLE_VALUE)) + { + HMENU hMenu = GetSystemMenu(hwndConsole, 0); + EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); + RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); + + SetWindowPos(hwndConsole, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); + SetWindowLong(hwndConsole, GWL_STYLE, GetWindowLong(hwndConsole, GWL_STYLE) & (~WS_MAXIMIZEBOX) & (~WS_MINIMIZEBOX)); + SetWindowPos(hwndConsole, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); + } + } +} + +/* + * Version info + */ +unsigned int x264_version_major(void) +{ + return g_x264_version.ver_major; +} + +unsigned int x264_version_minor(void) +{ + return g_x264_version.ver_minor; +} + +const char *x264_version_compiler(void) +{ + return g_x264_version_compiler; +} + +const char *x264_version_arch(void) +{ + return g_x264_version_arch; +} + +/* + * Get build date date + */ +const QDate &x264_version_date(void) +{ + if(!g_x264_version_date.isValid()) + { + int date[3] = {0, 0, 0}; char temp[12] = {'\0'}; + strncpy_s(temp, 12, g_x264_version.ver_date, _TRUNCATE); + + if(strlen(temp) == 11) + { + temp[3] = temp[6] = '\0'; + date[2] = atoi(&temp[4]); + date[0] = atoi(&temp[7]); + + for(int j = 0; j < 12; j++) + { + if(!_strcmpi(&temp[0], g_x264_months[j])) + { + date[1] = j+1; + break; + } + } + + g_x264_version_date = QDate(date[0], date[1], date[2]); + } + + if(!g_x264_version_date.isValid()) + { + qFatal("Internal error: Date format could not be recognized!"); + } + } + + return g_x264_version_date; +} + +const char *x264_version_time(void) +{ + return g_x264_version.ver_time; +} + +/* + * Detect CPU features + */ +x264_cpu_t x264_detect_cpu_features(int argc, char **argv) +{ + typedef BOOL (WINAPI *IsWow64ProcessFun)(__in HANDLE hProcess, __out PBOOL Wow64Process); + typedef VOID (WINAPI *GetNativeSystemInfoFun)(__out LPSYSTEM_INFO lpSystemInfo); + + static IsWow64ProcessFun IsWow64ProcessPtr = NULL; + static GetNativeSystemInfoFun GetNativeSystemInfoPtr = NULL; + + x264_cpu_t features; + SYSTEM_INFO systemInfo; + int CPUInfo[4] = {-1}; + char CPUIdentificationString[0x40]; + char CPUBrandString[0x40]; + + memset(&features, 0, sizeof(x264_cpu_t)); + memset(&systemInfo, 0, sizeof(SYSTEM_INFO)); + memset(CPUIdentificationString, 0, sizeof(CPUIdentificationString)); + memset(CPUBrandString, 0, sizeof(CPUBrandString)); + + __cpuid(CPUInfo, 0); + memcpy(CPUIdentificationString, &CPUInfo[1], sizeof(int)); + memcpy(CPUIdentificationString + 4, &CPUInfo[3], sizeof(int)); + memcpy(CPUIdentificationString + 8, &CPUInfo[2], sizeof(int)); + features.intel = (_stricmp(CPUIdentificationString, "GenuineIntel") == 0); + strncpy_s(features.vendor, 0x40, CPUIdentificationString, _TRUNCATE); + + if(CPUInfo[0] >= 1) + { + __cpuid(CPUInfo, 1); + features.mmx = (CPUInfo[3] & 0x800000) || false; + features.sse = (CPUInfo[3] & 0x2000000) || false; + features.sse2 = (CPUInfo[3] & 0x4000000) || false; + features.ssse3 = (CPUInfo[2] & 0x200) || false; + features.sse3 = (CPUInfo[2] & 0x1) || false; + features.ssse3 = (CPUInfo[2] & 0x200) || false; + features.stepping = CPUInfo[0] & 0xf; + features.model = ((CPUInfo[0] >> 4) & 0xf) + (((CPUInfo[0] >> 16) & 0xf) << 4); + features.family = ((CPUInfo[0] >> 8) & 0xf) + ((CPUInfo[0] >> 20) & 0xff); + } + + __cpuid(CPUInfo, 0x80000000); + int nExIds = qMax(qMin(CPUInfo[0], 0x80000004), 0x80000000); + + for(int i = 0x80000002; i <= nExIds; ++i) + { + __cpuid(CPUInfo, i); + switch(i) + { + case 0x80000002: + memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo)); + break; + case 0x80000003: + memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo)); + break; + case 0x80000004: + memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo)); + break; + } + } + + strncpy_s(features.brand, 0x40, CPUBrandString, _TRUNCATE); + + if(strlen(features.brand) < 1) strncpy_s(features.brand, 0x40, "Unknown", _TRUNCATE); + if(strlen(features.vendor) < 1) strncpy_s(features.vendor, 0x40, "Unknown", _TRUNCATE); + +#if !defined(_M_X64 ) && !defined(_M_IA64) + if(!IsWow64ProcessPtr || !GetNativeSystemInfoPtr) + { + QLibrary Kernel32Lib("kernel32.dll"); + IsWow64ProcessPtr = (IsWow64ProcessFun) Kernel32Lib.resolve("IsWow64Process"); + GetNativeSystemInfoPtr = (GetNativeSystemInfoFun) Kernel32Lib.resolve("GetNativeSystemInfo"); + } + if(IsWow64ProcessPtr) + { + BOOL x64 = FALSE; + if(IsWow64ProcessPtr(GetCurrentProcess(), &x64)) + { + features.x64 = x64; + } + } + if(GetNativeSystemInfoPtr) + { + GetNativeSystemInfoPtr(&systemInfo); + } + else + { + GetSystemInfo(&systemInfo); + } + features.count = qBound(1UL, systemInfo.dwNumberOfProcessors, 64UL); +#else + GetNativeSystemInfo(&systemInfo); + features.count = systemInfo.dwNumberOfProcessors; + features.x64 = true; +#endif + + if((argv != NULL) && (argc > 0)) + { + bool flag = false; + for(int i = 0; i < argc; i++) + { + if(!_stricmp("--force-cpu-no-64bit", argv[i])) { flag = true; features.x64 = false; } + if(!_stricmp("--force-cpu-no-sse", argv[i])) { flag = true; features.sse = features.sse2 = features.sse3 = features.ssse3 = false; } + if(!_stricmp("--force-cpu-no-intel", argv[i])) { flag = true; features.intel = false; } + } + if(flag) qWarning("CPU flags overwritten by user-defined parameters. Take care!\n"); + } + + return features; +} + +/* + * Get the native operating system version + */ +DWORD x264_get_os_version(void) +{ + OSVERSIONINFO osVerInfo; + memset(&osVerInfo, 0, sizeof(OSVERSIONINFO)); + osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + DWORD version = 0; + + if(GetVersionEx(&osVerInfo) == TRUE) + { + if(osVerInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) + { + throw "Ouuups: Not running under Windows NT. This is not supposed to happen!"; + } + version = (DWORD)((osVerInfo.dwMajorVersion << 16) | (osVerInfo.dwMinorVersion & 0xffff)); + } + + return version; +} + +/* + * Check for compatibility mode + */ +static bool x264_check_compatibility_mode(const char *exportName, const char *executableName) +{ + QLibrary kernel32("kernel32.dll"); + + if(exportName != NULL) + { + if(kernel32.resolve(exportName) != NULL) + { + qWarning("Function '%s' exported from 'kernel32.dll' -> Windows compatibility mode!", exportName); + qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(QString::fromLatin1(executableName)).toLatin1().constData()); + return false; + } + } + + return true; +} + +/* + * Check for process elevation + */ +static bool x264_check_elevation(void) +{ + typedef enum { x264_token_elevationType_class = 18, x264_token_elevation_class = 20 } X264_TOKEN_INFORMATION_CLASS; + typedef enum { x264_elevationType_default = 1, x264_elevationType_full, x264_elevationType_limited } X264_TOKEN_ELEVATION_TYPE; + + HANDLE hToken = NULL; + bool bIsProcessElevated = false; + + if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) + { + X264_TOKEN_ELEVATION_TYPE tokenElevationType; + DWORD returnLength; + if(GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS) x264_token_elevationType_class, &tokenElevationType, sizeof(X264_TOKEN_ELEVATION_TYPE), &returnLength)) + { + if(returnLength == sizeof(X264_TOKEN_ELEVATION_TYPE)) + { + switch(tokenElevationType) + { + case x264_elevationType_default: + qDebug("Process token elevation type: Default -> UAC is disabled.\n"); + break; + case x264_elevationType_full: + qWarning("Process token elevation type: Full -> potential security risk!\n"); + bIsProcessElevated = true; + break; + case x264_elevationType_limited: + qDebug("Process token elevation type: Limited -> not elevated.\n"); + break; + } + } + } + CloseHandle(hToken); + } + else + { + qWarning("Failed to open process token!"); + } + + return !bIsProcessElevated; +} + +/* + * Initialize Qt framework + */ +bool x264_init_qt(int argc, char* argv[]) +{ + static bool qt_initialized = false; + bool isWine = false; + typedef BOOL (WINAPI *SetDllDirectoryProc)(WCHAR *lpPathName); + + //Don't initialized again, if done already + if(qt_initialized) + { + return true; + } + + //Secure DLL loading + QLibrary kernel32("kernel32.dll"); + if(kernel32.load()) + { + SetDllDirectoryProc pSetDllDirectory = (SetDllDirectoryProc) kernel32.resolve("SetDllDirectoryW"); + if(pSetDllDirectory != NULL) pSetDllDirectory(L""); + kernel32.unload(); + } + + //Extract executable name from argv[] array + char *executableName = argv[0]; + while(char *temp = strpbrk(executableName, "\\/:?")) + { + executableName = temp + 1; + } + + //Check Qt version + qDebug("Using Qt v%s [%s], %s, %s", qVersion(), QLibraryInfo::buildDate().toString(Qt::ISODate).toLatin1().constData(), (qSharedBuild() ? "DLL" : "Static"), QLibraryInfo::buildKey().toLatin1().constData()); + qDebug("Compiled with Qt v%s [%s], %s\n", QT_VERSION_STR, QT_PACKAGEDATE_STR, QT_BUILD_KEY); + if(_stricmp(qVersion(), QT_VERSION_STR)) + { + qFatal("%s", QApplication::tr("Executable '%1' requires Qt v%2, but found Qt v%3.").arg(QString::fromLatin1(executableName), QString::fromLatin1(QT_VERSION_STR), QString::fromLatin1(qVersion())).toLatin1().constData()); + return false; + } + if(QLibraryInfo::buildKey().compare(QString::fromLatin1(QT_BUILD_KEY), Qt::CaseInsensitive)) + { + qFatal("%s", QApplication::tr("Executable '%1' was built for Qt '%2', but found Qt '%3'.").arg(QString::fromLatin1(executableName), QString::fromLatin1(QT_BUILD_KEY), QLibraryInfo::buildKey()).toLatin1().constData()); + return false; + } + + //Check the Windows version + switch(QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) + { + case 0: + case QSysInfo::WV_NT: + qFatal("%s", QApplication::tr("Executable '%1' requires Windows 2000 or later.").arg(QString::fromLatin1(executableName)).toLatin1().constData()); + break; + case QSysInfo::WV_2000: + qDebug("Running on Windows 2000 (not officially supported!).\n"); + x264_check_compatibility_mode("GetNativeSystemInfo", executableName); + break; + case QSysInfo::WV_XP: + qDebug("Running on Windows XP.\n"); + x264_check_compatibility_mode("GetLargePageMinimum", executableName); + break; + case QSysInfo::WV_2003: + qDebug("Running on Windows Server 2003 or Windows XP x64-Edition.\n"); + x264_check_compatibility_mode("GetLocaleInfoEx", executableName); + break; + case QSysInfo::WV_VISTA: + qDebug("Running on Windows Vista or Windows Server 2008.\n"); + x264_check_compatibility_mode("CreateRemoteThreadEx", executableName); + break; + case QSysInfo::WV_WINDOWS7: + qDebug("Running on Windows 7 or Windows Server 2008 R2.\n"); + x264_check_compatibility_mode(NULL, executableName); + break; + default: + { + DWORD osVersionNo = x264_get_os_version(); + qWarning("Running on an unknown/untested WinNT-based OS (v%u.%u).\n", HIWORD(osVersionNo), LOWORD(osVersionNo)); + } + break; + } + + //Check for Wine + QLibrary ntdll("ntdll.dll"); + if(ntdll.load()) + { + if(ntdll.resolve("wine_nt_to_unix_file_name") != NULL) isWine = true; + if(ntdll.resolve("wine_get_version") != NULL) isWine = true; + if(isWine) qWarning("It appears we are running under Wine, unexpected things might happen!\n"); + ntdll.unload(); + } + + //Create Qt application instance and setup version info + QApplication *application = new QApplication(argc, argv); + application->setApplicationName("LameXP - Audio Encoder Front-End"); + application->setApplicationVersion(QString().sprintf("%d.%02d", x264_version_major(), x264_version_minor())); + application->setOrganizationName("LoRd_MuldeR"); + application->setOrganizationDomain("mulder.at.gg"); + application->setWindowIcon(QIcon(":/icons/movie.ico")); + + //application->setEventFilter(x264_event_filter); + + //Set text Codec for locale + QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); + + //Load plugins from application directory + QCoreApplication::setLibraryPaths(QStringList() << QApplication::applicationDirPath()); + qDebug("Library Path:\n%s\n", QApplication::libraryPaths().first().toUtf8().constData()); + + //Check for supported image formats + QList supportedFormats = QImageReader::supportedImageFormats(); + for(int i = 0; g_x264_imageformats[i]; i++) + { + if(!supportedFormats.contains(g_x264_imageformats[i])) + { + qFatal("Qt initialization error: QImageIOHandler for '%s' missing!", g_x264_imageformats[i]); + return false; + } + } + + //Add default translations + // g_x264_translation.files.insert(x264_DEFAULT_LANGID, ""); + // g_x264_translation.names.insert(x264_DEFAULT_LANGID, "English"); + + //Check for process elevation + if(!x264_check_elevation()) + { + if(QMessageBox::warning(NULL, "LameXP", "LameXP was started with elevated rights. This is a potential security risk!", "Quit Program (Recommended)", "Ignore") == 0) + { + return false; + } + } + + //Update console icon, if a console is attached + if(g_x264_console_attached && !isWine) + { + typedef DWORD (__stdcall *SetConsoleIconFun)(HICON); + QLibrary kernel32("kernel32.dll"); + if(kernel32.load()) + { + SetConsoleIconFun SetConsoleIconPtr = (SetConsoleIconFun) kernel32.resolve("SetConsoleIcon"); + if(SetConsoleIconPtr != NULL) SetConsoleIconPtr(QIcon(":/icons/movie.ico").pixmap(16, 16).toWinHICON()); + kernel32.unload(); + } + } + + //Done + qt_initialized = true; + return true; +} + +/* + * Check for debugger (detect routine) + */ +static bool x264_check_for_debugger(void) +{ + __try + { + DebugBreak(); + } + __except(GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + { + return false; + } + return true; +} + +/* + * Check for debugger (thread proc) + */ +static void WINAPI x264_debug_thread_proc(__in LPVOID lpParameter) +{ + while(!(IsDebuggerPresent() || x264_check_for_debugger())) + { + Sleep(333); + } + TerminateProcess(GetCurrentProcess(), -1); +} + +/* + * Check for debugger (startup routine) + */ +static HANDLE x264_debug_thread_init(void) +{ + if(IsDebuggerPresent() || x264_check_for_debugger()) + { + FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!"); + TerminateProcess(GetCurrentProcess(), -1); + } + + return CreateThread(NULL, NULL, reinterpret_cast(&x264_debug_thread_proc), NULL, NULL, NULL); +} + +/* + * Initialize debug thread + */ +static const HANDLE g_debug_thread = X264_DEBUG ? NULL : x264_debug_thread_init(); + +/* + * Get number private bytes [debug only] + */ +SIZE_T x264_dbg_private_bytes(void) +{ +#if X264_DEBUG + PROCESS_MEMORY_COUNTERS_EX memoryCounters; + memoryCounters.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX); + GetProcessMemoryInfo(GetCurrentProcess(), (PPROCESS_MEMORY_COUNTERS) &memoryCounters, sizeof(PROCESS_MEMORY_COUNTERS_EX)); + return memoryCounters.PrivateUsage; +#else + throw "Cannot call this function in a non-debug build!"; +#endif //X264_DEBUG +} + +/* + * Finalization function + */ +void x264_finalization(void) +{ + /* NOP */ +} diff --git a/src/global.h b/src/global.h new file mode 100644 index 0000000..06389cf --- /dev/null +++ b/src/global.h @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#include "targetver.h" + +//C++ includes +#include +#include +#include +#include + +//Win32 includes +#define WIN32_LEAN_AND_MEAN +#include + +//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(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 +class QString; +class QStringList; +class QDate; +class QTime; +class QIcon; +class QWidget; +class LockedFile; +enum QtMsgType; + +//Types definitions +typedef struct +{ + int family; + int model; + int stepping; + int count; + bool x64; + bool mmx; + bool sse; + bool sse2; + bool sse3; + bool ssse3; + char vendor[0x40]; + char brand[0x40]; + bool intel; +} +x264_cpu_t; + +//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); +unsigned int x264_version_major(void); +unsigned int x264_version_minor(void); +const QDate &x264_version_date(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); +SIZE_T x264_dbg_private_bytes(void); +void x264_finalization(void); diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..a09f361 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,152 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#include "global.h" +#include "win_main.h" + +//Qt includes +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// Main function +/////////////////////////////////////////////////////////////////////////////// + +static int x264_main(int argc, char* argv[]) +{ + //Init console + x264_init_console(argc, argv); + + //Print version info + qDebug("Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth", x264_version_major(), x264_version_minor()); + qDebug("Copyright (c) 2004-%04d LoRd_MuldeR . Some rights reserved.", qMax(x264_version_date().year(),QDate::currentDate().year())); + qDebug("Built on %s at %s with %s for Win-%s.\n", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch()); + + //print license info + qDebug("This program is free software: you can redistribute it and/or modify"); + qDebug("it under the terms of the GNU General Public License ."); + qDebug("Note that this program is distributed with ABSOLUTELY NO WARRANTY.\n"); + + //Print warning, if this is a "debug" build + if(X264_DEBUG) + { + qWarning("---------------------------------------------------------"); + qWarning("DEBUG BUILD: DO NOT RELEASE THIS BINARY TO THE PUBLIC !!!"); + qWarning("---------------------------------------------------------\n"); + } + + //Detect CPU capabilities + 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 brand string : %s", cpuFeatures.brand); + qDebug(" CPU signature : Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping); + qDebug("CPU capabilities : MMX: %s, SSE: %s, SSE2: %s, SSE3: %s, SSSE3: %s, x64: %s", X264_BOOL(cpuFeatures.mmx), 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); + + //Initialize Qt + if(!x264_init_qt(argc, argv)) + { + return -1; + } + + //Run application + MainWindow *mainWin = new MainWindow; + mainWin->show(); + int ret = qApp->exec(); + X264_DELETE(mainWin); + return ret; +} + +/////////////////////////////////////////////////////////////////////////////// +// Applicaton entry point +/////////////////////////////////////////////////////////////////////////////// + +static int _main(int argc, char* argv[]) +{ + if(X264_DEBUG) + { + int iResult = -1; + qInstallMsgHandler(x264_message_handler); + X264_MEMORY_CHECK(iResult = x264_main(argc, argv)); + x264_finalization(); + return iResult; + } + else + { + int iResult = -1; + try + { + qInstallMsgHandler(x264_message_handler); + iResult = x264_main(argc, argv); + x264_finalization(); + } + catch(char *error) + { + fflush(stdout); + fflush(stderr); + fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error message: %s\n", error); + FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + } + catch(int error) + { + fflush(stdout); + fflush(stderr); + fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error); + FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + } + catch(...) + { + fflush(stdout); + fflush(stderr); + fprintf(stderr, "\nGURU MEDITATION !!!\n"); + FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + } + return iResult; + } +} + +int main(int argc, char* argv[]) +{ + if(X264_DEBUG) + { + return _main(argc, argv); + } + else + { + __try + { + SetUnhandledExceptionFilter(x264_exception_handler); + _set_invalid_parameter_handler(x264_invalid_param_handler); + return _main(argc, argv); + } + __except(1) + { + fflush(stdout); + fflush(stderr); + fprintf(stderr, "\nGURU MEDITATION !!!\n\nUnhandeled structured exception error! [code: 0x%X]\n", GetExceptionCode()); + FatalAppExit(0, L"Unhandeled structured exception error, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + } + } +} diff --git a/src/targetver.h b/src/targetver.h new file mode 100644 index 0000000..87c0086 --- /dev/null +++ b/src/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..11ab6c4 --- /dev/null +++ b/src/version.h @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#define VER_X264_MAJOR (2) +#define VER_X264_MINOR (0) diff --git a/src/win_main.cpp b/src/win_main.cpp new file mode 100644 index 0000000..420d006 --- /dev/null +++ b/src/win_main.cpp @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#include "win_main.h" +#include "global.h" + +/////////////////////////////////////////////////////////////////////////////// +// Constructor & Destructor +/////////////////////////////////////////////////////////////////////////////// + +MainWindow::MainWindow(void) +{ + //Init the dialog, from the .ui file + setupUi(this); + setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint); +} + +MainWindow::~MainWindow(void) +{ +} diff --git a/src/win_main.h b/src/win_main.h new file mode 100644 index 0000000..4ce8fdd --- /dev/null +++ b/src/win_main.h @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////////////////////// +// Simple x264 Launcher +// Copyright (C) 2004-2012 LoRd_MuldeR +// +// 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 +/////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "uic_win_main.h" + +class MainWindow: public QMainWindow, private Ui::MainWindow +{ + Q_OBJECT + +public: + MainWindow(); + ~MainWindow(void); +}; diff --git a/x264_launcher.sln b/x264_launcher.sln new file mode 100644 index 0000000..5ebdfec --- /dev/null +++ b/x264_launcher.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x264_launcher", "x264_launcher.vcxproj", "{563D953B-CBC3-4C75-AFC2-5BD87531C332}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {563D953B-CBC3-4C75-AFC2-5BD87531C332}.Debug|Win32.ActiveCfg = Debug|Win32 + {563D953B-CBC3-4C75-AFC2-5BD87531C332}.Debug|Win32.Build.0 = Debug|Win32 + {563D953B-CBC3-4C75-AFC2-5BD87531C332}.Release|Win32.ActiveCfg = Release|Win32 + {563D953B-CBC3-4C75-AFC2-5BD87531C332}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/x264_launcher.vcxproj b/x264_launcher.vcxproj new file mode 100644 index 0000000..4035c78 --- /dev/null +++ b/x264_launcher.vcxproj @@ -0,0 +1,137 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {563D953B-CBC3-4C75-AFC2-5BD87531C332} + Win32Proj + x264_launcher + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)obj\$(Configuration)\ + + + false + $(SolutionDir)bin\$(Configuration)\ + $(SolutionDir)obj\$(Configuration)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;QT_DEBUG;QT_DLL;%(PreprocessorDefinitions) + $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) + + + Windows + true + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + QtMaind.lib;QtCored4.lib;QtGuid4.lib;psapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + Full + true + true + WIN32;NDEBUG;QT_NO_DEBUG;QT_DLL;%(PreprocessorDefinitions) + $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) + AnySuitable + Speed + true + MultiThreadedDLL + NotSet + Fast + false + + + Windows + true + true + true + $(QTDIR)\lib;%(AdditionalLibraryDirectories) + QtMain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) + + + + + Document + "$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\uic\uic_%(Filename).h" "%(FullPath)" + UIC "$(SolutionDir)tmp\UIC_%(Filename).h" + $(SolutionDir)tmp\uic\uic_%(Filename).h;%(Outputs) + "$(QTDIR)\bin\uic.exe" -o "$(SolutionDir)tmp\uic\uic_%(Filename).h" "%(FullPath)" + UIC "$(SolutionDir)tmp\UIC_%(Filename).h" + $(SolutionDir)tmp\uic\uic_%(Filename).h;%(Outputs) + + + + Document + "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\qrc\qrc_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" + RCC "$(SolutionDir)tmp\QRC_%(Filename).cpp" + $(SolutionDir)tmp\qrc\qrc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\rcc.exe" -o "$(SolutionDir)tmp\qrc\qrc_%(Filename).cpp" -name "%(Filename)" "%(FullPath)" + RCC "$(SolutionDir)tmp\QRC_%(Filename).cpp" + $(SolutionDir)tmp\qrc\qrc_%(Filename).cpp;%(Outputs) + + + + + + + + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + $(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs) + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\moc\moc_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + $(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs) + + + + + + + + + + + + + \ No newline at end of file diff --git a/x264_launcher.vcxproj.filters b/x264_launcher.vcxproj.filters new file mode 100644 index 0000000..ce4f564 --- /dev/null +++ b/x264_launcher.vcxproj.filters @@ -0,0 +1,65 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {c2fedf5a-a6cd-4538-bbc1-269ebb2beb39} + + + {961e9f99-8107-45a2-984d-188819a67e8e} + + + + + + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Generated Files + + + Generated Files + + + + + Dialogs + + + Header Files + + + Resource Files + + + \ No newline at end of file