OSDN Git Service

matroskadec: full seeking support in index-less files
authorAurelien Jacobs <aurel@gnuage.org>
Mon, 25 Aug 2008 00:15:49 +0000 (00:15 +0000)
committerAurelien Jacobs <aurel@gnuage.org>
Mon, 25 Aug 2008 00:15:49 +0000 (00:15 +0000)
when trying to seek past the last index entry, just parse more clusters to add them to the index, until an index entry match the desired position

Originally committed as revision 14959 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/matroskadec.c

index 9ab8126..68d3aa3 100644 (file)
@@ -1657,11 +1657,15 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
     if (timestamp < 0)
         timestamp = 0;
 
-    index = av_index_search_timestamp(st, timestamp, flags);
-    if (index < 0)
-        return 0;
+    while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
+        matroska_clear_queue(matroska);
+        if (matroska_parse_cluster(matroska) < 0)
+            break;
+    }
 
     matroska_clear_queue(matroska);
+    if (index < 0)
+        return 0;
 
     url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET);
     matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);