Libav
buffer.h
Go to the documentation of this file.
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 
25 #ifndef AVUTIL_BUFFER_H
26 #define AVUTIL_BUFFER_H
27 
28 #include <stdint.h>
29 
73 typedef struct AVBuffer AVBuffer;
74 
81 typedef struct AVBufferRef {
83 
93  int size;
94 } AVBufferRef;
95 
102 
108 
113 #define AV_BUFFER_FLAG_READONLY (1 << 0)
114 
131  void (*free)(void *opaque, uint8_t *data),
132  void *opaque, int flags);
133 
139 void av_buffer_default_free(void *opaque, uint8_t *data);
140 
148 
155 void av_buffer_unref(AVBufferRef **buf);
156 
163 int av_buffer_is_writable(const AVBufferRef *buf);
164 
175 
191 int av_buffer_realloc(AVBufferRef **buf, int size);
192 
231 typedef struct AVBufferPool AVBufferPool;
232 
242 AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
243 
254 
262 
267 #endif /* AVUTIL_BUFFER_H */
int av_buffer_make_writable(AVBufferRef **buf)
Create a writable reference from a given buffer reference, avoiding data copy if possible.
Definition: buffer.c:128
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:105
int size
BufferPoolEntry *volatile pool
uint8_t
const char data[16]
Definition: mxf.c:66
static int flags
Definition: log.c:44
The buffer pool.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
Definition: buffer.c:60
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:27
int av_buffer_realloc(AVBufferRef **buf, int size)
Reallocate a given buffer.
Definition: buffer.c:146
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:120
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:65
uint8_t * data
The data buffer.
Definition: buffer.h:89
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:81
AVBuffer * buffer
Definition: buffer.h:82
void av_buffer_pool_uninit(AVBufferPool **pool)
Mark the pool as being available for freeing.
Definition: buffer.c:226
A reference counted buffer type.
int size
Size of data in bytes.
Definition: buffer.h:93
A reference to a data buffer.
Definition: buffer.h:81
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
Definition: buffer.c:196
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:91
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:314
AVBufferRef *(* alloc)(int size)