From c5a64adc40b276455c0337a4deb5017f1464d202 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 20 Mar 2019 14:49:07 +1100 Subject: [PATCH] excised frei0r effect --- effects/effect.cpp | 4 - effects/effect.h | 4 +- effects/effectloaders.cpp | 84 +----------- effects/internal/frei0reffect.cpp | 219 ------------------------------ effects/internal/frei0reffect.h | 55 -------- olive.pro | 2 - timeline/clip.cpp | 6 +- 7 files changed, 10 insertions(+), 364 deletions(-) delete mode 100644 effects/internal/frei0reffect.cpp delete mode 100644 effects/internal/frei0reffect.h diff --git a/effects/effect.cpp b/effects/effect.cpp index 4a8f29f7f..387a374bb 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -66,7 +66,6 @@ #include "effects/internal/cornerpineffect.h" #include "effects/internal/vsthost.h" #include "effects/internal/fillleftrighteffect.h" -#include "effects/internal/frei0reffect.h" #include "effects/internal/richtexteffect.h" QVector olive::effects; @@ -89,9 +88,6 @@ EffectPtr Effect::Create(Clip* c, const EffectMeta* em) { case EFFECT_INTERNAL_FILLLEFTRIGHT: return std::make_shared(c, em); #ifndef NOVST case EFFECT_INTERNAL_VST: return std::make_shared(c, em); -#endif -#ifndef NOFREI0R - case EFFECT_INTERNAL_FREI0R: return std::make_shared(c, em); #endif case EFFECT_INTERNAL_RICHTEXT: return std::make_shared(c, em); } diff --git a/effects/effect.h b/effects/effect.h index 6123bb348..89d4809bd 100644 --- a/effects/effect.h +++ b/effects/effect.h @@ -108,7 +108,6 @@ enum EffectInternal { EFFECT_INTERNAL_FILLLEFTRIGHT, EFFECT_INTERNAL_VST, EFFECT_INTERNAL_CORNERPIN, - EFFECT_INTERNAL_FREI0R, EFFECT_INTERNAL_RICHTEXT, EFFECT_INTERNAL_COUNT }; @@ -179,8 +178,7 @@ public: enum VideoEffectFlags { ShaderFlag = 0x1, CoordsFlag = 0x2, - SuperimposeFlag = 0x4, - ImageFlag = 0x8 + SuperimposeFlag = 0x4 }; int Flags(); void SetFlags(int flags); diff --git a/effects/effectloaders.cpp b/effects/effectloaders.cpp index 1d635d664..ee694a73f 100644 --- a/effects/effectloaders.cpp +++ b/effects/effectloaders.cpp @@ -20,6 +20,10 @@ #include "effectloaders.h" +#include +#include +#include + #include "effects/effect.h" #include "effects/transition.h" #include "global/path.h" @@ -28,16 +32,6 @@ #include "global/crossplatformlib.h" #include "global/config.h" -#include -#include - -#include - -#ifndef NOFREI0R -#include -typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info); -#endif - QMutex olive::effects_loaded; void load_internal_effects() { @@ -206,73 +200,6 @@ void EffectInit::StartLoading() { init_thread->start(); } -#ifndef NOFREI0R -void load_frei0r_effects_worker(const QString& dir, EffectMeta& em, QVector& loaded_names) { - QDir search_dir(dir); - if (search_dir.exists()) { - QList entry_list = search_dir.entryList(LibFilter(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); - for (int j=0;j(LibAddress(effect, "f0r_get_plugin_info")); - if (get_info_func != nullptr) { - f0r_plugin_info_t info; - get_info_func(&info); - - if (!loaded_names.contains(info.name) - && info.plugin_type == F0R_PLUGIN_TYPE_FILTER - && info.color_model == F0R_COLOR_MODEL_RGBA8888) { - em.name = info.name; - em.path = dir; - em.filename = entry_list.at(j); - em.tooltip = QString("%1\n%2\n%3\n%4").arg(em.name, info.author, info.explanation, em.filename); - - loaded_names.append(em.name); - - olive::effects.append(em); - } -// qDebug() << "Found:" << info.name << "by" << info.author; - } - LibClose(effect); - } -// qDebug() << search_dir.filePath(entry_list.at(j)); - } - } - } -} - -void load_frei0r_effects() { - QList effect_dirs = get_effects_paths(); - - // add defined paths for frei0r plugins on unix -#if defined(__APPLE__) || defined(__linux__) || defined(__HAIKU__) - effect_dirs.prepend("/usr/lib/frei0r-1"); - effect_dirs.prepend("/usr/local/lib/frei0r-1"); - effect_dirs.prepend(QDir::homePath() + "/.frei0r-1/lib"); -#endif - - QString env_path(qgetenv("FREI0R_PATH")); - if (!env_path.isEmpty()) effect_dirs.append(env_path); - - QVector loaded_names; - - // search for paths - EffectMeta em; - em.category = "Frei0r"; - em.type = EFFECT_TYPE_EFFECT; - em.subtype = EFFECT_TYPE_VIDEO; - em.internal = EFFECT_INTERNAL_FREI0R; - - for (int i=0;i. - -***/ - -#include "frei0reffect.h" - -#ifndef NOFREI0R - -#include -#include - -#include "timeline/clip.h" - -typedef f0r_instance_t (*f0rConstructFunc)(unsigned int width, unsigned int height); -typedef int (*f0rInitFunc) (); -typedef void (*f0rDeinitFunc) (); -typedef void (*f0rUpdateFunc) (f0r_instance_t instance, - double time, const uint32_t* inframe, uint32_t* outframe); -typedef void (*f0rDestructFunc)(f0r_instance_t instance); -typedef void (*f0rGetPluginInfo)(f0r_plugin_info_t* info); -typedef void (*f0rSetParamValue) (f0r_instance_t instance, - f0r_param_t param, int param_index); - -Frei0rEffect::Frei0rEffect(Clip* c, const EffectMeta *em) : - Effect(c, em), - open(false) -{ - SetFlags(ImageFlag); - - // Windows DLL loading routine - QString dll_fn = QDir(em->path).filePath(em->filename); - - handle = LibLoad(dll_fn); - if(handle == nullptr) { - QString dll_error; - -#ifdef _WIN32 - DWORD dll_err = GetLastError(); - dll_error = QString::number(dll_err); -#elif __linux__ - 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); - -#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."); -#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."); -#endif - } -#endif - - QMessageBox::critical(nullptr, tr("Error loading Frei0r plugin"), msg_err); - - return; - } - - f0rInitFunc init = reinterpret_cast(LibAddress(handle, "f0r_init")); - init(); - - construct_module(); - - f0r_plugin_info_t info; - f0rGetPluginInfo info_func = reinterpret_cast(LibAddress(handle, "f0r_get_plugin_info")); - info_func(&info); - - param_count = info.num_params; - - get_param_info = reinterpret_cast(LibAddress(handle, "f0r_get_param_info")); - for (int i=0;i= 0 && param_info.type <= F0R_PARAM_STRING) { - EffectRow* row = new EffectRow(this, param_info.name); - switch (param_info.type) { - case F0R_PARAM_BOOL: - new BoolField(row, QString::number(i)); - break; - case F0R_PARAM_DOUBLE: - { - DoubleField* f = new DoubleField(row, QString::number(i)); - f->SetMinimum(0); - f->SetMaximum(100); - } - break; - case F0R_PARAM_COLOR: - new ColorField(row, QString::number(i)); - break; - case F0R_PARAM_POSITION: - { - DoubleField* fx = new DoubleField(row, QString("%1X").arg(QString::number(i))); - fx->SetMinimum(0); - fx->SetMaximum(100); - DoubleField* fy = new DoubleField(row, QString("%1Y").arg(QString::number(i))); - fy->SetMinimum(0); - fy->SetMaximum(100); - } - break; - case F0R_PARAM_STRING: - new StringField(row, QString::number(i)); - break; - } - } - } -} - -Frei0rEffect::~Frei0rEffect() { - if (handle != nullptr) { - f0rDeinitFunc deinit = reinterpret_cast(LibAddress(handle, "f0r_deinit")); - deinit(); - - LibClose(handle); - } -} - -void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *output, int) { - f0rUpdateFunc update_func = reinterpret_cast(LibAddress(handle, "f0r_update")); - - for (int i=0;i(LibAddress(handle, "f0r_set_param_value")); - switch (param_info.type) { - case F0R_PARAM_BOOL: - { - double b = param_row->Field(0)->GetValueAt(timecode).toBool(); - - set_param(instance, &b, i); - } - break; - case F0R_PARAM_DOUBLE: - { - double d = param_row->Field(0)->GetValueAt(timecode).toDouble()*0.01; - - set_param(instance, &d, i); - } - break; - case F0R_PARAM_COLOR: - { - QColor qcolor = param_row->Field(0)->GetValueAt(timecode).value(); - - f0r_param_color fcolor; - fcolor.r = float(qcolor.redF()); - fcolor.g = float(qcolor.greenF()); - fcolor.b = float(qcolor.blueF()); - - set_param(instance, &fcolor, i); - } - break; - case F0R_PARAM_POSITION: - { - f0r_param_position pos; - - pos.x = param_row->Field(0)->GetValueAt(timecode).toDouble(); - pos.y = param_row->Field(1)->GetValueAt(timecode).toDouble(); - - set_param(instance, &pos, i); - } - break; - case F0R_PARAM_STRING: - { - QByteArray bytes = param_row->Field(0)->GetValueAt(timecode).toString().toUtf8(); - - char* byte_data = bytes.data(); - set_param(instance, &byte_data, i); - } - break; - } - } - - update_func(instance, timecode, reinterpret_cast(input), reinterpret_cast(output)); -} - -void Frei0rEffect::refresh() { - destruct_module(); - construct_module(); -} - -void Frei0rEffect::destruct_module() { - if (open) { - f0rDestructFunc destruct = reinterpret_cast(LibAddress(handle, "f0r_destruct")); - destruct(instance); - - open = false; - } -} - -void Frei0rEffect::construct_module() { - f0rConstructFunc construct = reinterpret_cast(LibAddress(handle, "f0r_construct")); - instance = construct(parent_clip->media_width(), parent_clip->media_height()); - - open = true; -} - -#endif diff --git a/effects/internal/frei0reffect.h b/effects/internal/frei0reffect.h deleted file mode 100644 index 4551d63b7..000000000 --- a/effects/internal/frei0reffect.h +++ /dev/null @@ -1,55 +0,0 @@ -/*** - - Olive - Non-Linear Video Editor - Copyright (C) 2019 Olive Team - - 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 3 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, see . - -***/ - -#ifndef FREI0REFFECT_H -#define FREI0REFFECT_H - -#ifndef NOFREI0R - -#include - -#include "effects/effect.h" -#include "global/crossplatformlib.h" - -typedef void (*f0rGetParamInfo)(f0r_param_info_t * info, - int param_index ); - -class Frei0rEffect : public Effect { - Q_OBJECT -public: - Frei0rEffect(Clip* c, const EffectMeta* em); - ~Frei0rEffect(); - - virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); - - virtual void refresh(); -private: - ModulePtr handle; - f0r_instance_t instance; - int param_count; - f0rGetParamInfo get_param_info; - void destruct_module(); - void construct_module(); - bool open; -}; - -#endif - -#endif // FREI0REFFECT_H diff --git a/olive.pro b/olive.pro index 96c32b374..f0f948fa0 100644 --- a/olive.pro +++ b/olive.pro @@ -133,7 +133,6 @@ SOURCES += \ dialogs/debugdialog.cpp \ ui/viewerwindow.cpp \ project/projectfilter.cpp \ - effects/internal/frei0reffect.cpp \ effects/effectloaders.cpp \ global/crossplatformlib.cpp \ effects/internal/vsthost.cpp \ @@ -260,7 +259,6 @@ HEADERS += \ dialogs/debugdialog.h \ ui/viewerwindow.h \ project/projectfilter.h \ - effects/internal/frei0reffect.h \ effects/effectloaders.h \ global/crossplatformlib.h \ effects/internal/vsthost.h \ diff --git a/timeline/clip.cpp b/timeline/clip.cpp index 57e5c60fc..036fd99ca 100644 --- a/timeline/clip.cpp +++ b/timeline/clip.cpp @@ -582,6 +582,7 @@ bool Clip::Retrieve() f->glPixelStorei(GL_UNPACK_ROW_LENGTH, frame->linesize[0]/kRGBAComponentCount); + /* // 2 data buffers to ping-pong between bool using_db_1 = true; uint8_t* data_buffer_1 = frame->data[0]; @@ -608,15 +609,18 @@ bool Clip::Retrieve() using_db_1 = !using_db_1; } } + */ texture->setData(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, - const_cast(using_db_1 ? data_buffer_1 : data_buffer_2)); + const_cast(frame->data[0])); + /* if (data_buffer_1 != frame->data[0]) { delete [] data_buffer_1; delete [] data_buffer_2; } + */ f->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);