From 0d93886ee9b1e0e4d722ee2e0fc0defc2e6699c9 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Wed, 29 Feb 2012 21:54:44 -0800 Subject: [PATCH] remove consumer_aspect_ratio property - use profile instead --- src/framework/mlt_consumer.c | 6 ++---- src/framework/mlt_frame.c | 1 - src/framework/mlt_profile.c | 1 - src/framework/mlt_tractor.c | 1 - src/framework/mlt_transition.c | 14 +++++++++----- src/modules/core/filter_crop.c | 2 +- src/modules/core/filter_watermark.c | 6 +++--- src/modules/kdenlive/filter_freeze.c | 1 - src/modules/kdenlive/producer_framebuffer.c | 1 - src/modules/oldfilm/filter_dust.c | 1 - src/modules/plus/filter_affine.c | 14 ++++++-------- src/modules/plus/transition_affine.c | 2 +- 12 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index a45ce472..9de63323 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -581,11 +581,9 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer self ) if ( test_card != NULL ) mlt_properties_set_data( frame_properties, "test_card_producer", test_card, 0, NULL, NULL ); - // Attach the rescale property + // Pass along the interpolation and deinterlace options + // TODO: get rid of consumer_deinterlace and use profile.progressive mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale" ) ); - - // Aspect ratio and other jiggery pokery - mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_int( properties, "progressive" ) | mlt_properties_get_int( properties, "deinterlace" ) ); mlt_properties_set( frame_properties, "deinterlace_method", mlt_properties_get( properties, "deinterlace_method" ) ); mlt_properties_set_int( frame_properties, "consumer_tff", mlt_properties_get_int( properties, "top_field_first" ) ); diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 6a3b6b36..7d38d44e 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -483,7 +483,6 @@ int mlt_frame_get_image( mlt_frame self, uint8_t **buffer, mlt_image_format *for if ( test_frame ) { mlt_properties test_properties = MLT_FRAME_PROPERTIES( test_frame ); - mlt_properties_set_double( test_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) ); mlt_properties_set( test_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); mlt_frame_get_image( test_frame, buffer, format, width, height, writable ); mlt_properties_set_data( properties, "test_card_frame", test_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 66f76012..8766349f 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -406,7 +406,6 @@ void mlt_profile_from_producer( mlt_profile profile, mlt_producer producer ) if ( ! mlt_service_get_frame( MLT_PRODUCER_SERVICE(producer), &fr, 0 ) && fr ) { - mlt_properties_set_double( MLT_FRAME_PROPERTIES( fr ), "consumer_aspect_ratio", mlt_profile_sar( profile ) ); if ( ! mlt_frame_get_image( fr, &buffer, &fmt, &w, &h, 0 ) ) { // Some source properties are not exposed until after the first get_image call. diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index e2164586..97c6a172 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -267,7 +267,6 @@ static int producer_get_image( mlt_frame self, uint8_t **buffer, mlt_image_forma mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); mlt_properties_set_int( frame_properties, "resize_alpha", mlt_properties_get_int( properties, "resize_alpha" ) ); mlt_properties_set_int( frame_properties, "distort", mlt_properties_get_int( properties, "distort" ) ); - mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_int( properties, "consumer_deinterlace" ) ); mlt_properties_set( frame_properties, "deinterlace_method", mlt_properties_get( properties, "deinterlace_method" ) ); mlt_properties_set_int( frame_properties, "consumer_tff", mlt_properties_get_int( properties, "consumer_tff" ) ); diff --git a/src/framework/mlt_transition.c b/src/framework/mlt_transition.c index 7657d6ec..90eb774e 100644 --- a/src/framework/mlt_transition.c +++ b/src/framework/mlt_transition.c @@ -311,6 +311,7 @@ mlt_frame mlt_transition_process( mlt_transition self, mlt_frame a_frame, mlt_fr static int get_image_a( mlt_frame a_frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { + mlt_transition self = mlt_frame_pop_service( a_frame ); mlt_properties a_props = MLT_FRAME_PROPERTIES( a_frame ); // All transitions get scaling @@ -319,14 +320,15 @@ static int get_image_a( mlt_frame a_frame, uint8_t **image, mlt_image_format *fo mlt_properties_set( a_props, "rescale.interp", "nearest" ); // Ensure sane aspect ratio - if ( mlt_properties_get_double( a_props, "aspect_ratio" ) == 0.0 ) - mlt_properties_set_double( a_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + if ( mlt_frame_get_aspect_ratio( a_frame ) == 0.0 ) + mlt_frame_set_aspect_ratio( a_frame, mlt_profile_sar( mlt_service_profile( MLT_TRANSITION_SERVICE(self) ) ) ); return mlt_frame_get_image( a_frame, image, format, width, height, writable ); } static int get_image_b( mlt_frame b_frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { + mlt_transition self = mlt_frame_pop_service( b_frame ); mlt_frame a_frame = mlt_frame_pop_frame( b_frame ); mlt_properties a_props = MLT_FRAME_PROPERTIES( a_frame ); mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); @@ -341,11 +343,11 @@ static int get_image_b( mlt_frame b_frame, uint8_t **image, mlt_image_format *fo } // Ensure sane aspect ratio - if ( mlt_properties_get_double( b_props, "aspect_ratio" ) == 0.0 ) - mlt_properties_set_double( b_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + if ( mlt_frame_get_aspect_ratio( b_frame ) == 0.0 ) + mlt_frame_set_aspect_ratio( b_frame, mlt_profile_sar( mlt_service_profile( MLT_TRANSITION_SERVICE(self) ) ) ); mlt_properties_pass_list( b_props, a_props, - "consumer_deinterlace, deinterlace_method, consumer_aspect_ratio, consumer_tff" ); + "consumer_deinterlace, deinterlace_method, consumer_tff" ); return mlt_frame_get_image( b_frame, image, format, width, height, writable ); } @@ -478,8 +480,10 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i if ( !( a_hide & type ) && !( b_hide & type ) ) { // Add hooks for pre-processing frames + mlt_frame_push_service( a_frame_ptr, self ); mlt_frame_push_get_image( a_frame_ptr, get_image_a ); mlt_frame_push_frame( b_frame_ptr, a_frame_ptr ); + mlt_frame_push_service( b_frame_ptr, self ); mlt_frame_push_get_image( b_frame_ptr, get_image_b ); // Process the transition diff --git a/src/modules/core/filter_crop.c b/src/modules/core/filter_crop.c index e61ac906..168f687b 100644 --- a/src/modules/core/filter_crop.c +++ b/src/modules/core/filter_crop.c @@ -174,7 +174,7 @@ static mlt_frame filter_process( mlt_filter filter, mlt_frame frame ) { double aspect_ratio = mlt_frame_get_aspect_ratio( frame ); if ( aspect_ratio == 0.0 ) - aspect_ratio = mlt_properties_get_double( frame_props, "consumer_aspect_ratio" ); + aspect_ratio = mlt_profile_sar( profile ); double input_ar = aspect_ratio * width / height; double output_ar = mlt_profile_dar( mlt_service_profile( MLT_FILTER_SERVICE(filter) ) ); int bias = mlt_properties_get_int( filter_props, "center_bias" ); diff --git a/src/modules/core/filter_watermark.c b/src/modules/core/filter_watermark.c index 31e8e069..b5adba31 100644 --- a/src/modules/core/filter_watermark.c +++ b/src/modules/core/filter_watermark.c @@ -143,17 +143,17 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format // Get the a and b frame properties mlt_properties a_props = MLT_FRAME_PROPERTIES( frame ); mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); + mlt_profile profile = mlt_service_profile( service ); // Set the b frame to be in the same position and have same consumer requirements mlt_frame_set_position( b_frame, position ); - mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); mlt_properties_set_int( b_props, "consumer_deinterlace", mlt_properties_get_int( a_props, "consumer_deinterlace" ) || mlt_properties_get_int( properties, "deinterlace" ) ); // Check for the special case - no aspect ratio means no problem :-) if ( mlt_frame_get_aspect_ratio( b_frame ) == 0 ) - mlt_properties_set_double( b_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + mlt_frame_set_aspect_ratio( b_frame, mlt_profile_sar( profile ) ); if ( mlt_frame_get_aspect_ratio( frame ) == 0 ) - mlt_properties_set_double( a_props, "aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + mlt_frame_set_aspect_ratio( frame, mlt_profile_sar( profile ) ); if ( mlt_properties_get_int( properties, "distort" ) ) { diff --git a/src/modules/kdenlive/filter_freeze.c b/src/modules/kdenlive/filter_freeze.c index ceede0f9..c040604d 100755 --- a/src/modules/kdenlive/filter_freeze.c +++ b/src/modules/kdenlive/filter_freeze.c @@ -68,7 +68,6 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format mlt_service_get_frame( mlt_producer_service(producer), &freeze_frame, 0 ); mlt_properties freeze_properties = MLT_FRAME_PROPERTIES( freeze_frame ); - mlt_properties_set_double( freeze_properties, "consumer_aspect_ratio", mlt_properties_get_double( props, "consumer_aspect_ratio" ) ); mlt_properties_set( freeze_properties, "rescale.interp", mlt_properties_get( props, "rescale.interp" ) ); mlt_properties_set_double( freeze_properties, "aspect_ratio", mlt_frame_get_aspect_ratio( frame ) ); mlt_properties_set_int( freeze_properties, "progressive", mlt_properties_get_int( props, "progressive" ) ); diff --git a/src/modules/kdenlive/producer_framebuffer.c b/src/modules/kdenlive/producer_framebuffer.c index d41148ec..7df00cc5 100644 --- a/src/modules/kdenlive/producer_framebuffer.c +++ b/src/modules/kdenlive/producer_framebuffer.c @@ -152,7 +152,6 @@ static int framebuffer_get_image( mlt_frame frame, uint8_t **image, mlt_image_fo uint8_t *first_alpha = mlt_properties_get_data( first_frame_properties, "alpha", NULL ); if ( !first_image ) { - mlt_properties_set_double( first_frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( frame_properties, "consumer_aspect_ratio" ) ); mlt_properties_set( first_frame_properties, "rescale.interp", mlt_properties_get( frame_properties, "rescale.interp" ) ); int error = mlt_frame_get_image( first_frame, &first_image, format, width, height, writable ); diff --git a/src/modules/oldfilm/filter_dust.c b/src/modules/oldfilm/filter_dust.c index b20f4391..5a967317 100644 --- a/src/modules/oldfilm/filter_dust.c +++ b/src/modules/oldfilm/filter_dust.c @@ -123,7 +123,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &luma_frame, 0 ) == 0 ){ - mlt_properties_set_double ( MLT_FRAME_PROPERTIES ( luma_frame ) , "consumer_aspect_ratio" , 1.0 ); mlt_image_format luma_format = mlt_image_yuv422; luma_width = dx; luma_height = luma_width * mlt_properties_get_int( MLT_FRAME_PROPERTIES ( luma_frame ) , "height" ) / mlt_properties_get_int( MLT_FRAME_PROPERTIES ( luma_frame ) , "width" ); diff --git a/src/modules/plus/filter_affine.c b/src/modules/plus/filter_affine.c index a21b3d24..d53bdd3c 100644 --- a/src/modules/plus/filter_affine.c +++ b/src/modules/plus/filter_affine.c @@ -48,18 +48,17 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL ); mlt_transition transition = mlt_properties_get_data( properties, "transition", NULL ); mlt_frame a_frame = NULL; + mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) ); if ( producer == NULL ) { char *background = mlt_properties_get( properties, "background" ); - mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) ); producer = mlt_factory_producer( profile, NULL, background ); mlt_properties_set_data( properties, "producer", producer, 0, (mlt_destructor)mlt_producer_close, NULL ); } if ( transition == NULL ) { - mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) ); transition = mlt_factory_transition( profile, "affine", NULL ); mlt_properties_set_data( properties, "transition", transition, 0, (mlt_destructor)mlt_transition_close, NULL ); } @@ -70,7 +69,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties frame_properties = MLT_FRAME_PROPERTIES( this ); mlt_position in = mlt_filter_get_in( filter ); mlt_position out = mlt_filter_get_out( filter ); - double consumer_ar = mlt_properties_get_double( frame_properties, "consumer_aspect_ratio" ); + double consumer_ar = mlt_profile_sar( profile ); mlt_transition_set_in_and_out( transition, in, out ); if ( out > 0 ) { mlt_properties_set_position( MLT_PRODUCER_PROPERTIES( producer ), "length", out - in + 1 ); @@ -85,11 +84,10 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * // mlt_properties_set_int( MLT_FRAME_PROPERTIES( a_frame ), "distort", 1 ); // Special case - aspect_ratio = 0 - if ( mlt_properties_get_double( frame_properties, "aspect_ratio" ) == 0 ) - mlt_properties_set_double( frame_properties, "aspect_ratio", consumer_ar ); - if ( mlt_properties_get_double( MLT_FRAME_PROPERTIES( a_frame ), "aspect_ratio" ) == 0 ) - mlt_properties_set_double( MLT_FRAME_PROPERTIES( a_frame ), "aspect_ratio", consumer_ar ); - mlt_properties_set_double( MLT_FRAME_PROPERTIES( a_frame ), "consumer_aspect_ratio", consumer_ar ); + if ( mlt_frame_get_aspect_ratio( this ) == 0 ) + mlt_frame_set_aspect_ratio( this, consumer_ar ); + if ( mlt_frame_get_aspect_ratio( a_frame ) == 0 ) + mlt_frame_set_aspect_ratio( a_frame, consumer_ar ); // Add the affine transition onto the frame stack mlt_service_unlock( MLT_FILTER_SERVICE( filter ) ); diff --git a/src/modules/plus/transition_affine.c b/src/modules/plus/transition_affine.c index 80ae6e7c..cbac2758 100644 --- a/src/modules/plus/transition_affine.c +++ b/src/modules/plus/transition_affine.c @@ -397,7 +397,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f int normalised_width = profile->width; int normalised_height = profile->height; - double consumer_ar = mlt_properties_get_double( a_props, "consumer_aspect_ratio" ); + double consumer_ar = mlt_profile_sar( mlt_service_profile( MLT_TRANSITION_SERVICE(transition) ) ); // Structures for geometry struct mlt_geometry_item_s result; -- 2.39.2