typedef struct AVBuffer AVBuffer;/*** A reference to a data buffer.** The size of this struct is not a part of the public ABI and it is not meant* to be allocated directly.*/ typedef struct AVBufferRef {AVBuffer *buffer;/*** The data buffer. It is considered writable if and only if* this is the only reference to the buffer, in which case* av_buffer_is_writable() returns 1.*/uint8_t *data;/*** Size of data in bytes.*/int size; } AVBufferRef;/*** Allocate an AVBuffer of the given size using av_malloc().** &#64;return an AVBufferRef of given size or NULL when out of memory*/ AVBufferRef *av_buffer_alloc(int size);/*** Same as av_buffer_alloc(), except the returned buffer will be initialized* to zero.*/ AVBufferRef *av_buffer_allocz(int size);/*** Always treat the buffer as read-only, even when it has only one* reference.*/ #define AV_BUFFER_FLAG_READONLY (1 <<0)/*** 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.* &#64;param data data array* &#64;param size size of data in bytes* &#64;param free a callback for freeing this buffer&#39;s data* &#64;param opaque parameter to be got for processing or passed to free* &#64;param flags a combination of AV_BUFFER_FLAG_*** &#64;return an AVBufferRef referring to data on success, NULL on failure.*/ AVBufferRef *av_buffer_create(uint8_t *data, int size,void (*free)(void *opaque, uint8_t *data),void *opaque, int flags);/*** 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.*/ void av_buffer_default_free(void *opaque, uint8_t *data);/*** Create a new reference to an AVBuffer.** &#64;return a new AVBufferRef referring to the same AVBuffer as buf or NULL on* failure.*/ AVBufferRef *av_buffer_ref(AVBufferRef *buf);/*** Free a given reference and automatically free the buffer if there are no more* references to it.** &#64;param buf the reference to be freed. The pointer is set to NULL on return.*/ void av_buffer_unref(AVBufferRef **buf);/*** &#64;return 1 if the caller may write to the data referred to by buf (which is* true if and only if buf is the only reference to the underlying AVBuffer).* Return 0 otherwise.* A positive answer is valid until av_buffer_ref() is called on buf.*/ int av_buffer_is_writable(const AVBufferRef *buf);/*** &#64;return the opaque parameter set by av_buffer_create.*/ void *av_buffer_get_opaque(const AVBufferRef *buf);int av_buffer_get_ref_count(const AVBufferRef *buf);/*** Create a writable reference from a given buffer reference, avoiding data copy* if possible.** &#64;param 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.* &#64;return 0 on success, a negative AVERROR on failure.*/ int av_buffer_make_writable(AVBufferRef **buf);/*** Reallocate a given buffer.** &#64;param 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.* &#64;param size required new buffer size.* &#64;return 0 on success, a negative AVERROR on failure.** &#64;note the buffer is actually reallocated with av_realloc() only if it was* initially allocated through av_buffer_realloc(NULL) and there is only one* reference to it (i.e. the one passed to this function). In all other cases* a new buffer is allocated and the data is copied.*/ int av_buffer_realloc(AVBufferRef **buf, int size);/*** &#64;}*/typedef struct AVBufferPool AVBufferPool;/*** Allocate and initialize a buffer pool.** &#64;param size size of each buffer in this pool* &#64;param alloc a function that will be used to allocate new buffers when the* pool is empty. May be NULL, then the default allocator will be used* (av_buffer_alloc()).* &#64;return newly created buffer pool on success, NULL on error.*/ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));/*** Allocate and initialize a buffer pool with a more complex allocator.** &#64;param size size of each buffer in this pool* &#64;param opaque arbitrary user data used by the allocator* &#64;param alloc a function that will be used to allocate new buffers when the* pool is empty.* &#64;param pool_free a function that will be called immediately before the pool* is freed. I.e. after av_buffer_pool_can_uninit() is called* by the pool and all the frames are returned to the pool and* freed. It is intended to uninitialize the user opaque data.* &#64;return newly created buffer pool on success, NULL on error.*/ AVBufferPool *av_buffer_pool_init2(int size, void *opaque,AVBufferRef* (*alloc)(void *opaque, int size),void (*pool_free)(void *opaque));/*** Mark the pool as being available for freeing. It will actually be freed only* once all the allocated buffers associated with the pool are released. Thus it* is safe to call this function while some of the allocated buffers are still* in use.** &#64;param pool pointer to the pool to be freed. It will be set to NULL.*/ void av_buffer_pool_uninit(AVBufferPool **pool);/*** Allocate a new AVBuffer, reusing an old buffer from the pool when available.* This function may be called simultaneously from multiple threads.** &#64;return a reference to the new buffer on success, NULL on error.*/ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);/*** &#64;}*/#endif /* AVUTIL_BUFFER_H */