FFmpeg
container_fifo.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 AVCODEC_CONTAINER_FIFO_H
20 #define AVCODEC_CONTAINER_FIFO_H
21 
22 #include <stddef.h>
23 
24 /**
25  * ContainerFifo is a FIFO for "containers" - dynamically allocated reusable
26  * structs (e.g. AVFrame or AVPacket). ContainerFifo uses an internal pool of
27  * such containers to avoid allocating and freeing them repeatedly.
28  */
29 typedef struct ContainerFifo ContainerFifo;
30 
31 /**
32  * Allocate a new ContainerFifo for the container type defined by provided
33  * callbacks.
34  *
35  * @param container_alloc allocate a new container instance and return a pointer
36  * to it, or NULL on failure
37  * @param container_reset reset the provided container instance to a clean state
38  * @param container_free free the provided container instance
39  * @param fifo_write transfer the contents of src to dst, where src is a
40  * container instance provided to ff_container_fifo_write()
41  * @param fifo_read transfer the contents of src to dst in other cases
42  *
43  * @note fifo_read() and fifo_write() are different parameters in order to allow
44  * fifo_write() implementations that make a new reference in dst, leaving
45  * src untouched (see e.g. ff_container_fifo_alloc_avframe())
46  */
49  void (*container_reset)(void *obj),
50  void (*container_free) (void *obj),
51  int (*fifo_write) (void *dst, void *src),
52  int (*fifo_read) (void *dst, void *src));
53 
54 /**
55  * Allocate a ContainerFifo instance for AVFrames.
56  * Note that ff_container_fifo_write() will call av_frame_ref() on src, making a
57  * new reference in dst and leaving src untouched.
58  *
59  * @param flags unused currently
60  */
62 
63 /**
64  * Free a ContainerFifo and everything in it.
65  */
67 
68 /**
69  * Write the contents of obj to the FIFO.
70  *
71  * The fifo_write() callback previously provided to ff_container_fifo_alloc()
72  * will be called with obj as src in order to perform the actual transfer.
73  */
74 int ff_container_fifo_write(ContainerFifo *pf, void *obj);
75 
76 /**
77  * Read the next available object from the FIFO into obj.
78  *
79  * The fifo_read() callback previously provided to ff_container_fifo_alloc()
80  * will be called with obj as dst in order to perform the actual transfer.
81  */
82 int ff_container_fifo_read(ContainerFifo *pf, void *obj);
83 
84 /**
85  * @return number of objects available for reading
86  */
88 
89 #endif // AVCODEC_CONTAINER_FIFO_H
ContainerFifo::container_free
void(* container_free)(void *obj)
Definition: container_fifo.c:33
ff_container_fifo_alloc_avframe
ContainerFifo * ff_container_fifo_alloc_avframe(unsigned flags)
Allocate a ContainerFifo instance for AVFrames.
Definition: container_fifo.c:191
ff_container_fifo_read
int ff_container_fifo_read(ContainerFifo *pf, void *obj)
Read the next available object from the FIFO into obj.
Definition: container_fifo.c:121
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
ContainerFifo
ContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
Definition: container_fifo.c:27
ff_container_fifo_free
void ff_container_fifo_free(ContainerFifo **pf)
Free a ContainerFifo and everything in it.
Definition: container_fifo.c:100
ContainerFifo::fifo_write
int(* fifo_write)(void *dst, void *src)
Definition: container_fifo.c:34
ContainerFifo::fifo_read
int(* fifo_read)(void *dst, void *src)
Definition: container_fifo.c:35
ff_container_fifo_write
int ff_container_fifo_write(ContainerFifo *pf, void *obj)
Write the contents of obj to the FIFO.
Definition: container_fifo.c:136
ff_container_fifo_alloc
ContainerFifo * ff_container_fifo_alloc(void *(*container_alloc)(void), void(*container_reset)(void *obj), void(*container_free)(void *obj), int(*fifo_write)(void *dst, void *src), int(*fifo_read)(void *dst, void *src))
Allocate a new ContainerFifo for the container type defined by provided callbacks.
Definition: container_fifo.c:64
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
ContainerFifo::container_alloc
void *(* container_alloc)(void)
Definition: container_fifo.c:31
ff_container_fifo_can_read
size_t ff_container_fifo_can_read(ContainerFifo *pf)
Definition: container_fifo.c:159
ContainerFifo::container_reset
void(* container_reset)(void *obj)
Definition: container_fifo.c:32
src
#define src
Definition: vp8dsp.c:248