From 83aa999e8f5e76547159c9fc202e109c706a03ac Mon Sep 17 00:00:00 2001 From: jstebbins <jstebbins.hb@gmail.com> Date: Fri, 19 Dec 2014 19:17:17 +0000 Subject: [PATCH] libhb: make hb_get_preview2 always return a valid image When we fail to read the preview image, create a blank image git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6612 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/hb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libhb/hb.c b/libhb/hb.c index 2ae9e7e4c..141d68f8d 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -725,9 +725,9 @@ hb_image_t* hb_get_preview2(hb_handle_t * h, int title_idx, int picture, swsflags = SWS_LANCZOS | SWS_ACCURATE_RND; preview_buf = hb_frame_buffer_init(AV_PIX_FMT_RGB32, width, height); + // fill in AVPicture hb_avpicture_fill( &pic_preview, preview_buf ); - // Allocate the AVPicture frames and fill in memset( filename, 0, 1024 ); @@ -736,13 +736,13 @@ hb_image_t* hb_get_preview2(hb_handle_t * h, int title_idx, int picture, if (title == NULL) { hb_error( "hb_get_preview2: invalid title (%d)", title_idx ); - return NULL; + goto fail; } in_buf = hb_read_preview( h, title, picture ); if ( in_buf == NULL ) { - return NULL; + goto fail; } hb_avpicture_fill( &pic_in, in_buf ); @@ -788,6 +788,11 @@ hb_image_t* hb_get_preview2(hb_handle_t * h, int title_idx, int picture, hb_buffer_close( &preview_buf ); return image; + +fail: + + image = hb_image_init(AV_PIX_FMT_RGB32, width, height); + return image; } /** -- 2.40.0