|
FFmpeg
|
#include <stdatomic.h>#include <stdint.h>#include <string.h>#include "refstruct.h"#include "sanitizer.h"#include "avassert.h"#include "error.h"#include "macros.h"#include "mem.h"#include "mem_internal.h"#include "thread.h"Go to the source code of this file.
Data Structures | |
| struct | RefCount |
| struct | AVRefStructPool |
| AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API. More... | |
Macros | |
| #define | ASSERT_LEVEL 0 |
| #define | REFSTRUCT_CHECKED (ASSERT_LEVEL >= 1) |
| #define | ff_assert(cond) |
| #define | REFSTRUCT_COOKIE |
| #define | REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX(ALIGN_64, _Alignof(max_align_t))) |
| #define | COMMON_FLAGS AV_REFSTRUCT_POOL_FLAG_NO_ZEROING |
Functions | |
| static RefCount * | get_refcount (void *obj) |
| static const RefCount * | cget_refcount (const void *obj) |
| static void * | get_userdata (void *buf) |
| static void | refcount_init (RefCount *ref, AVRefStructOpaque opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj)) |
| void * | av_refstruct_alloc_ext_c (size_t size, unsigned flags, AVRefStructOpaque opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj)) |
Allocate a refcounted object of usable size size managed via the RefStruct API. | |
| void | av_refstruct_unref (void *objp) |
| Decrement the reference count of the underlying object and automatically free the object if there are no more references to it. | |
| void * | av_refstruct_ref (void *obj) |
| Create a new reference to an object managed via this API, i.e. | |
| const void * | av_refstruct_ref_c (const void *obj) |
| Analog of av_refstruct_ref(), but for constant objects. | |
| void | av_refstruct_replace (void *dstp, const void *src) |
Ensure *dstp refers to the same object as src. | |
| int | av_refstruct_exclusive (const void *obj) |
| Check whether the reference count of an object managed via this API is 1. | |
| static void | pool_free (AVRefStructPool *pool) |
| static void | pool_free_entry (AVRefStructPool *pool, RefCount *ref) |
| static void | pool_return_entry (void *ref_) |
| static void | pool_reset_entry (AVRefStructOpaque opaque, void *entry) |
| static int | refstruct_pool_get_ext (void *datap, AVRefStructPool *pool) |
| void * | av_refstruct_pool_get (AVRefStructPool *pool) |
| Get an object from the pool, reusing an old one from the pool when available. | |
| static void | pool_unref (void *ref) |
| Hint: The content of pool_unref() and refstruct_pool_uninit() could currently be merged; they are only separate functions in case we would ever introduce weak references. | |
| static void | refstruct_pool_uninit (AVRefStructOpaque unused, void *obj) |
| AVRefStructPool * | av_refstruct_pool_alloc (size_t size, unsigned flags) |
| Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL) | |
| AVRefStructPool * | av_refstruct_pool_alloc_ext_c (size_t size, unsigned flags, AVRefStructOpaque opaque, int(*init_cb)(AVRefStructOpaque opaque, void *obj), void(*reset_cb)(AVRefStructOpaque opaque, void *obj), void(*free_entry_cb)(AVRefStructOpaque opaque, void *obj), void(*free_cb)(AVRefStructOpaque opaque)) |
| Allocate an AVRefStructPool, potentially using complex callbacks. | |
| #define ASSERT_LEVEL 0 |
Definition at line 35 of file refstruct.c.
| #define REFSTRUCT_CHECKED (ASSERT_LEVEL >= 1) |
Definition at line 37 of file refstruct.c.
| #define ff_assert | ( | cond | ) |
Definition at line 43 of file refstruct.c.
Referenced by cget_refcount(), get_refcount(), refstruct_pool_get_ext(), and refstruct_pool_uninit().
| #define REFSTRUCT_COOKIE |
Definition at line 46 of file refstruct.c.
Referenced by cget_refcount(), get_refcount(), and refcount_init().
Definition at line 50 of file refstruct.c.
Referenced by av_refstruct_alloc_ext_c(), cget_refcount(), get_refcount(), and get_userdata().
| #define COMMON_FLAGS AV_REFSTRUCT_POOL_FLAG_NO_ZEROING |
Referenced by av_refstruct_pool_alloc_ext_c().
|
static |
Definition at line 71 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext_c(), av_refstruct_ref(), av_refstruct_ref_c(), av_refstruct_unref(), pool_free(), and refstruct_pool_get_ext().
|
static |
Definition at line 78 of file refstruct.c.
Referenced by av_refstruct_exclusive().
|
static |
Definition at line 85 of file refstruct.c.
Referenced by av_refstruct_alloc_ext_c(), pool_free_entry(), pool_return_entry(), pool_unref(), and refstruct_pool_get_ext().
|
static |
Definition at line 90 of file refstruct.c.
Referenced by av_refstruct_alloc_ext_c().
| void * av_refstruct_alloc_ext_c | ( | size_t | size, |
| unsigned | flags, | ||
| AVRefStructOpaque | opaque, | ||
| void(* | free_cb )(AVRefStructOpaque opaque, void *obj) ) |
Allocate a refcounted object of usable size size managed via the RefStruct API.
By default (in the absence of flags to the contrary), the returned object is initially zeroed.
| size | Desired usable size of the returned object. |
| flags | A bitwise combination of AV_REFSTRUCT_FLAG_* flags. |
| opaque | A pointer that will be passed to the free_cb callback. |
| free_cb | A callback for freeing this object's content when its reference count reaches zero; it must not free the object itself. |
Definition at line 103 of file refstruct.c.
Referenced by av_refstruct_alloc_ext(), and cbs_alloc_content().
| void av_refstruct_unref | ( | void * | objp | ) |
Decrement the reference count of the underlying object and automatically free the object if there are no more references to it.
*objp == NULL is legal and a no-op.
| objp | Pointer to a pointer that is either NULL or points to an object managed via this API. *objp is set to NULL on return. |
Definition at line 121 of file refstruct.c.
Referenced by alf_free(), alloc_and_insert_node(), alloc_progress(), aps_decode_alf(), aps_decode_scaling(), apv_decode(), av1_decode_free(), av1_frame_unref(), av_container_fifo_drain(), av_container_fifo_free(), av_container_fifo_read(), av_container_fifo_write(), av_frame_unref(), av_refstruct_pool_uninit(), av_refstruct_replace(), blackdetect_vulkan_filter_frame(), build_packet(), cbs_av1_close(), cbs_av1_write_obu(), cbs_clone_noncomplex_unit_content(), cbs_free_user_data_registered(), cbs_free_user_data_unregistered(), cbs_h264_close(), cbs_h264_flush(), cbs_h265_close(), cbs_h265_flush(), cbs_h266_flush(), cbs_h266_free_slice(), cbs_h266_replace_ps(), cbs_lcevc_delete_process_block(), cbs_lcevc_flush(), cbs_sei_delete_message(), cbs_unit_uninit(), check_dither(), check_filter(), check_lut_3d(), copy_oc(), cudascale_filter_init(), decode_close(), decode_close(), decode_data_free(), decode_end(), decode_end(), decode_frame(), decode_frame(), decode_frame(), decode_frame(), decode_pps(), decode_receive_frame_internal(), decode_sps(), dts2pts_filter(), encode_close(), exec_discard_deps(), ff_attach_decode_data(), ff_cbs_lcevc_free_process_block_list(), ff_cbs_sei_free_message_list(), ff_codec_close(), ff_decode_internal_uninit(), ff_dovi_ctx_flush(), ff_dovi_ctx_unref(), ff_dovi_rpu_generate(), ff_dovi_rpu_parse(), ff_ffv1_close(), ff_frame_thread_free(), ff_h2645_sei_message_decode(), ff_h2645_sei_reset(), ff_h264_decode_picture_parameter_set(), ff_h264_decode_seq_parameter_set(), ff_h264_ps_uninit(), ff_h264_unref_picture(), ff_hevc_decode_nal_pps(), ff_hevc_decode_nal_sps(), ff_hevc_decode_nal_vps(), ff_hevc_ps_uninit(), ff_hevc_unref_frame(), ff_lcevc_alloc(), ff_mpv_encode_end(), ff_mpv_unref_picture(), ff_nvdec_decode_uninit(), ff_nvdec_start_frame_sep_ref(), ff_op_priv_unref(), ff_progress_frame_get_buffer(), ff_progress_frame_unref(), ff_qsv_enc_close(), ff_qsv_init_session_frames(), ff_sws_filter_generate(), ff_thread_get_ext_buffer(), ff_thread_release_ext_buffer(), ff_v4l2_m2m_codec_end(), ff_v4l2_m2m_create_context(), ff_vk_decode_add_slice(), ff_vk_decode_create_params(), ff_vk_decode_free_frame(), ff_vk_decode_uninit(), ff_vk_exec_move_dep_refstruct(), ff_vk_get_pooled_buffer(), ff_vk_host_map_buffer(), ff_vk_params_invalidate(), ff_vk_video_common_uninit(), ff_vvc_ctu_free_cus(), ff_vvc_frame_ps_free(), ff_vvc_ps_uninit(), ff_vvc_sei_decode(), ff_vvc_unref_frame(), ffv1_decode_close(), ffv1_vk_packet_free(), free_additional_info(), free_encoded_data(), free_fn(), free_node(), free_picture_config(), get_packet(), get_packet(), graph_uninit(), hevc_decode_free(), hevc_pps_free(), hevc_queue_frame(), hevc_sps_free(), host_map_frame(), lcevc_frame_reset_cb(), load_input_picture(), make_unit_writable(), mpv_pic_reset(), nlmeans_vulkan_filter_frame(), nvdec_decoder_create(), nvdec_fdd_priv_free(), nvdec_retrieve_data(), nvdec_unmap_mapped_frame(), oh_buffer_release(), oh_decode_close(), op_pass_free(), op_uninit(), parse_ext_ele(), pass_free(), pkt_buf_free(), pps_alloc(), pps_free(), pps_free(), prores_vk_packet_free(), qsv_decode_close_qsvcontext(), qsv_frame_alloc(), qsv_frame_free(), qsv_init_session(), read_header(), remove_pps(), remove_sps(), remove_sps(), remove_vps(), rkmpp_close_decoder(), rkmpp_release_frame(), scdet_vulkan_filter_frame(), select_input_picture(), set_bframe_chain_length(), set_sps(), slices_free(), sps_alloc(), sps_free(), sws_filter_free(), sws_freeContext(), sws_uops_macros_gen(), uop_uninit(), update_frame_pool(), v4l2_free_buffer(), vaapi_encode_discard(), vaapi_encode_get_coded_data(), vaapi_encode_issue(), vaapi_encode_output(), vk_apv_end_frame(), vk_apv_free_frame_priv(), vk_ffv1_free_frame_priv(), vk_prores_free_frame_priv(), vk_prores_raw_free_frame_priv(), vp3_decode_end(), vp8_alloc_frame(), vp8_release_frame(), vp9_decode_free(), vp9_frame_unref(), vulkan_decode_bootstrap(), vulkan_encode_apv_close(), vulkan_encode_ffv1_close(), vulkan_encode_ffv1_submit_frame(), vulkan_encode_get_recon_frame(), vulkan_encode_output(), vulkan_encode_recon_free(), vulkan_transfer_frame(), wavpack_decode_block(), and wv_dsd_reset().
| void * av_refstruct_ref | ( | void * | obj | ) |
Create a new reference to an object managed via this API, i.e.
increment the reference count of the underlying object and return obj.
Definition at line 141 of file refstruct.c.
Referenced by aarch64_setup_dither(), cbs_av1_write_obu(), cbs_h266_read_nal_unit(), compile(), compile_single(), DECL_SETUP(), DECL_SETUP(), ff_attach_decode_data(), ff_cbs_lcevc_add_process_block(), ff_cbs_sei_add_message(), ff_nvdec_start_frame(), ff_progress_frame_ref(), ff_sws_op_list_duplicate(), ff_sws_op_list_optimize(), ff_thread_ref_frame(), ff_vk_exec_add_dep_refstruct(), get_current_frame(), hevc_ref_frame(), insert_unit_content(), nvdec_retrieve_data(), oh_decode_wrap_hw_buffer(), qsv_setup_mids(), rkmpp_retrieve_frame(), setup_dither(), translate_rw_op(), v4l2_buf_increase_ref(), vaapi_encode_output(), vk_ffv1_start_frame(), vp9_decode_frame(), and vulkan_encode_ffv1_submit_frame().
| const void * av_refstruct_ref_c | ( | const void * | obj | ) |
Analog of av_refstruct_ref(), but for constant objects.
Definition at line 150 of file refstruct.c.
Referenced by alloc_frame(), alloc_frame(), alloc_picture(), av_refstruct_replace(), DECL_SETUP(), ff_h264_decode_picture_parameter_set(), ff_hevc_decode_nal_pps(), ff_hevc_parse_sps(), ff_sws_op_list_duplicate(), hevc_ref_frame(), set_sps(), and translate_op().
| void av_refstruct_replace | ( | void * | dstp, |
| const void * | src ) |
Ensure *dstp refers to the same object as src.
If *dstp is already equal to src, do nothing. Otherwise unreference *dstp and replace it with a new reference to src in case src != NULL (this involves incrementing the reference count of src's underlying object) or with NULL otherwise.
| dstp | Pointer to a pointer that is either NULL or points to an object managed via this API. |
| src | A pointer to an object managed via this API or NULL. |
Definition at line 161 of file refstruct.c.
Referenced by aps_decode_alf(), aps_decode_scaling(), av1_frame_replace(), av1_receive_frame_internal(), cbs_av1_read_unit(), cbs_h266_replace_ph(), cbs_h266_replace_ps(), copy_oc(), decode_frame_ps(), decode_ph(), decode_slice(), ff_decode_internal_sync(), ff_dovi_ctx_replace(), ff_h2645_sei_ctx_replace(), ff_h264_update_thread_context(), ff_mpv_replace_picture(), ff_mpv_workpic_from_pic(), ff_sws_pass_link_output(), ff_thread_replace_frame(), ff_thread_sync_ref(), ff_vk_update_thread_context(), ff_vvc_decode_aps(), ff_vvc_decode_sh(), frame_copy_props(), h264_copy_picture_params(), h264_field_start(), h264_init_ps(), hevc_frame_start(), hevc_ref_frame(), LCEVC_BLOCK_FUNC(), LCEVC_BLOCK_FUNC(), LCEVC_BLOCK_FUNC(), LCEVC_BLOCK_FUNC(), parse_nal_units(), pps_alloc(), ref_frame(), sps_alloc(), update_context_from_thread(), vp9_decode_frame(), and vp9_frame_replace().
| int av_refstruct_exclusive | ( | const void * | obj | ) |
Check whether the reference count of an object managed via this API is 1.
| obj | A pointer to an object managed via this API. |
Definition at line 175 of file refstruct.c.
Referenced by make_unit_writable().
|
static |
Definition at line 209 of file refstruct.c.
Referenced by av_buffer_pool_init2(), pool_return_entry(), and pool_unref().
|
static |
Definition at line 217 of file refstruct.c.
Referenced by pool_return_entry(), and refstruct_pool_uninit().
|
static |
Definition at line 226 of file refstruct.c.
Referenced by refstruct_pool_get_ext().
|
static |
Definition at line 251 of file refstruct.c.
Referenced by refstruct_pool_get_ext().
|
static |
Definition at line 258 of file refstruct.c.
Referenced by av_refstruct_pool_get().
| void * av_refstruct_pool_get | ( | AVRefStructPool * | pool | ) |
Get an object from the pool, reusing an old one from the pool when available.
Every call to this function must happen before av_refstruct_pool_uninit(). Otherwise undefined behaviour may occur.
| pool | the pool from which to get the object |
Definition at line 315 of file refstruct.c.
Referenced by alloc_and_insert_node(), alloc_cu(), alloc_frame(), alloc_frame(), alloc_picture(), alloc_picture(), alloc_tu(), av_container_fifo_write(), ff_attach_decode_data(), ff_nvdec_start_frame(), ff_nvdec_start_frame_sep_ref(), ff_progress_frame_alloc(), ff_vk_decode_init(), ff_vk_decode_prepare_frame(), ff_vk_get_pooled_buffer(), ff_vk_imageviews_alloc(), load_input_picture(), vaapi_encode_issue(), vp9_frame_alloc(), vulkan_encode_create_dpb(), vulkan_encode_get_recon_frame(), and wavpack_decode_block().
|
static |
Hint: The content of pool_unref() and refstruct_pool_uninit() could currently be merged; they are only separate functions in case we would ever introduce weak references.
Definition at line 327 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext_c().
|
static |
Definition at line 334 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext_c().
| AVRefStructPool * av_refstruct_pool_alloc | ( | size_t | size, |
| unsigned | flags ) |
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
Definition at line 353 of file refstruct.c.
Referenced by dts2pts_init(), frame_context_init(), h264_init_context(), init_table_pools(), pic_arrays_init(), pic_arrays_init(), and vp9_frame_alloc().
| AVRefStructPool * av_refstruct_pool_alloc_ext_c | ( | size_t | size, |
| unsigned | flags, | ||
| AVRefStructOpaque | opaque, | ||
| int(* | init_cb )(AVRefStructOpaque opaque, void *obj), | ||
| void(* | reset_cb )(AVRefStructOpaque opaque, void *obj), | ||
| void(* | free_entry_cb )(AVRefStructOpaque opaque, void *obj), | ||
| void(* | free_cb )(AVRefStructOpaque opaque) ) |
Allocate an AVRefStructPool, potentially using complex callbacks.
| size | size of the entries of the pool |
| flags | a bitwise combination of AV_REFSTRUCT_POOL_FLAG_* flags |
| opaque | A pointer that will be passed to the callbacks below. |
| init | A callback that will be called directly after a new entry has been allocated. obj has already been zeroed unless the AV_REFSTRUCT_POOL_FLAG_NO_ZEROING flag is in use. |
| reset | A callback that will be called after an entry has been returned to the pool and before it is reused. |
| free_entry | A callback that will be called when an entry is freed after the pool has been marked as to be uninitialized. |
| free | A callback that will be called when the pool itself is freed (after the last entry has been returned and freed). |
Definition at line 358 of file refstruct.c.
Referenced by av_refstruct_pool_alloc_ext().