]> git.sesse.net Git - mlt/commitdiff
Fix image sequences sometimes not advancing.
authorDan Dennedy <dan@dennedy.org>
Wed, 27 May 2009 06:36:26 +0000 (23:36 -0700)
committerDan Dennedy <dan@dennedy.org>
Wed, 27 May 2009 06:36:26 +0000 (23:36 -0700)
Signed-off-by: Dan Dennedy <dan@dennedy.org>
src/modules/gtk2/producer_pixbuf.c
src/modules/qimage/qimage_wrapper.cpp
src/modules/qimage/qimage_wrapper.h

index 17f9c5610e626bcd269dfd235e8f4bc69c890c82..b72e9c827ba4ffb6af6c24b12a929e15ac81ca87 100644 (file)
@@ -21,6 +21,7 @@
 #include <framework/mlt_producer.h>
 #include <framework/mlt_frame.h>
 #include <framework/mlt_cache.h>
+#include <framework/mlt_log.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include <stdio.h>
@@ -45,7 +46,7 @@ struct producer_pixbuf_s
        mlt_properties filenames;
        int count;
        int image_idx;
-
+       int pixbuf_idx;
        int width;
        int height;
        uint8_t *image;
@@ -274,12 +275,13 @@ static void refresh_image( producer_pixbuf this, mlt_frame frame, int width, int
     // optimization for subsequent iterations on single picture
        if ( width != 0 && ( image_idx != this->image_idx || width != this->width || height != this->height ) )
                this->image = NULL;
-       if ( image_idx != this->image_idx )
+       if ( image_idx != this->pixbuf_idx )
                pixbuf = NULL;
-       if ( pixbuf == NULL && ( width == 0 || this->image == NULL ) )
+       mlt_log_debug( MLT_PRODUCER_SERVICE( producer ), "image %p pixbuf %p idx %d image_idx %d pixbuf_idx %d width %d\n",
+               this->image, pixbuf, image_idx, this->image_idx, this->pixbuf_idx, width );
+       if ( !pixbuf && !this->image )
        {
                this->image = NULL;
-               this->image_idx = image_idx;
                pixbuf = gdk_pixbuf_new_from_file( mlt_properties_get_value( this->filenames, image_idx ), &error );
 
                if ( pixbuf )
@@ -288,6 +290,7 @@ static void refresh_image( producer_pixbuf this, mlt_frame frame, int width, int
                        mlt_cache_item_close( pixbuf_cache );
                        mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "pixbuf.pixbuf", pixbuf, 0, ( mlt_destructor )g_object_unref );
                        pixbuf_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "pixbuf.pixbuf" );
+                       this->pixbuf_idx = image_idx;
 
                        mlt_events_block( producer_props, NULL );
                        mlt_properties_set_int( producer_props, "_real_width", gdk_pixbuf_get_width( pixbuf ) );
@@ -301,7 +304,7 @@ static void refresh_image( producer_pixbuf this, mlt_frame frame, int width, int
        }
 
        // If we have a pixbuf and we need an image
-       if ( pixbuf && width > 0 && this->image == NULL )
+       if ( pixbuf && width > 0 && !this->image )
        {
                char *interps = mlt_properties_get( properties, "rescale.interp" );
                int interp = GDK_INTERP_BILINEAR;
@@ -326,6 +329,7 @@ static void refresh_image( producer_pixbuf this, mlt_frame frame, int width, int
                        mlt_cache_item_close( this->image_cache );
                mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "pixbuf.image", this->image, width * ( height + 1 ) * 2, mlt_pool_release );
                this->image_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "pixbuf.image" );
+               this->image_idx = image_idx;
 
                // Extract YUV422 and alpha
                if ( gdk_pixbuf_get_has_alpha( pixbuf ) )
index d8722e002458e97900f76f2dbe793c53f4da204a..6c038f64610b537f9c23519d435e0e93977cb053 100644 (file)
@@ -159,12 +159,11 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
     // optimization for subsequent iterations on single picture
        if ( width != 0 && ( image_idx != self->image_idx || width != self->current_width || height != self->current_height ) )
                self->current_image = NULL;
-       if ( image_idx != self->image_idx )
+       if ( image_idx != self->qimage_idx )
                qimage = NULL;
-       if ( qimage == NULL && ( width == 0 || self->current_image == NULL ) )
+       if ( !qimage && !self->current_image )
        {
                self->current_image = NULL;
-               self->image_idx = image_idx;
                qimage = new QImage( mlt_properties_get_value( self->filenames, image_idx ) );
 
                if ( !qimage->isNull( ) )
@@ -177,6 +176,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
                        mlt_cache_item_close( qimage_cache );
                        mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "qimage.qimage", qimage, 0, ( mlt_destructor )qimage_delete );
                        qimage_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "qimage.qimage" );
+                       self->qimage_idx = image_idx;
 
                        mlt_events_block( producer_props, NULL );
                        mlt_properties_set_int( producer_props, "_real_width", self->current_width );
@@ -191,7 +191,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
        }
 
        // If we have a pixbuf and this request specifies a valid dimension and we haven't already got a cached version...
-       if ( qimage && width > 0 && self->current_image == NULL )
+       if ( qimage && width > 0 && !self->current_image )
        {
                char *interps = mlt_properties_get( properties, "rescale.interp" );
                int interp = 0;
@@ -230,6 +230,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
                        mlt_cache_item_close( self->image_cache );
                mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "qimage.image", self->current_image, width * ( height + 1 ) * 2, mlt_pool_release );
                self->image_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "qimage.image" );
+               self->image_idx = image_idx;
 
                if (!hasAlpha) {
                        mlt_convert_rgb24_to_yuv422( temp.bits(), self->current_width, self->current_height, temp.bytesPerLine(), self->current_image ); 
index 9c9243ef0589170c92988e8c38d9ab0f84224628..c87b193041197c201bee7e5a1076a6e65ef887ea 100644 (file)
@@ -39,6 +39,7 @@ struct producer_qimage_s
        mlt_properties filenames;
        int count;
        int image_idx;
+       int qimage_idx;
        uint8_t *current_image;
        uint8_t *current_alpha;
        int current_width;