X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Ffezzik%2Fproducer_fezzik.c;h=297655772c606a4cbe497fe12e01649cf3b7019d;hb=23571c330fd1644833dcb73661ac987eda177200;hp=bd43e1ccb75757fe60caba1524af4a995af4ef1e;hpb=36aad7b318537612374acfd3f626a8c1364ad95d;p=melted diff --git a/src/modules/fezzik/producer_fezzik.c b/src/modules/fezzik/producer_fezzik.c index bd43e1c..2976557 100644 --- a/src/modules/fezzik/producer_fezzik.c +++ b/src/modules/fezzik/producer_fezzik.c @@ -23,9 +23,13 @@ #include #include #include +#include +#include #include +static mlt_properties dictionary = NULL; + static void track_service( mlt_tractor tractor, void *service, mlt_destructor destructor ) { mlt_properties properties = mlt_tractor_properties( tractor ); @@ -38,52 +42,71 @@ static void track_service( mlt_tractor tractor, void *service, mlt_destructor de free( real ); } +static mlt_producer create_from( char *file, char *services ) +{ + mlt_producer producer = NULL; + char *temp = strdup( services ); + char *service = temp; + do + { + char *p = strchr( service, ',' ); + if ( p != NULL ) + *p ++ = '\0'; + producer = mlt_factory_producer( service, file ); + service = p; + } + while ( producer == NULL && service != NULL ); + free( temp ); + return producer; +} + static mlt_producer create_producer( char *file ) { mlt_producer result = NULL; - // 1st Line preferences - if ( strstr( file, ".inigo" ) ) - result = mlt_factory_producer( "inigo_file", file ); - else if ( strstr( file, ".mpg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".mpeg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".jpg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".JPG" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".jpeg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".png" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".txt" ) ) - result = mlt_factory_producer( "pango", file ); - else if ( strstr( file, ".westley" ) ) - result = mlt_factory_producer( "westley", file ); - else if ( strstr( file, ".ogg" ) ) - result = mlt_factory_producer( "vorbis", file ); - - // 2nd Line fallbacks - if ( result == NULL ) + // 1st Line - check for service:resource handling + if ( strchr( file, ':' ) ) { - if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "libdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "libdv", file ); + char *temp = strdup( file ); + char *service = temp; + char *resource = strchr( temp, ':' ); + *resource ++ = '\0'; + result = mlt_factory_producer( service, resource ); + free( temp ); } - // 3rd line fallbacks + // 2nd Line preferences if ( result == NULL ) - result = mlt_factory_producer( "avformat", file ); + { + int i = 0; + char *lookup = strdup( file ); + char *p = lookup; - // 4th line fallbacks - if ( result == NULL ) - result = mlt_factory_producer( "ffmpeg", file ); + // We only need to load the dictionary once + if ( dictionary == NULL ) + { + char temp[ 1024 ]; + sprintf( temp, "%s/fezzik.dict", mlt_factory_prefix( ) ); + dictionary = mlt_properties_load( temp ); + } + + // Convert the lookup string to lower case + while ( *p ) + { + *p = tolower( *p ); + p ++; + } + + // Iterate through the dictionary + for ( i = 0; result == NULL && i < mlt_properties_count( dictionary ); i ++ ) + { + char *name = mlt_properties_get_name( dictionary, i ); + if ( fnmatch( name, lookup, 0 ) == 0 ) + result = create_from( file, mlt_properties_get_value( dictionary, i ) ); + } + + free( lookup ); + } return result; } @@ -108,7 +131,10 @@ static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *e mlt_producer producer_fezzik_init( char *arg ) { // Create the producer that the tractor will contain - mlt_producer producer = create_producer( arg ); + mlt_producer producer = NULL; + + if ( arg != NULL ) + producer = create_producer( arg ); // Build the tractor if we have a producer and it isn't already westley'd :-) if ( producer != NULL && mlt_properties_get( mlt_producer_properties( producer ), "westley" ) == NULL ) @@ -132,6 +158,7 @@ mlt_producer producer_fezzik_init( char *arg ) mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); // Now attach normalising filters + last = create_filter( tractor, last, "deinterlace" ); last = create_filter( tractor, last, "rescale" ); last = create_filter( tractor, last, "resize" ); last = create_filter( tractor, last, "resample" ); @@ -152,6 +179,9 @@ mlt_producer producer_fezzik_init( char *arg ) // We need to ensure that all further properties are mirrored in the producer mlt_properties_mirror( properties, mlt_producer_properties( producer ) ); + // Ensure that the inner producer ignores the in point + mlt_properties_set_int( mlt_producer_properties( producer ), "ignore_points", 1 ); + // Now, we return the producer of the tractor producer = mlt_tractor_producer( tractor ); } @@ -160,4 +190,3 @@ mlt_producer producer_fezzik_init( char *arg ) // Return the tractor's producer return producer; } -