]> git.sesse.net Git - mlt/blobdiff - src/modules/core/transition_region.c
Fix composite using wrong B frame scaling.
[mlt] / src / modules / core / transition_region.c
index 77878dd1f83b9a5ac9c2cad13bd77f149832fa2b..f9187afa36a409e52417a0d02d5e976a142905bb 100644 (file)
@@ -123,11 +123,11 @@ static uint8_t *filter_get_alpha_mask( mlt_frame this )
                        *p ++ = ( int )( ( ( *image ++ - 16 ) * 299 ) / 255 );
                        image ++;
                }
-               mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "alpha", alpha, region_width * region_height, mlt_pool_release, NULL );
+               mlt_frame_set_alpha( this, alpha, region_width * region_height, mlt_pool_release );
        }
        else
        {
-               mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "alpha", alpha, region_width * region_height, NULL, NULL );
+               mlt_frame_set_alpha( this, alpha, region_width * region_height, NULL );
        }
 
        this->get_alpha_mask = NULL;
@@ -152,17 +152,16 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
        // Get the properties of the transition
        mlt_properties properties = MLT_TRANSITION_PROPERTIES( this );
 
+       mlt_service_lock( MLT_TRANSITION_SERVICE( this ) );
+
        // Get the composite from the transition
        mlt_transition composite = mlt_properties_get_data( properties, "composite", NULL );
 
        // Look for the first filter
        mlt_filter filter = mlt_properties_get_data( properties, "_filter_0", NULL );
 
-       // Get the unique id of the filter (used to reacquire the producer position)
-       char *name = mlt_properties_get( properties, "_unique_id" );
-
-       // Get the original producer position
-       mlt_position position = mlt_properties_get_position( MLT_FRAME_PROPERTIES( frame ), name );
+       // Get the position
+       mlt_position position = mlt_transition_get_position( this, frame );
 
        // Create a composite if we don't have one
        if ( composite == NULL )
@@ -265,14 +264,11 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
                }
        }
 
-       // Get the image
-       error = mlt_frame_get_image( frame, image, format, width, height, 1 );
-
        // Only continue if we have both filter and composite
        if ( composite != NULL )
        {
                // Get the resource of this filter (could be a shape [rectangle/circle] or an alpha provider of choice
-               char *resource =  mlt_properties_get( properties, "resource" );
+               const char *resource =  mlt_properties_get( properties, "resource" );
 
                // Get the old resource in case it's changed
                char *old_resource =  mlt_properties_get( properties, "_old_resource" );
@@ -290,12 +286,10 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
                        b_frame = composite_copy_region( composite, frame, position );
 
                        // Ensure a destructor
+                       char *name = mlt_properties_get( properties, "_unique_id" );
                        mlt_properties_set_data( MLT_FRAME_PROPERTIES( frame ), name, b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL );
                }
 
-               // Set the position of the b_frame
-               mlt_frame_set_position( b_frame, position );
-
                // Make sure the filter is in the correct position
                while ( filter != NULL )
                {
@@ -338,13 +332,7 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
 
                                // Special case circle resource
                                if ( strcmp( resource, "circle" ) == 0 )
-                               {
-                                       // Special case to ensure that fezzik produces a pixbuf with a NULL constructor
-                                       resource = "pixbuf";
-
-                                       // Specify the svg circle
-                                       mlt_properties_set( properties, "producer.resource", "<svg width='100' height='100'><circle cx='50' cy='50' r='50' fill='black'/></svg>" );
-                               }
+                                       resource = "pixbuf:<svg width='100' height='100'><circle cx='50' cy='50' r='50' fill='black'/></svg>";
 
                                // Create the producer
                                mlt_profile profile = mlt_service_profile( MLT_TRANSITION_SERVICE( this ) );
@@ -392,6 +380,8 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
                error = mlt_frame_get_image( frame, image, format, width, height, 0 );
        }
 
+       mlt_service_unlock( MLT_TRANSITION_SERVICE( this ) );
+
        return error;
 }
 
@@ -400,15 +390,6 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
 
 static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
 {
-       // Get the properties of the frame
-       mlt_properties properties = MLT_FRAME_PROPERTIES( a_frame );
-
-       // Get a unique name to store the frame position
-       char *name = mlt_properties_get( MLT_TRANSITION_PROPERTIES( this ), "_unique_id" );
-
-       // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( a_frame ) );
-
        // Push the transition on to the frame
        mlt_frame_push_service( a_frame, this );
 
@@ -440,7 +421,7 @@ mlt_transition transition_region_init( mlt_profile profile, mlt_service_type typ
                this->process = transition_process;
 
                // Default factory
-               mlt_properties_set( properties, "factory", "fezzik" );
+               mlt_properties_set( properties, "factory", mlt_environment( "MLT_PRODUCER" ) );
                
                // Resource defines the shape of the region
                mlt_properties_set( properties, "resource", arg == NULL ? "rectangle" : arg );