#include <framework/mlt.h>
static mlt_properties dictionary = NULL;
+static mlt_properties normalisers = NULL;
static void track_service( mlt_tractor tractor, void *service, mlt_destructor destructor )
{
char temp[ 1024 ];
sprintf( temp, "%s/fezzik.dict", mlt_factory_prefix( ) );
dictionary = mlt_properties_load( temp );
+ mlt_factory_register_for_clean_up( dictionary, ( mlt_destructor )mlt_properties_close );
}
// Convert the lookup string to lower case
free( lookup );
}
+ // Finally, try just loading as service
+ if ( result == NULL )
+ result = mlt_factory_producer( file, NULL );
+
return result;
}
-static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *effect )
+static mlt_service create_filter( mlt_tractor tractor, mlt_service last, char *effect, int *created )
{
char *id = strdup( effect );
char *arg = strchr( id, ':' );
mlt_filter_connect( filter, last, 0 );
track_service( tractor, filter, ( mlt_destructor )mlt_filter_close );
last = mlt_filter_service( filter );
+ *created = 1;
}
free( id );
return last;
}
+static mlt_service attach_normalisers( mlt_tractor tractor, mlt_service last )
+{
+ // Loop variable
+ int i;
+
+ // Tokeniser
+ mlt_tokeniser tokeniser = mlt_tokeniser_init( );
+
+ // We only need to load the normalising properties once
+ if ( normalisers == NULL )
+ {
+ char temp[ 1024 ];
+ sprintf( temp, "%s/fezzik.ini", mlt_factory_prefix( ) );
+ normalisers = mlt_properties_load( temp );
+ mlt_factory_register_for_clean_up( normalisers, ( mlt_destructor )mlt_properties_close );
+ }
+
+ // Apply normalisers
+ for ( i = 0; i < mlt_properties_count( normalisers ); i ++ )
+ {
+ int j = 0;
+ int created = 0;
+ char *value = mlt_properties_get_value( normalisers, i );
+ mlt_tokeniser_parse_new( tokeniser, value, "," );
+ for ( j = 0; !created && j < mlt_tokeniser_count( tokeniser ); j ++ )
+ last = create_filter( tractor, last, mlt_tokeniser_get_string( tokeniser, j ), &created );
+ }
+
+ // Close the tokeniser
+ mlt_tokeniser_close( tokeniser );
+
+ return last;
+}
+
mlt_producer producer_fezzik_init( char *arg )
{
// Create the producer that the tractor will contain
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" );
+ last = attach_normalisers( tractor, last );
// Connect the tractor to the last
mlt_tractor_connect( tractor, last );