filter-blur: Use self-registration feature

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2017-12-14 00:24:37 +01:00
parent 9e813d98f1
commit 61f20a83ad
3 changed files with 16 additions and 5 deletions

View file

@ -19,6 +19,8 @@
#include "filter-blur.h"
#include "strings.h"
#include <math.h>
#include <map>
extern "C" {
#pragma warning (push)
@ -29,14 +31,24 @@ extern "C" {
#pragma warning (pop)
}
#include <math.h>
#include <map>
// Initialize & Finalizer
static Filter::Blur* handler;
INITIALIZER(HandlerInit) {
initializerFunctions.push_back([] {
handler = new Filter::Blur();
});
finalizerFunctions.push_back([] {
delete handler;
});
}
enum ColorFormat : uint64_t {
RGB,
YUV, // 701
};
struct g_blurEffect {
gs_effect_t* effect;
std::vector<gs_texture_t*> kernels;

View file

@ -20,6 +20,7 @@
#pragma once
#include "plugin.h"
#include "gs-helper.h"
#include "gs-effect.h"
#define S_FILTER_BLUR "Filter.Blur"
#define S_FILTER_BLUR_TYPE "Filter.Blur.Type"
@ -92,6 +93,7 @@ namespace Filter {
gs_technique_t *m_technique;
gs_texrender_t *m_primaryRT, *m_secondaryRT;
gs_texrender_t *m_rtHorizontal, *m_rtVertical;
std::shared_ptr<GS::Effect> m_effectCache;
// Blur
Type m_type;

View file

@ -27,7 +27,6 @@ OBS_DECLARE_MODULE();
OBS_MODULE_AUTHOR("Michael Fabian Dirks");
OBS_MODULE_USE_DEFAULT_LOCALE("obs-stream-effects", "en-US");
Filter::Blur *filterBlur;
Filter::Displacement *filterDisplacement;
Filter::Shape *filterShape;
Filter::Transform *filterTransform;
@ -39,7 +38,6 @@ MODULE_EXPORT bool obs_module_load(void) {
filterDisplacement = new Filter::Displacement();
filterShape = new Filter::Shape();
filterTransform = new Filter::Transform();
filterBlur = new Filter::Blur();
for (auto func : initializerFunctions) {
func();
}
@ -53,7 +51,6 @@ MODULE_EXPORT void obs_module_unload(void) {
delete filterTransform;
delete filterShape;
delete filterDisplacement;
delete filterBlur;
}
MODULE_EXPORT const char* obs_module_name() {