From: Dan Dennedy Date: Wed, 9 Mar 2011 08:00:02 +0000 (-0800) Subject: Refactor to mlt_filter_get_position(). X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1787842cb1fb67c95868e16fd0e9127ae9c23d2c;p=mlt Refactor to mlt_filter_get_position(). --- diff --git a/src/modules/core/filter_luma.c b/src/modules/core/filter_luma.c index a44416b2..71af8367 100644 --- a/src/modules/core/filter_luma.c +++ b/src/modules/core/filter_luma.c @@ -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 ); diff --git a/src/modules/core/filter_watermark.c b/src/modules/core/filter_watermark.c index bf2b87d9..54a4693c 100644 --- a/src/modules/core/filter_watermark.c +++ b/src/modules/core/filter_watermark.c @@ -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 ); diff --git a/src/modules/dgraft/filter_telecide.c b/src/modules/dgraft/filter_telecide.c index d76f45ea..545def24 100644 --- a/src/modules/dgraft/filter_telecide.c +++ b/src/modules/dgraft/filter_telecide.c @@ -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]; diff --git a/src/modules/kdenlive/filter_freeze.c b/src/modules/kdenlive/filter_freeze.c index 3f9dce7b..e8df1134 100755 --- a/src/modules/kdenlive/filter_freeze.c +++ b/src/modules/kdenlive/filter_freeze.c @@ -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 ); diff --git a/src/modules/motion_est/filter_autotrack_rectangle.c b/src/modules/motion_est/filter_autotrack_rectangle.c index f9a2e6ec..e57aa9df 100644 --- a/src/modules/motion_est/filter_autotrack_rectangle.c +++ b/src/modules/motion_est/filter_autotrack_rectangle.c @@ -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 ) ); diff --git a/src/modules/motion_est/filter_crop_detect.c b/src/modules/motion_est/filter_crop_detect.c index 902b66cb..37df47da 100644 --- a/src/modules/motion_est/filter_crop_detect.c +++ b/src/modules/motion_est/filter_crop_detect.c @@ -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 ); diff --git a/src/modules/oldfilm/filter_vignette.c b/src/modules/oldfilm/filter_vignette.c index f4550d0b..2a51e794 100644 --- a/src/modules/oldfilm/filter_vignette.c +++ b/src/modules/oldfilm/filter_vignette.c @@ -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; } diff --git a/src/modules/plus/filter_affine.c b/src/modules/plus/filter_affine.c index 1318b281..0b55ff04 100644 --- a/src/modules/plus/filter_affine.c +++ b/src/modules/plus/filter_affine.c @@ -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; } diff --git a/src/modules/vmfx/filter_shape.c b/src/modules/vmfx/filter_shape.c index 00b0ed08..a3a0e969 100644 --- a/src/modules/vmfx/filter_shape.c +++ b/src/modules/vmfx/filter_shape.c @@ -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;