#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
/** Do it :-).
*/
// Get the composite from the filter
mlt_transition composite = mlt_properties_get_data( properties, "composite", NULL );
+ // Get the resource to use
+ char *resource = mlt_properties_get( properties, "resource" );
+
+ // Get the old resource
+ char *old_resource = mlt_properties_get( properties, "_old_resource" );
+
// Create a composite if we don't have one
if ( composite == NULL )
{
}
// Create a producer if don't have one
- if ( producer == NULL )
+ if ( producer == NULL || ( old_resource != NULL && strcmp( resource, old_resource ) ) )
{
- // Get the resource to use
- char *resource = mlt_properties_get( properties, "resource" );
-
// Get the factory producer service
char *factory = mlt_properties_get( properties, "factory" );
// Ensure that we loop
mlt_properties_set( mlt_producer_properties( producer ), "eof", "loop" );
+
+ // Set the old resource
+ mlt_properties_set( properties, "_old_resource", resource );
}
}
// Get the b frame and process with composite if successful
if ( mlt_service_get_frame( service, &b_frame, 0 ) == 0 )
- mlt_transition_process( composite, frame, b_frame );
-
- // Get the image
- error = mlt_frame_get_image( frame, image, format, width, height, 1 );
+ {
+ // Set the b frame to be in the same position
+ mlt_frame_set_position( b_frame, position );
+
+ 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
+ {
+ mlt_properties a_props = mlt_frame_properties( frame );
+ mlt_properties b_props = mlt_frame_properties( b_frame );
+ mlt_transition_process( composite, b_frame, frame );
+ mlt_properties_set( a_props, "rescale.interp", "nearest" );
+ mlt_properties_set( b_props, "rescale.interp", "nearest" );
+ mlt_properties_set_int( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
+ mlt_service_apply_filters( mlt_filter_service( this ), frame, 0 );
+ error = mlt_frame_get_image( b_frame, image, format, width, height, 1 );
+ mlt_properties_set_data( b_props, "image", *image, 0, NULL, NULL );
+ mlt_properties_set_data( a_props, "image", *image, *width * *height * 2, mlt_pool_release, NULL );
+ mlt_properties_set_int( a_props, "width", *width );
+ mlt_properties_set_int( a_props, "height", *height );
+ }
+ }
// Close the b frame
mlt_frame_close( b_frame );
char *name = mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
// Assign the current position to the name
- mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
+ mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
// Push the filter on to the stack
mlt_frame_push_service( frame, this );
mlt_properties_set( properties, "factory", "fezzik" );
if ( arg != NULL )
mlt_properties_set( properties, "resource", arg );
+ // Ensure that attached filters are handled privately
+ mlt_properties_set_int( properties, "_filter_private", 1 );
}
return this;
}