diff --git a/app/node/plugins/Plugin.h b/app/node/plugins/Plugin.h index 61c7518c0..6133def42 100644 --- a/app/node/plugins/Plugin.h +++ b/app/node/plugins/Plugin.h @@ -20,7 +20,7 @@ #define PLUGIN_NODES_H #include "node/node.h" #include "pluginSupport/Plugin.h" -#include "pluginSupport/olive_plugin.h" +#include "pluginSupport/OlivePlugin.h" namespace olive { namespace plugin diff --git a/app/pluginSupport/CMakeLists.txt b/app/pluginSupport/CMakeLists.txt index 4586c893f..4ef75de73 100644 --- a/app/pluginSupport/CMakeLists.txt +++ b/app/pluginSupport/CMakeLists.txt @@ -1,6 +1,7 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - pluginSupport/olive_plugin.h + pluginSupport/OlivePlugin.h + pluginSupport/OlivePlugin.cpp pluginSupport/Dialog.cpp pluginSupport/Core.cpp pluginSupport/DrawSuite.cpp diff --git a/app/pluginSupport/Dialog.cpp b/app/pluginSupport/Dialog.cpp index d39f4f896..5a37fd612 100644 --- a/app/pluginSupport/Dialog.cpp +++ b/app/pluginSupport/Dialog.cpp @@ -16,3 +16,10 @@ * along with this program. If not, see . */ +#include +#include + +OfxStatus NotifyRedrawPending() +{ + return kOfxStatReplyDefault; +} diff --git a/app/pluginSupport/OlivePlugin.cpp b/app/pluginSupport/OlivePlugin.cpp new file mode 100644 index 000000000..b0360367a --- /dev/null +++ b/app/pluginSupport/OlivePlugin.cpp @@ -0,0 +1,43 @@ +/* + * Olive Community Edition - Non-Linear Video Editor + * Copyright (C) 2025 Olive CE 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 . + */ +#include "OlivePlugin.h" + +#include +olive::plugin::OlivePlugin::~OlivePlugin() +{ + for (void *p:mems) { + free(p); + } +} +void olive::plugin::OlivePlugin::setProp(QString key, int index, Value val) +{ + props[key][index]=std::move(val); +} + +OfxStatus olive::plugin::OlivePlugin::getProp(QString key, int index, Value &val) +{ + if (props.contains(key)) { + if (props[key].contains(index)) { + val = props[key][index]; + return kOfxStatOK; + } + return kOfxStatErrBadIndex; + } + return kOfxStatErrUnknown; +} + diff --git a/app/pluginSupport/OlivePlugin.h b/app/pluginSupport/OlivePlugin.h new file mode 100644 index 000000000..1bcf587ea --- /dev/null +++ b/app/pluginSupport/OlivePlugin.h @@ -0,0 +1,137 @@ +/* + * Olive Community Edition - Non-Linear Video Editor + * Copyright (C) 2025 Olive CE 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 OLIVE_PLUGIN_H +#define OLIVE_PLUGIN_H +#include "ofxCore.h" + +#include +#include +#include +#include +namespace olive +{ +namespace plugin +{ +class Value { +private: + enum Type { + FLOAT, STRING, INT, NONE + }; + int64_t valueInt=0; + double valueDouble=0; + QString valueString; + Type type=NONE; + +public: + + Value()=default; + Value(int64_t val) + { + valueInt=val; + type=INT; + } + Value(double val) + { + valueDouble=val; + type=FLOAT; + } + Value(QString val) + { + valueString=val; + type=STRING; + } + void setValue(int64_t val) + { + valueInt=val; + type=INT; + } + void setValue(double val) + { + valueDouble=val; + type=FLOAT; + } + void setValue(QString val) + { + valueString=val; + type=STRING; + } + void setValue(nullptr_t val) + { + valueInt=0; + valueDouble=0; + valueString=QString(); + type=NONE; + } + int64_t getInt() const + { + return valueInt; + } + double getFloat() const + { + return valueDouble; + } + QString getString() + { + return valueString; + } + bool isInt() + { + return type==INT; + } + bool isFloat() + { + return type==FLOAT; + } + bool isString() + { + return type==STRING; + } + bool isNull() + { + return type==NONE; + } +}; +struct plugin_mem_ptr { + void *mem; + int32_t count=0; +}; + +class OlivePlugin { +public: + OlivePlugin()=default; + ~OlivePlugin(); + void setProp(QString key, int index, Value val); + OfxStatus getProp(QString key, int index, Value &val); + void addMem(void *mem) + { + mems.emplace_back(mem); + } +private: + uint64_t id; + QString name; + QString version; + QMap> props; + std::list mems; +}; +} +} +struct OfxPropertySetStruct { + olive::plugin::OlivePlugin* plugin; +}; +#endif //OLIVE_PLUGIN_H diff --git a/app/pluginSupport/Property.cpp b/app/pluginSupport/Property.cpp index 52182e8d4..12ca34162 100644 --- a/app/pluginSupport/Property.cpp +++ b/app/pluginSupport/Property.cpp @@ -15,3 +15,34 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#include "node/plugins/Plugin.h" + +#include + +OfxStatus propSetPointer(OfxPropertySetHandle properties, + const char *property, int index, void *value) +{ + olive::plugin::Value val; + if (properties->plugin) { + OfxStatus status= properties->plugin->getProp(property, index, val); + if (val.isInt()) { + value=calloc(1,sizeof(long)); + *(int64_t*)value=val.getInt(); + properties->plugin->addMem(value); + } + else if (val.isFloat()) { + value=calloc(1,sizeof(double)); + *(double*)value=val.getFloat(); + properties->plugin->addMem(value); + } + else if (val.isString()) { + QString str=val.getString(); + value=(void *)calloc(str.size()+1, sizeof(char)); + memcpy(value, str.data(), str.size()); + properties->plugin->addMem(value); + } + return status; + } + return kOfxStatErrBadHandle; + +} \ No newline at end of file diff --git a/app/pluginSupport/olive_plugin.h b/app/pluginSupport/olive_plugin.h deleted file mode 100644 index 05e3acd39..000000000 --- a/app/pluginSupport/olive_plugin.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Olive Community Edition - Non-Linear Video Editor - * Copyright (C) 2025 Olive CE 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 OLIVE_PLUGIN_H -#define OLIVE_PLUGIN_H -#include -struct olive_color { - uint8_t red; - uint8_t green; - uint8_t blue; -}; -struct olive_node_ctx_functions { - bool (*get_ctx_int)(uint64_t handle, char *name, int *val); - bool (*get_ctx_float)(uint64_t handle, char *name, float *out_val); - bool (*get_ctx_rational)(uint64_t handle, char *name, double *out_val); - bool (*get_ctx_bool)(uint64_t handle, char *name, bool *out_val); - bool (*get_ctx_string)(uint64_t handle, char *name, char **out_str); - bool (*get_ctx_font)(uint64_t handle, char *name, char **out_font); - bool (*get_ctx_path)(uint64_t handle, char *name, char **out_path); - bool (*get_sample_buffer_handle)(uint64_t handle, char *name, uint64_t *out_handle); - bool (*get_ctx_samples)(uint64_t handle, char *name, uint64_t *out_handle); - bool (*get_ctx_video_params)(uint64_t handle, char *name, uint64_t *out_params); - bool (*get_ctx_audio_params)(uint64_t handle, char *name, uint64_t *out_params); - bool (*get_ctx_subtitle_params)(uint64_t handle, char *name, uint64_t *out_params); - bool (*get_ctx_bezier)(uint64_t handle, char *name, uint64_t *out_bezier); - bool (*get_ctx_vec2)(uint64_t handle, char *name, double **vec); - bool (*get_ctx_vec3)(uint64_t handle, char *name, double **vec); - bool (*get_ctx_vec4)(uint64_t handle, char *name, double **vec); - - int64_t (*get_size_need)(char *name); - // 下面几个函数请先获取缓冲区大小 - bool (*get_ctx_matrix)(uint64_t handle, char *name, int ***buffer, size_t buffer_size, - int *out_rows, int *out_cols); - bool (*get_ctx_texture)(uint64_t handle, char *name, uint8_t **buffer, size_t buffer_size, - int *out_len); - bool (*get_ctx_binary)(uint64_t handle, char *name, uint8_t* buffer, size_t buffer_size); -}; -struct olive_node_methods { - bool (*name)(char *buffer, size_t buffer_size); //最长63个char - bool (*id)(char *buffer, size_t buffer_size); //最长63个char - bool (*category)(char *buffer, size_t buffer_size); //最长63个char - bool (*description)(char *buffer, size_t buffer_size); //最长1023个char - void (*value)(struct olive_node_ctx_functions *functions); - -}; -#endif //OLIVE_PLUGIN_H diff --git a/third_party/openfx b/third_party/openfx index 158c8b69d..6aa45d817 160000 --- a/third_party/openfx +++ b/third_party/openfx @@ -1 +1 @@ -Subproject commit 158c8b69d9a2016755696138e027fdfd71bab552 +Subproject commit 6aa45d81799f04208af26434cc62a292ebd22924