From: lilo_booter Date: Wed, 3 Mar 2004 23:19:33 +0000 (+0000) Subject: transition region X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=9ab18ed63c37a9ef65e06697ae25f5c198d788bb;p=melted transition region git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@189 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 0b1eee5..51298bd 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -128,6 +128,11 @@ int mlt_consumer_start( mlt_consumer this ) system( mlt_properties_get( properties, "ante" ) ); } } + else + { + // Allow the hash table to speed things up + mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); + } // Start the service if ( this->start != NULL ) @@ -156,19 +161,20 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this ) // Get the frame properties mlt_properties frame_properties = mlt_frame_properties( frame ); - // Attach the test frame producer to it. + // Get the test card producer mlt_producer test_card = mlt_properties_get_data( properties, "test_card_producer", NULL ); - mlt_properties_set_data( frame_properties, "test_card_producer", test_card, 0, NULL, NULL ); + + // Attach the test frame producer to it. + if ( test_card != NULL ) + mlt_properties_set_data( frame_properties, "test_card_producer", test_card, 0, NULL, NULL ); // Attach the rescale property - if ( mlt_properties_get( properties, "rescale" ) != NULL ) - mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale" ) ); + mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale" ) ); // Aspect ratio and other jiggery pokery mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_progressive", mlt_properties_get_int( properties, "progressive" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_int( properties, "deinterlace" ) ); - } // Return the frame diff --git a/src/framework/mlt_consumer.h b/src/framework/mlt_consumer.h index 5dce836..290d02b 100644 --- a/src/framework/mlt_consumer.h +++ b/src/framework/mlt_consumer.h @@ -22,6 +22,7 @@ #define _MLT_CONSUMER_H_ #include "mlt_service.h" +#include /** The interface definition for all consumers. */ @@ -40,6 +41,13 @@ struct mlt_consumer_s // Private data void *private; void *child; + + int ahead; + int width; + int height; + mlt_image_format format; + mlt_deque queue; + pthread_t ahead_thread; }; /** Public final methods diff --git a/src/framework/mlt_frame.h b/src/framework/mlt_frame.h index a35086e..2534293 100644 --- a/src/framework/mlt_frame.h +++ b/src/framework/mlt_frame.h @@ -26,16 +26,6 @@ typedef enum { - mlt_image_none = 0, - mlt_image_rgb24, - mlt_image_rgb24a, - mlt_image_yuv422, - mlt_image_yuv420p -} -mlt_image_format; - -typedef enum -{ mlt_video_standard_pal = 0, mlt_video_standard_ntsc } diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index cebaa90..2824cca 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -156,14 +156,14 @@ static inline mlt_property mlt_properties_find( mlt_properties this, char *name { property_list *list = this->private; mlt_property value = NULL; - int i = 0; int key = generate_hash( name ); + int i = list->hash[ key ]; // Check if we're hashed if ( list->count > 0 && - name[ 0 ] == list->name[ list->hash[ key ] ][ 0 ] && - !strcmp( list->name[ list->hash[ key ] ], name ) ) - value = list->value[ list->hash[ key ] ]; + name[ 0 ] == list->name[ i ][ 0 ] && + !strcmp( list->name[ i ], name ) ) + value = list->value[ i ]; // Locate the item for ( i = 0; value == NULL && i < list->count; i ++ ) diff --git a/src/framework/mlt_service.h b/src/framework/mlt_service.h index 21168cd..99d1966 100644 --- a/src/framework/mlt_service.h +++ b/src/framework/mlt_service.h @@ -63,7 +63,6 @@ struct mlt_service_s */ extern int mlt_service_init( mlt_service this, void *child ); -//extern mlt_properties mlt_service_properties( mlt_service this ); extern int mlt_service_connect_producer( mlt_service this, mlt_service producer, int index ); extern mlt_service_state mlt_service_get_state( mlt_service this ); extern void mlt_service_close( mlt_service this ); diff --git a/src/framework/mlt_types.h b/src/framework/mlt_types.h index f55bc9a..5e061bb 100644 --- a/src/framework/mlt_types.h +++ b/src/framework/mlt_types.h @@ -27,6 +27,16 @@ typedef enum { + mlt_image_none = 0, + mlt_image_rgb24, + mlt_image_rgb24a, + mlt_image_yuv422, + mlt_image_yuv420p +} +mlt_image_format; + +typedef enum +{ mlt_whence_relative_start, mlt_whence_relative_current, mlt_whence_relative_end diff --git a/src/modules/core/Makefile b/src/modules/core/Makefile index 379abf8..63eeace 100644 --- a/src/modules/core/Makefile +++ b/src/modules/core/Makefile @@ -13,10 +13,11 @@ OBJS = factory.o \ filter_resize.o \ filter_volume.o \ filter_watermark.o \ + producer_colour.o \ transition_composite.o \ transition_luma.o \ transition_mix.o \ - producer_colour.o + transition_region.o CFLAGS = -O3 -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread @@ -39,3 +40,4 @@ clean: ifneq ($(wildcard .depend),) include .depend endif + diff --git a/src/modules/core/configure b/src/modules/core/configure index 54af3ea..735cece 100755 --- a/src/modules/core/configure +++ b/src/modules/core/configure @@ -25,6 +25,7 @@ cat << EOF >> ../transitions.dat composite libmltcore.so luma libmltcore.so mix libmltcore.so +region libmltcore.so EOF fi diff --git a/src/modules/core/factory.c b/src/modules/core/factory.c index 6812dfb..3f47b47 100644 --- a/src/modules/core/factory.c +++ b/src/modules/core/factory.c @@ -31,10 +31,11 @@ #include "filter_region.h" #include "filter_volume.h" #include "filter_watermark.h" +#include "producer_colour.h" #include "transition_composite.h" #include "transition_luma.h" #include "transition_mix.h" -#include "producer_colour.h" +#include "transition_region.h" void *mlt_create_producer( char *id, void *arg ) { @@ -78,6 +79,8 @@ void *mlt_create_transition( char *id, void *arg ) return transition_luma_init( arg ); if ( !strcmp( id, "mix" ) ) return transition_mix_init( arg ); + if ( !strcmp( id, "region" ) ) + return transition_region_init( arg ); return NULL; } diff --git a/src/modules/core/filter_region.c b/src/modules/core/filter_region.c index b6ef970..b47eb37 100644 --- a/src/modules/core/filter_region.c +++ b/src/modules/core/filter_region.c @@ -19,7 +19,7 @@ */ #include "filter_region.h" -#include "transition_composite.h" +#include "transition_region.h" #include @@ -27,299 +27,32 @@ #include #include -static int create_instance( mlt_filter this, char *name, char *value, int count ) -{ - // Return from this function - int error = 0; - - // Duplicate the value - char *type = strdup( value ); - - // Pointer to filter argument - char *arg = type == NULL ? NULL : strchr( type, ':' ); - - // New filter being created - mlt_filter filter = NULL; - - // Cleanup type and arg - if ( arg != NULL ) - *arg ++ = '\0'; - - // Create the filter - filter = mlt_factory_filter( type, arg ); - - // If we have a filter, then initialise and store it - if ( filter != NULL ) - { - // Properties of this - mlt_properties properties = mlt_filter_properties( this ); - - // String to hold the property name - char id[ 256 ]; - - // String to hold the passdown key - char key[ 256 ]; - - // Construct id - sprintf( id, "_filter_%d", count ); - - // Counstruct key - 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.start", "0%,0%:100%x100%" ); - mlt_properties_set( mlt_filter_properties( filter ), "composite.fill", "true" ); - - // Pass all the key properties on the filter down - mlt_properties_pass( mlt_filter_properties( filter ), properties, key ); - - // Ensure that filter is assigned - mlt_properties_set_data( properties, id, filter, 0, ( mlt_destructor )mlt_filter_close, NULL ); - } - else - { - // Indicate that an error has occurred - error = 1; - } - - // Cleanup - free( type ); - - // Return error condition - return error; -} - -static uint8_t *filter_get_alpha_mask( mlt_frame this ) -{ - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( this ); - - // Return the alpha mask - return mlt_properties_get_data( properties, "alpha", NULL ); -} - -/** Do it :-). +/** Filter processing. */ -static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) +static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { - // Error we will return - int error = 0; - - // Get the watermark filter object - mlt_filter this = mlt_frame_pop_service( frame ); - // Get the properties of the filter mlt_properties properties = mlt_filter_properties( this ); - // Get the composite from the filter - 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 ); - - // Create a composite if we don't have one - if ( composite == NULL ) - { - // Create composite via the factory - composite = mlt_factory_transition( "composite", NULL ); - - // If we have one - if ( composite != NULL ) - { - // Get the properties - mlt_properties composite_properties = mlt_transition_properties( composite ); - - // We want to ensure that we don't get a wobble... - mlt_properties_set( composite_properties, "distort", "true" ); - mlt_properties_set( composite_properties, "progressive", "1" ); - - // Pass all the composite. properties on the filter down - mlt_properties_pass( composite_properties, properties, "composite." ); - - // Register the composite for reuse/destruction - mlt_properties_set_data( properties, "composite", composite, 0, ( mlt_destructor )mlt_transition_close, NULL ); - } - } - - // Create filters - if ( filter == NULL ) - { - // Loop Variable - int i = 0; - - // Number of filters created - int count = 0; + // Get the region transition + mlt_transition transition = mlt_properties_get_data( properties, "_transition", NULL ); - // Loop for all properties - for ( i = 0; i < mlt_properties_count( properties ); i ++ ) - { - // Get the name of this property - char *name = mlt_properties_get_name( properties, i ); - - // If the name does not contain a . and matches filter - if ( strchr( name, '.' ) == NULL && !strncmp( name, "filter", 6 ) ) - { - // Get the filter constructor - char *value = mlt_properties_get_value( properties, i ); - - // Create an instance - if ( create_instance( this, name, value, count ) == 0 ) - count ++; - } - } - } - - // 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 && filter != NULL ) + // Create the transition if not available + if ( transition == 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" ); - - // String to hold the filter to query on - char id[ 256 ]; - - // Index to hold the count - int i = 0; - - // We will get the 'b frame' from the composite - mlt_frame b_frame = composite_copy_region( composite, frame, position ); - - // Make sure the filter is in the correct position - while ( filter != NULL ) - { - // Stack this filter - mlt_filter_process( filter, b_frame ); - - // Generate the key for the next - sprintf( id, "_filter_%d", ++ i ); - - // Get the next filter - filter = mlt_properties_get_data( properties, id, NULL ); - } - - // Hmm - this is probably going to go wrong.... - mlt_frame_set_position( frame, position ); - - // Get the b frame and process with composite if successful - mlt_transition_process( composite, frame, b_frame ); - - // If we have a shape producer copy the alpha mask from the shape frame to the b_frame - if ( strcmp( resource, "rectangle" ) != 0 ) - { - // Get the producer from the filter - mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL ); - - // If We have no producer then create one - if ( producer == NULL ) - { - // Get the factory producer service - char *factory = mlt_properties_get( properties, "factory" ); - - // 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", "" ); - } - - // Create the producer - producer = mlt_factory_producer( factory, resource ); + // Create the transition + transition = mlt_factory_transition( "region", NULL ); - // If we have one - if ( producer != NULL ) - { - // Get the producer properties - mlt_properties producer_properties = mlt_producer_properties( producer ); + // Pass all properties down + mlt_properties_pass( mlt_transition_properties( transition ), properties, "" ); - // Ensure that we loop - mlt_properties_set( producer_properties, "eof", "loop" ); - - // Now pass all producer. properties on the filter down - mlt_properties_pass( producer_properties, properties, "producer." ); - - // Register the producer for reuse/destruction - mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); - } - } - - // Now use the shape producer - if ( producer != NULL ) - { - // We will get the alpha frame from the producer - mlt_frame shape_frame = NULL; - - // Make sure the producer is in the correct position - mlt_producer_seek( producer, position ); - - // Get the shape frame - if ( mlt_service_get_frame( mlt_producer_service( producer ), &shape_frame, 0 ) == 0 ) - { - int region_width = mlt_properties_get_int( mlt_frame_properties( b_frame ), "width" ); - int region_height = mlt_properties_get_int( mlt_frame_properties( b_frame ), "height" ); - - // Get the shape image to trigger alpha creation - mlt_properties_set( mlt_frame_properties( shape_frame ), "distort", "true" ); - error = mlt_frame_get_image( shape_frame, image, format, ®ion_width, ®ion_height, 1 ); - - // Only override any existing b_frame alpha if the shape has an alpha - if ( mlt_frame_get_alpha_mask( shape_frame ) != NULL ) - { - // Set the b_frame alpha from the shape frame - mlt_properties_set_data( mlt_frame_properties( b_frame ), "alpha", mlt_frame_get_alpha_mask( shape_frame ), 0 , NULL, NULL ); - b_frame->get_alpha_mask = filter_get_alpha_mask; - } - - // Ensure that the shape frame will be closed - mlt_properties_set_data( mlt_frame_properties( b_frame ), "shape_frame", shape_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); - } - } - } - - // Get the image - error = mlt_frame_get_image( frame, image, format, width, height, 0 ); - - // Close the b frame - mlt_frame_close( b_frame ); + // Register with the filter + mlt_properties_set_data( properties, "_transition", transition, 0, ( mlt_destructor )mlt_transition_close, NULL ); } - return error; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - // Get the properties of the frame - mlt_properties properties = mlt_frame_properties( frame ); - - // Get a unique name to store the frame position - 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 ) ); - - // Push the filter on to the frame - mlt_frame_push_service( frame, this ); - - // Push the filter method - mlt_frame_push_get_image( frame, filter_get_image ); - - // Return the frame - return frame; + // Process the frame + return mlt_transition_process( transition, frame, NULL ); } /** Constructor for the filter. @@ -339,8 +72,6 @@ mlt_filter filter_region_init( void *arg ) // Assign the filter process method this->process = filter_process; - mlt_properties_set( properties, "factory", "fezzik" ); - // Resource defines the shape of the region mlt_properties_set( properties, "resource", arg == NULL ? "rectangle" : arg ); } diff --git a/src/modules/core/transition_region.c b/src/modules/core/transition_region.c new file mode 100644 index 0000000..4e2eb11 --- /dev/null +++ b/src/modules/core/transition_region.c @@ -0,0 +1,362 @@ +/* + * transition_region.c -- region transition + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "transition_region.h" +#include "transition_composite.h" + +#include + +#include +#include +#include + +static int create_instance( mlt_transition this, char *name, char *value, int count ) +{ + // Return from this function + int error = 0; + + // Duplicate the value + char *type = strdup( value ); + + // Pointer to filter argument + char *arg = type == NULL ? NULL : strchr( type, ':' ); + + // New filter being created + mlt_filter filter = NULL; + + // Cleanup type and arg + if ( arg != NULL ) + *arg ++ = '\0'; + + // Create the filter + filter = mlt_factory_filter( type, arg ); + + // If we have a filter, then initialise and store it + if ( filter != NULL ) + { + // Properties of this + mlt_properties properties = mlt_transition_properties( this ); + + // String to hold the property name + char id[ 256 ]; + + // String to hold the passdown key + char key[ 256 ]; + + // Construct id + sprintf( id, "_filter_%d", count ); + + // Counstruct key + 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.start", "0%,0%:100%x100%" ); + mlt_properties_set( mlt_filter_properties( filter ), "composite.fill", "true" ); + + // Pass all the key properties on the filter down + mlt_properties_pass( mlt_filter_properties( filter ), properties, key ); + + // Ensure that filter is assigned + mlt_properties_set_data( properties, id, filter, 0, ( mlt_destructor )mlt_filter_close, NULL ); + } + else + { + // Indicate that an error has occurred + error = 1; + } + + // Cleanup + free( type ); + + // Return error condition + return error; +} + +static uint8_t *filter_get_alpha_mask( mlt_frame this ) +{ + // Obtain properties of frame + mlt_properties properties = mlt_frame_properties( this ); + + // Get the shape frame + mlt_frame shape_frame = mlt_properties_get_data( properties, "shape_frame", NULL ); + + // Get the width and height of the image + int region_width = mlt_properties_get_int( mlt_frame_properties( this ), "width" ); + int region_height = mlt_properties_get_int( mlt_frame_properties( this ), "height" ); + uint8_t *image = NULL; + mlt_image_format format = mlt_image_yuv422; + + // Get the shape image to trigger alpha creation + mlt_properties_set( mlt_frame_properties( shape_frame ), "distort", "true" ); + mlt_frame_get_image( shape_frame, &image, &format, ®ion_width, ®ion_height, 0 ); + + return mlt_frame_get_alpha_mask( shape_frame ); +} + +/** Do it :-). +*/ + +static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) +{ + // Error we will return + int error = 0; + + // Get the watermark transition object + mlt_transition this = mlt_frame_pop_service( frame ); + + // We will get the 'b frame' from the frame stack + mlt_frame b_frame = mlt_frame_pop_frame( frame ); + + // Get the properties of the transition + mlt_properties properties = mlt_transition_properties( 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 ); + + // Create a composite if we don't have one + if ( composite == NULL ) + { + // Create composite via the factory + composite = mlt_factory_transition( "composite", NULL ); + + // If we have one + if ( composite != NULL ) + { + // Get the properties + mlt_properties composite_properties = mlt_transition_properties( composite ); + + // We want to ensure that we don't get a wobble... + mlt_properties_set( composite_properties, "distort", "true" ); + mlt_properties_set( composite_properties, "progressive", "1" ); + + // Pass all the composite. properties on the transition down + mlt_properties_pass( composite_properties, properties, "composite." ); + + // Register the composite for reuse/destruction + mlt_properties_set_data( properties, "composite", composite, 0, ( mlt_destructor )mlt_transition_close, NULL ); + } + } + + // Create filters + if ( filter == NULL ) + { + // Loop Variable + int i = 0; + + // Number of filters created + int count = 0; + + // Loop for all properties + for ( i = 0; i < mlt_properties_count( properties ); i ++ ) + { + // Get the name of this property + char *name = mlt_properties_get_name( properties, i ); + + // If the name does not contain a . and matches filter + if ( strchr( name, '.' ) == NULL && !strncmp( name, "filter", 6 ) ) + { + // Get the filter constructor + char *value = mlt_properties_get_value( properties, i ); + + // Create an instance + if ( create_instance( this, name, value, count ) == 0 ) + count ++; + } + } + } + + // 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" ); + + // String to hold the filter to query on + char id[ 256 ]; + + // Index to hold the count + int i = 0; + + // We will get the 'b frame' from the composite only if it's NULL + if ( b_frame == NULL ) + { + // Copy the region + b_frame = composite_copy_region( composite, frame, position ); + + // Ensure a destructor + mlt_properties_set_data( mlt_frame_properties( frame ), name, b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + } + + // Make sure the filter is in the correct position + while ( filter != NULL ) + { + // Stack this filter + mlt_filter_process( filter, b_frame ); + + // Generate the key for the next + sprintf( id, "_filter_%d", ++ i ); + + // Get the next filter + filter = mlt_properties_get_data( properties, id, NULL ); + } + + // Hmm - this is probably going to go wrong.... + mlt_frame_set_position( frame, position ); + + // Get the b frame and process with composite if successful + mlt_transition_process( composite, frame, b_frame ); + + // If we have a shape producer copy the alpha mask from the shape frame to the b_frame + if ( strcmp( resource, "rectangle" ) != 0 ) + { + // Get the producer from the transition + mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL ); + + // If We have no producer then create one + if ( producer == NULL ) + { + // Get the factory producer service + char *factory = mlt_properties_get( properties, "factory" ); + + // 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", "" ); + } + + // Create the producer + producer = mlt_factory_producer( factory, resource ); + + // If we have one + if ( producer != NULL ) + { + // Get the producer properties + mlt_properties producer_properties = mlt_producer_properties( producer ); + + // Ensure that we loop + mlt_properties_set( producer_properties, "eof", "loop" ); + + // Now pass all producer. properties on the transition down + mlt_properties_pass( producer_properties, properties, "producer." ); + + // Register the producer for reuse/destruction + mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); + } + } + + // Now use the shape producer + if ( producer != NULL ) + { + // We will get the alpha frame from the producer + mlt_frame shape_frame = NULL; + + // Make sure the producer is in the correct position + mlt_producer_seek( producer, position ); + + // Get the shape frame + if ( mlt_service_get_frame( mlt_producer_service( producer ), &shape_frame, 0 ) == 0 ) + { + // Ensure that the shape frame will be closed + mlt_properties_set_data( mlt_frame_properties( b_frame ), "shape_frame", shape_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + + // Specify the callback for evaluation + b_frame->get_alpha_mask = filter_get_alpha_mask; + } + } + } + + // Get the image + error = mlt_frame_get_image( frame, image, format, width, height, 0 ); + } + + return error; +} + +/** Filter processing. +*/ + +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 ); + + // Push the transition method + mlt_frame_push_get_image( a_frame, transition_get_image ); + + // Push the b_frame on to the stack + mlt_frame_push_frame( a_frame, b_frame ); + + // Return the frame + return a_frame; +} + +/** Constructor for the transition. +*/ + +mlt_transition transition_region_init( void *arg ) +{ + // Create a new transition + mlt_transition this = mlt_transition_new( ); + + // Further initialisation + if ( this != NULL ) + { + // Get the properties from the transition + mlt_properties properties = mlt_transition_properties( this ); + + // Assign the transition process method + this->process = transition_process; + + // Default factory + mlt_properties_set( properties, "factory", "fezzik" ); + + // Resource defines the shape of the region + mlt_properties_set( properties, "resource", arg == NULL ? "rectangle" : arg ); + } + + // Return the transition + return this; +} + diff --git a/src/modules/core/transition_region.h b/src/modules/core/transition_region.h new file mode 100644 index 0000000..c192ec4 --- /dev/null +++ b/src/modules/core/transition_region.h @@ -0,0 +1,28 @@ +/* + * transition_region.h -- region transition + * Copyright (C) 2003-2004 Ushodaya Enterprises Limited + * Author: Charles Yates + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _TRANSITION_REGION_H_ +#define _TRANSITION_REGION_H_ + +#include + +extern mlt_transition transition_region_init( void *arg ); + +#endif