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

Marton Balint cus at passwd.hu
Sun Sep 20 11:52:53 EEST 2020


This should increase the effectiveness of ffio_ensure_seekback.

Note: increasing buffer size to non-streamed or write buffer should also
work, but they both cause fate failures... The reason for that should be
checked.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/aviobuf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index aa1d6c0830..13cad7f5f0 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_READ && 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);
-- 
2.26.2



More information about the ffmpeg-devel mailing list