summaryrefslogtreecommitdiff
path: root/libavformat/asfdec.c
diff options
context:
space:
mode:
authorJoakim Plate <elupus@ecce.se>2011-09-12 21:35:32 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-12 22:12:14 +0200
commit6c9a24636b9b4f1289191c362877285a58a0c48a (patch)
tree47c71cc0a2099e8cededc3f84a29e47cf593aa67 /libavformat/asfdec.c
parent9efae6a16109e055d763dd6a5cd1667866033f61 (diff)
asf: only try to read asf index once
This avoid retrying to read ASF index in files for every attempt to seek. This makes a big difference to protocols with slow seeking (for example http) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/asfdec.c')
-rw-r--r--libavformat/asfdec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index fe3737242e..e09b70070f 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1198,8 +1198,10 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
int64_t current_pos= avio_tell(s->pb);
int i;
- if(avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET) < 0)
+ if(avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET) < 0) {
+ asf->index_read= -1;
return;
+ }
ff_get_guid(s->pb, &g);
@@ -1209,6 +1211,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
int64_t gsize= avio_rl64(s->pb);
if (gsize < 24 || url_feof(s->pb)) {
avio_seek(s->pb, current_pos, SEEK_SET);
+ asf->index_read= -1;
return;
}
avio_skip(s->pb, gsize-24);
@@ -1264,7 +1267,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
if (!asf->index_read)
asf_build_simple_index(s, stream_index);
- if((asf->index_read && st->index_entries)){
+ if((asf->index_read > 0 && st->index_entries)){
index= av_index_search_timestamp(st, pts, flags);
if(index >= 0) {
/* find the position */