From aea672c471e7d222798f29736cb2f33bafd0d795 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Fri, 6 May 2011 22:46:59 -0700 Subject: [PATCH] Factor out some frame properties in transitions. Transitions had to apply a pattern of copying some properties from the A frame to the B frame that was unrelated to its core routine. This is now largely taken care of by a recent commit to mlt_transition.c. --- src/modules/core/transition_composite.c | 21 +++++++-------------- src/modules/core/transition_luma.c | 20 -------------------- src/modules/frei0r/transition_frei0r.c | 13 ------------- src/modules/plus/transition_affine.c | 4 +--- 4 files changed, 8 insertions(+), 50 deletions(-) diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 22eb091e..7b2622b3 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -750,6 +750,7 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); mlt_properties properties = MLT_TRANSITION_PROPERTIES( this ); uint8_t resize_alpha = mlt_properties_get_int( b_props, "resize_alpha" ); + double consumer_ar = mlt_profile_sar( mlt_service_profile( MLT_TRANSITION_SERVICE(this) ) ); // Do not scale if we are cropping - the compositing rectangle can crop the b image // TODO: Use the animatable w and h of the crop geometry to scale independently of crop rectangle @@ -758,7 +759,6 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** int real_width = get_value( b_props, "real_width", "width" ); int real_height = get_value( b_props, "real_height", "height" ); double input_ar = mlt_properties_get_double( b_props, "aspect_ratio" ); - double consumer_ar = mlt_properties_get_double( b_props, "consumer_aspect_ratio" ); double background_ar = mlt_properties_get_double( b_props, "output_ratio" ); double output_ar = background_ar != 0.0 ? background_ar : consumer_ar; int scaled_width = rint( ( input_ar == 0.0 ? output_ar : input_ar ) / output_ar * real_width ); @@ -775,7 +775,6 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** int real_width = get_value( b_props, "real_width", "width" ); int real_height = get_value( b_props, "real_height", "height" ); double input_ar = mlt_properties_get_double( b_props, "aspect_ratio" ); - double consumer_ar = mlt_properties_get_double( b_props, "consumer_aspect_ratio" ); double background_ar = mlt_properties_get_double( b_props, "output_ratio" ); double output_ar = background_ar != 0.0 ? background_ar : consumer_ar; int scaled_width = rint( ( input_ar == 0.0 ? output_ar : input_ar ) / output_ar * real_width ); @@ -1131,13 +1130,6 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f uint8_t *alpha_a = NULL; uint8_t *alpha_b = NULL; - // Composites always need scaling... defaulting to lowest - const char *rescale = mlt_properties_get( a_props, "rescale.interp" ); - if ( rescale == NULL || !strcmp( rescale, "none" ) ) - rescale = "nearest"; - mlt_properties_set( a_props, "rescale.interp", rescale ); - mlt_properties_set( b_props, "rescale.interp", rescale ); - // Do the calculation // NB: Locks needed here since the properties are being modified int invert = mlt_properties_get_int( properties, "invert" ); @@ -1145,11 +1137,12 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f composite_calculate( this, &result, invert ? b_frame : a_frame, position ); mlt_service_unlock( MLT_TRANSITION_SERVICE( this ) ); - // Since we are the consumer of the b_frame, we must pass along these - // consumer properties from the a_frame - mlt_properties_set_int( b_props, "consumer_deinterlace", mlt_properties_get_int( a_props, "consumer_deinterlace" ) || mlt_properties_get_int( properties, "deinterlace" ) ); - mlt_properties_set( b_props, "consumer_deinterlace_method", mlt_properties_get( a_props, "consumer_deinterlace_method" ) ); - mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); + // Manual option to deinterlace + if ( mlt_properties_get_int( properties, "deinterlace" ) ) + { + mlt_properties_set_int( a_props, "consumer_deinterlace", 1 ); + mlt_properties_set_int( a_props, "consumer_deinterlace", 1 ); + } // TODO: Dangerous/temporary optimisation - if nothing to do, then do nothing if ( mlt_properties_get_int( properties, "no_alpha" ) && diff --git a/src/modules/core/transition_luma.c b/src/modules/core/transition_luma.c index cb18dd5e..437eb9f1 100644 --- a/src/modules/core/transition_luma.c +++ b/src/modules/core/transition_luma.c @@ -45,7 +45,6 @@ static inline int dissolve_yuv( mlt_frame this, mlt_frame that, float weight, in if ( mlt_properties_get( &this->parent, "distort" ) ) mlt_properties_set( &that->parent, "distort", mlt_properties_get( &this->parent, "distort" ) ); - mlt_properties_set_int( &that->parent, "consumer_deinterlace", mlt_properties_get_int( &this->parent, "consumer_deinterlace" ) ); mlt_frame_get_image( this, &p_dest, &format, &width, &height, 1 ); alpha_dst = mlt_frame_get_alpha_mask( this ); mlt_frame_get_image( that, &p_src, &format, &width_src, &height_src, 0 ); @@ -103,7 +102,6 @@ static void luma_composite( mlt_frame a_frame, mlt_frame b_frame, int luma_width if ( mlt_properties_get( &a_frame->parent, "distort" ) ) mlt_properties_set( &b_frame->parent, "distort", mlt_properties_get( &a_frame->parent, "distort" ) ); - mlt_properties_set_int( &b_frame->parent, "consumer_deinterlace", mlt_properties_get_int( &a_frame->parent, "consumer_deinterlace" ) ); mlt_frame_get_image( a_frame, &p_dest, &format_dest, &width_dest, &height_dest, 1 ); mlt_frame_get_image( b_frame, &p_src, &format_src, &width_src, &height_src, 0 ); @@ -459,28 +457,10 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f int reverse = mlt_properties_get_int( properties, "reverse" ); int invert = mlt_properties_get_int( properties, "invert" ); - if ( mlt_properties_get( a_props, "rescale.interp" ) == NULL || !strcmp( mlt_properties_get( a_props, "rescale.interp" ), "none" ) ) - mlt_properties_set( a_props, "rescale.interp", "nearest" ); - - // Since we are the consumer of the b_frame, we must pass along this - // consumer property from the a_frame - 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_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" ) ); - mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); - // Honour the reverse here if ( mix >= 1.0 ) mix -= floor( mix ); - // Ensure we get scaling on the b_frame - if ( mlt_properties_get( b_props, "rescale.interp" ) == NULL || !strcmp( mlt_properties_get( b_props, "rescale.interp" ), "none" ) ) - mlt_properties_set( b_props, "rescale.interp", mlt_properties_get( a_props, "rescale.interp" ) ); - - if ( invert ) - mlt_properties_set_int( b_props, "consumer_deinterlace", mlt_properties_get_int( a_props, "consumer_deinterlace") ); - if ( mlt_properties_get( properties, "fixed" ) ) mix = mlt_properties_get_double( properties, "fixed" ); diff --git a/src/modules/frei0r/transition_frei0r.c b/src/modules/frei0r/transition_frei0r.c index 4e335b18..f36d1c4e 100644 --- a/src/modules/frei0r/transition_frei0r.c +++ b/src/modules/frei0r/transition_frei0r.c @@ -31,19 +31,6 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f int invert = mlt_properties_get_int( properties, "invert" ); - if ( mlt_properties_get( a_props, "rescale.interp" ) == NULL || !strcmp( mlt_properties_get( a_props, "rescale.interp" ), "none" ) ) - mlt_properties_set( a_props, "rescale.interp", "nearest" ); - - // set consumer_aspect_ratio for a and b frame - 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_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" ) ); - mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); - - if ( mlt_properties_get( b_props, "rescale.interp" ) == NULL || !strcmp( mlt_properties_get( b_props, "rescale.interp" ), "none" ) ) - mlt_properties_set( b_props, "rescale.interp", mlt_properties_get( a_props, "rescale.interp" ) ); - uint8_t *images[]={NULL,NULL,NULL}; *format = mlt_image_rgb24a; diff --git a/src/modules/plus/transition_affine.c b/src/modules/plus/transition_affine.c index 95e4a92a..b07cea31 100644 --- a/src/modules/plus/transition_affine.c +++ b/src/modules/plus/transition_affine.c @@ -426,12 +426,10 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f mlt_properties_set_int( b_props, "rescale_height", b_height ); // Suppress padding and aspect normalization. - char *interps = mlt_properties_get( b_props, "rescale.interp" ); + char *interps = mlt_properties_get( a_props, "rescale.interp" ); if ( interps ) interps = strdup( interps ); mlt_properties_set( b_props, "rescale.interp", "none" ); - if ( mlt_properties_get_double( b_props, "aspect_ratio" ) == 0.0 ) - mlt_properties_set_double( b_props, "aspect_ratio", consumer_ar ); // This is not a field-aware transform. mlt_properties_set_int( b_props, "consumer_deinterlace", 1 ); -- 2.39.2