From 6d49f598a3002bb6725b045ba29028f71fc159eb Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 20 Jan 2019 23:11:19 +1100 Subject: [PATCH] some corrections on windows --- effects/internal/frei0reffect.cpp | 43 +++++++++++++++---------------- io/crossplatformlib.cpp | 18 ++++++------- io/crossplatformlib.h | 16 ++++++------ playback/playback.cpp | 2 +- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/effects/internal/frei0reffect.cpp b/effects/internal/frei0reffect.cpp index fef9c937b..c0ae93f8e 100644 --- a/effects/internal/frei0reffect.cpp +++ b/effects/internal/frei0reffect.cpp @@ -19,44 +19,43 @@ Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { // Windows DLL loading routine QString dll_fn = QDir(em->path).filePath(em->filename); - handle = LibLoad(dll_fn); - if(handle == nullptr) { - QString dll_error; + handle = LibLoad(dll_fn); + if(handle == nullptr) { + QString dll_error; #ifdef _WIN32 DWORD dll_err = GetLastError(); - dll_error = QString::number(dll_err); - qCritical() << "Failed to load Frei0r plugin" << dll_fn_w << "-" << dll_err; + dll_error = QString::number(dll_err); #elif __linux__ - dll_error = dlerror(); - qCritical() << "Failed to load Frei0r plugin" << dll_fn << "-" << dll_error; + dll_error = dlerror(); #endif + qCritical() << "Failed to load Frei0r plugin" << dll_fn << "-" << dll_error; - QString msg_err = tr("Failed to load Frei0r plugin \"%1\": %2").arg(dll_fn, dll_error); + QString msg_err = tr("Failed to load Frei0r plugin \"%1\": %2").arg(dll_fn, dll_error); #ifdef _WIN32 if (dll_err == 193) { #ifdef _WIN64 - msg_err += "\n\n" + tr("NOTE: You can't load 32-bit Frei0r plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive."); + msg_err += "\n\n" + tr("NOTE: You can't load 32-bit Frei0r plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive."); #elif _WIN32 - msg_err += "\n\n" + tr("NOTE: You can't load 64-bit Frei0r plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive."); + msg_err += "\n\n" + tr("NOTE: You can't load 64-bit Frei0r plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive."); #endif } #endif - QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err); + QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err); return; - } + } - f0rInitFunc init = reinterpret_cast(LibAddress(handle, "f0r_init")); + f0rInitFunc init = reinterpret_cast(LibAddress(handle, "f0r_init")); init(); - f0rConstructFunc construct = reinterpret_cast(LibAddress(handle, "f0r_construct")); + f0rConstructFunc construct = reinterpret_cast(LibAddress(handle, "f0r_construct")); instance = construct(1920, 1080); f0r_plugin_info_t info; - f0rGetPluginInfo info_func = reinterpret_cast(LibAddress(handle, "f0r_get_plugin_info")); + f0rGetPluginInfo info_func = reinterpret_cast(LibAddress(handle, "f0r_get_plugin_info")); info_func(&info); param_count = info.num_params; @@ -65,7 +64,7 @@ Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { qDebug() << "Frei0r Param Count:" << info.num_params; qDebug() << "Frei0r Explanation:" << info.explanation; - get_param_info = reinterpret_cast(LibAddress(handle, "f0r_get_param_info")); + get_param_info = reinterpret_cast(LibAddress(handle, "f0r_get_param_info")); for (int i=0;i(LibAddress(handle, "f0r_destruct")); + if (handle != nullptr) { + f0rDestructFunc destruct = reinterpret_cast(LibAddress(handle, "f0r_destruct")); destruct(instance); - f0rDeinitFunc deinit = reinterpret_cast(LibAddress(handle, "f0r_deinit")); + f0rDeinitFunc deinit = reinterpret_cast(LibAddress(handle, "f0r_deinit")); deinit(); - LibClose(handle); + LibClose(handle); } } void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *output, int) { - f0rUpdateFunc update_func = reinterpret_cast(LibAddress(handle, "f0r_update")); + f0rUpdateFunc update_func = reinterpret_cast(LibAddress(handle, "f0r_update")); for (int i=0;i(LibAddress(handle, "f0r_set_param_value")); + f0rSetParamValue set_param = reinterpret_cast(LibAddress(handle, "f0r_set_param_value")); switch (param_info.type) { case F0R_PARAM_BOOL: { diff --git a/io/crossplatformlib.cpp b/io/crossplatformlib.cpp index d05558dc3..41d525525 100644 --- a/io/crossplatformlib.cpp +++ b/io/crossplatformlib.cpp @@ -2,24 +2,24 @@ #include -void *LibLoad(const QString &filename) { +ModulePtr LibLoad(const QString &filename) { #ifdef _WIN32 - LPCWSTR dll_fn_w = reinterpret_cast(filename.utf16()); - return LoadLibrary(dll_fn_w); + LPCWSTR dll_fn_w = reinterpret_cast(filename.utf16()); + return LoadLibrary(dll_fn_w); #elif __linux__ - return dlopen(filename.toUtf8(), RTLD_LAZY); + return dlopen(filename.toUtf8(), RTLD_LAZY); #else - qWarning() << "Olive doesn't know how to open dynamic libraries on this platform, external libraries will not be functional"; - return nullptr; + qWarning() << "Olive doesn't know how to open dynamic libraries on this platform, external libraries will not be functional"; + return nullptr; #endif } QStringList LibFilter() { #ifdef _WIN32 - return QStringList("*.dll"); + return QStringList("*.dll"); #elif __linux__ - return QStringList("*.so"); + return QStringList("*.so"); #elif __APPLE__ - return QStringList("*.dylib"); + return QStringList("*.dylib"); #endif } diff --git a/io/crossplatformlib.h b/io/crossplatformlib.h index 1b3eb266b..c4f21d9d2 100644 --- a/io/crossplatformlib.h +++ b/io/crossplatformlib.h @@ -4,15 +4,15 @@ #include #ifdef _WIN32 - #include - #define LibAddress GetProcAddress - #define CloseLib FreeModule - #define ModulePtr HMODULE + #include + #define LibAddress GetProcAddress + #define LibClose FreeModule + #define ModulePtr HMODULE #elif __linux__ - #include - #define LibAddress dlsym - #define LibClose dlclose - #define ModulePtr void* + #include + #define LibAddress dlsym + #define LibClose dlclose + #define ModulePtr void* #endif ModulePtr LibLoad(const QString& filename); diff --git a/playback/playback.cpp b/playback/playback.cpp index b8573942e..4495023e3 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -264,7 +264,7 @@ void get_clip_frame(Clip* c, long playhead, bool& texture_failed) { for (int i=0;ieffects.size();i++) { Effect* e = c->effects.at(i); - if (e->enable_image) { + if (e->enable_image && e->is_enabled()) { if (data_buffer_1 == target_frame->data[0]) { frame_size = target_frame->linesize[0]*target_frame->height;