summaryrefslogtreecommitdiff
path: root/libavformat/avidec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-06 03:52:16 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-06 03:54:35 +0200
commit187528441ab936c102b8e72f38925cc10fc14abc (patch)
treeb0525d23200ca282598538e8e868293a9f3949cb /libavformat/avidec.c
parentcde55897178fb79d194f9f4951a220fb7ca4cda9 (diff)
avidec: correct frame_offset for seeking
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r--libavformat/avidec.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 98b3be6738..7e97b7b4c9 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1303,7 +1303,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
{
AVIContext *avi = s->priv_data;
AVStream *st;
- int i, index;
+ int i, index, j;
int64_t pos, pos_min;
AVIStream *ast;
@@ -1367,6 +1367,22 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
index=0;
ast2->seek_pos= st2->index_entries[index].pos;
pos_min= FFMIN(pos_min,ast2->seek_pos);
+ }
+ for(i = 0; i < s->nb_streams; i++) {
+ AVStream *st2 = s->streams[i];
+ AVIStream *ast2 = st2->priv_data;
+
+ if (ast2->sub_ctx || st2->nb_index_entries <= 0)
+ continue;
+
+ index = av_index_search_timestamp(
+ st2,
+ av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
+ flags | AVSEEK_FLAG_BACKWARD);
+ if(index<0)
+ index=0;
+ while(index>0 && st2->index_entries[index-1].pos >= pos_min)
+ index--;
ast2->frame_offset = st2->index_entries[index].timestamp;
}