]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/buffer.h
buffer: add support for pools using caller data in allocation
[ffmpeg] / libavutil / buffer.h
index e348c6e019f26bfed968bc9cdf4caadb89821603..7fc18e09bfdea53ce3bd060a9b3c8371f8c03847 100644 (file)
@@ -121,7 +121,7 @@ AVBufferRef *av_buffer_allocz(int size);
  * If this function fails, data is left untouched.
  * @param data   data array
  * @param size   size of data in bytes
- * @param free   a callback for freeing data
+ * @param free   a callback for freeing this buffer's data
  * @param opaque parameter to be passed to free
  * @param flags  a combination of AV_BUFFER_FLAG_*
  *
@@ -241,6 +241,23 @@ typedef struct AVBufferPool AVBufferPool;
  */
 AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
 
+/**
+ * Allocate and initialize a buffer pool with a more complex allocator.
+ *
+ * @param size size of each buffer in this pool
+ * @param opaque arbitrary user data used by the allocator
+ * @param alloc a function that will be used to allocate new buffers when the
+ *              pool is empty.
+ * @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.
+ * @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