FFmpeg
|
Files | |
file | fifo.h |
Data Structures | |
struct | AVFifoBuffer |
Macros | |
#define | AV_FIFO_FLAG_AUTO_GROW (1 << 0) |
Automatically resize the FIFO on writes, so that the data fits. More... | |
Typedefs | |
typedef int | AVFifoCB(void *opaque, void *buf, size_t *nb_elems) |
Callback for writing or reading from a FIFO, passed to (and invoked from) the av_fifo_*_cb() functions. More... | |
Functions | |
AVFifo * | av_fifo_alloc2 (size_t elems, size_t elem_size, unsigned int flags) |
Allocate and initialize an AVFifo with a given element size. More... | |
size_t | av_fifo_elem_size (const AVFifo *f) |
void | av_fifo_auto_grow_limit (AVFifo *f, size_t max_elems) |
Set the maximum size (in elements) to which the FIFO can be resized automatically. More... | |
size_t | av_fifo_can_read (const AVFifo *f) |
size_t | av_fifo_can_write (const AVFifo *f) |
int | av_fifo_grow2 (AVFifo *f, size_t inc) |
Enlarge an AVFifo. More... | |
int | av_fifo_write (AVFifo *f, const void *buf, size_t nb_elems) |
Write data into a FIFO. More... | |
int | av_fifo_write_from_cb (AVFifo *f, AVFifoCB read_cb, void *opaque, size_t *nb_elems) |
Write data from a user-provided callback into a FIFO. More... | |
int | av_fifo_read (AVFifo *f, void *buf, size_t nb_elems) |
Read data from a FIFO. More... | |
int | av_fifo_read_to_cb (AVFifo *f, AVFifoCB write_cb, void *opaque, size_t *nb_elems) |
Feed data from a FIFO into a user-provided callback. More... | |
int | av_fifo_peek (const AVFifo *f, void *buf, size_t nb_elems, size_t offset) |
Read data from a FIFO without modifying FIFO state. More... | |
int | av_fifo_peek_to_cb (const AVFifo *f, AVFifoCB write_cb, void *opaque, size_t *nb_elems, size_t offset) |
Feed data from a FIFO into a user-provided callback. More... | |
void | av_fifo_drain2 (AVFifo *f, size_t size) |
Discard the specified amount of data from an AVFifo. More... | |
void | av_fifo_reset2 (AVFifo *f) |
void | av_fifo_freep2 (AVFifo **f) |
Free an AVFifo and reset pointer to NULL. More... | |
attribute_deprecated AVFifoBuffer * | av_fifo_alloc (unsigned int size) |
Initialize an AVFifoBuffer. More... | |
attribute_deprecated AVFifoBuffer * | av_fifo_alloc_array (size_t nmemb, size_t size) |
Initialize an AVFifoBuffer. More... | |
attribute_deprecated void | av_fifo_free (AVFifoBuffer *f) |
Free an AVFifoBuffer. More... | |
attribute_deprecated void | av_fifo_freep (AVFifoBuffer **f) |
Free an AVFifoBuffer and reset pointer to NULL. More... | |
attribute_deprecated void | av_fifo_reset (AVFifoBuffer *f) |
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. More... | |
attribute_deprecated 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... | |
attribute_deprecated 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... | |
attribute_deprecated 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... | |
attribute_deprecated 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... | |
attribute_deprecated 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... | |
attribute_deprecated 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... | |
attribute_deprecated int | av_fifo_realloc2 (AVFifoBuffer *f, unsigned int size) |
Resize an AVFifoBuffer. More... | |
attribute_deprecated int | av_fifo_grow (AVFifoBuffer *f, unsigned int additional_space) |
Enlarge an AVFifoBuffer. More... | |
attribute_deprecated void | av_fifo_drain (AVFifoBuffer *f, int size) |
Read and discard the specified amount of data from an AVFifoBuffer. More... | |
static attribute_deprecated uint8_t * | av_fifo_peek2 (const AVFifoBuffer *f, int offs) |
Return a pointer to the data stored in a FIFO buffer at a certain offset. More... | |
A generic FIFO API
#define AV_FIFO_FLAG_AUTO_GROW (1 << 0) |
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().
typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems) |
Callback for writing or reading from a FIFO, passed to (and invoked from) the av_fifo_*_cb() functions.
It may be invoked multiple times from a single av_fifo_*_cb() call and may process less data than the maximum size indicated by nb_elems.
opaque | the opaque pointer provided to the av_fifo_*_cb() function |
buf | the buffer for reading or writing the data, depending on which av_fifo_*_cb function is called |
nb_elems | On entry contains the maximum number of elements that can be read from / written into buf. On success, the callback should update it to contain the number of elements actually written. |
Allocate and initialize an AVFifo with a given element size.
elems | initial number of elements that can be stored in the FIFO |
elem_size | Size in bytes of a single element. Further operations on the returned FIFO will implicitly use this element size. |
flags | a combination of AV_FIFO_FLAG_* |
Definition at line 47 of file fifo.c.
Referenced by amf_load_library(), av1_decode_init(), av_audio_fifo_alloc(), av_thread_message_queue_alloc(), config_input(), cuvid_decode_init(), deshake_opencl_init(), dts2pts_init(), dv_init_mux(), ff_ccfifo_init(), ff_qsv_enc_init(), ff_qsvvpp_init(), ff_vaapi_encode_init(), ifilter_alloc(), init(), input_init(), libvorbis_encode_init(), main(), mpeg_mux_init(), nvenc_setup_surfaces(), ost_add(), packet_queue_init(), qsv_decode_init(), qsv_decode_preinit(), ring_init(), sq_add_stream(), start_jack(), swf_write_header(), tq_alloc(), udp_open(), and vpx_init().
size_t av_fifo_elem_size | ( | const AVFifo * | f | ) |
void av_fifo_auto_grow_limit | ( | AVFifo * | f, |
size_t | max_elems | ||
) |
size_t av_fifo_can_read | ( | const AVFifo * | f | ) |
Definition at line 87 of file fifo.c.
Referenced by activate(), amf_copy_buffer(), av_audio_fifo_realloc(), av_fifo_can_write(), av_fifo_drain2(), av_thread_message_flush(), av_thread_message_queue_nb_elems(), cuvid_is_buffer_full(), dts2pts_filter(), dv_assemble_frame(), ff_ccfifo_injectbytes(), ff_qsv_encode(), ff_qsvvpp_filter_frame(), ff_vaapi_encode_receive_packet(), fifo_peek_common(), flush_packet(), main(), mpeg_mux_end(), mpeg_mux_write_packet(), output_packet(), output_ready(), process_callback(), qsv_decode(), qsv_decode_frame(), queue_packet(), receive_for_stream(), ring_size(), swf_write_video(), tb_update(), udp_read(), and uninit().
size_t av_fifo_can_write | ( | const AVFifo * | f | ) |
In other words, this number of elements or less is guaranteed to fit into the FIFO. More data may be written when the AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this may involve memory allocation, which can fail.
Definition at line 94 of file fifo.c.
Referenced by activate(), av_audio_fifo_realloc(), dts2pts_filter(), dv_assemble_frame(), ff_vaapi_encode_receive_packet(), fifo_check_space(), libvorbis_encode_frame(), main(), mpeg_mux_write_packet(), process_callback(), queue_packet(), ring_space(), ringbuf_float_at(), supply_new_packets(), swf_write_audio(), tq_send(), and udp_write().
Enlarge an AVFifo.
On success, the FIFO will be large enough to hold exactly inc + av_fifo_can_read() + av_fifo_can_write() elements. In case of failure, the old FIFO is kept unchanged.
f | AVFifo to resize |
inc | number of elements to allocate for, in addition to the current allocated size |
Definition at line 99 of file fifo.c.
Referenced by av_audio_fifo_realloc(), fifo_check_space(), main(), mpeg_mux_write_packet(), and queue_packet().
Write data into a FIFO.
In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag was not specified at FIFO creation, nothing is written and an error is returned.
Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f).
f | the FIFO buffer |
buf | Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be read from buf on success. |
nb_elems | number of elements to write into FIFO |
Definition at line 188 of file fifo.c.
Referenced by activate(), av1_receive_frame_internal(), av_audio_fifo_write(), cuvid_handle_picture_display(), dv_assemble_frame(), encode_frame(), ff_amf_receive_packet(), ff_ccfifo_extractbytes(), ff_nvenc_receive_packet(), ff_qsvvpp_filter_frame(), ff_vaapi_encode_receive_packet(), filter_frame(), frame_data_submit(), h264_queue_frame(), handle_input(), ifilter_send_frame(), ifilter_sub2video(), libvorbis_encode_frame(), main(), mpeg_mux_write_packet(), nvenc_alloc_surface(), nvenc_send_frame(), packet_queue_put_private(), process_callback(), qsv_decode(), qsv_decode_frame(), queue_packet(), sq_send(), supply_new_packets(), swf_write_audio(), timestamp_queue_enqueue(), tq_send(), and udp_write().
Write data from a user-provided callback into a FIFO.
f | the FIFO buffer |
read_cb | Callback supplying the data to the FIFO. May be called multiple times. |
opaque | opaque user data to be provided to read_cb |
nb_elems | Should point to the maximum number of elements that can be written. Will be updated to contain the number of elements actually written. |
Definition at line 193 of file fifo.c.
Referenced by main(), and ring_write().
Read data from a FIFO.
In case nb_elems > av_fifo_can_read(f), nothing is read and an error is returned.
f | the FIFO buffer |
buf | Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes will be written into buf on success. |
nb_elems | number of elements to read from FIFO |
Definition at line 240 of file fifo.c.
Referenced by activate(), amf_copy_buffer(), audio_read_packet(), av1_decode_flush(), av1_decode_free(), av_audio_fifo_read(), configure_filtergraph(), cuvid_output_frame(), dts2pts_filter(), dts2pts_flush(), export_metadata(), ff_ccfifo_injectbytes(), ff_nvenc_receive_packet(), ff_qsv_enc_close(), ff_qsv_encode(), ff_qsvvpp_filter_frame(), ff_vaapi_encode_receive_packet(), fg_free(), fifo_free(), filter_frame(), free_debug_matches(), free_pkt_fifo(), get_free_frame(), libvorbis_encode_frame(), main(), nvenc_send_frame(), ost_free(), packet_queue_flush(), packet_queue_get(), process_callback(), qsv_clear_buffers(), qsv_decode(), qsv_decode_close_qsvcontext(), qsv_decode_frame(), receive_locked(), sq_free(), thread_start(), timestamp_queue_dequeue(), tq_free(), udp_read(), and uninit().
Feed data from a FIFO into a user-provided callback.
f | the FIFO buffer |
write_cb | Callback the data will be supplied to. May be called multiple times. |
opaque | opaque user data to be provided to write_cb |
nb_elems | Should point to the maximum number of elements that can be read. Will be updated to contain the total number of elements actually sent to the callback. |
Definition at line 247 of file fifo.c.
Referenced by av_thread_message_flush(), flush_packet(), main(), and swf_write_video().
Read data from a FIFO without modifying FIFO state.
Returns an error if an attempt is made to peek to nonexistent elements (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)).
f | the FIFO buffer |
buf | Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes will be written into buf. |
nb_elems | number of elements to read from FIFO |
offset | number of initial elements to skip. |
Definition at line 255 of file fifo.c.
Referenced by amf_copy_buffer(), av_audio_fifo_peek_at(), drain_input_pts(), dv_inject_audio(), filter_frame(), frame_data_apply(), libplacebo_activate(), main(), overflow_heartbeat(), receive_for_stream(), receive_samples(), ring_read(), and ringbuf_float_at().
int av_fifo_peek_to_cb | ( | const AVFifo * | f, |
AVFifoCB | write_cb, | ||
void * | opaque, | ||
size_t * | nb_elems, | ||
size_t | offset | ||
) |
Feed data from a FIFO into a user-provided callback.
f | the FIFO buffer |
write_cb | Callback the data will be supplied to. May be called multiple times. |
opaque | opaque user data to be provided to write_cb |
nb_elems | Should point to the maximum number of elements that can be read. Will be updated to contain the total number of elements actually sent to the callback. |
offset | number of initial elements to skip; offset + *nb_elems must not be larger than av_fifo_can_read(f). |
Definition at line 260 of file fifo.c.
Referenced by main().
void av_fifo_drain2 | ( | AVFifo * | f, |
size_t | size | ||
) |
Discard the specified amount of data from an AVFifo.
size | number of elements to discard, MUST NOT be larger than av_fifo_can_read(f) |
Definition at line 266 of file fifo.c.
Referenced by activate(), av_audio_fifo_drain(), av_fifo_read(), av_fifo_read_to_cb(), drain_input_pts(), dv_assemble_frame(), frame_data_apply(), receive_for_stream(), receive_samples(), ring_read(), and udp_read().
void av_fifo_reset2 | ( | AVFifo * | f | ) |
Definition at line 280 of file fifo.c.
Referenced by av_audio_fifo_reset(), ff_nvenc_encode_flush(), and ring_reset().
void av_fifo_freep2 | ( | AVFifo ** | f | ) |
Free an AVFifo and reset pointer to NULL.
f | Pointer to an AVFifo to free. *f == NULL is allowed. |
Definition at line 286 of file fifo.c.
Referenced by av1_decode_free(), av_audio_fifo_free(), av_thread_message_queue_free(), cuvid_decode_end(), deshake_opencl_uninit(), dts2pts_close(), dv_deinit(), ff_amf_encode_close(), ff_ccfifo_uninit(), ff_nvenc_encode_close(), ff_qsv_enc_close(), ff_qsvvpp_close(), ff_vaapi_encode_close(), fg_free(), fifo_free(), free_debug_matches(), free_pkt_fifo(), input_uninit(), libvorbis_encode_close(), main(), mpeg_mux_deinit(), ost_free(), packet_queue_destroy(), qsv_decode_close(), qsv_decode_close_qsvcontext(), ring_destroy(), sq_free(), swf_deinit(), tq_free(), udp_close(), udp_open(), and uninit().
attribute_deprecated AVFifoBuffer* av_fifo_alloc | ( | unsigned int | size | ) |
Initialize an AVFifoBuffer.
size | of FIFO |
attribute_deprecated AVFifoBuffer* av_fifo_alloc_array | ( | size_t | nmemb, |
size_t | size | ||
) |
Initialize an AVFifoBuffer.
nmemb | number of elements |
size | size of the single element |
Definition at line 300 of file fifo.c.
Referenced by av_fifo_alloc().
attribute_deprecated void av_fifo_free | ( | AVFifoBuffer * | f | ) |
Free an AVFifoBuffer.
f | AVFifoBuffer to free |
Definition at line 327 of file fifo.c.
Referenced by av_fifo_freep().
attribute_deprecated void av_fifo_freep | ( | AVFifoBuffer ** | f | ) |
Free an AVFifoBuffer and reset pointer to NULL.
f | AVFifoBuffer to free |
attribute_deprecated void av_fifo_reset | ( | AVFifoBuffer * | f | ) |
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
f | AVFifoBuffer to reset |
Definition at line 343 of file fifo.c.
Referenced by av_fifo_alloc_array().
attribute_deprecated 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.
f | AVFifoBuffer to read from |
Definition at line 349 of file fifo.c.
Referenced by av_fifo_drain(), av_fifo_generic_peek_at(), av_fifo_generic_read(), av_fifo_grow(), av_fifo_realloc2(), and av_fifo_space().
attribute_deprecated 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.
f | AVFifoBuffer to write into |
Definition at line 354 of file fifo.c.
Referenced by av_fifo_generic_write().
attribute_deprecated 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.
f | AVFifoBuffer to read from |
offset | offset from current read position |
buf_size | number of bytes to read |
func | generic read function |
dest | data destination |
Definition at line 442 of file fifo.c.
Referenced by av_fifo_generic_peek().
attribute_deprecated 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.
f | AVFifoBuffer to read from |
buf_size | number of bytes to read |
func | generic read function |
dest | data destination |
attribute_deprecated int av_fifo_generic_read | ( | AVFifoBuffer * | f, |
void * | dest, | ||
int | buf_size, | ||
void(*)(void *, void *, int) | func | ||
) |
Feed data from an AVFifoBuffer to a user-supplied callback.
f | AVFifoBuffer to read from |
buf_size | number of bytes to read |
func | generic read function |
dest | data destination |
attribute_deprecated 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.
f | AVFifoBuffer to write to |
src | data source; non-const since it may be used as a modifiable context by the function defined in func |
size | number of bytes to write |
func | generic 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. |
attribute_deprecated int av_fifo_realloc2 | ( | AVFifoBuffer * | f, |
unsigned int | size | ||
) |
Resize an AVFifoBuffer.
In case of reallocation failure, the old FIFO is kept unchanged.
f | AVFifoBuffer to resize |
size | new AVFifoBuffer size in bytes |
Definition at line 359 of file fifo.c.
Referenced by av_fifo_grow().
attribute_deprecated 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.
f | AVFifoBuffer to resize |
additional_space | the amount of space in bytes to allocate in addition to av_fifo_size() |
attribute_deprecated void av_fifo_drain | ( | AVFifoBuffer * | f, |
int | size | ||
) |
Read and discard the specified amount of data from an AVFifoBuffer.
f | AVFifoBuffer to read from |
size | amount of data to read in bytes |
Read and discard the specified amount of data from an AVFifoBuffer.
Definition at line 502 of file fifo.c.
Referenced by av_fifo_generic_read().
|
inlinestatic |
Return a pointer to the data stored in a FIFO buffer at a certain offset.
The FIFO buffer is not modified.
f | AVFifoBuffer to peek at, f must be non-NULL |
offs | an 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(). |