diff options
author | van <[email protected]> | 2009-01-10 04:47:48 +0000 |
---|---|---|
committer | van <[email protected]> | 2009-01-10 04:47:48 +0000 |
commit | 593765ab9ee887acec8573339bad3667f3e796d9 (patch) | |
tree | 6ac74b67861489e03efbc5cc1ba7137dc5aa62a5 /libhb/scan.c | |
parent | 24374882ef39dc1aa921c1ed3a93ee18b1866752 (diff) |
Get previews from H.264 content even if it's missing IDR frames (e.g., NZ TV & some blu-rays):
- Grab stream characteristics (IDRs or not, PCRs or not, RAPs or not) while we're reading to compute the duration rather than trying to guess with no information later.
- Only wait for an IDR after a seek if we know the stream has IDRs. Even then, wait for at most 255 frames.
- If the stream doesn't have IDRs tell scan (via a new flag in the title struct) so that it can read but discard a second's worth of frames to get the decoder in sync withe stream.
- While we're trying to sync the decoder, ffmpeg will spit out dozens of useless error messages so suppress them.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2071 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/scan.c')
-rw-r--r-- | libhb/scan.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libhb/scan.c b/libhb/scan.c index 6459c1d50..6cdaceb62 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -439,6 +439,21 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title ) vid_decoder->codec_param = title->video_codec_param; vid_decoder->init( vid_decoder, NULL ); hb_buffer_t * vid_buf = NULL; + int vidskip = 0; + + if ( title->flags & HBTF_NO_IDR ) + { + // title doesn't have IDR frames so we decode but drop one second's + // worth of frames to allow the decoder to converge. + if ( ! title->rate_base ) + { + vidskip = 30; + } + else + { + vidskip = (double)title->rate / (double)title->rate_base + 0.5; + } + } for( j = 0; j < 10240 ; j++ ) { @@ -446,6 +461,10 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title ) { if( !hb_dvd_read( data->dvd, buf_ps ) ) { + if ( vid_buf ) + { + break; + } hb_log( "Warning: Could not read data for preview %d, skipped", i + 1 ); goto skip_preview; } @@ -470,6 +489,13 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title ) if( buf_es->id == title->video_id && vid_buf == NULL ) { vid_decoder->work( vid_decoder, &buf_es, &vid_buf ); + if ( vid_buf && vidskip && --vidskip > 0 ) + { + // we're dropping frames to get the video decoder in sync + // when the video stream doesn't contain IDR frames + hb_buffer_close( &vid_buf ); + vid_buf = NULL; + } } else if( ! AllAudioOK( title ) ) { |