[FFmpeg-devel] [PATCH] avformat/async: allow to set buffer size

Michael Niedermayer michael at niedermayer.cc
Fri Sep 22 03:53:59 EEST 2017


On Fri, Sep 22, 2017 at 12:36:40AM +0900, Takayuki 'January June' Suwa wrote:
> ---
>  doc/protocols.texi  | 6 ++++++
>  libavformat/async.c | 7 ++++++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index a7968ff56e3..f321664d7bf 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -57,6 +57,12 @@ Asynchronous data filling wrapper for input stream.
>  
>  Fill data in a background thread, to decouple I/O operation from demux thread.
>  
> +The accepted options are:
> + at table @option
> + at item asyncbufsize
> +Set asynchronous data buffer size, in bytes. Default value is 8 MiB.
> + at end table
> +
>  @example
>  async:@var{URL}
>  async:http://host/resource
> diff --git a/libavformat/async.c b/libavformat/async.c
> index 54dbd2312a2..f8ac12c7aa0 100644
> --- a/libavformat/async.c
> +++ b/libavformat/async.c
> @@ -78,6 +78,8 @@ typedef struct Context {
>  
>      int             abort_request;
>      AVIOInterruptCB interrupt_callback;
> +
> +    int             asyncbufsize;
>  } Context;
>  
>  static int ring_init(RingBuffer *ring, unsigned int capacity, int read_back_capacity)
> @@ -242,10 +244,12 @@ static int async_open(URLContext *h, const char *arg, int flags, AVDictionary **
>      Context         *c = h->priv_data;
>      int              ret;
>      AVIOInterruptCB  interrupt_callback = {.callback = async_check_interrupt, .opaque = h};
> +    int              capacity;
>  
>      av_strstart(arg, "async:", &arg);
>  
> -    ret = ring_init(&c->ring, BUFFER_CAPACITY, READ_BACK_CAPACITY);
> +    capacity = FFMAX(4096, c->asyncbufsize / 2);
> +    ret = ring_init(&c->ring, capacity, capacity);

READ_BACK_CAPACITY is unused after this patch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170922/a6f20528/attachment.sig>


More information about the ffmpeg-devel mailing list