+ int width = mlt_properties_get_int( frame_props, "meta.media.width" );
+ int height = mlt_properties_get_int( frame_props, "meta.media.height" );
+ int use_profile = mlt_properties_get_int( filter_props, "use_profile" );
+ mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) );
+
+ if ( use_profile )
+ {
+ top = top * height / profile->height;
+ bottom = bottom * height / profile->height;
+ left = left * width / profile->width;
+ right = right * width / profile->width;
+ }
+ if ( mlt_properties_get_int( filter_props, "center" ) )
+ {
+ double aspect_ratio = mlt_frame_get_aspect_ratio( frame );
+ if ( aspect_ratio == 0.0 )
+ 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" );
+
+ if ( input_ar > output_ar )
+ {
+ left = right = ( width - rint( output_ar * height / aspect_ratio ) ) / 2;
+ if ( abs(bias) > left )
+ bias = bias < 0 ? -left : left;
+ else if ( use_profile )
+ bias = bias * width / profile->width;
+ left -= bias;
+ right += bias;
+ }
+ else
+ {
+ top = bottom = ( height - rint( aspect_ratio * width / output_ar ) ) / 2;
+ if ( abs(bias) > top )
+ bias = bias < 0 ? -top : top;
+ else if ( use_profile )
+ bias = bias * height / profile->height;
+ top -= bias;
+ bottom += bias;
+ }
+ }