FFmpeg
buffer.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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
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 {
82  AVBuffer *buffer;
83 
89  uint8_t *data;
93  int size;
94 } AVBufferRef;
95 
102 
108 
113 #define AV_BUFFER_FLAG_READONLY (1 << 0)
114 
130 AVBufferRef *av_buffer_create(uint8_t *data, int size,
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 
168 void *av_buffer_get_opaque(const AVBufferRef *buf);
169 
170 int av_buffer_get_ref_count(const AVBufferRef *buf);
171 
182 
198 int av_buffer_realloc(AVBufferRef **buf, int size);
199 
238 typedef struct AVBufferPool AVBufferPool;
239 
249 AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
250 
265 AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
266  AVBufferRef* (*alloc)(void *opaque, int size),
267  void (*pool_free)(void *opaque));
268 
278 
286 
291 #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:151
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:125
struct AVBufferRef AVBufferRef
A reference to a data buffer.
Definition: buffer_internal.h:76
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
Definition: buffer.c:62
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:28
int av_buffer_realloc(AVBufferRef **buf, int size)
Reallocate a given buffer.
Definition: buffer.c:169
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:133
AVBufferPool * av_buffer_pool_init2(int size, void *opaque, AVBufferRef *(*alloc)(void *opaque, int size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
Definition: buffer.c:218
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:67
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:83
void * av_buffer_get_opaque(const AVBufferRef *buf)
Definition: buffer.c:141
void av_buffer_pool_uninit(AVBufferPool **pool)
Mark the pool as being available for freeing.
Definition: buffer.c:275
Definition: buffer_internal.h:37
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:238
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:334