diff mbox series

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

Message ID 20200920085253.7107-3-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avformat/aviobuf: read till the very end of the IO buffer | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Marton Balint Sept. 20, 2020, 8:52 a.m. UTC
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@passwd.hu>
---
 libavformat/aviobuf.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer Sept. 20, 2020, 3:06 p.m. UTC | #1
On Sun, Sep 20, 2020 at 10:52:53AM +0200, Marton Balint wrote:
> 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@passwd.hu>
> ---
>  libavformat/aviobuf.c | 5 +++++
>  1 file changed, 5 insertions(+)

this is an interresting idea
have you done some tests/benchmarks that show specific advantages ?

thx

[...]
Marton Balint Sept. 20, 2020, 5:19 p.m. UTC | #2
On Sun, 20 Sep 2020, Michael Niedermayer wrote:

> On Sun, Sep 20, 2020 at 10:52:53AM +0200, Marton Balint wrote:
>> 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@passwd.hu>
>> ---
>>  libavformat/aviobuf.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> this is an interresting idea
> have you done some tests/benchmarks that show specific advantages ?

No, it is just a blind attempt for now.

Regards,
Marton
diff mbox series

Patch

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);