From: Dan Dennedy Date: Tue, 8 Mar 2011 05:55:53 +0000 (-0800) Subject: Refactor to mlt_filter_get_progress(). X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=81ced106ae75c0fe7a715d7ecdeecd0dde017c7b;p=mlt Refactor to mlt_filter_get_progress(). --- diff --git a/src/modules/core/filter_brightness.c b/src/modules/core/filter_brightness.c index 891f4b39..0a2bddb4 100644 --- a/src/modules/core/filter_brightness.c +++ b/src/modules/core/filter_brightness.c @@ -74,12 +74,8 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) if ( mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "end" ) != NULL ) { // Determine the time position of this frame in the transition duration - mlt_position in = mlt_filter_get_in( this ); - mlt_position out = mlt_filter_get_out( this ); - mlt_position time = mlt_frame_get_position( frame ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); double end = fabs( mlt_properties_get_double( MLT_FILTER_PROPERTIES( this ), "end" ) ); - level += ( end - level ) * position; + level += ( end - level ) * mlt_filter_get_progress( this, frame ); } // Push the frame filter diff --git a/src/modules/core/filter_obscure.c b/src/modules/core/filter_obscure.c index bc4d866e..882b85e5 100644 --- a/src/modules/core/filter_obscure.c +++ b/src/modules/core/filter_obscure.c @@ -131,22 +131,6 @@ static void geometry_calculate( struct geometry_s *output, struct geometry_s *in output->mask_h = lerp( in->mask_h + ( out->mask_h - in->mask_h ) * position, 1, -1 ); } -/** Calculate the position for this frame. -*/ - -static float position_calculate( mlt_filter this, mlt_frame frame ) -{ - // Get the in and out position - mlt_position in = mlt_filter_get_in( this ); - mlt_position out = mlt_filter_get_out( this ); - - // Get the position of the frame - mlt_position position = mlt_frame_get_position( frame ); - - // Now do the calcs - return ( float )( position - in ) / ( float )( out - in + 1 ); -} - /** The averaging function... */ @@ -283,7 +267,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) mlt_frame_push_service( frame, this ); // Calculate the position for the filter effect - float position = position_calculate( this, frame ); + double position = mlt_filter_get_progress( this, frame ); mlt_properties_set_double( MLT_FRAME_PROPERTIES( frame ), "filter_position", position ); // Push the get image call diff --git a/src/modules/kdenlive/filter_boxblur.c b/src/modules/kdenlive/filter_boxblur.c index c48fc3de..db0aee5f 100644 --- a/src/modules/kdenlive/filter_boxblur.c +++ b/src/modules/kdenlive/filter_boxblur.c @@ -122,12 +122,8 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) if ( mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "end" ) != NULL ) { // Determine the time position of this frame in the transition duration - mlt_position in = mlt_filter_get_in( this ); - mlt_position out = mlt_filter_get_out( this ); - mlt_position time = mlt_frame_get_position( frame ); - double position = (double) ( time - in ) / ( out - in + 1.0 ); double end = (double) mlt_properties_get_int( MLT_FILTER_PROPERTIES( this ), "end" ); - blur += ( end - blur ) * position; + blur += ( end - blur ) * mlt_filter_get_progress( this, frame ); } // Push the frame filter diff --git a/src/modules/kdenlive/filter_wave.c b/src/modules/kdenlive/filter_wave.c index 10811866..551f8bf9 100644 --- a/src/modules/kdenlive/filter_wave.c +++ b/src/modules/kdenlive/filter_wave.c @@ -103,12 +103,8 @@ static mlt_frame filter_process( mlt_filter filter, mlt_frame frame ) if ( mlt_properties_get( MLT_FILTER_PROPERTIES( filter ), "end" ) != NULL ) { // Determine the time position of this frame in the transition duration - mlt_position in = mlt_filter_get_in( filter ); - mlt_position out = mlt_filter_get_out( filter ); - mlt_position time = mlt_frame_get_position( frame ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); double end = fabs( mlt_properties_get_double( MLT_FILTER_PROPERTIES( filter ), "end" ) ); - wave += ( end - wave ) * position; + wave += ( end - wave ) * mlt_filter_get_progress( filter, frame ); } // Push the frame filter diff --git a/src/modules/normalize/filter_volume.c b/src/modules/normalize/filter_volume.c index c95a5220..ad503b7f 100644 --- a/src/modules/normalize/filter_volume.c +++ b/src/modules/normalize/filter_volume.c @@ -319,12 +319,6 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) // If there is an end adjust gain to the range if ( mlt_properties_get( filter_props, "end" ) != NULL ) { - // Determine the time position of this frame in the transition duration - mlt_position in = mlt_filter_get_in( this ); - mlt_position out = mlt_filter_get_out( this ); - mlt_position time = mlt_frame_get_position( frame ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); - double end = -1; char *p = mlt_properties_get( filter_props, "end" ); if ( strcmp( p, "" ) != 0 ) @@ -340,7 +334,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) end = fabs( end ); if ( end != -1 ) - gain += ( end - gain ) * position; + gain += ( end - gain ) * mlt_filter_get_progress( this, frame ); } } } @@ -419,12 +413,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) // If there is an end adjust gain to the range if ( mlt_properties_get( filter_props, "end" ) != NULL ) { - // Determine the time position of this frame in the transition duration - mlt_position in = mlt_filter_get_in( this ); - mlt_position out = mlt_filter_get_out( this ); - mlt_position time = mlt_frame_get_position( frame ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); - amplitude *= position; + amplitude *= mlt_filter_get_progress( this, frame ); } mlt_properties_set_int( instance_props, "normalise", 1 ); mlt_properties_set_double( instance_props, "amplitude", amplitude ); diff --git a/src/modules/oldfilm/filter_dust.c b/src/modules/oldfilm/filter_dust.c index d48ad878..b20f4391 100644 --- a/src/modules/oldfilm/filter_dust.c +++ b/src/modules/oldfilm/filter_dust.c @@ -66,11 +66,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * int maxdia = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxdiameter" ); int maxcount = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxcount" ); - mlt_position in = mlt_filter_get_in( filter ); - mlt_position out = mlt_filter_get_out( filter ); - mlt_position time = mlt_frame_get_position( this ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); - *format = mlt_image_yuv422; int error = mlt_frame_get_image( this, image, format, width, height, 1 ); // load svg @@ -84,6 +79,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if (!maxcount) return 0; + + double position = mlt_filter_get_progress( filter, this ); srand(position*10000); mlt_service_lock( MLT_FILTER_SERVICE( filter ) ); diff --git a/src/modules/oldfilm/filter_grain.c b/src/modules/oldfilm/filter_grain.c index 1095d1a1..029f9fdb 100644 --- a/src/modules/oldfilm/filter_grain.c +++ b/src/modules/oldfilm/filter_grain.c @@ -38,10 +38,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * int h = *height; int w = *width; - mlt_position in = mlt_filter_get_in( filter ); - mlt_position out = mlt_filter_get_out( filter ); - mlt_position time = mlt_frame_get_position( this ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); + double position = mlt_filter_get_progress( filter, this ); srand(position*10000); int noise = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "noise" ); diff --git a/src/modules/oldfilm/filter_lines.c b/src/modules/oldfilm/filter_lines.c index d4a9bdfc..f5254809 100644 --- a/src/modules/oldfilm/filter_lines.c +++ b/src/modules/oldfilm/filter_lines.c @@ -44,13 +44,11 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * char buf[256]; char typebuf[256]; - mlt_position in = mlt_filter_get_in( filter ); - mlt_position out = mlt_filter_get_out( filter ); - mlt_position time = mlt_frame_get_position( this ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); - srand(position*10000); if (!width_line) return 0; + + double position = mlt_filter_get_progress( filter, this ); + srand(position*10000); mlt_service_lock( MLT_FILTER_SERVICE( filter ) ); diff --git a/src/modules/oldfilm/filter_oldfilm.c b/src/modules/oldfilm/filter_oldfilm.c index 511aaa84..7e267ce5 100644 --- a/src/modules/oldfilm/filter_oldfilm.c +++ b/src/modules/oldfilm/filter_oldfilm.c @@ -53,10 +53,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * int x=0; int y=0; - mlt_position in = mlt_filter_get_in( filter ); - mlt_position out = mlt_filter_get_out( filter ); - mlt_position time = mlt_frame_get_position( this ); - double position = ( double )( time - in ) / ( double )( out - in + 1 ); + double position = mlt_filter_get_progress( filter, this ); srand(position*10000); int delta = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "delta" );