]> git.sesse.net Git - ffmpeg/commitdiff
avformat/aviobuf: don't reduce short seek threshold
authorAndriy Gelman <andriy.gelman@gmail.com>
Sun, 14 Mar 2021 04:54:32 +0000 (23:54 -0500)
committerAndriy Gelman <andriy.gelman@gmail.com>
Wed, 17 Mar 2021 02:46:25 +0000 (22:46 -0400)
Commit 8c8e5d5286bf598a89ef9993a2cf6ea409d03a32 added a way to reduce
seek time by waiting for the windowed tcp packets instead of creating a
new socket connection. It implemented this by overwriting
s->short_seek_threshold in avio_seek(). However,
s->short_seek_threshold could already be set and be higher than the
threshold set by the protocol (i.e. s->short_seek_threshold is set in
ff_configure_buffers_for_index()).

This new feature was only enabled for tls connections in
70d8077b795766e2486e6ec8110f22a97362d6d6. As in Ticket #9148 it reduced
performance because instead of waiting to refill the AVIOContext buffers
with an existing connections, a new HTTP request was often made instead.

Fixes Ticket #9148.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
libavformat/aviobuf.c

index 78cc60b2ae9cc055d89461c1b800b6af4a7faf2b..518cb1112936c60c691ae500cd6fb1bfef8a549e 100644 (file)
@@ -283,13 +283,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
     if (offset < 0)
         return AVERROR(EINVAL);
 
-    if (s->short_seek_get) {
-        short_seek = s->short_seek_get(s->opaque);
-        /* fallback to default short seek */
-        if (short_seek <= 0)
-            short_seek = s->short_seek_threshold;
-    } else
-        short_seek = s->short_seek_threshold;
+    short_seek = s->short_seek_threshold;
+    if (s->short_seek_get)
+        short_seek = FFMAX(s->short_seek_get(s->opaque), short_seek);
 
     offset1 = offset - pos; // "offset1" is the relative offset from the beginning of s->buffer
     s->buf_ptr_max = FFMAX(s->buf_ptr_max, s->buf_ptr);