]> git.sesse.net Git - mlt/commitdiff
fezzik gets a rhyming dictionary
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 19 Mar 2004 15:13:58 +0000 (15:13 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Fri, 19 Mar 2004 15:13:58 +0000 (15:13 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@222 d19143bc-622f-0410-bfdd-b5b2a6649095

docs/framework.txt
src/framework/mlt_properties.c
src/framework/mlt_properties.h
src/modules/Makefile
src/modules/configure
src/modules/core/producer_noise.c
src/modules/fezzik.dict [new file with mode: 0644]
src/modules/fezzik/producer_fezzik.c

index 12b38713b85b87270f1dad20ff98586c1909863e..865258b8921c77f6cc5f4221f9bc00a89107e90c 100644 (file)
@@ -959,7 +959,7 @@ mlt_frame:
        void *mlt_frame_pop_audio( mlt_frame this );
        void mlt_frame_close( mlt_frame this );
 
-       
+
 mlt_service:
 
        The service base class extends properties and allows 0 to m inputs and 0 to
@@ -1042,6 +1042,7 @@ mlt_producer:
 
        The public interface is defined by the following functions:
 
+       mlt_producer mlt_producer_new( );
        int mlt_producer_init( mlt_producer this, void *child );
        mlt_service mlt_producer_service( mlt_producer this );
        mlt_properties mlt_producer_properties( mlt_producer this );
@@ -1059,45 +1060,6 @@ mlt_producer:
        void mlt_producer_prepare_next( mlt_producer this );
        void mlt_producer_close( mlt_producer this );
 
-       For the sake of discussion here, we'll assume that someone wants to provide
-       a new producer which random noise
-
-       // Forward reference
-       static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index );
-
-       mlt_producer producer_green( void *arg )
-       {
-               // Create a new producer
-               mlt_producer this = mlt_producer_new( );
-
-               // Check that we were allocated a new producer
-               if ( this != NULL )
-               {
-                       // Get the service 
-                       mlt_service service = mlt_producer_service( this );
-
-                       // We need to override the get_frame method
-                       service->get_frame = producer_get_frame;
-               }
-
-               // Return this producer
-               return this;
-       }
-
-       static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index )
-       {
-               // Create a new frame
-               *frame = mlt_frame_init( );
-
-               // Specify the get_image
-               mlt_frame_push_get_image( *frame, producer_get_image );
-
-               // Specify the get_audio
-               mlt_frame_push_audio( *frame, producer_get_audio );
-
-               // Return that all was successful
-               return 0;
-       }
 
 mlt_filter:
 
@@ -1181,5 +1143,3 @@ mlt_playlist:
 mlt_tractor:
 
 
-mlt_factory
-
index 1638200c0a85bce147359fd649206f64452147c7..d4d14cf48bba69fa2f6ac6faa8bb4627871452a5 100644 (file)
@@ -74,6 +74,45 @@ mlt_properties mlt_properties_new( )
        return this;
 }
 
+/** Load properties from a file.
+*/
+
+mlt_properties mlt_properties_load( char *filename )
+{
+       // Construct a standalone properties object
+       mlt_properties this = mlt_properties_new( );
+
+       if ( this != NULL )
+       {
+               // Open the file
+               FILE *file = fopen( filename, "r" );
+
+               // Load contents of file
+               if ( file != NULL )
+               {
+                       // Temp string
+                       char temp[ 1024 ];
+
+                       // Read each string from the file
+                       while( fgets( temp, 1024, file ) )
+                       {
+                               // Chomp the string
+                               temp[ strlen( temp ) - 1 ] = '\0';
+
+                               // Parse and set the property
+                               if ( strcmp( temp, "" ) )
+                                       mlt_properties_parse( this, temp );
+                       }
+
+                       // Close the file
+                       fclose( file );
+               }
+       }
+
+       // Return the pointer
+       return this;
+}
+
 static inline int generate_hash( char *name )
 {
        int hash = 0;
index 6a043091f1226d59142a4fe471314a098e5559bb..d6060a03d0d2f6b9047a2694e755a302dde26dd6 100644 (file)
@@ -39,6 +39,7 @@ struct mlt_properties_s
 
 extern int mlt_properties_init( mlt_properties, void *child );
 extern mlt_properties mlt_properties_new( );
+extern mlt_properties mlt_properties_load( char *file );
 extern void mlt_properties_mirror( mlt_properties this, mlt_properties that );
 extern int mlt_properties_inherit( mlt_properties this, mlt_properties that );
 extern int mlt_properties_pass( mlt_properties this, mlt_properties that, char *prefix );
index 18df6509ce9b6be8227544bc681269814fe4bd94..ca2d852a52c76b346ee388848b8ced20ff6a331e 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo avformat vorbis speex westley fezzik xine
+include make.inc
 
 all clean depend install:
        list='$(SUBDIRS)'; \
@@ -9,7 +9,7 @@ all clean depend install:
        done
 
 dist-clean:
-       rm -f consumers.dat filters.dat producers.dat transitions.dat; \
+       rm -f consumers.dat filters.dat producers.dat transitions.dat make.inc; \
        list='$(SUBDIRS)'; \
        for subdir in $$list; do \
                if [ -f $$subdir/Makefile ] ; \
index b33bc3700b3fd54522a018f6318bb8b1df848ef7..14031a8b1b58a561beb415a20b06729c85309e18 100755 (executable)
@@ -3,6 +3,9 @@
 # Clean up disables if not in help mode
 [ "$help" != "1" ] && rm -f disable-* producers.dat filters.dat transitions.dat consumers.dat
 
+# Create the make.inc file
+echo SUBDIRS = `find -type d -maxdepth 1 | grep -v CVS | grep -v "^.$" | sed 's/\.\///'` > make.inc
+
 # Iterate through arguments
 for i in $*
 do
index 9c586c1046a34176baaaf922d233506ad90f518f..9afe3853602e3cec3fe9d14264821e5a306f1908 100644 (file)
@@ -92,11 +92,9 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                // Generate random noise
                while ( p != *buffer )
                {
-                       value = fast_rand( );
+                       value = fast_rand( ) & 0xff;
                        *( -- p ) = 128;
-                       *( -- p ) = value & 0xff;
-                       *( -- p ) = 128;
-                       *( -- p ) = ( ( value & 0xff00 ) >> 8 ) & 0xf0;
+                       *( -- p ) = value < 16 ? 16 : value > 240 ? 240 : value;
                }
        }
 
diff --git a/src/modules/fezzik.dict b/src/modules/fezzik.dict
new file mode 100644 (file)
index 0000000..012ecea
--- /dev/null
@@ -0,0 +1,19 @@
+http://*=avformat
+*.westley=westley
+*.inigo=inigo_file
+*.asf=avformat
+*.avi=avformat
+*.dv=mcdv,libdv,avformat
+*.dif=mcdv,libdv
+*.jpg=pixbuf
+*.jpeg=pixbuf
+*.mp3=avformat
+*.mpg=mcmpeg,avformat
+*.mpeg=mcmpeg,avformat
+*.ogg=vorbis
+*.png=pixbuf
+*.svg=pixbuf
+*.txt=pango
+*.wav=avformat
+*.wmv=avformat
+*=avformat
index 8173991239571d4697c29f209f184e468406149f..ea63282e27f14f4b63d9de17f2c0004537bc8463 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
+#include <fnmatch.h>
 
 #include <framework/mlt.h>
 
+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,11 +42,29 @@ 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;
 
-       // 0th Line - check for service:resource handling
+       // 1st Line - check for service:resource handling
        if ( strchr( file, ':' ) )
        {
                char *temp = strdup( file );
@@ -53,49 +75,38 @@ static mlt_producer create_producer( char *file )
                free( temp );
        }
 
-       // 1st Line preferences
+       // 2nd Line preferences
        if ( result == NULL )
        {
-               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, ".svg" ) )
-                       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 );
-       }
+               int i = 0;
+               char *lookup = strdup( file );
+               char *p = lookup;
 
-       // 2nd Line fallbacks
-       if ( result == NULL )
-       {
-               if ( strstr( file, ".dv" ) )
-                       result = mlt_factory_producer( "libdv", file );
-               else if ( strstr( file, ".dif" ) )
-                       result = mlt_factory_producer( "libdv", 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 );
+               }
 
-       // 3rd line fallbacks 
-       if ( result == NULL )
-               result = mlt_factory_producer( "avformat", file );
+               // 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;
 }
@@ -121,6 +132,7 @@ mlt_producer producer_fezzik_init( char *arg )
 {
        // Create the producer that the tractor will contain
        mlt_producer producer = NULL;
+
        if ( arg != NULL )
                producer = create_producer( arg );