FFmpeg
Data Structures | Functions
container_fifo.c File Reference
#include "avassert.h"
#include "container_fifo.h"
#include "error.h"
#include "fifo.h"
#include "frame.h"
#include "mem.h"
#include "refstruct.h"

Go to the source code of this file.

Data Structures

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

Functions

static int container_fifo_init_entry (AVRefStructOpaque opaque, void *obj)
 
static void container_fifo_reset_entry (AVRefStructOpaque opaque, void *obj)
 
static void container_fifo_free_entry (AVRefStructOpaque opaque, void *obj)
 
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. More...
 
void av_container_fifo_free (AVContainerFifo **pcf)
 Free a AVContainerFifo and everything in it. More...
 
int av_container_fifo_read (AVContainerFifo *cf, void *obj, unsigned flags)
 Read the next available object from the FIFO into obj. More...
 
int av_container_fifo_peek (AVContainerFifo *cf, void **pdst, size_t offset)
 Access objects stored in the FIFO without retrieving them. More...
 
void av_container_fifo_drain (AVContainerFifo *cf, size_t nb_elems)
 Discard the specified number of elements from the FIFO. More...
 
int av_container_fifo_write (AVContainerFifo *cf, void *obj, unsigned flags)
 Write the contents of obj to the FIFO. More...
 
size_t av_container_fifo_can_read (const AVContainerFifo *cf)
 
static void * frame_alloc (void *opaque)
 
static void frame_reset (void *opaque, void *obj)
 
static void frame_free (void *opaque, void *obj)
 
static int frame_transfer (void *opaque, void *dst, void *src, unsigned flags)
 
AVContainerFifoav_container_fifo_alloc_avframe (unsigned flags)
 Allocate an AVContainerFifo instance for AVFrames. More...
 

Function Documentation

◆ container_fifo_init_entry()

static int container_fifo_init_entry ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 39 of file container_fifo.c.

Referenced by av_container_fifo_alloc().

◆ container_fifo_reset_entry()

static void container_fifo_reset_entry ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 51 of file container_fifo.c.

Referenced by av_container_fifo_alloc().

◆ container_fifo_free_entry()

static void container_fifo_free_entry ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 57 of file container_fifo.c.

Referenced by av_container_fifo_alloc().

◆ av_container_fifo_alloc()

AVContainerFifo* av_container_fifo_alloc ( void *  opaque,
void *(*)(void *opaque)  container_alloc,
void(*)(void *opaque, void *obj)  container_reset,
void(*)(void *opaque, void *obj)  container_free,
int(*)(void *opaque, void *dst, void *src, unsigned flags fifo_transfer,
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

Definition at line 64 of file container_fifo.c.

Referenced by av_container_fifo_alloc_avframe(), and av_container_fifo_alloc_avpacket().

◆ av_container_fifo_free()

void av_container_fifo_free ( AVContainerFifo **  pcf)

Free a AVContainerFifo and everything in it.

Definition at line 101 of file container_fifo.c.

Referenced by av_container_fifo_alloc(), hevc_decode_free(), sq_free(), and tq_free().

◆ 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.

Definition at line 122 of file container_fifo.c.

Referenced by hevc_receive_frame(), receive_for_stream(), and receive_locked().

◆ 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

Definition at line 137 of file container_fifo.c.

Referenced by overflow_heartbeat(), receive_for_stream(), and receive_samples().

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

Definition at line 151 of file container_fifo.c.

Referenced by receive_samples().

◆ 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.

Definition at line 162 of file container_fifo.c.

Referenced by ff_hevc_output_frames(), sq_send(), and tq_send().

◆ av_container_fifo_can_read()

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

Definition at line 185 of file container_fifo.c.

Referenced by hevc_receive_frame(), receive_for_stream(), tb_update(), and tq_receive().

◆ frame_alloc()

static void* frame_alloc ( void *  opaque)
static

Definition at line 190 of file container_fifo.c.

Referenced by av_container_fifo_alloc_avframe().

◆ frame_reset()

static void frame_reset ( void *  opaque,
void *  obj 
)
static

Definition at line 195 of file container_fifo.c.

Referenced by av_container_fifo_alloc_avframe().

◆ frame_free()

static void frame_free ( void *  opaque,
void *  obj 
)
static

Definition at line 200 of file container_fifo.c.

Referenced by av_container_fifo_alloc_avframe().

◆ frame_transfer()

static int frame_transfer ( void *  opaque,
void *  dst,
void *  src,
unsigned  flags 
)
static

Definition at line 206 of file container_fifo.c.

Referenced by av_container_fifo_alloc_avframe().

◆ av_container_fifo_alloc_avframe()

AVContainerFifo* av_container_fifo_alloc_avframe ( unsigned  flags)

Allocate an AVContainerFifo instance for AVFrames.

Parameters
flagscurrently unused

Definition at line 215 of file container_fifo.c.

Referenced by hevc_init_context(), sq_add_stream(), and tq_alloc().