diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-01-06 16:32:49 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-02-07 00:31:23 +0100 |
commit | 14429f8fec231e1d6e0bfdb3f646e7461d11c736 (patch) | |
tree | 2b92f07a243b9e554346c5e8eae1f1ea53f8bad2 /libavutil/fifo.h | |
parent | 7329b22c058cf271e9ea3aa6e8ab2bb1c462d99f (diff) | |
download | ffmpeg-14429f8fec231e1d6e0bfdb3f646e7461d11c736.tar.gz |
lavu/fifo: add a flag for automatically growing the FIFO as needed
This will not increase the FIFO beyond 1MB, unless the caller explicitly
specifies otherwise.
Diffstat (limited to 'libavutil/fifo.h')
-rw-r--r-- | libavutil/fifo.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libavutil/fifo.h b/libavutil/fifo.h index f455022e3c..55548fbeb4 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -49,12 +49,19 @@ typedef struct AVFifo AVFifo; typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems); /** + * Automatically resize the FIFO on writes, so that the data fits. This + * automatic resizing happens up to a limit that can be modified with + * av_fifo_auto_grow_limit(). + */ +#define AV_FIFO_FLAG_AUTO_GROW (1 << 0) + +/** * Allocate and initialize an AVFifo with a given element size. * * @param elems initial number of elements that can be stored in the FIFO * @param elem_size Size in bytes of a single element. Further operations on * the returned FIFO will implicitly use this element size. - * @param flags currently unused, must be 0 + * @param flags a combination of AV_FIFO_FLAG_* * * @return newly-allocated AVFifo on success, a negative error code on failure */ @@ -68,6 +75,12 @@ AVFifo *av_fifo_alloc2(size_t elems, size_t elem_size, size_t av_fifo_elem_size(const AVFifo *f); /** + * Set the maximum size (in elements) to which the FIFO can be resized + * automatically. Has no effect unless AV_FIFO_FLAG_AUTO_GROW is used. + */ +void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems); + +/** * @return number of elements available for reading from the given FIFO. */ size_t av_fifo_can_read(const AVFifo *f); |