]> git.sesse.net Git - mlt/blobdiff - src/modules/opengl/filter_movit_glow.cpp
Let Movit effects supply their own fingerprint.
[mlt] / src / modules / opengl / filter_movit_glow.cpp
index 4026477aee32b560f8ecef1a6a14b67e84f2de33..ab9ea0c5e7372ac53a92ec2741367b4086569a5e 100644 (file)
 #include <string.h>
 #include <assert.h>
 
-#include "glsl_manager.h"
+#include "filter_glsl_manager.h"
 #include <movit/glow_effect.h>
 
+static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+{
+       mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
+       mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+       mlt_position position = mlt_filter_get_position( filter, frame );
+       mlt_position length = mlt_filter_get_length2( filter, frame );
+       GlslManager::get_instance()->lock_service( frame );
+       mlt_properties_set_double( properties, "movit.parms.float.radius",
+               mlt_properties_anim_get_double( properties, "radius", position, length ) );
+       mlt_properties_set_double( properties, "movit.parms.float.blurred_mix_amount",
+               mlt_properties_anim_get_double( properties, "blur_mix", position, length ) );
+       mlt_properties_set_double( properties, "movit.parms.float.highlight_cutoff",
+               mlt_properties_anim_get_double( properties, "highlight_cutoff", position, length ) );
+       GlslManager::get_instance()->unlock_service( frame );
+       *format = mlt_image_glsl;
+       int error = mlt_frame_get_image( frame, image, format, width, height, writable );
+       GlslManager::set_effect_input( MLT_FILTER_SERVICE( filter ), frame, (mlt_service) *image );
+       GlslManager::set_effect( MLT_FILTER_SERVICE( filter ), frame, new GlowEffect );
+       *image = (uint8_t *) MLT_FILTER_SERVICE( filter );
+       return error;
+}
+
 static mlt_frame process( mlt_filter filter, mlt_frame frame )
 {
-       if ( !mlt_frame_is_test_card( frame ) ) {
-               Effect* effect = GlslManager::get_effect( filter, frame );
-               if ( !effect )
-                       effect = GlslManager::add_effect( filter, frame, new GlowEffect() );
-               if ( effect ) {
-                       mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
-                       bool ok = effect->set_float( "radius", mlt_properties_get_double( filter_props, "radius" ) );
-                       ok |= effect->set_float( "blurred_mix_amount", mlt_properties_get_double( filter_props, "blur_mix" ) );
-                       ok |= effect->set_float( "highlight_cutoff", mlt_properties_get_double( filter_props, "highlight_cutoff" ) );
-                       assert(ok);
-               }
-       }
+       mlt_frame_push_service( frame, filter );
+       mlt_frame_push_get_image( frame, get_image );
        return frame;
 }