]> git.sesse.net Git - mlt/commitdiff
fix race condition in region filter when parallel processing
authorDan Dennedy <dan@dennedy.org>
Sat, 23 Jun 2012 22:15:53 +0000 (15:15 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 23 Jun 2012 22:15:53 +0000 (15:15 -0700)
based on patch from j-b-m

src/modules/core/filter_region.c

index 8fd8e8d6ab84e78a236e06dd2c58471471c39b04..7ccfe5287681abc2f73f6ce8c8b722df9cc9e12d 100644 (file)
 /** Filter processing.
 */
 
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
+       // Get the filter
+       mlt_filter filter = mlt_frame_pop_service( frame );
+
        // Get the properties of the filter
-       mlt_properties properties = MLT_FILTER_PROPERTIES( this );
+       mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
 
        // Get the region transition
        mlt_transition transition = mlt_properties_get_data( properties, "_transition", NULL );
@@ -42,21 +47,36 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        if ( transition == NULL )
        {
                // Create the transition
-               mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( this ) );
+               mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) );
                transition = mlt_factory_transition( profile, "region", NULL );
 
                // Register with the filter
                mlt_properties_set_data( properties, "_transition", transition, 0, ( mlt_destructor )mlt_transition_close, NULL );
 
                // Pass a reference to this filter down
-               mlt_properties_set_data( MLT_TRANSITION_PROPERTIES( transition ), "_region_filter", this, 0, NULL, NULL );
+               mlt_properties_set_data( MLT_TRANSITION_PROPERTIES( transition ), "_region_filter", filter, 0, NULL, NULL );
        }
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        // Pass all properties down
-       mlt_properties_pass( MLT_TRANSITION_PROPERTIES( transition ), properties, "" );
+       mlt_properties_inherit( MLT_TRANSITION_PROPERTIES( transition ), properties );
+
+       // Make the frame's position relative to this filter's in point
+       mlt_frame_set_position( frame, mlt_filter_get_position( filter, frame ) );
 
        // Process the frame
-       return mlt_transition_process( transition, frame, NULL );
+       mlt_transition_process( transition, frame, NULL );
+
+       return mlt_frame_get_image( frame, image, format, width, height, writable );
+}
+
+static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+{
+       mlt_frame_push_service( frame, this );
+       mlt_frame_push_get_image( frame, filter_get_image );
+
+       return frame;
 }
 
 /** Constructor for the filter.
@@ -86,4 +106,3 @@ mlt_filter filter_region_init( mlt_profile profile, mlt_service_type type, const
        // Return the filter
        return this;
 }
-