]> git.sesse.net Git - mlt/blobdiff - src/modules/opengl/filter_movit_white_balance.cpp
Hide the movit.parms properties from serialization.
[mlt] / src / modules / opengl / filter_movit_white_balance.cpp
index fa04776148ee53f80a2791d0172489626c237fd7..1103077a91fc4205e503fe26649d8b4b396b740d 100644 (file)
@@ -25,6 +25,8 @@
 #include "filter_glsl_manager.h"
 #include <movit/white_balance_effect.h>
 
+using namespace movit;
+
 static double srgb8_to_linear(int c)
 {
        double x = c / 255.0f;
@@ -40,32 +42,32 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
        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( MLT_FILTER_SERVICE( 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(
-                       srgb8_to_linear((color_int >> 24) & 0xff),
-                       srgb8_to_linear((color_int >> 16) & 0xff),
-                       srgb8_to_linear((color_int >> 8) & 0xff)
-               );
-               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);
-       }
+       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(
+               srgb8_to_linear((color_int >> 24) & 0xff),
+               srgb8_to_linear((color_int >> 16) & 0xff),
+               srgb8_to_linear((color_int >> 8) & 0xff)
+       );
+       mlt_properties_set_double( properties, "_movit.parms.vec3.neutral_color[0]", color.r );
+       mlt_properties_set_double( properties, "_movit.parms.vec3.neutral_color[1]", color.g );
+       mlt_properties_set_double( properties, "_movit.parms.vec3.neutral_color[2]", color.b );
+       double output_color_temperature =
+               mlt_properties_anim_get_double( properties, "color_temperature", position, length );
+       mlt_properties_set_double( properties, "_movit.parms.float.output_color_temperature",
+                output_color_temperature );
        GlslManager::get_instance()->unlock_service( frame );
        *format = mlt_image_glsl;
-       return mlt_frame_get_image( frame, image, format, width, height, writable );
+       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 WhiteBalanceEffect );
+       *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 ) ) {
-               if ( !GlslManager::get_effect( MLT_FILTER_SERVICE( filter ), frame ) )
-                       GlslManager::add_effect( MLT_FILTER_SERVICE( filter ), frame, new WhiteBalanceEffect );
-       }
        mlt_frame_push_service( frame, filter );
        mlt_frame_push_get_image( frame, get_image );
        return frame;
@@ -80,6 +82,7 @@ mlt_filter filter_white_balance_init( mlt_profile profile, mlt_service_type type
 
        if ( glsl && ( filter = mlt_filter_new() ) ) {
                mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+               glsl->add_ref( properties );
                mlt_properties_set( properties, "neutral_color", arg? arg : "#7f7f7f" );
                mlt_properties_set_double( properties, "color_temperature", 6500.0 );
                filter->process = process;