Commit 901922e0 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/utils: adjust short skip threshold in...

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: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent c9c7263e
...@@ -1785,6 +1785,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) ...@@ -1785,6 +1785,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
{ {
int ist1, ist2; int ist1, ist2;
int64_t pos_delta = 0; 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 //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); 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) ...@@ -1804,6 +1805,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
AVIndexEntry *e1 = &st1->index_entries[i1]; AVIndexEntry *e1 = &st1->index_entries[i1];
int64_t e1_pts = av_rescale_q(e1->timestamp, st1->time_base, AV_TIME_BASE_Q); 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++) { for (; i2 < st2->nb_index_entries; i2++) {
AVIndexEntry *e2 = &st2->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); 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) ...@@ -1823,6 +1825,10 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance)
ffio_set_buf_size(s->pb, pos_delta); ffio_set_buf_size(s->pb, pos_delta);
s->pb->short_seek_threshold = FFMAX(s->pb->short_seek_threshold, pos_delta/2); 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) int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, int flags)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment