+ {
+ // Get the a and b frame properties
+ mlt_properties a_props = MLT_FRAME_PROPERTIES( frame );
+ mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame );
+
+ // 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_double( a_props, "consumer_deinterlace" ) );
+ mlt_properties_set_int( b_props, "output_ratio", mlt_properties_get_double( a_props, "output_ratio" ) );
+
+ // 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" ) );
+ 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_properties_set_int( b_props, "normalised_width", mlt_properties_get_int( a_props, "normalised_width" ) );
+ mlt_properties_set_int( b_props, "normalised_height", mlt_properties_get_int( a_props, "normalised_height" ) );
+
+ if ( mlt_properties_get_int( properties, "distort" ) )
+ {
+ mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( composite ), "distort", 1 );
+ mlt_properties_set_int( a_props, "distort", 1 );
+ mlt_properties_set_int( b_props, "distort", 1 );
+ }
+
+ if ( mlt_properties_get_int( properties, "reverse" ) == 0 )
+ {
+ // Apply all filters that are attached to this filter to the b frame
+ mlt_service_apply_filters( MLT_FILTER_SERVICE( this ), b_frame, 0 );
+
+ // Process the frame
+ mlt_transition_process( composite, frame, b_frame );
+
+ // Get the image
+ error = mlt_frame_get_image( frame, image, format, width, height, 1 );
+ }
+ else
+ {
+ char temp[ 132 ];
+ int count = 0;
+ uint8_t *alpha = NULL;
+ char *rescale = mlt_properties_get( a_props, "rescale.interp" );
+ if ( rescale == NULL || !strcmp( rescale, "none" ) )
+ rescale = "hyper";
+ mlt_transition_process( composite, b_frame, frame );
+ mlt_properties_set_int( a_props, "consumer_deinterlace", 1 );
+ mlt_properties_set_int( b_props, "consumer_deinterlace", 1 );
+ mlt_properties_set( a_props, "rescale.interp", rescale );
+ mlt_properties_set( b_props, "rescale.interp", rescale );
+ mlt_service_apply_filters( MLT_FILTER_SERVICE( this ), b_frame, 0 );
+ error = mlt_frame_get_image( b_frame, image, format, width, height, 1 );
+ alpha = mlt_frame_get_alpha_mask( b_frame );
+ mlt_properties_set_data( a_props, "image", *image, *width * *height * 2, NULL, NULL );
+ mlt_properties_set_data( a_props, "alpha", alpha, *width * *height, NULL, NULL );
+ mlt_properties_set_int( a_props, "width", *width );
+ mlt_properties_set_int( a_props, "height", *height );
+ mlt_properties_set_int( a_props, "progressive", 1 );
+ mlt_properties_inc_ref( b_props );
+ strcpy( temp, "_b_frame" );
+ while( mlt_properties_get_data( a_props, temp, NULL ) != NULL )
+ sprintf( temp, "_b_frame%d", count ++ );
+ mlt_properties_set_data( a_props, temp, b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL );
+ }
+ }