]> git.sesse.net Git - mlt/blobdiff - src/modules/gtk2/producer_pixbuf.c
Avoid unnecessary compilation when running "./configure; make; make install" multiple...
[mlt] / src / modules / gtk2 / producer_pixbuf.c
index 1e922e7713519a38de7de5db7e2b3aca546183c5..1ec705e3e6fd4e8e24d3524079accccfadda1760 100644 (file)
@@ -25,8 +25,6 @@
 #include <framework/mlt_tokeniser.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "config.h"
-
 #ifdef USE_EXIF
 #include <libexif/exif-data.h>
 #endif
@@ -92,6 +90,7 @@ mlt_producer producer_pixbuf_init( char *filename )
                mlt_properties_set_int( properties, "aspect_ratio", 1 );
                mlt_properties_set_int( properties, "progressive", 1 );
                mlt_properties_set_int( properties, "seekable", 1 );
+               mlt_properties_set_int( properties, "loop", 1 );
 
                // Validate the resource
                if ( filename )
@@ -212,7 +211,7 @@ static int load_sequence_deprecated( producer_pixbuf self, mlt_properties proper
                        strncpy( s, start, n );
                        mlt_properties_set( properties, "begin", s );
                        free( s );
-                       s = calloc( 1, strlen( filename ) );
+                       s = calloc( 1, strlen( filename ) + 2 );
                        strncpy( s, filename, start - filename );
                        sprintf( s + ( start - filename ), ".%d%s", n, end );
                        result = load_sequence_sprintf( self, properties, s );
@@ -227,13 +226,16 @@ static int load_sequence_querystring( producer_pixbuf self, mlt_properties prope
        int result = 0;
 
        // Obtain filenames with pattern and begin value in query string
-       if ( strchr( filename, '%' ) && strchr( filename, '?' ) && strstr( filename, "begin=" ) )
+       if ( strchr( filename, '%' ) && strchr( filename, '?' ) )
        {
                // Split filename into pattern and query string
                char *s = strdup( filename );
                char *querystring = strrchr( s, '?' );
                *querystring++ = '\0';
-               mlt_properties_set( properties, "begin", strstr( querystring, "begin=" ) + 6 );
+               if ( strstr( filename, "begin=" ) )
+                       mlt_properties_set( properties, "begin", strstr( querystring, "begin=" ) + 6 );
+               else if ( strstr( filename, "begin:" ) )
+                       mlt_properties_set( properties, "begin", strstr( querystring, "begin:" ) + 6 );
                // Coerce to an int value so serialization does not have any extra query string cruft
                mlt_properties_set_int( properties, "begin", mlt_properties_get_int( properties, "begin" ) );
                result = load_sequence_sprintf( self, properties, s );
@@ -368,7 +370,13 @@ static int refresh_pixbuf( producer_pixbuf self, mlt_frame frame )
        position += mlt_producer_get_in( producer );
 
        // Image index
-       int current_idx = ( int )floor( ( double )position / ttl ) % self->count;
+       int loop = mlt_properties_get_int( producer_props, "loop" );
+       int current_idx;
+       if (loop) {
+               current_idx = ( int )floor( ( double )position / ttl ) % self->count;
+       } else {
+               current_idx = MIN(( double )position / ttl, self->count - 1);
+       }
 
        // Key for the cache
        char image_key[ 10 ];
@@ -437,6 +445,7 @@ static void refresh_image( producer_pixbuf self, mlt_frame frame, mlt_image_form
        if ( self->pixbuf && ( !self->image || ( format != mlt_image_none && format != self->format ) ) )
        {
                char *interps = mlt_properties_get( properties, "rescale.interp" );
+               if ( interps ) interps = strdup( interps );
                int interp = GDK_INTERP_BILINEAR;
 
                if ( !interps ) {
@@ -448,6 +457,7 @@ static void refresh_image( producer_pixbuf self, mlt_frame frame, mlt_image_form
                        interp = GDK_INTERP_TILES;
                else if ( strcmp( interps, "hyper" ) == 0 || strcmp( interps, "bicubic" ) == 0 )
                        interp = GDK_INTERP_HYPER;
+               if ( interps ) free( interps );
 
                // Note - the original pixbuf is already safe and ready for destruction
                pthread_mutex_lock( &g_mutex );
@@ -543,8 +553,10 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        mlt_producer producer = &self->parent;
 
        // Use the width and height suggested by the rescale filter because we can do our own scaling.
-       *width = mlt_properties_get_int( properties, "rescale_width" );
-       *height = mlt_properties_get_int( properties, "rescale_height" );
+       if ( mlt_properties_get_int( properties, "rescale_width" ) > 0 )
+               *width = mlt_properties_get_int( properties, "rescale_width" );
+       if ( mlt_properties_get_int( properties, "rescale_height" ) > 0 )
+               *height = mlt_properties_get_int( properties, "rescale_height" );
 
        // Restore pixbuf and image
        mlt_service_lock( MLT_PRODUCER_SERVICE( producer ) );