AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers. More...
AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers.
Frequently allocating and freeing large buffers may be slow. AVBufferPool is meant to solve this in cases when the caller needs a set of buffers of the same size (the most obvious use case being buffers for raw video or audio frames).
At the beginning, the user must call av_buffer_pool_init() to create the buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to get a reference to a new buffer, similar to av_buffer_alloc(). This new reference works in all aspects the same way as the one created by av_buffer_alloc(). However, when the last reference to this buffer is unreferenced, it is returned to the pool instead of being freed and will be reused for subsequent av_buffer_pool_get() calls.
When the caller is done with the pool and no longer needs to allocate any new buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable. Once all the buffers are released, it will automatically be freed.
Allocating and releasing buffers with this API is thread-safe as long as either the default alloc callback is used, or the user-supplied one is thread-safe.
Allocate and initialize a buffer pool.
Definition at line 217 of file buffer.c.
Referenced by ff_video_frame_pool_init(), init_table_pools(), pic_arrays_init(), and update_frame_pool().
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.
Definition at line 250 of file buffer.c.
Referenced by avcodec_close(), ff_h264_free_tables(), ff_video_frame_pool_uninit(), init_table_pools(), pic_arrays_free(), and update_frame_pool().
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
This function may be called simultaneously from multiple threads.
Definition at line 355 of file buffer.c.
Referenced by alloc_frame(), alloc_picture(), audio_get_buffer(), ff_video_frame_pool_get(), and video_get_buffer().