asfdec: fallback to binary search internally
authorVladimir Pantelic <vladoman@gmail.com>
Thu, 12 May 2011 08:25:54 +0000 (10:25 +0200)
committerReinhard Tartler <siretart@tauware.de>
Tue, 17 May 2011 19:48:16 +0000 (21:48 +0200)
lavf will do that anyway in case seek by index fails

libavformat/asfdec.c

index 77c8449..e2161fd 100644 (file)
@@ -1269,21 +1269,22 @@ 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(av_seek_frame_binary(s, stream_index, pts, flags)<0)
-            return -1;
-    }else{
+    if((asf->index_read && st->index_entries)){
         index= av_index_search_timestamp(st, pts, flags);
-        if(index<0)
-            return -1;
-
+        if(index >= 0) {
         /* find the position */
         pos = st->index_entries[index].pos;
 
         /* do the seek */
         av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
         avio_seek(s->pb, pos, SEEK_SET);
+        asf_reset_header(s);
+        return 0;
+        }
     }
+    /* no index or seeking by index failed */
+    if(av_seek_frame_binary(s, stream_index, pts, flags)<0)
+        return -1;
     asf_reset_header(s);
     return 0;
 }