FFmpeg
libavutil
buffer_internal.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
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
28
/**
29
* The buffer was av_realloc()ed, so it is reallocatable.
30
*/
31
#define BUFFER_FLAG_REALLOCATABLE (1 << 0)
32
33
struct
AVBuffer
{
34
uint8_t
*
data
;
/**< data described by this buffer */
35
int
size
;
/**< size of data in bytes */
36
37
/**
38
* number of existing AVBufferRef instances referring to this buffer
39
*/
40
atomic_uint
refcount
;
41
42
/**
43
* a callback for freeing the data
44
*/
45
void (*
free
)(
void
*
opaque
,
uint8_t
*
data
);
46
47
/**
48
* an opaque pointer, to be used by the freeing callback
49
*/
50
void
*
opaque
;
51
52
/**
53
* A combination of AV_BUFFER_FLAG_*
54
*/
55
int
flags
;
56
57
/**
58
* A combination of BUFFER_FLAG_*
59
*/
60
int
flags_internal
;
61
};
62
63
typedef
struct
BufferPoolEntry
{
64
uint8_t
*
data
;
65
66
/*
67
* Backups of the original opaque/free of the AVBuffer corresponding to
68
* data. They will be used to free the buffer when the pool is freed.
69
*/
70
void
*
opaque
;
71
void (*
free
)(
void
*
opaque
,
uint8_t
*
data
);
72
73
AVBufferPool
*
pool
;
74
struct
BufferPoolEntry
*
next
;
75
}
BufferPoolEntry
;
76
77
struct
AVBufferPool
{
78
AVMutex
mutex
;
79
BufferPoolEntry
*
pool
;
80
81
/*
82
* This is used to track when the pool is to be freed.
83
* The pointer to the pool itself held by the caller is considered to
84
* be one reference. Each buffer requested by the caller increases refcount
85
* by one, returning the buffer to the pool decreases it by one.
86
* refcount reaches zero when the buffer has been uninited AND all the
87
* buffers have been released, then it's safe to free the pool and all
88
* the buffers in it.
89
*/
90
atomic_uint
refcount
;
91
92
int
size
;
93
void
*
opaque
;
94
AVBufferRef
* (*alloc)(
int
size
);
95
AVBufferRef
* (*alloc2)(
void
*
opaque
,
int
size
);
96
void (*
pool_free
)(
void
*
opaque
);
97
};
98
99
#endif
/* AVUTIL_BUFFER_INTERNAL_H */
AVBufferPool::mutex
AVMutex mutex
Definition:
buffer_internal.h:78
AVBufferPool
The buffer pool.
Definition:
buffer_internal.h:77
thread.h
BufferPoolEntry::data
uint8_t * data
Definition:
buffer_internal.h:64
AVBufferPool::size
int size
Definition:
buffer_internal.h:92
AVBufferPool::refcount
atomic_uint refcount
Definition:
buffer_internal.h:90
AVBuffer::flags
int flags
A combination of AV_BUFFER_FLAG_*.
Definition:
buffer_internal.h:55
AVBufferPool::opaque
void * opaque
Definition:
buffer_internal.h:93
AVMutex
#define AVMutex
Definition:
thread.h:164
BufferPoolEntry::pool
AVBufferPool * pool
Definition:
buffer_internal.h:73
AVBuffer::free
void(* free)(void *opaque, uint8_t *data)
a callback for freeing the data
Definition:
buffer_internal.h:45
AVBuffer::flags_internal
int flags_internal
A combination of BUFFER_FLAG_*.
Definition:
buffer_internal.h:60
AVBuffer::opaque
void * opaque
an opaque pointer, to be used by the freeing callback
Definition:
buffer_internal.h:50
AVBufferPool::pool_free
void(* pool_free)(void *opaque)
Definition:
buffer_internal.h:96
AVBuffer::data
uint8_t * data
data described by this buffer
Definition:
buffer_internal.h:34
BufferPoolEntry::free
void(* free)(void *opaque, uint8_t *data)
Definition:
buffer_internal.h:71
AVBuffer::size
int size
size of data in bytes
Definition:
buffer_internal.h:35
BufferPoolEntry
Definition:
buffer_internal.h:63
buffer.h
BufferPoolEntry::opaque
void * opaque
Definition:
buffer_internal.h:70
AVBuffer
A reference counted buffer type.
Definition:
buffer_internal.h:33
AVBufferPool::pool
BufferPoolEntry * pool
Definition:
buffer_internal.h:79
uint8_t
uint8_t
Definition:
audio_convert.c:194
BufferPoolEntry::next
struct BufferPoolEntry * next
Definition:
buffer_internal.h:74
atomic_uint
intptr_t atomic_uint
Definition:
stdatomic.h:56
AVBufferRef
A reference to a data buffer.
Definition:
buffer.h:81
AVBuffer::refcount
atomic_uint refcount
number of existing AVBufferRef instances referring to this buffer
Definition:
buffer_internal.h:40
Generated on Wed Aug 24 2022 21:32:06 for FFmpeg by
1.8.17