avformat/utils: adjust short skip threshold in ff_configure_buffers_for_index() to...
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 15 Jul 2015 01:35:08 +0000 (03:35 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 15 Jul 2015 01:35:08 +0000 (03:35 +0200)
Fixes Ticket4126

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index c40b4d2..1690178 100644 (file)
@@ -1785,6 +1785,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
 {
     int ist1, ist2;
     int64_t pos_delta = 0;
+    int64_t skip = 0;
     //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable
     const char *proto = avio_find_protocol_name(s->filename);
 
@@ -1804,6 +1805,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
                 AVIndexEntry *e1 = &st1->index_entries[i1];
                 int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q);
 
+                skip = FFMAX(skip, e1->size);
                 for (; i2 < st2->nb_index_entries; i2++) {
                     AVIndexEntry *e2 = &st2->index_entries[i2];
                     int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
@@ -1823,6 +1825,10 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
         ffio_set_buf_size(s->pb, pos_delta);
         s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2);
     }
+
+    if (skip < (1<<23)) {
+        s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, skip);
+    }
 }
 
 int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)