lavu: add a new API for reference-counted data buffers.
[libav.git] / libavutil / buffer_internal.h
1 /*
2 * This file is part of Libav.
3 *
4 * Libav 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.
8 *
9 * Libav 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.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVUTIL_BUFFER_INTERNAL_H
20 #define AVUTIL_BUFFER_INTERNAL_H
21
22 #include <stdint.h>
23
24 #include "buffer.h"
25
26 /**
27 * The buffer is always treated as read-only.
28 */
29 #define BUFFER_FLAG_READONLY (1 << 0)
30 /**
31 * The buffer was av_realloc()ed, so it is reallocatable.
32 */
33 #define BUFFER_FLAG_REALLOCATABLE (1 << 1)
34
35 struct AVBuffer {
36 uint8_t *data; /**< data described by this buffer */
37 int size; /**< size of data in bytes */
38
39 /**
40 * number of existing AVBufferRef instances referring to this buffer
41 */
42 volatile int refcount;
43
44 /**
45 * a callback for freeing the data
46 */
47 void (*free)(void *opaque, uint8_t *data);
48
49 /**
50 * an opaque pointer, to be used by the freeing callback
51 */
52 void *opaque;
53
54 /**
55 * A combination of BUFFER_FLAG_*
56 */
57 int flags;
58 };
59
60 #endif /* AVUTIL_BUFFER_INTERNAL_H */