FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
fifo.h File Reference

a very simple circular buffer FIFO implementation More...

#include <stdint.h>
#include "avutil.h"
#include "attributes.h"

Go to the source code of this file.

Data Structures

struct  AVFifoBuffer
 

Functions

AVFifoBufferav_fifo_alloc (unsigned int size)
 Initialize an AVFifoBuffer. More...
 
AVFifoBufferav_fifo_alloc_array (size_t nmemb, size_t size)
 Initialize an AVFifoBuffer. More...
 
void av_fifo_free (AVFifoBuffer *f)
 Free an AVFifoBuffer. More...
 
void av_fifo_freep (AVFifoBuffer **f)
 Free an AVFifoBuffer and reset pointer to NULL. More...
 
void av_fifo_reset (AVFifoBuffer *f)
 Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. More...
 
int av_fifo_size (const AVFifoBuffer *f)
 Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from it. More...
 
int av_fifo_space (const AVFifoBuffer *f)
 Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write into it. More...
 
int av_fifo_generic_peek_at (AVFifoBuffer *f, void *dest, int offset, int buf_size, void(*func)(void *, void *, int))
 Feed data at specific position from an AVFifoBuffer to a user-supplied callback. More...
 
int av_fifo_generic_peek (AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
 Feed data from an AVFifoBuffer to a user-supplied callback. More...
 
int av_fifo_generic_read (AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
 Feed data from an AVFifoBuffer to a user-supplied callback. More...
 
int av_fifo_generic_write (AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
 Feed data from a user-supplied callback to an AVFifoBuffer. More...
 
int av_fifo_realloc2 (AVFifoBuffer *f, unsigned int size)
 Resize an AVFifoBuffer. More...
 
int av_fifo_grow (AVFifoBuffer *f, unsigned int additional_space)
 Enlarge an AVFifoBuffer. More...
 
void av_fifo_drain (AVFifoBuffer *f, int size)
 Read and discard the specified amount of data from an AVFifoBuffer. More...
 
static uint8_tav_fifo_peek2 (const AVFifoBuffer *f, int offs)
 Return a pointer to the data stored in a FIFO buffer at a certain offset. More...
 

Detailed Description

a very simple circular buffer FIFO implementation

Definition in file fifo.h.

Function Documentation

AVFifoBuffer* av_fifo_alloc ( unsigned int  size)
AVFifoBuffer* av_fifo_alloc_array ( size_t  nmemb,
size_t  size 
)

Initialize an AVFifoBuffer.

Parameters
nmembnumber of elements
sizesize of the single element
Returns
AVFifoBuffer or NULL in case of memory allocation failure

Definition at line 49 of file fifo.c.

Referenced by dv_init_mux(), ff_audio_interleave_init(), ff_frame_thread_encoder_init(), flac_parse_init(), init(), and start_jack().

void av_fifo_free ( AVFifoBuffer f)
void av_fifo_freep ( AVFifoBuffer **  f)
void av_fifo_reset ( AVFifoBuffer f)

Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.

Parameters
fAVFifoBuffer to reset

Definition at line 71 of file fifo.c.

Referenced by av_audio_fifo_reset(), fifo_alloc_common(), main(), mediacodec_decode_flush(), and ring_reset().

int av_fifo_size ( const AVFifoBuffer f)
int av_fifo_space ( const AVFifoBuffer f)
int av_fifo_generic_peek_at ( AVFifoBuffer f,
void dest,
int  offset,
int  buf_size,
void(*)(void *, void *, int func 
)

Feed data at specific position from an AVFifoBuffer to a user-supplied callback.

Similar as av_fifo_gereric_read but without discarding data.

Parameters
fAVFifoBuffer to read from
offsetoffset from current read position
buf_sizenumber of bytes to read
funcgeneric read function
destdata destination

Definition at line 151 of file fifo.c.

Referenced by av_audio_fifo_peek_at(), av_thread_message_flush(), main(), and ring_generic_read().

int av_fifo_generic_peek ( AVFifoBuffer f,
void dest,
int  buf_size,
void(*)(void *, void *, int func 
)

Feed data from an AVFifoBuffer to a user-supplied callback.

Similar as av_fifo_gereric_read but without discarding data.

Parameters
fAVFifoBuffer to read from
buf_sizenumber of bytes to read
funcgeneric read function
destdata destination

Definition at line 189 of file fifo.c.

Referenced by av_audio_fifo_peek(), and main().

int av_fifo_generic_read ( AVFifoBuffer f,
void dest,
int  buf_size,
void(*)(void *, void *, int func 
)
int av_fifo_generic_write ( AVFifoBuffer f,
void src,
int  size,
int(*)(void *, void *, int func 
)

Feed data from a user-supplied callback to an AVFifoBuffer.

Parameters
fAVFifoBuffer to write to
srcdata source; non-const since it may be used as a modifiable context by the function defined in func
sizenumber of bytes to write
funcgeneric write function; the first parameter is src, the second is dest_buf, the third is dest_buf_size. func must return the number of bytes written to dest_buf, or <= 0 to indicate no more data available to write. If func is NULL, src is interpreted as a simple byte array for source data.
Returns
the number of bytes written to the FIFO

Definition at line 122 of file fifo.c.

Referenced by av_audio_fifo_write(), av_buffersrc_add_frame_internal(), cuvid_handle_picture_display(), dv_assemble_frame(), encode_frame(), ff_audio_rechunk_interleave(), ff_nvenc_encode_frame(), ff_thread_video_encode_frame(), flac_parse(), ifilter_send_frame(), libvorbis_encode_frame(), main(), mediacodec_decode_frame(), mpeg_mux_write_packet(), process_callback(), qsv_decode(), qsv_decode_frame(), ring_generic_write(), supply_new_packets(), svc_decode_frame(), swf_write_audio(), timestamp_queue_enqueue(), transcode_subtitles(), udp_write(), write_packet(), and write_to_fifo().

int av_fifo_realloc2 ( AVFifoBuffer f,
unsigned int  size 
)

Resize an AVFifoBuffer.

In case of reallocation failure, the old FIFO is kept unchanged.

Parameters
fAVFifoBuffer to resize
sizenew AVFifoBuffer size in bytes
Returns
<0 for failure, >=0 otherwise

Definition at line 87 of file fifo.c.

Referenced by av_audio_fifo_realloc(), av_buffersrc_add_frame_internal(), av_fifo_grow(), ff_audio_rechunk_interleave(), flac_parse(), ifilter_send_frame(), mediacodec_decode_frame(), mpeg_mux_write_packet(), qsv_decode_frame(), svc_decode_frame(), transcode_subtitles(), write_packet(), and write_to_fifo().

int av_fifo_grow ( AVFifoBuffer f,
unsigned int  additional_space 
)

Enlarge an AVFifoBuffer.

In case of reallocation failure, the old FIFO is kept unchanged. The new fifo size may be larger than the requested size.

Parameters
fAVFifoBuffer to resize
additional_spacethe amount of space in bytes to allocate in addition to av_fifo_size()
Returns
<0 for failure, >=0 otherwise

Definition at line 107 of file fifo.c.

Referenced by main().

void av_fifo_drain ( AVFifoBuffer f,
int  size 
)

Read and discard the specified amount of data from an AVFifoBuffer.

Parameters
fAVFifoBuffer to read from
sizeamount of data to read in bytes

Read and discard the specified amount of data from an AVFifoBuffer.

Definition at line 233 of file fifo.c.

Referenced by av_audio_fifo_drain(), av_fifo_generic_read(), av_thread_message_flush(), dv_assemble_frame(), flac_parse(), ring_generic_read(), and udp_read().

static uint8_t* av_fifo_peek2 ( const AVFifoBuffer f,
int  offs 
)
inlinestatic

Return a pointer to the data stored in a FIFO buffer at a certain offset.

The FIFO buffer is not modified.

Parameters
fAVFifoBuffer to peek at, f must be non-NULL
offsan offset in bytes, its absolute value must be less than the used buffer size or the returned pointer will point outside to the buffer data. The used buffer size can be checked with av_fifo_size().

Definition at line 169 of file fifo.h.

Referenced by dv_inject_audio(), and main().