summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2020-09-20 00:02:19 +0200
committerMarton Balint <cus@passwd.hu>2020-10-09 21:07:18 +0200
commita11cc04786c298a8e4df3da12d8e275eaaf6b333 (patch)
treecdfdc451637c6b89f1d8a268d56e017f5e4640bb /libavformat/aviobuf.c
parent25ced19aa3097abc0f8b76045efa06b3332c8b94 (diff)
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@passwd.hu>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c5
1 files changed, 5 insertions, 0 deletions
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);