]> git.sesse.net Git - mlt/commitdiff
Refactor to mlt_filter_get_position().
authorDan Dennedy <dan@dennedy.org>
Wed, 9 Mar 2011 08:00:02 +0000 (00:00 -0800)
committerDan Dennedy <dan@dennedy.org>
Fri, 11 Mar 2011 07:15:45 +0000 (23:15 -0800)
src/modules/core/filter_luma.c
src/modules/core/filter_watermark.c
src/modules/dgraft/filter_telecide.c
src/modules/kdenlive/filter_freeze.c
src/modules/motion_est/filter_autotrack_rectangle.c
src/modules/motion_est/filter_crop_detect.c
src/modules/oldfilm/filter_vignette.c
src/modules/plus/filter_affine.c
src/modules/vmfx/filter_shape.c

index a44416b2a480e9de5dbbd6967b0b46455fe4de0b..71af8367cb01509e94beb781d12a6defdd020ce3 100644 (file)
@@ -46,8 +46,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        int out = mlt_properties_get_int( properties, "period" );
        int cycle = mlt_properties_get_int( properties, "cycle" );
        int duration = mlt_properties_get_int( properties, "duration" );
-       char *name = mlt_properties_get( properties, "_unique_id" );
-       mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES(this), name );
+       mlt_position position = mlt_filter_get_position( filter, this );
 
        out = out? out + 1 : 25;
        if ( cycle )
@@ -124,12 +123,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
-       // Get a unique name to store the frame position
-       char *name = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "_unique_id" );
-
-       // Assign the current position to the name
-       mlt_properties_set_position( MLT_FRAME_PROPERTIES( frame ), name, mlt_frame_get_position( frame ) );
-
        // Push the filter on to the stack
        mlt_frame_push_service( frame, this );
 
index bf2b87d99a8d7ded70a8ea5bb1c09d6d5c5105a0..54a4693c8921eb92377945bcd3c414a9ed756978 100644 (file)
@@ -128,11 +128,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                // We will get the 'b frame' from the producer
                mlt_frame b_frame = NULL;
 
-               // Get the unique id of the filter (used to reacquire the producer position)
-               char *name = mlt_properties_get( properties, "_unique_id" );
-
                // Get the original producer position
-               mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES( frame ), name );
+               mlt_position position = mlt_filter_get_position( this, frame );
 
                // Make sure the producer is in the correct position
                mlt_producer_seek( producer, position );
@@ -230,15 +227,9 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        // Get the properties of the frame
        mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
 
-       // Get a unique name to store the frame position
-       char *name = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "_unique_id" );
-
        // Assign the frame out point to the filter (just in case we need it later)
        mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "_out", mlt_properties_get_int( properties, "out" ) );
 
-       // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
-
        // Push the filter on to the stack
        mlt_frame_push_service( frame, this );
 
index d76f45eabb4c6df14fa0349a15392ce0204912a4..545def2416ea0d4fcfb6406fb6de296f710bd323 100644 (file)
@@ -782,7 +782,7 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
        {
                // Put the current image into the image cache, keyed on position
                size_t image_size = (*width * *height) << 1;
-               mlt_position pos = mlt_frame_get_position( frame );
+               mlt_position pos = mlt_filter_get_position( filter, frame );
                uint8_t *image_copy = mlt_pool_alloc( image_size );
                memcpy( image_copy, *image, image_size );
                char key[20];
index 3f9dce7beac1e6f2eaba71911f8608e381d3b271..e8df1134f29e9a369dd722d6d8a0532e850860e4 100755 (executable)
@@ -38,7 +38,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        int freeze_before = mlt_properties_get_int( properties, "freeze_before" );
        int freeze_after = mlt_properties_get_int( properties, "freeze_after" );
        mlt_position pos = mlt_properties_get_position( properties, "frame" );
-       mlt_position currentpos = mlt_properties_get_position( properties, "_seek_frame" );
+       mlt_position currentpos = mlt_filter_get_position( filter, this );
 
        int do_freeze = 0;
        if (freeze_before == 0 && freeze_after == 0) {
@@ -100,9 +100,6 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        // Push the filter on to the stack
        mlt_frame_push_service( frame, this );
 
-       // Determine the time position of this frame
-       mlt_properties_set_position( MLT_FILTER_PROPERTIES( this ), "_seek_frame", mlt_frame_get_position( frame ) -  mlt_filter_get_in( this ) );
-
        // Push the frame filter
        mlt_frame_push_get_image( frame, filter_get_image );
 
index f9a2e6ec84d613d0af656ba6f854f3752aba738c..e57aa9dfc1fec8dd2b2caa09df338b844db2f299 100644 (file)
@@ -120,7 +120,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        mlt_properties frame_properties = MLT_FRAME_PROPERTIES(frame);
 
        // Get the frame position
-       mlt_position position = mlt_frame_get_position( frame );
+       mlt_position position = mlt_filter_get_position( filter, frame );
 
        // Get the new image
        int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
@@ -215,7 +215,7 @@ static int attach_boundry_to_frame( mlt_frame frame, uint8_t **image, mlt_image_
        mlt_properties frame_properties = MLT_FRAME_PROPERTIES(frame);
 
        // Get the frame position
-       mlt_position position = mlt_frame_get_position( frame );
+       mlt_position position = mlt_filter_get_position( filter, frame );
        
        mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
 
index 902b66cb586de4bdf948b5781376284c9789405a..37df47da1e73a55e376cce0e23ab3d638b8b4de8 100644 (file)
@@ -77,7 +77,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        }
 
        // For periodic detection (with offset of 'skip')
-       if( frequency == 0 || (int)(mlt_frame_get_position(this)+skip) % frequency  != 0)
+       if( frequency == 0 || (int)(mlt_filter_get_position(filter, this)+skip) % frequency  != 0)
        {
                // Inject in stream 
                mlt_properties_set_data( MLT_FRAME_PROPERTIES(this), "bounds", bounds, sizeof( struct mlt_geometry_item_s ), NULL, NULL );
index f4550d0b2ec842f1c1a80960cba136564b9fa239..2a51e794f939a31bc7456476971c9ccbd8cbcc75 100644 (file)
@@ -55,7 +55,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        {
                float smooth, radius, cx, cy, opac;
                mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter ) ;
-               mlt_position pos = mlt_properties_get_position( filter_props, "_pos" );
+               mlt_position pos = mlt_filter_get_position( filter, this );
 
                smooth = geometry_to_float ( mlt_properties_get( filter_props , "smooth" ) , pos ) * 100.0 ;
                radius = geometry_to_float ( mlt_properties_get( filter_props , "radius" ) , pos ) * *width;
@@ -103,12 +103,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
-       
        mlt_frame_push_service( frame, this );
-       
-       // Determine the time position of this frame
-       mlt_properties_set_position( MLT_FILTER_PROPERTIES( this ), "_pos", mlt_frame_get_position( frame ) -  mlt_filter_get_in( this ) );
-       
        mlt_frame_push_get_image( frame, filter_get_image );
        return frame;
 }
index 1318b2814f1a66cfa6dc412293c5cdf6c571ea60..0b55ff0464404ff39ccc6767150ba6d9449686a1 100644 (file)
@@ -66,8 +66,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
                if ( producer != NULL && transition != NULL )
                {
-                       char *name = mlt_properties_get( properties, "_unique_id" );
-                       mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES( this ), name );
+                       mlt_position position = mlt_filter_get_position( filter, this );
                        mlt_properties frame_properties = MLT_FRAME_PROPERTIES( this );
                        mlt_position in = mlt_filter_get_in( filter );
                        mlt_position out = mlt_filter_get_out( filter );
@@ -77,12 +76,12 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                                mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( producer ), "length", out - in + 1 );
                                mlt_producer_set_in_and_out( producer, in, out );
                        }
-                       mlt_producer_seek( producer, position - in );
+                       mlt_producer_seek( producer, in + position );
                        mlt_frame_set_position( this, position );
                        mlt_properties_pass( MLT_PRODUCER_PROPERTIES( producer ), properties, "producer." );
                        mlt_properties_pass( MLT_TRANSITION_PROPERTIES( transition ), properties, "transition." );
                        mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &a_frame, 0 );
-                       mlt_frame_set_position( a_frame, position );
+                       mlt_frame_set_position( a_frame, in + position );
 //                     mlt_properties_set_int( MLT_FRAME_PROPERTIES( a_frame ), "distort", 1 );
 
                        // Special case - aspect_ratio = 0
@@ -122,15 +121,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
-       // Get the properties of the frame
-       mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
-
-       // Get a unique name to store the frame position
-       char *name = mlt_properties_get( MLT_FILTER_PROPERTIES( this ), "_unique_id" );
-
-       // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
-
        // Push the frame filter
        mlt_frame_push_service( frame, this );
        mlt_frame_push_get_image( frame, filter_get_image );
@@ -147,7 +137,7 @@ mlt_filter filter_affine_init( mlt_profile profile, mlt_service_type type, const
        if ( this != NULL )
        {
                this->process = filter_process;
-               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "background", "colour:black" );
+               mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "background", arg ? arg : "colour:black" );
        }
        return this;
 }
index 00b0ed082538d743719d39c260a562960b019131..a3a0e9698eee84b63306494f7218210b165fa6de 100644 (file)
@@ -114,7 +114,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        double alpha_mix = 0.0;
 
        // Calculate the position and length
-       int position = mlt_frame_get_position( frame ) - mlt_filter_get_in( this );
+       int position = mlt_filter_get_position( this, frame );
        int in = mlt_filter_get_in( this );
        int out = mlt_filter_get_out( this );
        int length;