Go to the documentation of this file.
53 printf(
"Testing av_buffer_alloc()\n");
56 printf(
"alloc: size=%zu data=%s\n", buf->
size, buf->
data ?
"set" :
"null");
60 printf(
"after unref: %s\n", buf ==
NULL ?
"null" :
"leaked");
64 printf(
"\nTesting av_buffer_allocz()\n");
68 for (
int i = 0;
i < 16;
i++)
69 if (buf->
data[
i] != 0) zeroed = 0;
70 printf(
"allocz: zeroed=%s\n", zeroed ?
"yes" :
"no");
75 printf(
"\nTesting av_buffer_create()\n");
86 printf(
"custom_free called: %s\n",
95 printf(
"\nTesting AV_BUFFER_FLAG_READONLY\n");
111 printf(
"\nTesting av_buffer_ref()\n");
118 printf(
"shared data: %s\n",
119 buf2->
data[0] == 0xAB ?
"yes" :
"no");
129 printf(
"\nTesting av_buffer_make_writable()\n");
136 printf(
"make_writable ret: %d\n",
ret >= 0);
137 printf(
"data preserved: %s\n",
138 buf2->
data[0] == 0xCD ?
"yes" :
"no");
140 printf(
"original still valid: %s\n",
141 buf->
data[0] == 0xCD ?
"yes" :
"no");
148 printf(
"\nTesting av_buffer_realloc()\n");
151 memset(buf->
data, 0xEF, 16);
155 printf(
"data preserved: %s\n",
156 buf->
data[0] == 0xEF ?
"yes" :
"no");
163 printf(
"realloc from null: %s\n", buf ?
"OK" :
"FAIL");
167 printf(
"\nTesting av_buffer_replace()\n");
172 buf2->
data[0] = 0x22;
174 printf(
"replace: data=0x%02x\n", buf->
data[0]);
184 printf(
"replace with null: %s\n", buf ==
NULL ?
"OK" :
"FAIL");
188 printf(
"\nTesting av_buffer_pool()\n");
203 printf(
"pool uninit: %s\n", pool ==
NULL ?
"OK" :
"FAIL");
207 printf(
"\nTesting av_buffer_pool_init2()\n");
216 printf(
"pool_buffer_get_opaque: %s\n",
225 printf(
"\nTesting OOM paths\n");
228 printf(
"alloc OOM: %s\n", buf ?
"FAIL" :
"OK");
231 printf(
"allocz OOM: %s\n", buf ?
"FAIL" :
"OK");
234 printf(
"pool init OOM: %s\n", pool ?
"FAIL" :
"OK");
242 printf(
"ref OOM: %s\n", buf2 ?
"FAIL" :
"OK");
244 printf(
"realloc OOM: %s\n",
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
static int pool_free_called
__device__ int printf(const char *,...)
static void pool_free_cb(void *opaque)
uint8_t * data
The data buffer.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_max_alloc(size_t max)
Set the maximum size that may be allocated in one block.
AVBufferPool * av_buffer_pool_init2(size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
static int pool_alloc2_called
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define i(width, name, range_min, range_max)
int av_buffer_make_writable(AVBufferRef **pbuf)
Create a writable reference from a given buffer reference, avoiding data copy if possible.
int av_buffer_get_ref_count(const AVBufferRef *buf)
void * av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref)
Query the original opaque parameter of an allocated buffer in the pool.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
size_t size
Size of data in bytes.
static void custom_free(void *opaque, uint8_t *data)
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
int av_buffer_is_writable(const AVBufferRef *buf)
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
void * av_buffer_get_opaque(const AVBufferRef *buf)
A reference to a data buffer.
static int custom_free_called
static AVBufferRef * pool_alloc2(void *opaque, size_t size)