diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 16:05:59 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-08 16:06:20 +0100 |
commit | 532f31a695c9530ce67a847be00d72e6e8acfd11 (patch) | |
tree | aa78d9b5840629c23ab2aaf94079930eca8e8c02 /libavutil/buffer_internal.h | |
parent | 36099df521b5e26403b3379f8ffafdfb7b9e96c7 (diff) | |
parent | 1cec0624d0e6f48590283a57169b58b9fe8449d3 (diff) | |
download | ffmpeg-532f31a695c9530ce67a847be00d72e6e8acfd11.tar.gz |
Merge commit '1cec0624d0e6f48590283a57169b58b9fe8449d3'
* commit '1cec0624d0e6f48590283a57169b58b9fe8449d3':
AVBuffer: add a new API for buffer pools
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/buffer_internal.h')
-rw-r--r-- | libavutil/buffer_internal.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libavutil/buffer_internal.h b/libavutil/buffer_internal.h index 7e33703e22..b2602f8809 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 */ |