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

Go to the source code of this file.

Data Structures

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

Functions

static int container_fifo_init_entry (FFRefStructOpaque opaque, void *obj)
 
static void container_fifo_reset_entry (FFRefStructOpaque opaque, void *obj)
 
static void container_fifo_free_entry (FFRefStructOpaque opaque, void *obj)
 
ContainerFifoff_container_fifo_alloc (void *(*container_alloc)(void), void(*container_reset)(void *obj), void(*container_free)(void *obj), int(*fifo_write)(void *dst, void *src), int(*fifo_read)(void *dst, void *src))
 Allocate a new ContainerFifo for the container type defined by provided callbacks. More...
 
void ff_container_fifo_free (ContainerFifo **pcf)
 Free a ContainerFifo and everything in it. More...
 
int ff_container_fifo_read (ContainerFifo *cf, void *obj)
 Read the next available object from the FIFO into obj. More...
 
int ff_container_fifo_write (ContainerFifo *cf, void *obj)
 Write the contents of obj to the FIFO. More...
 
size_t ff_container_fifo_can_read (ContainerFifo *cf)
 
static void * frame_alloc (void)
 
static void frame_reset (void *obj)
 
static void frame_free (void *obj)
 
static int frame_ref (void *dst, void *src)
 
static int frame_move_ref (void *dst, void *src)
 
ContainerFifoff_container_fifo_alloc_avframe (unsigned flags)
 Allocate a ContainerFifo instance for AVFrames. More...
 

Function Documentation

◆ container_fifo_init_entry()

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

Definition at line 39 of file container_fifo.c.

Referenced by ff_container_fifo_alloc().

◆ container_fifo_reset_entry()

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

Definition at line 51 of file container_fifo.c.

Referenced by ff_container_fifo_alloc().

◆ container_fifo_free_entry()

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

Definition at line 57 of file container_fifo.c.

Referenced by ff_container_fifo_alloc().

◆ ff_container_fifo_alloc()

ContainerFifo* ff_container_fifo_alloc ( void *(*)(void)  container_alloc,
void(*)(void *obj)  container_reset,
void(*)(void *obj)  container_free,
int(*)(void *dst, void *src fifo_write,
int(*)(void *dst, void *src fifo_read 
)

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

Parameters
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_writetransfer the contents of src to dst, where src is a container instance provided to ff_container_fifo_write()
fifo_readtransfer the contents of src to dst in other cases
Note
fifo_read() and fifo_write() are different parameters in order to allow fifo_write() implementations that make a new reference in dst, leaving src untouched (see e.g. ff_container_fifo_alloc_avframe())

Definition at line 64 of file container_fifo.c.

Referenced by ff_container_fifo_alloc_avframe().

◆ ff_container_fifo_free()

void ff_container_fifo_free ( ContainerFifo **  pcf)

Free a ContainerFifo and everything in it.

Definition at line 100 of file container_fifo.c.

Referenced by ff_container_fifo_alloc(), and hevc_decode_free().

◆ ff_container_fifo_read()

int ff_container_fifo_read ( ContainerFifo pf,
void *  obj 
)

Read the next available object from the FIFO into obj.

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

Definition at line 121 of file container_fifo.c.

Referenced by hevc_receive_frame().

◆ ff_container_fifo_write()

int ff_container_fifo_write ( ContainerFifo pf,
void *  obj 
)

Write the contents of obj to the FIFO.

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

Definition at line 136 of file container_fifo.c.

Referenced by ff_hevc_output_frames().

◆ ff_container_fifo_can_read()

size_t ff_container_fifo_can_read ( ContainerFifo pf)
Returns
number of objects available for reading

Definition at line 159 of file container_fifo.c.

Referenced by hevc_receive_frame().

◆ frame_alloc()

static void* frame_alloc ( void  )
static

Definition at line 164 of file container_fifo.c.

Referenced by ff_container_fifo_alloc_avframe().

◆ frame_reset()

static void frame_reset ( void *  obj)
static

Definition at line 169 of file container_fifo.c.

Referenced by ff_container_fifo_alloc_avframe().

◆ frame_free()

static void frame_free ( void *  obj)
static

Definition at line 174 of file container_fifo.c.

Referenced by ff_container_fifo_alloc_avframe().

◆ frame_ref()

static int frame_ref ( void *  dst,
void *  src 
)
static

◆ frame_move_ref()

static int frame_move_ref ( void *  dst,
void *  src 
)
static

Definition at line 185 of file container_fifo.c.

Referenced by ff_container_fifo_alloc_avframe().

◆ ff_container_fifo_alloc_avframe()

ContainerFifo* ff_container_fifo_alloc_avframe ( unsigned  flags)

Allocate a ContainerFifo instance for AVFrames.

Note that ff_container_fifo_write() will call av_frame_ref() on src, making a new reference in dst and leaving src untouched.

Parameters
flagsunused currently

Definition at line 191 of file container_fifo.c.

Referenced by hevc_init_context().