FFmpeg
libavutil
buffer_internal.h
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
19
#ifndef AVUTIL_BUFFER_INTERNAL_H
20
#define AVUTIL_BUFFER_INTERNAL_H
21
22
#include <stdatomic.h>
23
#include <stdint.h>
24
25
#include "
buffer.h
"
26
#include "thread.h"
27
31
#define BUFFER_FLAG_READONLY (1 << 0)
32
35
#define BUFFER_FLAG_REALLOCATABLE (1 << 1)
36
37
struct
AVBuffer
{
38
uint8_t *
data
;
39
int
size
;
44
atomic_uint
refcount
;
45
49
void (*
free
)(
void
*
opaque
, uint8_t *
data
);
50
54
void
*
opaque
;
55
59
int
flags
;
60
};
61
62
typedef
struct
BufferPoolEntry
{
63
uint8_t *
data
;
64
65
/*
66
* Backups of the original opaque/free of the AVBuffer corresponding to
67
* data. They will be used to free the buffer when the pool is freed.
68
*/
69
void
*
opaque
;
70
void (*
free
)(
void
*
opaque
, uint8_t *
data
);
71
72
AVBufferPool
*pool;
73
struct
BufferPoolEntry
*next;
74
}
BufferPoolEntry
;
75
76
struct
AVBufferPool
{
77
AVMutex mutex;
78
BufferPoolEntry
*pool;
79
80
/*
81
* This is used to track when the pool is to be freed.
82
* The pointer to the pool itself held by the caller is considered to
83
* be one reference. Each buffer requested by the caller increases refcount
84
* by one, returning the buffer to the pool decreases it by one.
85
* refcount reaches zero when the buffer has been uninited AND all the
86
* buffers have been released, then it's safe to free the pool and all
87
* the buffers in it.
88
*/
89
atomic_uint
refcount
;
90
91
int
size
;
92
void
*
opaque
;
93
AVBufferRef
* (*alloc)(
int
size
);
94
AVBufferRef
* (*alloc2)(
void
*
opaque
,
int
size
);
95
void (*pool_free)(
void
*
opaque
);
96
};
97
98
#endif
/* AVUTIL_BUFFER_INTERNAL_H */
AVBuffer::data
uint8_t * data
data described by this buffer
Definition:
buffer_internal.h:38
AVBuffer::refcount
atomic_uint refcount
number of existing AVBufferRef instances referring to this buffer
Definition:
buffer_internal.h:44
AVBufferPool
Definition:
buffer_internal.h:76
AVBuffer::flags
int flags
A combination of BUFFER_FLAG_*.
Definition:
buffer_internal.h:59
AVBuffer::free
void(* free)(void *opaque, uint8_t *data)
a callback for freeing the data
Definition:
buffer_internal.h:49
AVBuffer
Definition:
buffer_internal.h:37
buffer.h
refcounted data buffer API
BufferPoolEntry
Definition:
buffer_internal.h:62
AVBuffer::opaque
void * opaque
an opaque pointer, to be used by the freeing callback
Definition:
buffer_internal.h:54
AVBufferRef
A reference to a data buffer.
Definition:
buffer.h:81
AVBuffer::size
int size
size of data in bytes
Definition:
buffer_internal.h:39
Generated by
1.8.12