29 void (*free)(
void *opaque,
uint8_t *data),
30 void *opaque,
int flags)
88 memset(ret->
data, 0, size);
190 }
else if (buf->
size == size)
254 if (!ppool || !*ppool)
269 while (cur != last) {
293 cur = get_pool(pool);
306 if(CONFIG_MEMORY_POISONING)
362 buf = get_pool(pool);
366 buf = get_pool(pool);
373 add_to_pool(buf->
next);
void(* free)(void *opaque, uint8_t *data)
a callback for freeing the data
int av_buffer_make_writable(AVBufferRef **pbuf)
Create a writable reference from a given buffer reference, avoiding data copy if possible.
#define avpriv_atomic_int_add_and_fetch
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
ptrdiff_t const GLvoid * data
memory handling functions
#define ff_mutex_unlock(mutex)
#define BUFFER_FLAG_READONLY
The buffer is always treated as read-only.
struct BufferPoolEntry * next
volatile int refcount
number of existing AVBufferRef instances referring to this buffer
static AVBufferRef * pool_alloc_buffer(AVBufferPool *pool)
uint8_t * data
data described by this buffer
static av_cold int end(AVCodecContext *avctx)
#define avpriv_atomic_int_set
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
#define avpriv_atomic_ptr_cas
#define avpriv_atomic_int_get
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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.
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
#define ff_mutex_destroy(mutex)
int av_buffer_is_writable(const AVBufferRef *buf)
#define ff_mutex_lock(mutex)
void(* free)(void *opaque, uint8_t *data)
int flags
A combination of BUFFER_FLAG_*.
#define ff_mutex_init(mutex, attr)
static void pool_release_buffer(void *opaque, uint8_t *data)
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
volatile int nb_allocated
uint8_t * data
The data buffer.
int av_buffer_get_ref_count(const AVBufferRef *buf)
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
void * av_buffer_get_opaque(const AVBufferRef *buf)
static void buffer_pool_free(AVBufferPool *pool)
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
static void buffer_replace(AVBufferRef **dst, AVBufferRef **src)
A reference counted buffer type.
int size
Size of data in bytes.
void * opaque
an opaque pointer, to be used by the freeing callback
A reference to a data buffer.
common internal and external API header
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
int size
size of data in bytes
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define BUFFER_FLAG_REALLOCATABLE
The buffer was av_realloc()ed, so it is reallocatable.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVBufferRef *(* alloc)(int size)