FFmpeg 8.1
Loading...
Searching...
No Matches
AVRefStructOpaque Union Reference

RefStruct is an API for creating reference-counted objects with minimal overhead. More...

#include <libavutil/refstruct.h>

Data Fields

void * nc
const void * c

Detailed Description

RefStruct is an API for creating reference-counted objects with minimal overhead.

The API is designed for objects, not buffers like the AVBuffer API. The main differences to the AVBuffer API are as follows:

  • It uses void* instead of uint8_t* as its base type due to its focus on objects.
  • There are no equivalents of AVBuffer and AVBufferRef. E.g. there is no way to get the usable size of the object: The user is supposed to know what is at the other end of the pointer. It also avoids one level of indirection.
  • Custom allocators are not supported. This allows to simplify the implementation and reduce the amount of allocations.
  • It also has the advantage that the user's free callback need only free the resources owned by the object, but not the object itself.
  • Because referencing (and replacing) an object managed by the RefStruct API does not involve allocations, they can not fail and therefore need not be checked.
Note
Referencing and unreferencing the buffers is thread-safe and thus may be done from multiple threads simultaneously without any need for additional locking. This union is used for all opaque parameters in this API to spare the user to cast const away in case the opaque to use is const-qualified.

The functions provided by this API with an AVRefStructOpaque come in pairs named foo_c and foo. The foo function accepts void* as opaque and is just a wrapper around the foo_c function; "_c" means "(potentially) const".

Definition at line 58 of file refstruct.h.

Field Documentation

◆ nc

void* AVRefStructOpaque::nc

Definition at line 59 of file refstruct.h.

◆ c

const void* AVRefStructOpaque::c

Definition at line 60 of file refstruct.h.


The documentation for this union was generated from the following file: