Skip to content
Snippets Groups Projects
Commit ded3c7da authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

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
parent e9b78eeb
No related branches found
No related tags found
No related merge requests found
...@@ -626,9 +626,9 @@ resync: ...@@ -626,9 +626,9 @@ resync:
pkt->stream_index = avi->stream_index; pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->index_entries){
AVIndexEntry *e; AVIndexEntry *e;
int index; int index;
assert(st->index_entries);
index= av_index_search_timestamp(st, pkt->dts, 0); index= av_index_search_timestamp(st, pkt->dts, 0);
e= &st->index_entries[index]; e= &st->index_entries[index];
...@@ -637,11 +637,6 @@ resync: ...@@ -637,11 +637,6 @@ resync:
if (e->flags & AVINDEX_KEYFRAME) if (e->flags & AVINDEX_KEYFRAME)
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
} }
} else {
/* if no index, better to say that all frames
are key frames */
pkt->flags |= PKT_FLAG_KEY;
}
} else { } else {
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
} }
...@@ -735,6 +730,13 @@ resync: ...@@ -735,6 +730,13 @@ resync:
avi->stream_index= n; avi->stream_index= n;
ast->packet_size= size + 8; ast->packet_size= size + 8;
ast->remaining= size; 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; goto resync;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment