FFmpeg
|
#include <stdatomic.h>
#include <stdint.h>
#include <string.h>
#include "internal.h"
#include "refstruct.h"
#include "libavutil/avassert.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
Go to the source code of this file.
Data Structures | |
struct | RefCount |
Macros | |
#define | ASSERT_LEVEL 0 |
#define | REFSTRUCT_CHECKED (ASSERT_LEVEL >= 1) |
#define | ff_assert(cond) ((void)0) |
#define | REFSTRUCT_COOKIE |
#define | REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX(STRIDE_ALIGN, 16)) |
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, FFRefStructOpaque opaque, void(*free_cb)(FFRefStructOpaque opaque, void *obj)) |
void * | ff_refstruct_alloc_ext_c (size_t size, unsigned flags, FFRefStructOpaque opaque, void(*free_cb)(FFRefStructOpaque opaque, void *obj)) |
Allocate a refcounted object of usable size size managed via the RefStruct API. More... | |
void | ff_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. More... | |
void * | ff_refstruct_ref (void *obj) |
Create a new reference to an object managed via this API, i.e. More... | |
const void * | ff_refstruct_ref_c (const void *obj) |
Analog of ff_refstruct_ref(), but for constant objects. More... | |
void | ff_refstruct_replace (void *dstp, const void *src) |
Ensure *dstp refers to the same object as src. More... | |
int | ff_refstruct_exclusive (const void *obj) |
Check whether the reference count of an object managed via this API is 1. More... | |
#define ASSERT_LEVEL 0 |
Definition at line 32 of file refstruct.c.
#define REFSTRUCT_CHECKED (ASSERT_LEVEL >= 1) |
Definition at line 34 of file refstruct.c.
#define ff_assert | ( | cond | ) | ((void)0) |
Definition at line 40 of file refstruct.c.
#define REFSTRUCT_COOKIE |
#define REFCOUNT_OFFSET FFALIGN(sizeof(RefCount), FFMAX(STRIDE_ALIGN, 16)) |
Definition at line 49 of file refstruct.c.
|
static |
Definition at line 67 of file refstruct.c.
Referenced by ff_refstruct_ref(), ff_refstruct_ref_c(), and ff_refstruct_unref().
|
static |
Definition at line 74 of file refstruct.c.
Referenced by ff_refstruct_exclusive().
|
static |
Definition at line 81 of file refstruct.c.
Referenced by ff_refstruct_alloc_ext_c().
|
static |
Definition at line 86 of file refstruct.c.
Referenced by ff_refstruct_alloc_ext_c().
void* ff_refstruct_alloc_ext_c | ( | size_t | size, |
unsigned | flags, | ||
FFRefStructOpaque | opaque, | ||
void(*)(FFRefStructOpaque opaque, void *obj) | free_cb | ||
) |
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 FF_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 98 of file refstruct.c.
Referenced by cbs_alloc_content(), and ff_refstruct_alloc_ext().
void ff_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 116 of file refstruct.c.
Referenced by av1_decode_free(), av1_frame_unref(), avcodec_close(), 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_read_fragment_content(), cbs_sei_delete_message(), cbs_unit_uninit(), ff_cbs_make_unit_writable(), ff_cbs_sei_free_message_list(), ff_dovi_ctx_flush(), ff_dovi_ctx_unref(), ff_frame_thread_free(), 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_mpeg_unref_picture(), ff_nvdec_decode_uninit(), ff_refstruct_replace(), ff_thread_get_ext_buffer(), ff_thread_release_ext_buffer(), ff_vk_decode_uninit(), nvdec_decoder_create(), nvdec_fdd_priv_free(), nvdec_unmap_mapped_frame(), pps_free(), remove_pps(), remove_sps(), remove_vps(), update_frame_pool(), vp8_alloc_frame(), vp8_release_frame(), vp9_frame_unref(), vulkan_decode_bootstrap(), wavpack_decode_end(), and wv_dsd_reset().
void* ff_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 136 of file refstruct.c.
Referenced by cbs_av1_write_obu(), ff_cbs_insert_unit_content(), ff_cbs_sei_add_message(), ff_nvdec_start_frame(), ff_thread_ref_frame(), get_current_frame(), and hevc_ref_frame().
const void* ff_refstruct_ref_c | ( | const void * | obj | ) |
Analog of ff_refstruct_ref(), but for constant objects.
Definition at line 145 of file refstruct.c.
Referenced by alloc_picture(), ff_h264_decode_picture_parameter_set(), and ff_refstruct_replace().
void ff_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 156 of file refstruct.c.
Referenced by av1_frame_ref(), av1_receive_frame_internal(), cbs_av1_read_unit(), cbs_h2645_replace_ps(), ff_dovi_ctx_replace(), ff_h264_ref_picture(), ff_h264_replace_picture(), ff_h264_update_thread_context(), ff_mpeg_ref_picture(), ff_thread_replace_frame(), ff_vk_update_thread_context(), h264_copy_picture_params(), h264_init_ps(), hevc_ref_frame(), parse_nal_units(), update_context_from_thread(), and vp9_frame_ref().
int ff_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 170 of file refstruct.c.
Referenced by ff_cbs_make_unit_writable().