]> git.sesse.net Git - mlt/blobdiff - src/modules/opengl/filter_white_balance.cpp
Add property animation to the other movit services.
[mlt] / src / modules / opengl / filter_white_balance.cpp
index e3f1d9c5352df84b576c17b555b093a273d35e9f..1b458e7dab6ef12b6d04aba3093decd43166308b 100644 (file)
 #include "glsl_manager.h"
 #include <movit/white_balance_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 );
+       GlslManager::get_instance()->lock_service( frame );
+       Effect* effect = GlslManager::get_effect( filter, frame );
+       if ( effect ) {
+               mlt_position position = mlt_filter_get_position( filter, frame );
+               mlt_position length = mlt_filter_get_length2( filter, frame );
+               int color_int = mlt_properties_anim_get_int( properties, "neutral_color", position, length );
+               RGBTriplet color(
+                       float((color_int >> 24) & 0xff) / 255.0f,
+                       float((color_int >> 16) & 0xff) / 255.0f,
+                       float((color_int >> 8) & 0xff) / 255.0f
+               );
+               bool ok = effect->set_vec3( "neutral_color", (float*) &color );
+               ok |= effect->set_float( "output_color_temperature",
+                       mlt_properties_anim_get_double( properties, "color_temperature", position, length ) );
+               assert(ok);
+       }
+       GlslManager::get_instance()->unlock_service( frame );
+       *format = mlt_image_glsl;
+       return mlt_frame_get_image( frame, image, format, width, height, writable );
+}
+
 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 WhiteBalanceEffect );
-               if ( effect ) {
-                       mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
-                       int color_int = mlt_properties_get_int( filter_props, "neutral_color" );
-                       RGBTriplet color(
-                               float((color_int >> 24) & 0xff) / 255.0f,
-                               float((color_int >> 16) & 0xff) / 255.0f,
-                               float((color_int >> 8) & 0xff) / 255.0f
-                       );
-                       bool ok = effect->set_vec3( "neutral_color", (float*) &color );
-                       ok |= effect->set_float( "output_color_temperature", mlt_properties_get_double( filter_props, "color_temperature" ) );
-                       assert(ok);
-               }
+               if ( !GlslManager::get_effect( filter, frame ) )
+                       GlslManager::add_effect( filter, frame, new WhiteBalanceEffect );
        }
+       mlt_frame_push_service( frame, filter );
+       mlt_frame_push_get_image( frame, get_image );
        return frame;
 }