]> git.sesse.net Git - mlt/commitdiff
Return and handle errors on failure to produce image (kdenlive-1312).
authorDan Dennedy <dan@dennedy.org>
Wed, 20 Jan 2010 05:36:31 +0000 (21:36 -0800)
committerDan Dennedy <dan@dennedy.org>
Wed, 20 Jan 2010 05:36:31 +0000 (21:36 -0800)
src/framework/mlt_frame.c
src/modules/core/filter_rescale.c
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pixbuf.c
src/modules/qimage/producer_qimage.c

index e5ba7c1f408be657c183040d6490e80a0b6e51db..976cecf0e7d37a1903b617a72ae1a2a9f6582a49 100644 (file)
@@ -387,11 +387,19 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
        {
                mlt_properties_set_int( properties, "image_count", mlt_properties_get_int( properties, "image_count" ) - 1 );
                error = get_image( this, buffer, format, width, height, writable );
-               mlt_properties_set_int( properties, "width", *width );
-               mlt_properties_set_int( properties, "height", *height );
-               mlt_properties_set_int( properties, "format", *format );
-               if ( this->convert_image )
-                       this->convert_image( this, buffer, format, requested_format );
+               if ( !error )
+               {
+                       mlt_properties_set_int( properties, "width", *width );
+                       mlt_properties_set_int( properties, "height", *height );
+                       mlt_properties_set_int( properties, "format", *format );
+                       if ( this->convert_image )
+                               this->convert_image( this, buffer, format, requested_format );
+               }
+               else
+               {
+                       // Cause the image to be loaded from test card or fallback (white) below.
+                       mlt_frame_get_image( this, buffer, format, width, height, writable );
+               }
        }
        else if ( mlt_properties_get_data( properties, "image", NULL ) )
        {
index 546914babd33f73c4a1143f044814edb2052cbfd..621575b1bc976d9df4faa8d3f2a4495dc88bf0be 100644 (file)
@@ -148,6 +148,8 @@ static void scale_alpha( mlt_frame this, int iwidth, int iheight, int owidth, in
 
 static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
 {
+       int error = 0;
+       
        // Get the frame properties
        mlt_properties properties = MLT_FRAME_PROPERTIES( this );
 
@@ -246,20 +248,10 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        }
        else
        {
-               // Store the requested width/height
-               int iwidth = *width;
-               int iheight = *height;
-
-               // Get the image as requested
-               mlt_frame_get_image( this, image, format, &iwidth, &iheight, writable );
-
-               // Too small - for now just assign as though we got what we wanted
-               *width = iwidth;
-               *height = iheight;
+               error = 1;
        }
 
-
-       return 0;
+       return error;
 }
 
 /** Filter processing.
index 1df060501d68a9c677228fd39c0b5bf18d9a8512..660247d8ca925c1a85dda358af32ecddda362e88 100644 (file)
@@ -457,6 +457,7 @@ static void refresh_image( mlt_frame frame, int width, int height )
 
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
+       int error = 0;
        producer_pango this = ( producer_pango ) mlt_frame_pop_service( frame );
 
        // Obtain properties of frame
@@ -487,17 +488,12 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        }
        else
        {
-               // TODO: Review all cases of invalid images
-               *buffer = mlt_pool_alloc( 50 * 50 * 2 );
-               mlt_properties_set_data( properties, "image", *buffer, 50 * 50 * 2, mlt_pool_release, NULL );
-               *width = 50;
-               *height = 50;
-               *format = mlt_image_yuv422;
+               error = 1;
        }
 
        pthread_mutex_unlock( &pango_mutex );
 
-       return 0;
+       return error;
 }
 
 static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index )
index 6f87772bb5510ac6264d521a61c13ec2a400485c..6f39eb809379bc2f96b74d8b7161cb2701c291af 100644 (file)
@@ -386,6 +386,8 @@ static void refresh_image( producer_pixbuf this, mlt_frame frame, int width, int
 
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
+       int error = 0;
+       
        // Obtain properties of frame
        mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
 
@@ -420,19 +422,14 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        }
        else
        {
-               // TODO: Review all cases of invalid images
-               *buffer = mlt_pool_alloc( 50 * 50 * 2 );
-               mlt_properties_set_data( properties, "image", *buffer, 50 * 50 * 2, mlt_pool_release, NULL );
-               *width = 50;
-               *height = 50;
-               *format = mlt_image_yuv422;
+               error = 1;
        }
 
        // Release references and locks
        pthread_mutex_unlock( &this->mutex );
        mlt_cache_item_close( this->image_cache );
 
-       return 0;
+       return error;
 }
 
 static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index )
index a290899edca3438d3577dddf0fb1fbd967eba3e5..66d0833395da078b38c4226f0b4a3e844931fa1e 100644 (file)
@@ -172,6 +172,8 @@ static void load_filenames( producer_qimage this, mlt_properties producer_proper
 
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
+       int error = 0;
+       
        // Obtain properties of frame
        mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
 
@@ -206,19 +208,14 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        }
        else
        {
-               // TODO: Review all cases of invalid images
-               *buffer = mlt_pool_alloc( 50 * 50 * 2 );
-               mlt_properties_set_data( properties, "image", *buffer, 50 * 50 * 2, mlt_pool_release, NULL );
-               *width = 50;
-               *height = 50;
-               *format = mlt_image_yuv422;
+               error = 1;
        }
 
        // Release references and locks
        pthread_mutex_unlock( &this->mutex );
        mlt_cache_item_close( this->image_cache );
 
-       return 0;
+       return error;
 }
 
 static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index )