From: Dan Dennedy Date: Tue, 20 Apr 2010 03:37:53 +0000 (-0700) Subject: Improve error handling on video decode failure (kdenlive-1553). X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1519edd7d4cf655290a30a494359f3f7c81582e7;p=mlt Improve error handling on video decode failure (kdenlive-1553). --- diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 76d23346..4f394ca6 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -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 ) diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 5af5c3f1..83ce78ec 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -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