summaryrefslogtreecommitdiff
path: root/libavutil/buffer_internal.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-01-20 08:03:13 +0100
committerAnton Khirnov <anton@khirnov.net>2013-03-08 07:33:28 +0100
commit1cec0624d0e6f48590283a57169b58b9fe8449d3 (patch)
tree47cf0e154245654e523e9b29cda8f77fb89f9090 /libavutil/buffer_internal.h
parent8e401dbe90cc77b1f3067a917d9fa48cefa3fcdb (diff)
AVBuffer: add a new API for buffer pools
Diffstat (limited to 'libavutil/buffer_internal.h')
-rw-r--r--libavutil/buffer_internal.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h
index 677c341d64..cce83c3cd1 100644
--- a/libavutil/buffer_internal.h
+++ b/libavutil/buffer_internal.h
@@ -57,4 +57,36 @@ struct AVBuffer {
int flags;
};
+typedef struct BufferPoolEntry {
+ uint8_t *data;
+
+ /*
+ * Backups of the original opaque/free of the AVBuffer corresponding to
+ * data. They will be used to free the buffer when the pool is freed.
+ */
+ void *opaque;
+ void (*free)(void *opaque, uint8_t *data);
+
+ AVBufferPool *pool;
+ struct BufferPoolEntry * volatile next;
+} BufferPoolEntry;
+
+struct AVBufferPool {
+ BufferPoolEntry * volatile pool;
+
+ /*
+ * This is used to track when the pool is to be freed.
+ * The pointer to the pool itself held by the caller is considered to
+ * be one reference. Each buffer requested by the caller increases refcount
+ * by one, returning the buffer to the pool decreases it by one.
+ * refcount reaches zero when the buffer has been uninited AND all the
+ * buffers have been released, then it's safe to free the pool and all
+ * the buffers in it.
+ */
+ volatile int refcount;
+
+ int size;
+ AVBufferRef* (*alloc)(int size);
+};
+
#endif /* AVUTIL_BUFFER_INTERNAL_H */