]> git.sesse.net Git - mlt/commitdiff
add image sequences where scanf format contains begin value
authorDan Dennedy <dan@dennedy.org>
Tue, 6 Mar 2012 06:40:51 +0000 (22:40 -0800)
committerDan Dennedy <dan@dennedy.org>
Tue, 6 Mar 2012 06:40:51 +0000 (22:40 -0800)
For example, if an image sequence begins with the file foo1234.png, you
can use the resource string "foo%1234d.png" to load it.

src/modules/gtk2/producer_pixbuf.c
src/modules/qimage/producer_qimage.c

index d1b3517f7e1e0f050ad419dda8fb0530de08bcc7..ea75cadc50e0f250eef4dd3f48221ecee221da99 100644 (file)
@@ -39,6 +39,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <dirent.h>
+#include <ctype.h>
 
 // this protects concurrent access to gdk_pixbuf
 static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -191,6 +192,33 @@ static int load_sequence( producer_pixbuf self, mlt_properties properties, const
        return result;
 }
 
+static int load_sequence2( producer_pixbuf self, mlt_properties properties, const char *filename )
+{
+       int result = 0;
+       const char *start;
+
+       // Obtain filenames with pattern containing a begin value, e.g. foo%1234d.png
+       if ( ( start = strchr( filename, '%' ) ) )
+       {
+               const char *end = ++start;
+               while ( isdigit( *end ) ) end++;
+               if ( end > start && ( end[0] == 'd' || end[0] == 'i' ) )
+               {
+                       int n = end - start;
+                       char *s = calloc( 1, n + 1 );
+                       strncpy( s, start, n );
+                       mlt_properties_set( properties, "begin", s );
+                       free( s );
+                       s = calloc( 1, strlen( filename ) );
+                       strncpy( s, filename, start - filename );
+                       sprintf( s + ( start - filename ), ".%d%s", n, end );
+                       result = load_sequence( self, properties, s );
+                       free( s );
+               }
+       }
+       return result;
+}
+
 static int load_folder( producer_pixbuf self, mlt_properties properties, const char *filename )
 {
        int result = 0;
@@ -220,6 +248,7 @@ static void load_filenames( producer_pixbuf self, mlt_properties properties )
 
        if (!load_svg( self, properties, filename ) &&
                !load_sequence( self, properties, filename ) &&
+               !load_sequence2( self, properties, filename ) &&
                !load_folder( self, properties, filename ) )
        {
                mlt_properties_set( self->filenames, "0", filename );
index 3a96dab71c88a673cec243a6914cbcbad515121e..47cb82cf4491fb812794be4b4d4cc336950f67f8 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <ctype.h>
 
 static void load_filenames( producer_qimage self, mlt_properties producer_properties );
 static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
@@ -138,6 +139,33 @@ static int load_sequence( producer_qimage self, mlt_properties properties, const
        return result;
 }
 
+static int load_sequence2( producer_qimage self, mlt_properties properties, const char *filename )
+{
+       int result = 0;
+       const char *start;
+
+       // Obtain filenames with pattern containing a begin value, e.g. foo%1234d.png
+       if ( ( start = strchr( filename, '%' ) ) )
+       {
+               const char *end = ++start;
+               while ( isdigit( *end ) ) end++;
+               if ( end > start && ( end[0] == 'd' || end[0] == 'i' ) )
+               {
+                       int n = end - start;
+                       char *s = calloc( 1, n + 1 );
+                       strncpy( s, start, n );
+                       mlt_properties_set( properties, "begin", s );
+                       free( s );
+                       s = calloc( 1, strlen( filename ) );
+                       strncpy( s, filename, start - filename );
+                       sprintf( s + ( start - filename ), ".%d%s", n, end );
+                       result = load_sequence( self, properties, s );
+                       free( s );
+               }
+       }
+       return result;
+}
+
 static int load_folder( producer_qimage self, mlt_properties properties, const char *filename )
 {
        int result = 0;
@@ -167,6 +195,7 @@ static void load_filenames( producer_qimage self, mlt_properties properties )
 
        if (!load_svg( self, properties, filename ) &&
                !load_sequence( self, properties, filename ) &&
+               !load_sequence2( self, properties, filename ) &&
                !load_folder( self, properties, filename ) )
        {
                mlt_properties_set( self->filenames, "0", filename );