AVBuffer: add a new API for buffer pools
This commit is contained in:
parent
8e401dbe90
commit
1cec0624d0
3 changed files with 245 additions and 0 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue