]> git.sesse.net Git - ffmpeg/commitdiff
avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed...
authorMarton Balint <cus@passwd.hu>
Sat, 19 Sep 2020 22:02:19 +0000 (00:02 +0200)
committerMarton Balint <cus@passwd.hu>
Fri, 9 Oct 2020 19:07:18 +0000 (21:07 +0200)
This should increase the effectiveness of ffio_ensure_seekback by reducing the
number of buffer reallocations and memmoves/memcpys because even a small
seekback window requires max_buffer_size+window_size buffer space.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/aviobuf.c

index c4195e310b4bd3db76e19bd02fdc9f36bb79d1bc..15d91f91bc717c15aae30ad805dc0c45fedcccf7 100644 (file)
@@ -938,6 +938,11 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
     } else {
         buffer_size = IO_BUFFER_SIZE;
     }
+    if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
+        if (buffer_size > INT_MAX/2)
+            return AVERROR(EINVAL);
+        buffer_size *= 2;
+    }
     buffer = av_malloc(buffer_size);
     if (!buffer)
         return AVERROR(ENOMEM);