]> git.sesse.net Git - mlt/blobdiff - src/modules/opengl/filter_movit_white_balance.cpp
Change how the Movit chain is built.
[mlt] / src / modules / opengl / filter_movit_white_balance.cpp
index fa04776148ee53f80a2791d0172489626c237fd7..71a325d51cb94f38968b4d80ad2d7d793fc818c0 100644 (file)
@@ -40,32 +40,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;