summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-04-24 22:38:05 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-24 22:38:05 +0200
commitfbfcc8f1b71b51ff87f09e269d22328be5594f40 (patch)
treeff12650f5dc5b824b3d4f454ca315d4ddb53c194 /libavformat
parent8a68697dc66234d0a5fc50b4d67a94921c9893d1 (diff)
avi: try to synchronize the points in time of the starts of streams after seeking.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avidec.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 77d068658f..83c55d08e9 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -54,6 +54,8 @@ typedef struct AVIStream {
AVFormatContext *sub_ctx;
AVPacket sub_pkt;
uint8_t *sub_buffer;
+
+ int64_t seek_pos;
} AVIStream;
typedef struct {
@@ -987,6 +989,12 @@ resync:
ast->packet_size= 0;
}
+ if(!avi->non_interleaved && ast->seek_pos > pkt->pos){
+ av_free_packet(pkt);
+ goto resync;
+ }
+ ast->seek_pos= 0;
+
return size;
}
@@ -1252,7 +1260,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
AVIContext *avi = s->priv_data;
AVStream *st;
int i, index;
- int64_t pos;
+ int64_t pos, pos_min;
AVIStream *ast;
if (!avi->index_loaded) {
@@ -1289,6 +1297,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
return 0;
}
+ pos_min= pos;
for(i = 0; i < s->nb_streams; i++) {
AVStream *st2 = s->streams[i];
AVIStream *ast2 = st2->priv_data;
@@ -1312,21 +1321,13 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
flags | AVSEEK_FLAG_BACKWARD);
if(index<0)
index=0;
-
- if(!avi->non_interleaved){
- while(index>0 && st2->index_entries[index].pos > pos)
- index--;
- while(index+1 < st2->nb_index_entries && st2->index_entries[index].pos < pos)
- index++;
- }
-
-// av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
- /* extract the current frame number */
+ ast2->seek_pos= st2->index_entries[index].pos;
+ pos_min= FFMIN(pos_min,ast2->seek_pos);
ast2->frame_offset = st2->index_entries[index].timestamp;
}
/* do the seek */
- avio_seek(s->pb, pos, SEEK_SET);
+ avio_seek(s->pb, pos_min, SEEK_SET);
avi->stream_index= -1;
return 0;
}