matroskadec: seek to the last position known in the index before resorting to
authorAurelien Jacobs <aurel@gnuage.org>
Wed, 27 Aug 2008 19:57:42 +0000 (19:57 +0000)
committerAurelien Jacobs <aurel@gnuage.org>
Wed, 27 Aug 2008 19:57:42 +0000 (19:57 +0000)
full cluster parsing when seeking after the end of index

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

libavformat/matroskadec.c

index f994e48..c32ca36 100644 (file)
@@ -1655,11 +1655,15 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
     if (timestamp < 0)
         timestamp = 0;
 
+    if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
+        if (st->nb_index_entries)
+            url_fseek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
     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)