Skip to content

Commit

Permalink
avformat/aviobuf: increase default read buffer size to 2*max_buffer_s…
Browse files Browse the repository at this point in the history
…ize 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 <[email protected]>
  • Loading branch information
cus committed Oct 9, 2020
1 parent 25ced19 commit a11cc04
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libavformat/aviobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a11cc04

Please sign in to comment.