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 280 of file buffer.c.
Referenced by buffer_pool_get(), ff_frame_pool_audio_init(), ff_frame_pool_video_init(), get_frame_buffer(), get_output_ref(), init_table_pools(), libdav1d_picture_allocator(), nvdec_init_hwframes(), pic_arrays_init(), qsv_decode_init_context(), update_frame_pool(), and vp9_frame_alloc().
Allocate and initialize a buffer pool with a more complex allocator.
Definition at line 259 of file buffer.c.
Referenced by create_stream(), cuda_frames_init(), d3d11va_frames_init(), dxva2_init_pool(), ff_nvdec_decode_init(), ff_vaapi_encode_init(), opencl_frames_init(), qsv_init_pool(), vaapi_frames_init(), vdpau_frames_init(), vt_frames_init(), and vulkan_frames_init().
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 322 of file buffer.c.
Referenced by eb_enc_close(), ff_frame_pool_uninit(), ff_h264_free_tables(), ff_nvdec_decode_uninit(), ff_vaapi_encode_close(), frame_pool_free(), get_frame_buffer(), get_output_ref(), hwframe_ctx_free(), init_table_pools(), libdav1d_close(), libdav1d_picture_allocator(), mpegts_free(), nvdec_free_dummy(), pic_arrays_free(), qsv_decode_close_qsvcontext(), vp9_decode_free(), vp9_frame_alloc(), vpx_free(), and xcbgrab_read_close().
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 387 of file buffer.c.
Referenced by alloc_frame(), alloc_picture(), audio_get_buffer(), buffer_pool_get(), cuda_get_buffer(), d3d11va_get_buffer(), drm_get_buffer(), dxva2_get_buffer(), ff_frame_pool_get(), ff_nvdec_start_frame(), ff_nvdec_start_frame_sep_ref(), get_frame_buffer(), get_output_ref(), libdav1d_picture_allocator(), opencl_get_buffer(), qsv_get_buffer(), qsv_get_continuous_buffer(), vaapi_encode_issue(), vaapi_frames_init(), vaapi_get_buffer(), vdpau_get_buffer(), video_get_buffer(), vp9_frame_alloc(), vt_get_buffer(), and vulkan_get_buffer().
Query the original opaque parameter of an allocated buffer in the pool.