diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2007-02-05 23:06:08 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2007-02-05 23:06:08 +0000 |
commit | ded3c7da61e64cf23d2f7bedbd9cf269743e64a6 (patch) | |
tree | 13eb6ecf4dd730f4a86076f809c4db4598dc7293 /libavformat/avidec.c | |
parent | e9b78eeba22b050810a507e69df1b652e56ab62b (diff) | |
download | ffmpeg-ded3c7da61e64cf23d2f7bedbd9cf269743e64a6.tar.gz |
dynamic index building so forward and backward seeking in avi without an index is possible
Originally committed as revision 7842 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r-- | libavformat/avidec.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 273c20b449..90fc6b383f 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -626,9 +626,9 @@ resync: pkt->stream_index = avi->stream_index; if (st->codec->codec_type == CODEC_TYPE_VIDEO) { - if(st->index_entries){ AVIndexEntry *e; int index; + assert(st->index_entries); index= av_index_search_timestamp(st, pkt->dts, 0); e= &st->index_entries[index]; @@ -637,11 +637,6 @@ resync: if (e->flags & AVINDEX_KEYFRAME) pkt->flags |= PKT_FLAG_KEY; } - } else { - /* if no index, better to say that all frames - are key frames */ - pkt->flags |= PKT_FLAG_KEY; - } } else { pkt->flags |= PKT_FLAG_KEY; } @@ -735,6 +730,13 @@ resync: avi->stream_index= n; ast->packet_size= size + 8; ast->remaining= size; + + { + uint64_t pos= url_ftell(pb) - 8; + if(!st->index_entries || !st->nb_index_entries || st->index_entries[st->nb_index_entries - 1].pos < pos){ + av_add_index_entry(st, pos, ast->frame_offset / FFMAX(1, ast->sample_size), size, 0, AVINDEX_KEYFRAME); + } + } goto resync; } } |