From 63bd1ac597715f09c9a19b2f34a3e517dc8a3b6f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 21 Jan 2019 16:22:42 +1100 Subject: [PATCH] fixed clip sizes not updating in frei0r --- effects/internal/frei0reffect.cpp | 38 +++++++++++++++++++++++-------- effects/internal/frei0reffect.h | 7 +++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/effects/internal/frei0reffect.cpp b/effects/internal/frei0reffect.cpp index 50ccd6698..a45efcf36 100644 --- a/effects/internal/frei0reffect.cpp +++ b/effects/internal/frei0reffect.cpp @@ -5,6 +5,8 @@ #include #include +#include "project/clip.h" + typedef f0r_instance_t (*f0rConstructFunc)(unsigned int width, unsigned int height); typedef int (*f0rInitFunc) (); typedef void (*f0rDeinitFunc) (); @@ -15,7 +17,10 @@ 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) { +Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : + Effect(c, em), + open(false) +{ enable_image = true; // Windows DLL loading routine @@ -53,8 +58,7 @@ Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { f0rInitFunc init = reinterpret_cast(LibAddress(handle, "f0r_init")); init(); - f0rConstructFunc construct = reinterpret_cast(LibAddress(handle, "f0r_construct")); - instance = construct(1920, 1080); + construct_module(); f0r_plugin_info_t info; f0rGetPluginInfo info_func = reinterpret_cast(LibAddress(handle, "f0r_get_plugin_info")); @@ -62,10 +66,6 @@ Frei0rEffect::Frei0rEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { param_count = info.num_params; -// qDebug() << "Frei0r Name:" << info.name; -// qDebug() << "Frei0r Param Count:" << info.num_params; -// qDebug() << "Frei0r Explanation:" << info.explanation; - get_param_info = reinterpret_cast(LibAddress(handle, "f0r_get_param_info")); for (int i=0;i(LibAddress(handle, "f0r_destruct")); - destruct(instance); - f0rDeinitFunc deinit = reinterpret_cast(LibAddress(handle, "f0r_deinit")); deinit(); @@ -173,4 +170,25 @@ void Frei0rEffect::process_image(double timecode, uint8_t *input, uint8_t *outpu 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->getWidth(), parent_clip->getHeight()); + + open = true; +} + #endif diff --git a/effects/internal/frei0reffect.h b/effects/internal/frei0reffect.h index a9730b6c5..413baf676 100644 --- a/effects/internal/frei0reffect.h +++ b/effects/internal/frei0reffect.h @@ -19,11 +19,16 @@ public: ~Frei0rEffect(); virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); + + virtual void refresh(); private: - ModulePtr handle; + ModulePtr handle; f0r_instance_t instance; int param_count; f0rGetParamInfo get_param_info; + void destruct_module(); + void construct_module(); + bool open; }; #endif