diff options
author | van <[email protected]> | 2008-11-19 04:13:11 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-11-19 04:13:11 +0000 |
commit | 4846dfacbfb26d3ee614033ef1b5284ec360a717 (patch) | |
tree | 7eb52896a22681a7485cbfbc1c45e4c88b2f7d3e /libhb/stream.c | |
parent | 1ea0fa911340c4792b6a5daaa35cab9f7341caf1 (diff) |
- get rid of an unnecessary seek that was messing up either mkv or vc1 decoding.
- switch av_seek_frame to zero back to time-based rather than byte-based since time-based screws up mkv & mp4 while time-based works for everything but vc1.
- since ffmpeg doesn't correctly indicate key frames in vc1 look for them ourselves so that vc1 previews & cropping will work.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1927 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/stream.c')
-rwxr-xr-x | libhb/stream.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index e531d6002..156fe995a 100755 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -2486,7 +2486,6 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title ) // indexed its stream so we need to remap them so they point // to this stream. ffmpeg_remap_stream( stream, title ); - ffmpeg_seek( stream, 0. ); av_log_set_level( AV_LOG_ERROR ); } else @@ -2659,6 +2658,7 @@ static int64_t av_to_hb_pts( int64_t pts, double conv_factor ) static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf ) { int err; + again: if ( ( err = av_read_frame( stream->ffmpeg_ic, stream->ffmpeg_pkt )) < 0 ) { // XXX the following conditional is to handle avi files that @@ -2701,6 +2701,20 @@ static int ffmpeg_read( hb_stream_t *stream, hb_buffer_t *buf ) buf->id = stream->ffmpeg_pkt->stream_index; if ( buf->id == stream->ffmpeg_video_id ) { + if ( stream->need_keyframe && + stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]->codec->codec_id == + CODEC_ID_VC1 ) + { + // XXX the VC1 codec doesn't seek to key frames so to get previews + // we do it ourselves here. The decoder gets messed up if it + // doesn't get a SEQ header first so we consider that to be a key frame. + uint8_t *pkt = stream->ffmpeg_pkt->data; + if ( pkt[0] || pkt[1] || pkt[2] != 1 || pkt[3] != 0x0f ) + { + goto again; + } + stream->need_keyframe = 0; + } ++stream->frames; } @@ -2735,7 +2749,7 @@ static int ffmpeg_seek( hb_stream_t *stream, float frac ) } else { - av_seek_frame( ic, -1, pos, AVSEEK_FLAG_BYTE ); + av_seek_frame( ic, -1, pos, AVSEEK_FLAG_BACKWARD ); } return 1; } |