summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-15 03:35:08 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-15 03:35:08 +0200
commit901922e0475c590140b3b947df58de458326b817 (patch)
treea368fcd675c41acacec60856403ff8dcce69cbb3 /libavformat/utils.c
parentc9c7263e5820c957598643216c42be9b1c4f2d2b (diff)
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@niedermayer.cc>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c40b4d2b27..16901786a9 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)