]> git.sesse.net Git - mlt/commitdiff
Refactor to mlt_filter_get_progress().
authorDan Dennedy <dan@dennedy.org>
Tue, 8 Mar 2011 05:55:53 +0000 (21:55 -0800)
committerDan Dennedy <dan@dennedy.org>
Fri, 11 Mar 2011 07:15:45 +0000 (23:15 -0800)
src/modules/core/filter_brightness.c
src/modules/core/filter_obscure.c
src/modules/kdenlive/filter_boxblur.c
src/modules/kdenlive/filter_wave.c
src/modules/normalize/filter_volume.c
src/modules/oldfilm/filter_dust.c
src/modules/oldfilm/filter_grain.c
src/modules/oldfilm/filter_lines.c
src/modules/oldfilm/filter_oldfilm.c

index 891f4b39864cee627dc1eb2d01417cb34d3965ed..0a2bddb4160268929d111022a3e717d81772ff2a 100644 (file)
@@ -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
index bc4d866e1555dc8ce8bc1e0dc0e0dcff37ec7340..882b85e5d3a7b4cc7a797e4d781983ee2612dd30 100644 (file)
@@ -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
index c48fc3dee99fcbe563ace166a84f92aa16c1690e..db0aee5f0e618415f0b9219f60deb1800249384e 100644 (file)
@@ -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
index 10811866219f29f390d2bbf387bbef169d6b12b6..551f8bf9ecbc14c4c22f877b354918fb669ea33e 100644 (file)
@@ -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
index c95a5220b36bd0a6db202ea620bb3d8185b91651..ad503b7f9c3cfa1231e89d8887e8370be67b9eca 100644 (file)
@@ -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 );
index d48ad87874779f49e3b9a2060f70f33eb5225d62..b20f4391b990031d22db570895b23fea697df909 100644 (file)
@@ -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 ) );
index 1095d1a1b2eaf2f480771a839fd05f656ae7dccd..029f9fdb47e7756cf69413f2a0c7ff9d1f98d983 100644 (file)
@@ -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" );
index d4a9bdfc79347d2510d6560bd07333b215d699db..f525480924e3b93150815ea69b92d783c9a39e95 100644 (file)
@@ -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 ) );
 
index 511aaa84381d3f72d89bef6dffe226321c85f2e3..7e267ce579492b9f2aa6925810acced456e5ade3 100644 (file)
@@ -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" );