IC4_BUFFER_POOL Struct Reference

The buffer pool allows allocating additional image buffers for use by the program. More...

Detailed Description

The buffer pool allows allocating additional image buffers for use by the program.

This type is opaque, programs only use pointers of type IC4_BUFFER_POOL*.

Most programs will only use image buffers provided by one of the sink types. However, some programs require additional buffers, for example to use as destination for image processing.

To create additional buffers, first create a buffer pool using ic4_bufferpool_create(). Then, use ic4_bufferpool_get_buffer() to create a new image buffer with a specified image type. Allocation options can be specified to customizer image buffer's memory alignment, pitch and total buffer size.

When the image buffer is no longer required, call ic4_imagebuffer_unref on it. The buffer will then be returned to the buffer pool.

The buffer pool has configurable caching behavior. By default, the buffer pool will cache one image buffer and return it the next time a matching image buffer is requested.

Buffer pool objects are reference-counted, and created with an initial reference count of one. To share a buffer pool object between multiple parts of a program, create a new reference by calling ic4_bufferpool_ref(). When a reference is no longer required, call ic4_bufferpool_unref().

If the buffer pool object's internal reference count reaches zero, the buffer pool object is destroyed. Even after that, image buffers created by the buffer pool are still valid until they are released by calling ic4_imagebuffer_unref.