- if ( mlt_properties_get_int( properties, "aligned" ) && mlt_properties_get_int( properties, "distort" ) == 0 && mlt_properties_get_int( b_props, "distort" ) == 0 && geometry->item.distort == 0 )
+ // 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
+ if ( mlt_properties_get( properties, "crop" ) )
+ {
+ 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 );
+ int scaled_height = real_height;
+ geometry->sw = scaled_width;
+ geometry->sh = scaled_height;
+ }
+ // Normalise aspect ratios and scale preserving aspect ratio
+ else if ( mlt_properties_get_int( properties, "aligned" ) && mlt_properties_get_int( properties, "distort" ) == 0 && mlt_properties_get_int( b_props, "distort" ) == 0 && geometry->item.distort == 0 )