[FFmpeg-cvslog] avformat/utils: adjust short skip threshold in ff_configure_buffers_for_index() to avoid seeking if a packet is skiped

Michael Niedermayer git at videolan.org
Wed Jul 15 04:10:06 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Jul 15 03:35:08 2015 +0200| [901922e0475c590140b3b947df58de458326b817] | committer: Michael Niedermayer

avformat/utils: adjust short skip threshold in ff_configure_buffers_for_index() to avoid seeking if a packet is skiped

Fixes Ticket4126

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=901922e0475c590140b3b947df58de458326b817
---

 libavformat/utils.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index c40b4d2..1690178 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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)



More information about the ffmpeg-cvslog mailing list