FFmpeg
|
AVBuffer is an API for reference-counted data buffers. More...
Files | |
file | buffer.h |
refcounted data buffer API | |
Data Structures | |
struct | AVBufferRef |
A reference to a data buffer. More... | |
Macros | |
#define | AV_BUFFER_FLAG_READONLY (1 << 0) |
Always treat the buffer as read-only, even when it has only one reference. More... | |
Functions | |
AVBufferRef * | av_buffer_alloc (int size) |
Allocate an AVBuffer of the given size using av_malloc(). More... | |
AVBufferRef * | av_buffer_allocz (int size) |
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero. More... | |
AVBufferRef * | av_buffer_create (uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags) |
Create an AVBuffer from an existing array. More... | |
void | av_buffer_default_free (void *opaque, uint8_t *data) |
Default free callback, which calls av_free() on the buffer data. More... | |
AVBufferRef * | av_buffer_ref (AVBufferRef *buf) |
Create a new reference to an AVBuffer. More... | |
void | av_buffer_unref (AVBufferRef **buf) |
Free a given reference and automatically free the buffer if there are no more references to it. More... | |
int | av_buffer_is_writable (const AVBufferRef *buf) |
void * | av_buffer_get_opaque (const AVBufferRef *buf) |
int | av_buffer_get_ref_count (const AVBufferRef *buf) |
int | av_buffer_make_writable (AVBufferRef **buf) |
Create a writable reference from a given buffer reference, avoiding data copy if possible. More... | |
int | av_buffer_realloc (AVBufferRef **buf, int size) |
Reallocate a given buffer. More... | |
AVBuffer is an API for reference-counted data buffers.
There are two core objects in this API – AVBuffer and AVBufferRef. AVBuffer represents the data buffer itself; it is opaque and not meant to be accessed by the caller directly, but only through AVBufferRef. However, the caller may e.g. compare two AVBuffer pointers to check whether two different references are describing the same data buffer. AVBufferRef represents a single reference to an AVBuffer and it is the object that may be manipulated by the caller directly.
There are two functions provided for creating a new AVBuffer with a single reference – av_buffer_alloc() to just allocate a new buffer, and av_buffer_create() to wrap an existing array in an AVBuffer. From an existing reference, additional references may be created with av_buffer_ref(). Use av_buffer_unref() to free a reference (this will automatically free the data once all the references are freed).
The convention throughout this API and the rest of FFmpeg is such that the buffer is considered writable if there exists only one reference to it (and it has not been marked as read-only). The av_buffer_is_writable() function is provided to check whether this is true and av_buffer_make_writable() will automatically create a new writable buffer when necessary. Of course nothing prevents the calling code from violating this convention, however that is safe only when all the existing references are under its control.
#define AV_BUFFER_FLAG_READONLY (1 << 0) |
Always treat the buffer as read-only, even when it has only one reference.
Definition at line 113 of file buffer.h.
Referenced by av_buffer_create(), av_buffer_is_writable(), av_hwdevice_ctx_alloc(), av_hwframe_ctx_alloc(), ff_videotoolbox_buffer_create(), ffmmal_set_ref(), get_buffer(), mediacodec_wrap_hw_buffer(), vaapi_encode_alloc_output_buffer(), vaapi_pool_alloc(), vdpau_pool_alloc(), and wrapped_avframe_encode().
AVBufferRef* av_buffer_alloc | ( | int | size | ) |
Allocate an AVBuffer of the given size using av_malloc().
Definition at line 67 of file buffer.c.
Referenced by asf_parse_packet(), av_buffer_allocz(), av_buffer_make_writable(), av_buffer_pool_init(), av_frame_new_side_data(), av_grow_packet(), av_packet_merge_side_data(), extract_extradata_h2645(), ff_flac_parse_picture(), ff_mjpeg_decode_frame(), ff_videotoolbox_alloc_frame(), ffmmal_add_packet(), filter_frame(), get_audio_buffer(), get_video_buffer(), mpegts_push_data(), qsv_frame_lock(), raw_decode(), raw_init_decoder(), read_apic(), thread_get_buffer_internal(), and vtenc_populate_extradata().
AVBufferRef* av_buffer_allocz | ( | int | size | ) |
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition at line 83 of file buffer.c.
Referenced by alloc_frame(), alloc_frame_buffer(), alloc_picture(), alloc_picture_tables(), ff_default_get_audio_buffer(), ff_default_get_video_buffer(), ff_er_frame_end(), ff_h264_decode_picture_parameter_set(), ff_h264_decode_seq_parameter_set(), ff_hevc_decode_nal_sps(), ff_hevc_decode_nal_vps(), get_buffer(), init_table_pools(), pic_arrays_init(), qsv_init_opaque_alloc(), update_frame_pool(), vp8_alloc_frame(), and vp9_frame_alloc().
AVBufferRef* av_buffer_create | ( | uint8_t * | data, |
int | size, | ||
void(*)(void *opaque, uint8_t *data) | free, | ||
void * | opaque, | ||
int | flags | ||
) |
Create an AVBuffer from an existing array.
If this function is successful, data is owned by the AVBuffer. The caller may only access data through the returned AVBufferRef and references derived from it. If this function fails, data is left untouched.
data | data array |
size | size of data in bytes |
free | a callback for freeing this buffer's data |
opaque | parameter to be got for processing or passed to free |
flags | a combination of AV_BUFFER_FLAG_* |
Definition at line 28 of file buffer.c.
Referenced by av_buffer_alloc(), av_buffer_pool_get(), av_buffer_realloc(), av_hwdevice_ctx_alloc(), av_hwframe_ctx_alloc(), av_packet_from_data(), cuda_pool_alloc(), dxva2_pool_alloc(), ff_hevc_decode_nal_pps(), ff_hwframe_map_create(), ff_videotoolbox_buffer_create(), ffmmal_set_ref(), filter_packet(), get_buffer(), get_buffer2(), mediacodec_wrap_hw_buffer(), mmap_read_frame(), qsv_create_mids(), qsv_pool_alloc(), vaapi_encode_alloc_output_buffer(), vaapi_pool_alloc(), vda_old_h264_end_frame(), vdpau_pool_alloc(), and wrapped_avframe_encode().
Default free callback, which calls av_free() on the buffer data.
This function is meant to be passed to av_buffer_create(), not called directly.
Definition at line 62 of file buffer.c.
Referenced by av_buffer_alloc(), av_buffer_create(), av_buffer_realloc(), av_packet_from_data(), and filter_packet().
AVBufferRef* av_buffer_ref | ( | AVBufferRef * | buf | ) |
Create a new reference to an AVBuffer.
Definition at line 93 of file buffer.c.
Referenced by av_buffersrc_parameters_set(), av_frame_ref(), av_hwframe_ctx_alloc(), av_hwframe_ctx_create_derived(), av_hwframe_get_buffer(), av_packet_ref(), avcodec_copy_context(), avfilter_config_links(), config_props(), configure_filtergraph(), copy_packet_data(), cudaupload_config_output(), cuvid_decode_init(), cuvid_output_frame(), deint_vaapi_config_input(), deint_vaapi_config_output(), ff_h264_ref_picture(), ff_h264_update_thread_context(), ff_hwframe_map_create(), ff_mpeg_ref_picture(), ff_mpv_export_qp_table(), ff_thread_ref_frame(), ff_vaapi_encode_init(), ffmmal_add_packet(), frame_copy_props(), get_format(), h264_init_ps(), hevc_ref_frame(), hevc_update_thread_context(), hwdownload_config_input(), hwmap_config_output(), hwmap_filter_frame(), hwupload_config_output(), hwupload_query_formats(), ifilter_parameters_from_frame(), init_output_stream(), init_processing_chain(), init_scale_session(), parse_nal_units(), qsv_create_mids(), qsv_frame_lock(), qsv_init_session(), qsv_map_from(), qsv_setup_mids(), qsvenc_init_session(), raw_decode(), scale_vaapi_config_input(), scale_vaapi_config_output(), try_push_frame(), update_context_from_thread(), vaapi_decode_init(), and vp9_frame_ref().
void av_buffer_unref | ( | AVBufferRef ** | buf | ) |
Free a given reference and automatically free the buffer if there are no more references to it.
buf | the reference to be freed. The pointer is set to NULL on return. |
Definition at line 125 of file buffer.c.
Referenced by asf_parse_packet(), av_buffersrc_parameters_set(), av_frame_set_qp_table(), av_frame_unref(), av_free_packet(), av_hwdevice_ctx_create(), av_hwframe_ctx_alloc(), av_hwframe_ctx_create_derived(), av_hwframe_get_buffer(), av_packet_unref(), avcodec_close(), avfilter_free(), copy_context_reset(), cudaupload_config_output(), cudaupload_uninit(), cuvid_decode_end(), cuvid_init(), cuvid_uninit(), deint_vaapi_config_output(), deint_vaapi_pipeline_uninit(), deint_vaapi_uninit(), dxva2_create_decoder(), dxva2_init(), dxva2_uninit(), extract_extradata_h2645(), ff_er_frame_end(), ff_flac_parse_picture(), ff_frame_thread_free(), ff_free_picture_tables(), ff_get_format(), ff_h264_decode_picture_parameter_set(), ff_h264_decode_seq_parameter_set(), ff_h264_ps_uninit(), ff_h264_unref_picture(), ff_h264_update_thread_context(), ff_hevc_decode_nal_pps(), ff_hevc_decode_nal_sps(), ff_hevc_decode_nal_vps(), ff_hevc_unref_frame(), ff_hwframe_map_create(), ff_hwframe_unmap(), ff_mpeg_unref_picture(), ff_qsv_decode_close(), ff_qsv_enc_close(), ff_qsv_init_session_hwcontext(), ff_thread_release_buffer(), ff_vaapi_decode_uninit(), ff_vaapi_encode_close(), ff_vdpau_common_init(), ff_videotoolbox_buffer_create(), ffmmal_add_packet(), ffmmal_fill_input_port(), ffmmal_stop_decoder(), ffmpeg_cleanup(), filter_frame(), frame_copy_props(), frame_new_side_data(), free_apic(), free_link(), free_picture(), free_side_data(), get_video_buffer(), h264_init_ps(), handle_packets(), hevc_decode_free(), hevc_parser_close(), hevc_update_thread_context(), hwdownload_config_input(), hwdownload_uninit(), hwframe_ctx_free(), hwmap_config_output(), hwmap_uninit(), hwupload_config_output(), hwupload_query_formats(), hwupload_uninit(), ifilter_parameters_from_frame(), init_scale_session(), init_stage(), input_callback(), mediacodec_wrap_hw_buffer(), mids_buf_free(), mpegts_close_filter(), nppscale_uninit(), parse_nal_units(), pool_alloc_buffer(), qsv_create_mids(), qsv_device_free(), qsv_frame_alloc(), qsv_frame_free(), qsv_frames_uninit(), qsv_init(), qsv_init_child_ctx(), qsv_init_session(), qsv_setup_mids(), qsv_uninit(), qsvdeint_uninit(), qsvenc_init_session(), qsvscale_uninit(), raw_close_decoder(), raw_decode(), remove_pps(), remove_sps(), remove_vps(), reset_pes_packet_state(), scale_vaapi_config_output(), scale_vaapi_pipeline_uninit(), scale_vaapi_uninit(), thread_get_buffer_internal(), transcode(), uninit(), update_context_from_thread(), vaapi_decode_uninit(), vaapi_device_init(), vaapi_encode_discard(), vaapi_encode_output(), vaapi_frames_init(), vdpau_alloc(), vdpau_uninit(), vp8_release_frame(), and vp9_frame_unref().
int av_buffer_is_writable | ( | const AVBufferRef * | buf | ) |
Definition at line 133 of file buffer.c.
Referenced by av_buffer_make_writable(), av_buffer_realloc(), and av_frame_is_writable().
void* av_buffer_get_opaque | ( | const AVBufferRef * | buf | ) |
Definition at line 141 of file buffer.c.
Referenced by vdadec_decode().
int av_buffer_get_ref_count | ( | const AVBufferRef * | buf | ) |
Definition at line 146 of file buffer.c.
Referenced by ff_h264_build_ref_list().
int av_buffer_make_writable | ( | AVBufferRef ** | buf | ) |
Create a writable reference from a given buffer reference, avoiding data copy if possible.
buf | buffer reference to make writable. On success, buf is either left untouched, or it is unreferenced and a new writable AVBufferRef is written in its place. On failure, buf is left untouched. |
Definition at line 151 of file buffer.c.
Referenced by raw_decode().
int av_buffer_realloc | ( | AVBufferRef ** | buf, |
int | size | ||
) |
Reallocate a given buffer.
buf | a buffer reference to reallocate. On success, buf will be unreferenced and a new reference with the required size will be written in its place. On failure buf will be left untouched. *buf may be NULL, then a new buffer is allocated. |
size | required new buffer size. |
Definition at line 169 of file buffer.c.
Referenced by av_buffer_realloc(), av_grow_packet(), avcodec_encode_audio2(), avcodec_encode_video2(), and packet_alloc().