diff mbox series

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

Message ID 20200929211021.25030-9-cus@passwd.hu
State Accepted
Commit a11cc04786c298a8e4df3da12d8e275eaaf6b333
Headers show
Series [FFmpeg-devel,1/9] avformat/aviobuf: write data into the IO buffer till the very end of the 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. 29, 2020, 9:10 p.m. UTC
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 | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Paul B Mahol Sept. 29, 2020, 10:25 p.m. UTC | #1
On Tue, Sep 29, 2020 at 11:10:21PM +0200, Marton Balint wrote:
> 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 | 5 +++++
>  1 file changed, 5 insertions(+)
> 

This patch set fixes demuxing chained oggs via pipe,
so I'm not against it.
Marton Balint Oct. 6, 2020, 3:02 p.m. UTC | #2
On Wed, 30 Sep 2020, Paul B Mahol wrote:

> On Tue, Sep 29, 2020 at 11:10:21PM +0200, Marton Balint wrote:
>> 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 | 5 +++++
>>  1 file changed, 5 insertions(+)
>> 
>
> This patch set fixes demuxing chained oggs via pipe,
> so I'm not against it.

Thanks for testing.

Is there anybody who would like to comment on the patch series 
before I push it?

I know that some regression tests for avio would be good, but it is not 
something I plan working on.

Thanks,
Marton
Marton Balint Oct. 8, 2020, 7:48 p.m. UTC | #3
On Tue, 6 Oct 2020, Marton Balint wrote:

>
>
> On Wed, 30 Sep 2020, Paul B Mahol wrote:
>
>> On Tue, Sep 29, 2020 at 11:10:21PM +0200, Marton Balint wrote:
>>> 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 | 5 +++++
>>>  1 file changed, 5 insertions(+)
>>> 
>>
>> This patch set fixes demuxing chained oggs via pipe,
>> so I'm not against it.
>
> Thanks for testing.
>
> Is there anybody who would like to comment on the patch series 
> before I push it?
>
> I know that some regression tests for avio would be good, but it is not 
> something I plan working on.

Last ping, will apply soon.

Thanks,
Marton
Marton Balint Oct. 9, 2020, 7:25 p.m. UTC | #4
On Thu, 8 Oct 2020, Marton Balint wrote:

>
>
> On Tue, 6 Oct 2020, Marton Balint wrote:
>
>>
>>
>> On Wed, 30 Sep 2020, Paul B Mahol wrote:
>>
>>> On Tue, Sep 29, 2020 at 11:10:21PM +0200, Marton Balint wrote:
>>>> 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 | 5 +++++
>>>>  1 file changed, 5 insertions(+)
>>>> 
>>>
>>> This patch set fixes demuxing chained oggs via pipe,
>>> so I'm not against it.
>>
>> Thanks for testing.
>>
>> Is there anybody who would like to comment on the patch series 
>> before I push it?
>>
>> I know that some regression tests for avio would be good, but it is not 
>> something I plan working on.
>
> Last ping, will apply soon.

Applied the series.

Regards,
Marton
diff mbox series

Patch

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