#include "binaries.h"
+#include "global.h"
#include "model_sysinfo.h"
#include "model_preferences.h"
#include "model_options.h"
//Sanity check
if(baseName.isEmpty() || arch.isEmpty() || variant.isEmpty())
{
- throw "Failed to determine the encoder binarty path!";
+ THROW("Failed to determine the encoder binarty path!");
}
//Return path
*/
#include "checksum.h"
+
+#include "global.h"
#include "3rd_party/blake2.h"
#include <malloc.h>
{
if(!(state = (blake2b_state*) _aligned_malloc(sizeof(blake2b_state), 64)))
{
- throw std::runtime_error("Aligend malloc has failed!");
+ THROW("Aligend malloc has failed!");
}
memset(state, 0, sizeof(blake2b_state));
}
{
if(m_finalized)
{
- throw std::runtime_error("BLAKE2 was already finalized!");
+ THROW("BLAKE2 was already finalized!");
}
if(data.size() > 0)
{
if(blake2b_update(m_context->state, (const uint8_t*) data.constData(), data.size()) != 0)
{
- throw std::runtime_error("BLAKE2 internal error!");
+ THROW("BLAKE2 internal error!");
}
}
}
{
if(blake2b_final(m_context->state, (uint8_t*) m_hash.data(), m_hash.size()) != 0)
{
- throw std::runtime_error("BLAKE2 internal error!");
+ THROW("BLAKE2 internal error!");
}
m_finalized = true;
return tr("N/A");
}
+
+const AbstractEncoderInfo& AbstractEncoder::getEncoderInfo(void)
+{
+ THROW("[getEncoderInfo] This function must be overwritten in sub-classes!");
+}
virtual ~AbstractEncoder(void);
virtual bool runEncodingPass(AbstractSource* pipedSource, const QString outputFile, const unsigned int &frames, const int &pass = 0, const QString &passLogFile = QString());
+
static const AbstractEncoderInfo& getEncoderInfo(void);
protected:
#include "encoder_x264.h"
+#include "global.h"
#include "model_options.h"
#include "model_status.h"
#include "binaries.h"
{
if(options->encType() != OptionsModel::EncType_X264)
{
- throw "Invalid encoder type!";
+ THROW("Invalid encoder type!");
}
}
cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break;
default:
- throw "Bad rate-control mode !!!";
- break;
+ THROW("Bad rate-control mode !!!");
}
if((pass == 1) || (pass == 2))
if(usePipe)
{
- if(frames < 1) throw "Frames not set!";
+ if(frames < 1) THROW("Frames not set!");
cmdLine << "--frames" << QString::number(frames);
cmdLine << "--demuxer" << "y4m";
cmdLine << "--stdin" << "y4m" << "-";
#include "encoder_x265.h"
+#include "global.h"
#include "model_options.h"
#include "model_status.h"
#include "binaries.h"
-#include "binaries.h"
#include <QStringList>
#include <QDir>
{
if(options->encType() != OptionsModel::EncType_X265)
{
- throw "Invalid encoder type!";
+ THROW("Invalid encoder type!");
}
}
cmdLine << "--bitrate" << QString::number(m_options->bitrate());
break;
default:
- throw "Bad rate-control mode !!!";
+ THROW("Bad rate-control mode !!!");
break;
}
if(usePipe)
{
- if(frames < 1) throw "Frames not set!";
+ if(frames < 1) THROW("Frames not set!");
cmdLine << "--frames" << QString::number(frames);
cmdLine << "--y4m" << "-";
}
if((type == QtCriticalMsg) || (type == QtFatalMsg))
{
lock.unlock();
- x264_fatal_exit(L"The application has encountered a critical error and will exit now!", QWCHAR(QString::fromUtf8(msg)));
+ x264_fatal_exit(L"The application has encountered a critical error and will exit now!", QString::fromUtf8(msg).toLatin1().constData());
}
}
}
/*
+ * Exception class
+ */
+X264Exception::X264Exception(const char *message, ...)
+:
+ runtime_error(message)
+{
+ va_list args;
+ va_start(args, message);
+ vsnprintf_s(m_message, MAX_MSGLEN, _TRUNCATE, message, args);
+ va_end(args);
+}
+
+/*
* Check for debugger (detect routine)
*/
static __forceinline bool x264_check_for_debugger(void)
* Fatal application exit
*/
#pragma intrinsic(_InterlockedExchange)
-void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage)
+void x264_fatal_exit(const wchar_t* exitMessage, const char* errorBoxMessage)
{
static volatile long bFatalFlag = 0L;
if(errorBoxMessage)
{
- MessageBoxW(NULL, errorBoxMessage, L"Simple x264 Launcher - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
+ MessageBoxA(NULL, errorBoxMessage, "Simple x264 Launcher - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
}
FatalAppExit(0, exitMessage);
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!";
+ THROW("Cannot call this function in a non-debug build!");
#endif //X264_DEBUG
}
#define _CRT_RAND_S
#include <cstdlib>
+#include <stdexcept>
//Forward declarations
class QString;
extern const x264_os_version_t x264_winver_win80;
extern const x264_os_version_t x264_winver_win81;
+//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];
+};
+
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
size_t x264_dbg_private_bytes(void);
x264_cpu_t x264_detect_cpu_features(const int argc, char **argv);
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 char* errorBoxMessage = NULL);
void x264_finalization(void);
void x264_init_console(const int argc, char **argv);
void x264_init_process(QProcess &process, const QString &wokringDir, const bool bReplaceTempDir = true);
#endif
//Helper macro for throwing exceptions
-#define THROW(MESSAGE) do \
-{ \
- throw std::runtime_error((MESSAGE)); \
-} \
-while(0)
-#define THROW_FMT(FORMAT, ...) do \
+#define THROW(MESSAGE, ...) do \
{ \
- char _error_msg[512]; \
- _snprintf_s(_error_msg, 512, _TRUNCATE, (FORMAT), __VA_ARGS__); \
- throw std::runtime_error(_error_msg); \
+ throw X264Exception((MESSAGE), __VA_ARGS__); \
} \
while(0)
{
if(m_initialized < 0)
{
- throw std::runtime_error("IPC not initialized!");
+ THROW("IPC not initialized!");
}
if(!m_semaphoreWr->acquire())
if(m_initialized < 0)
{
- throw std::runtime_error("IPC not initialized!");
+ THROW("IPC not initialized!");
}
if(!m_semaphoreRd->acquire())
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);
+#define PRINT_ERROR(MESSAGE, ...) do \
+{ \
+ fflush(stdout); \
+ fflush(stderr); \
+ fprintf(stderr, (MESSAGE), __VA_ARGS__); \
+ fflush(stderr); \
+} \
+while(0)
+
static int _main(int argc, char* argv[])
{
if(X264_DEBUG)
iResult = x264_main(argc, argv);
x264_finalization();
}
+ catch(const X264Exception &e)
+ {
+ PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error message: %s\n", e.what());
+ x264_fatal_exit(L"An internal error was detected, application will exit!", e.what());
+ }
+ catch(const std::exception &e)
+ {
+ PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error message: %s\n", e.what());
+ x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!", e.what());
+ }
catch(char *error)
{
- fflush(stdout);
- fflush(stderr);
- fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error message: %s\n", error);
+ PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error message: %s\n", error);
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(int error)
{
- fflush(stdout);
- fflush(stderr);
- fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error);
+ PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error);
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
- fflush(stdout);
- fflush(stderr);
- fprintf(stderr, "\nGURU MEDITATION !!!\n");
+ PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown C++ exception!\n");
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
return iResult;
WinSevenTaskbar::WinSevenTaskbar(void)
{
- throw "Cannot create instance of this class!";
+ THROW("Cannot create instance of this class!");
}
WinSevenTaskbar::~WinSevenTaskbar(void)
#define VER_X264_MAJOR 2
#define VER_X264_MINOR 3
#define VER_X264_PATCH 5
-#define VER_X264_BUILD 816
+#define VER_X264_BUILD 818
#define VER_X264_PORTABLE_EDITION (0)
ui->labelProfile->setEnabled(!noProf);
ui->cbxProfile->setEnabled(!noProf);
if(noProf) ui->cbxProfile->setCurrentIndex(0);
+
+ variantIndexChanged(ui->cbxEncoderVariant->currentIndex());
}
void AddJobDialog::variantIndexChanged(int index)
ui->labelProfile->setEnabled(!noProf);
ui->cbxProfile->setEnabled(!noProf);
if(noProf) ui->cbxProfile->setCurrentIndex(0);
+
+ modeIndexChanged(ui->cbxRateControlMode->currentIndex());
}
void AddJobDialog::modeIndexChanged(int index)
{
- ui->spinQuantizer->setEnabled(index == 0 || index == 1);
- ui->spinBitrate->setEnabled(index == 2 || index == 3);
+ ui->spinQuantizer->setEnabled(index == OptionsModel::RCMode_CRF || index == OptionsModel::RCMode_CQ);
+ ui->spinBitrate ->setEnabled(index == OptionsModel::RCMode_ABR || index == OptionsModel::RCMode_2Pass);
}
void AddJobDialog::accept(void)
}
break;
default:
- throw std::exception("Unknown command received!");
+ THROW("Unknown command received!");
}
}
UPDATE_ICON(3, "play");
break;
default:
- throw "Unknown status code!";
+ THROW("Unknown status code!");
}
}