[FFmpeg-cvslog] avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data

Marton Balint git at videolan.org
Fri Oct 9 22:25:31 EEST 2020


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Sep 20 00:02:19 2020 +0200| [a11cc04786c298a8e4df3da12d8e275eaaf6b333] | committer: Marton Balint

avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data

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 at passwd.hu>

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

 libavformat/aviobuf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c4195e310b..15d91f91bc 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -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);



More information about the ffmpeg-cvslog mailing list