]> git.sesse.net Git - mlt/blobdiff - src/modules/core/transition_region.c
refactor dissolve_yuv() to use composite_line_yuv()
[mlt] / src / modules / core / transition_region.c
index 77878dd1f83b9a5ac9c2cad13bd77f149832fa2b..3822df9bbc532b28882e7d234ffe805aa9b0badf 100644 (file)
@@ -68,7 +68,7 @@ static int create_instance( mlt_transition this, char *name, char *value, int co
                sprintf( key, "%s.", name );
 
                // Just in case, let's assume that the filter here has a composite
-               //mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "composite.geometry", "0%,0%:100%x100%" );
+               //mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "composite.geometry", "0%/0%:100%x100%" );
                //mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "composite.fill", 1 );
 
                // Pass all the key properties on the filter down
@@ -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,14 @@ 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 );
+       mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "width", *width );
+       mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "height", *height );
 
        // 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" );
@@ -283,18 +282,23 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for
                // Index to hold the count
                int i = 0;
 
-               // We will get the 'b frame' from the composite only if it's NULL
+               // We will get the 'b frame' from the composite only if it's NULL (region filter)
                if ( b_frame == NULL )
                {
                        // Copy the region
                        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 );
+               // filter_only prevents copying the alpha channel of the shape to the output frame
+               // by compositing filtered frame over itself
+               if ( mlt_properties_get_int( properties, "filter_only" ) )
+               {
+                       frame = composite_copy_region( composite, b_frame, position );
+               }
 
                // Make sure the filter is in the correct position
                while ( filter != NULL )
@@ -338,13 +342,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 +390,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 +400,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 +431,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 );