X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Ftransition_composite.c;h=cab4f253cdf4d104d8c72e8829a90648bcf7b797;hb=375348a13f7a2fabc5740e67bbc0b533275baa5d;hp=22eb091e209674b18204f232ffb5b3fdb93ebac8;hpb=051100a9b57a55ad7a3faacff7b15d4465ed634e;p=mlt diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 22eb091e..cab4f253 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -156,6 +156,7 @@ static mlt_geometry transition_parse_keys( mlt_transition this, int normalised_w item.frame = -1; if ( mlt_geometry_parse_item( geometry, &item, mlt_properties_get( properties, "end" ) ) == 0 ) mlt_geometry_insert( geometry, &item ); + mlt_geometry_interpolate( geometry ); } return geometry; @@ -364,13 +365,28 @@ static inline uint8_t sample_mix( uint8_t dest, uint8_t src, int mix ) /** Composite a source line over a destination line */ +#if defined(USE_SSE) && defined(ARCH_X86_64) +#include "composite_line_yuv_sse2_simple.c" +#endif static void composite_line_yuv( uint8_t *dest, uint8_t *src, int width, uint8_t *alpha_b, uint8_t *alpha_a, int weight, uint16_t *luma, int soft, uint32_t step ) { - register int j; + register int j = 0; register int mix; - for ( j = 0; j < width; j ++ ) +#if defined(USE_SSE) && defined(ARCH_X86_64) + if ( !luma && width > 7 ) + { + composite_line_yuv_sse2_simple(dest, src, width, alpha_b, alpha_a, weight); + j = width - width % 8; + dest += j * 2; + src += j * 2; + alpha_a += j; + alpha_b += j; + } +#endif + + for ( ; j < width; j ++ ) { mix = calculate_mix( luma, j, soft, weight, *alpha_b ++, step ); *dest = sample_mix( *dest, *src++, mix ); @@ -444,8 +460,8 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, uint int stride_src = geometry.sw * bpp; int stride_dest = width_dest * bpp; int i_softness = ( 1 << 16 ) * softness; - int weight = ( ( 1 << 16 ) - 1 ) * geometry.item.mix / 100; - uint32_t luma_step = ( ( 1 << 16 ) - 1 ) * geometry.item.mix / 100 * ( 1.0 + softness ); + int weight = ( ( ( 1 << 16 ) - 1 ) * geometry.item.mix + 50 ) / 100; + uint32_t luma_step = ( ( ( 1 << 16 ) - 1 ) * geometry.item.mix + 50 ) / 100 * ( 1.0 + softness ); // Adjust to consumer scale int x = rint( geometry.item.x * width_dest / geometry.nw ); @@ -750,6 +766,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 +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 ); @@ -775,7 +791,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 ); @@ -919,7 +934,7 @@ static mlt_geometry composite_calculate( mlt_transition this, struct geometry_s sprintf( key, "%s.in", name ); if ( mlt_properties_get( a_props, key ) ) { - sscanf( mlt_properties_get( a_props, key ), "%f,%f,%f,%f,%f,%d,%d", &result->item.x, &result->item.y, &result->item.w, &result->item.h, &result->item.mix, &result->nw, &result->nh ); + sscanf( mlt_properties_get( a_props, key ), "%f %f %f %f %f %d %d", &result->item.x, &result->item.y, &result->item.w, &result->item.h, &result->item.mix, &result->nw, &result->nh ); } else { @@ -1022,9 +1037,9 @@ mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_pos } // Store the key - sprintf( key, "%s.in=%d,%d,%d,%d,%f,%d,%d", name, x, y, w, h, result.item.mix, width, height ); + sprintf( key, "%s.in=%d %d %d %d %f %d %d", name, x, y, w, h, result.item.mix, width, height ); mlt_properties_parse( a_props, key ); - sprintf( key, "%s.out=%d,%d,%d,%d,%f,%d,%d", name, x, y, w, h, result.item.mix, width, height ); + sprintf( key, "%s.out=%d %d %d %d %f %d %d", name, x, y, w, h, result.item.mix, width, height ); mlt_properties_parse( a_props, key ); ds = w * 2; @@ -1121,6 +1136,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f // Calculate the position double delta = mlt_transition_get_progress_delta( this, a_frame ); + mlt_position length = mlt_transition_get_length( this ); // Get the image from the b frame uint8_t *image_b = NULL; @@ -1131,13 +1147,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 +1154,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( b_props, "consumer_deinterlace", 1 ); + } // TODO: Dangerous/temporary optimisation - if nothing to do, then do nothing if ( mlt_properties_get_int( properties, "no_alpha" ) && @@ -1240,7 +1250,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f for ( field = 0; field < ( progressive ? 1 : 2 ); field++ ) { // Assume lower field (0) first - double field_position = position + field * delta; + double field_position = position + field * delta * length; // Do the calculation if we need to // NB: Locks needed here since the properties are being modified @@ -1327,7 +1337,7 @@ mlt_transition transition_composite_init( mlt_profile profile, mlt_service_type this->process = composite_process; // Default starting motion and zoom - mlt_properties_set( properties, "start", arg != NULL ? arg : "0,0:100%x100%" ); + mlt_properties_set( properties, "start", arg != NULL ? arg : "0/0:100%x100%" ); // Default factory mlt_properties_set( properties, "factory", mlt_environment( "MLT_PRODUCER" ) );