2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef AVUTIL_BUFFER_INTERNAL_H
20 #define AVUTIL_BUFFER_INTERNAL_H
22 #include <stdatomic.h>
29 * The buffer was av_realloc()ed, so it is reallocatable.
31 #define BUFFER_FLAG_REALLOCATABLE (1 << 0)
34 uint8_t *data; /**< data described by this buffer */
35 int size; /**< size of data in bytes */
38 * number of existing AVBufferRef instances referring to this buffer
43 * a callback for freeing the data
45 void (*free)(void *opaque, uint8_t *data);
48 * an opaque pointer, to be used by the freeing callback
53 * A combination of AV_BUFFER_FLAG_*
58 * A combination of BUFFER_FLAG_*
63 typedef struct BufferPoolEntry {
67 * Backups of the original opaque/free of the AVBuffer corresponding to
68 * data. They will be used to free the buffer when the pool is freed.
71 void (*free)(void *opaque, uint8_t *data);
74 struct BufferPoolEntry *next;
79 BufferPoolEntry *pool;
82 * This is used to track when the pool is to be freed.
83 * The pointer to the pool itself held by the caller is considered to
84 * be one reference. Each buffer requested by the caller increases refcount
85 * by one, returning the buffer to the pool decreases it by one.
86 * refcount reaches zero when the buffer has been uninited AND all the
87 * buffers have been released, then it's safe to free the pool and all
94 AVBufferRef* (*alloc)(int size);
95 AVBufferRef* (*alloc2)(void *opaque, int size);
96 void (*pool_free)(void *opaque);
99 #endif /* AVUTIL_BUFFER_INTERNAL_H */