From 1c21746fddce15b97dbb797e2a37b3e2e784c297 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Tue, 28 Oct 2014 19:41:17 +0000 Subject: libhb: improve CC detection We are failing to detect CCs in some sources because the CC data is not present on every frame. Makes scan always decode a few extra frames to give the decode a better chance of seeing the CC data. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6471 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/scan.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'libhb') diff --git a/libhb/scan.c b/libhb/scan.c index 08b8e9e24..f952706f9 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -494,6 +494,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) int doubled_frame_count = 0; int interlaced_preview_count = 0; int frame_wait = 0; + int cc_wait = 10; hb_stream_t * stream = NULL; info_list_t * info_list = calloc( data->preview_count+1, sizeof(*info_list) ); crop_record_t *crops = crop_record_init( data->preview_count ); @@ -665,16 +666,23 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) if( buf_es->s.id == title->video_id && vid_buf == NULL ) { vid_decoder->work( vid_decoder, &buf_es, &vid_buf ); - if (vid_buf != NULL && frame_wait) + // There are 2 conditions we decode additional + // video frames for during scan. + // 1. We did not detect IDR frames, so the initial video + // frames may be corrupt. We docode extra frames to + // increase the probability of a complete preview frame + // 2. Some frames do not contain CC data, even though + // CCs are present in the stream. So we need to decode + // additional frames to find the CCs. + if (vid_buf != NULL && (frame_wait || cc_wait)) { - if (vid_buf->s.frametype != HB_FRAME_I) + if (vid_buf->s.frametype == HB_FRAME_I) + frame_wait = 0; + if (frame_wait || cc_wait) { hb_buffer_close(&vid_buf); - frame_wait--; - } - else - { - frame_wait = 0; + if (frame_wait) frame_wait--; + if (cc_wait) cc_wait--; } } } -- cgit v1.2.3