FFmpeg 8.0.1
Loading...
Searching...
No Matches
container_fifo.h File Reference
#include <stddef.h>

Go to the source code of this file.

Typedefs

typedef struct AVContainerFifo AVContainerFifo
 AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e.g.

Enumerations

enum  AVContainerFifoFlags { AV_CONTAINER_FIFO_FLAG_REF = (1 << 0) , AV_CONTAINER_FIFO_FLAG_USER = (1 << 16) }

Functions

AVContainerFifoav_container_fifo_alloc (void *opaque, void *(*container_alloc)(void *opaque), void(*container_reset)(void *opaque, void *obj), void(*container_free)(void *opaque, void *obj), int(*fifo_transfer)(void *opaque, void *dst, void *src, unsigned flags), unsigned flags)
 Allocate a new AVContainerFifo for the container type defined by provided callbacks.
AVContainerFifoav_container_fifo_alloc_avframe (unsigned flags)
 Allocate an AVContainerFifo instance for AVFrames.
void av_container_fifo_free (AVContainerFifo **cf)
 Free a AVContainerFifo and everything in it.
int av_container_fifo_write (AVContainerFifo *cf, void *obj, unsigned flags)
 Write the contents of obj to the FIFO.
int av_container_fifo_read (AVContainerFifo *cf, void *obj, unsigned flags)
 Read the next available object from the FIFO into obj.
int av_container_fifo_peek (AVContainerFifo *cf, void **pobj, size_t offset)
 Access objects stored in the FIFO without retrieving them.
void av_container_fifo_drain (AVContainerFifo *cf, size_t nb_elems)
 Discard the specified number of elements from the FIFO.
size_t av_container_fifo_can_read (const AVContainerFifo *cf)

Typedef Documentation

◆ AVContainerFifo

AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e.g.

AVFrame or AVPacket). AVContainerFifo uses an internal pool of such containers to avoid allocating and freeing them repeatedly.

Definition at line 29 of file container_fifo.h.

Enumeration Type Documentation

◆ AVContainerFifoFlags

Enumerator
AV_CONTAINER_FIFO_FLAG_REF 

Signal to av_container_fifo_write() that it should make a new reference to data in src rather than consume its contents.

Note
you must handle this flag manually in your own fifo_transfer() callback
AV_CONTAINER_FIFO_FLAG_USER 

This and all higher bits in flags may be set to any value by the caller and are guaranteed to be passed through to the fifo_transfer() callback and not be interpreted by AVContainerFifo code.

Definition at line 31 of file container_fifo.h.

Function Documentation

◆ av_container_fifo_alloc()

AVContainerFifo * av_container_fifo_alloc ( void * opaque,
void *(* container_alloc )(void *opaque),
void(* container_reset )(void *opaque, void *obj),
void(* container_free )(void *opaque, void *obj),
int(* fifo_transfer )(void *opaque, void *dst, void *src, unsigned flags),
unsigned flags )

Allocate a new AVContainerFifo for the container type defined by provided callbacks.

Parameters
opaqueuser data that will be passed to the callbacks provided to this function
container_allocallocate a new container instance and return a pointer to it, or NULL on failure
container_resetreset the provided container instance to a clean state
container_freefree the provided container instance
fifo_transferTransfer the contents of container src to dst.
flagscurrently unused
Returns
newly allocated AVContainerFifo, or NULL on failure

◆ av_container_fifo_alloc_avframe()

AVContainerFifo * av_container_fifo_alloc_avframe ( unsigned flags)

Allocate an AVContainerFifo instance for AVFrames.

Parameters
flagscurrently unused

◆ av_container_fifo_free()

void av_container_fifo_free ( AVContainerFifo ** cf)

Free a AVContainerFifo and everything in it.

◆ av_container_fifo_write()

int av_container_fifo_write ( AVContainerFifo * cf,
void * obj,
unsigned flags )

Write the contents of obj to the FIFO.

The fifo_transfer() callback previously provided to av_container_fifo_alloc() will be called with obj as src in order to perform the actual transfer.

◆ av_container_fifo_read()

int av_container_fifo_read ( AVContainerFifo * cf,
void * obj,
unsigned flags )

Read the next available object from the FIFO into obj.

The fifo_read() callback previously provided to av_container_fifo_alloc() will be called with obj as dst in order to perform the actual transfer.

◆ av_container_fifo_peek()

int av_container_fifo_peek ( AVContainerFifo * cf,
void ** pobj,
size_t offset )

Access objects stored in the FIFO without retrieving them.

The fifo_transfer() callback will NOT be invoked and the FIFO state will not be modified.

Parameters
pobjPointer to the object stored in the FIFO will be written here on success. The object remains owned by the FIFO and the caller may only access it as long as the FIFO is not modified.
offsetPosition of the object to retrieve - 0 is the next item that would be read, 1 the one after, etc. Must be smaller than av_container_fifo_can_read().
Return values
0success, a pointer was written into pobj
AVERROR(EINVAL)invalid offset value

◆ av_container_fifo_drain()

void av_container_fifo_drain ( AVContainerFifo * cf,
size_t nb_elems )

Discard the specified number of elements from the FIFO.

Parameters
nb_elemsnumber of elements to discard, MUST NOT be larger than av_fifo_can_read(f)

◆ av_container_fifo_can_read()

size_t av_container_fifo_can_read ( const AVContainerFifo * cf)
Returns
number of objects available for reading