]> git.sesse.net Git - mlt/commitdiff
Improve error handling on video decode failure (kdenlive-1553).
authorDan Dennedy <dan@dennedy.org>
Tue, 20 Apr 2010 03:37:53 +0000 (20:37 -0700)
committerDan Dennedy <dan@dennedy.org>
Tue, 20 Apr 2010 03:37:53 +0000 (20:37 -0700)
src/framework/mlt_frame.c
src/modules/avformat/producer_avformat.c

index 76d23346df679da55e89f5ff413c7edb66a096be..4f394ca6ba88511e551d2e29dab230d4cbc6ca48 100644 (file)
@@ -387,7 +387,7 @@ 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 );
-               if ( !error )
+               if ( !error && *buffer )
                {
                        mlt_properties_set_int( properties, "width", *width );
                        mlt_properties_set_int( properties, "height", *height );
@@ -407,7 +407,7 @@ int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *for
                *buffer = mlt_properties_get_data( properties, "image", NULL );
                *width = mlt_properties_get_int( properties, "width" );
                *height = mlt_properties_get_int( properties, "height" );
-               if ( this->convert_image )
+               if ( this->convert_image && *buffer )
                        this->convert_image( this, buffer, format, requested_format );
        }
        else if ( producer )
index 5af5c3f19d76577357dbca1c940e284838abd7ee..83ce78ec71c8d928e7a5e4d987fa2a3faec6891d 100644 (file)
@@ -877,6 +877,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                        mlt_properties_set_data( frame_properties, "avformat.image_cache", item, 0, ( mlt_destructor )mlt_cache_item_close, NULL );
                        mlt_properties_set_data( frame_properties, "image", *buffer, size, NULL, NULL );
                        this->top_field_first = mlt_properties_get_int( frame_properties, "top_field_first" );
+                       this->got_picture = 1;
 
                        goto exit_get_image;
                }
@@ -1230,8 +1231,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                                }
                        }
                }
-               if ( !got_picture )
-                       mlt_frame_get_image( frame, buffer, format, width, height, writable );
        }
 
        avformat_unlock();
@@ -1257,7 +1256,7 @@ exit_get_image:
        // Regardless of speed, we expect to get the next frame (cos we ain't too bright)
        this->video_expected = position + 1;
 
-       return 0;
+       return !this->got_picture;
 }
 
 /** Process properties as AVOptions and apply to AV context obj