FFmpeg
fifo.c
Go to the documentation of this file.
1 /*
2  * a very simple circular buffer FIFO implementation
3  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4  * Copyright (c) 2006 Roman Shaposhnik
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <stdint.h>
24 #include <string.h>
25 
26 #include "avassert.h"
27 #include "error.h"
28 #include "fifo.h"
29 #include "macros.h"
30 #include "mem.h"
31 
32 // by default the FIFO can be auto-grown to 1MB
33 #define AUTO_GROW_DEFAULT_BYTES (1024 * 1024)
34 
35 struct AVFifo {
36  uint8_t *buffer;
37 
39  size_t offset_r, offset_w;
40  // distinguishes the ambiguous situation offset_r == offset_w
41  int is_empty;
42 
43  unsigned int flags;
45 };
46 
47 AVFifo *av_fifo_alloc2(size_t nb_elems, size_t elem_size,
48  unsigned int flags)
49 {
50  AVFifo *f;
51  void *buffer = NULL;
52 
53  if (!elem_size)
54  return NULL;
55 
56  if (nb_elems) {
57  buffer = av_realloc_array(NULL, nb_elems, elem_size);
58  if (!buffer)
59  return NULL;
60  }
61  f = av_mallocz(sizeof(*f));
62  if (!f) {
63  av_free(buffer);
64  return NULL;
65  }
66  f->buffer = buffer;
67  f->nb_elems = nb_elems;
68  f->elem_size = elem_size;
69  f->is_empty = 1;
70 
71  f->flags = flags;
72  f->auto_grow_limit = FFMAX(AUTO_GROW_DEFAULT_BYTES / elem_size, 1);
73 
74  return f;
75 }
76 
77 void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems)
78 {
79  f->auto_grow_limit = max_elems;
80 }
81 
82 size_t av_fifo_elem_size(const AVFifo *f)
83 {
84  return f->elem_size;
85 }
86 
87 size_t av_fifo_can_read(const AVFifo *f)
88 {
89  if (f->offset_w <= f->offset_r && !f->is_empty)
90  return f->nb_elems - f->offset_r + f->offset_w;
91  return f->offset_w - f->offset_r;
92 }
93 
94 size_t av_fifo_can_write(const AVFifo *f)
95 {
96  return f->nb_elems - av_fifo_can_read(f);
97 }
98 
99 int av_fifo_grow2(AVFifo *f, size_t inc)
100 {
101  uint8_t *tmp;
102 
103  if (inc > SIZE_MAX - f->nb_elems)
104  return AVERROR(EINVAL);
105 
106  tmp = av_realloc_array(f->buffer, f->nb_elems + inc, f->elem_size);
107  if (!tmp)
108  return AVERROR(ENOMEM);
109  f->buffer = tmp;
110 
111  // move the data from the beginning of the ring buffer
112  // to the newly allocated space
113  if (f->offset_w <= f->offset_r && !f->is_empty) {
114  const size_t copy = FFMIN(inc, f->offset_w);
115  memcpy(tmp + f->nb_elems * f->elem_size, tmp, copy * f->elem_size);
116  if (copy < f->offset_w) {
117  memmove(tmp, tmp + copy * f->elem_size,
118  (f->offset_w - copy) * f->elem_size);
119  f->offset_w -= copy;
120  } else
121  f->offset_w = copy == inc ? 0 : f->nb_elems + copy;
122  }
123 
124  f->nb_elems += inc;
125 
126  return 0;
127 }
128 
129 static int fifo_check_space(AVFifo *f, size_t to_write)
130 {
131  const size_t can_write = av_fifo_can_write(f);
132  const size_t need_grow = to_write > can_write ? to_write - can_write : 0;
133  size_t can_grow;
134 
135  if (!need_grow)
136  return 0;
137 
138  can_grow = f->auto_grow_limit > f->nb_elems ?
139  f->auto_grow_limit - f->nb_elems : 0;
140  if ((f->flags & AV_FIFO_FLAG_AUTO_GROW) && need_grow <= can_grow) {
141  // allocate a bit more than necessary, if we can
142  const size_t inc = (need_grow < can_grow / 2 ) ? need_grow * 2 : can_grow;
143  return av_fifo_grow2(f, inc);
144  }
145 
146  return AVERROR(ENOSPC);
147 }
148 
149 static int fifo_write_common(AVFifo *f, const uint8_t *buf, size_t *nb_elems,
150  AVFifoCB read_cb, void *opaque)
151 {
152  size_t to_write = *nb_elems;
153  size_t offset_w;
154  int ret = 0;
155 
156  ret = fifo_check_space(f, to_write);
157  if (ret < 0)
158  return ret;
159 
160  offset_w = f->offset_w;
161 
162  while (to_write > 0) {
163  size_t len = FFMIN(f->nb_elems - offset_w, to_write);
164  uint8_t *wptr = f->buffer + offset_w * f->elem_size;
165 
166  if (read_cb) {
167  ret = read_cb(opaque, wptr, &len);
168  if (ret < 0 || len == 0)
169  break;
170  } else {
171  memcpy(wptr, buf, len * f->elem_size);
172  buf += len * f->elem_size;
173  }
174  offset_w += len;
175  if (offset_w >= f->nb_elems)
176  offset_w = 0;
177  to_write -= len;
178  }
179  f->offset_w = offset_w;
180 
181  if (*nb_elems != to_write)
182  f->is_empty = 0;
183  *nb_elems -= to_write;
184 
185  return ret;
186 }
187 
188 int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
189 {
190  return fifo_write_common(f, buf, &nb_elems, NULL, NULL);
191 }
192 
194  void *opaque, size_t *nb_elems)
195 {
196  return fifo_write_common(f, NULL, nb_elems, read_cb, opaque);
197 }
198 
199 static int fifo_peek_common(const AVFifo *f, uint8_t *buf, size_t *nb_elems,
200  size_t offset, AVFifoCB write_cb, void *opaque)
201 {
202  size_t to_read = *nb_elems;
203  size_t offset_r = f->offset_r;
204  size_t can_read = av_fifo_can_read(f);
205  int ret = 0;
206 
207  if (offset > can_read || to_read > can_read - offset) {
208  *nb_elems = 0;
209  return AVERROR(EINVAL);
210  }
211 
212  if (offset_r >= f->nb_elems - offset)
213  offset_r -= f->nb_elems - offset;
214  else
215  offset_r += offset;
216 
217  while (to_read > 0) {
218  size_t len = FFMIN(f->nb_elems - offset_r, to_read);
219  uint8_t *rptr = f->buffer + offset_r * f->elem_size;
220 
221  if (write_cb) {
222  ret = write_cb(opaque, rptr, &len);
223  if (ret < 0 || len == 0)
224  break;
225  } else {
226  memcpy(buf, rptr, len * f->elem_size);
227  buf += len * f->elem_size;
228  }
229  offset_r += len;
230  if (offset_r >= f->nb_elems)
231  offset_r = 0;
232  to_read -= len;
233  }
234 
235  *nb_elems -= to_read;
236 
237  return ret;
238 }
239 
240 int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
241 {
242  int ret = fifo_peek_common(f, buf, &nb_elems, 0, NULL, NULL);
243  av_fifo_drain2(f, nb_elems);
244  return ret;
245 }
246 
248  void *opaque, size_t *nb_elems)
249 {
250  int ret = fifo_peek_common(f, NULL, nb_elems, 0, write_cb, opaque);
251  av_fifo_drain2(f, *nb_elems);
252  return ret;
253 }
254 
255 int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset)
256 {
257  return fifo_peek_common(f, buf, &nb_elems, offset, NULL, NULL);
258 }
259 
261  size_t *nb_elems, size_t offset)
262 {
263  return fifo_peek_common(f, NULL, nb_elems, offset, write_cb, opaque);
264 }
265 
266 void av_fifo_drain2(AVFifo *f, size_t size)
267 {
268  const size_t cur_size = av_fifo_can_read(f);
269 
270  av_assert0(cur_size >= size);
271  if (cur_size == size)
272  f->is_empty = 1;
273 
274  if (f->offset_r >= f->nb_elems - size)
275  f->offset_r -= f->nb_elems - size;
276  else
277  f->offset_r += size;
278 }
279 
281 {
282  f->offset_r = f->offset_w = 0;
283  f->is_empty = 1;
284 }
285 
287 {
288  if (*f) {
289  av_freep(&(*f)->buffer);
290  av_freep(f);
291  }
292 }
293 
294 
295 #if FF_API_FIFO_OLD_API
297 #define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX)
298 
299 AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size)
300 {
301  AVFifoBuffer *f;
302  void *buffer;
303 
304  if (nmemb > OLD_FIFO_SIZE_MAX / size)
305  return NULL;
306 
307  buffer = av_realloc_array(NULL, nmemb, size);
308  if (!buffer)
309  return NULL;
310  f = av_mallocz(sizeof(AVFifoBuffer));
311  if (!f) {
312  av_free(buffer);
313  return NULL;
314  }
315  f->buffer = buffer;
316  f->end = f->buffer + nmemb * size;
317  av_fifo_reset(f);
318  return f;
319 }
320 
322 {
323  return av_fifo_alloc_array(size, 1);
324 }
325 
327 {
328  if (f) {
329  av_freep(&f->buffer);
330  av_free(f);
331  }
332 }
333 
335 {
336  if (f) {
337  av_fifo_free(*f);
338  *f = NULL;
339  }
340 }
341 
343 {
344  f->wptr = f->rptr = f->buffer;
345  f->wndx = f->rndx = 0;
346 }
347 
349 {
350  return (uint32_t)(f->wndx - f->rndx);
351 }
352 
354 {
355  return f->end - f->buffer - av_fifo_size(f);
356 }
357 
358 int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
359 {
360  unsigned int old_size = f->end - f->buffer;
361 
362  if (new_size > OLD_FIFO_SIZE_MAX)
363  return AVERROR(EINVAL);
364 
365  if (old_size < new_size) {
366  size_t offset_r = f->rptr - f->buffer;
367  size_t offset_w = f->wptr - f->buffer;
368  uint8_t *tmp;
369 
370  tmp = av_realloc(f->buffer, new_size);
371  if (!tmp)
372  return AVERROR(ENOMEM);
373 
374  // move the data from the beginning of the ring buffer
375  // to the newly allocated space
376  // the second condition distinguishes full vs empty fifo
377  if (offset_w <= offset_r && av_fifo_size(f)) {
378  const size_t copy = FFMIN(new_size - old_size, offset_w);
379  memcpy(tmp + old_size, tmp, copy);
380  if (copy < offset_w) {
381  memmove(tmp, tmp + copy , offset_w - copy);
382  offset_w -= copy;
383  } else
384  offset_w = old_size + copy;
385  }
386 
387  f->buffer = tmp;
388  f->end = f->buffer + new_size;
389  f->rptr = f->buffer + offset_r;
390  f->wptr = f->buffer + offset_w;
391  }
392  return 0;
393 }
394 
395 int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
396 {
397  unsigned int old_size = f->end - f->buffer;
398  if(size + (unsigned)av_fifo_size(f) < size)
399  return AVERROR(EINVAL);
400 
401  size += av_fifo_size(f);
402 
403  if (old_size < size)
404  return av_fifo_realloc2(f, FFMAX(size, 2*old_size));
405  return 0;
406 }
407 
408 /* src must NOT be const as it can be a context for func that may need
409  * updating (like a pointer or byte counter) */
411  int (*func)(void *, void *, int))
412 {
413  int total = size;
414  uint32_t wndx= f->wndx;
415  uint8_t *wptr= f->wptr;
416 
417  if (size > av_fifo_space(f))
418  return AVERROR(ENOSPC);
419 
420  do {
421  int len = FFMIN(f->end - wptr, size);
422  if (func) {
423  len = func(src, wptr, len);
424  if (len <= 0)
425  break;
426  } else {
427  memcpy(wptr, src, len);
428  src = (uint8_t *)src + len;
429  }
430  wptr += len;
431  if (wptr >= f->end)
432  wptr = f->buffer;
433  wndx += len;
434  size -= len;
435  } while (size > 0);
436  f->wndx= wndx;
437  f->wptr= wptr;
438  return total - size;
439 }
440 
441 int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int))
442 {
443  uint8_t *rptr = f->rptr;
444 
445  if (offset < 0 || buf_size > av_fifo_size(f) - offset)
446  return AVERROR(EINVAL);
447 
448  if (offset >= f->end - rptr)
449  rptr += offset - (f->end - f->buffer);
450  else
451  rptr += offset;
452 
453  while (buf_size > 0) {
454  int len;
455 
456  if (rptr >= f->end)
457  rptr -= f->end - f->buffer;
458 
459  len = FFMIN(f->end - rptr, buf_size);
460  if (func)
461  func(dest, rptr, len);
462  else {
463  memcpy(dest, rptr, len);
464  dest = (uint8_t *)dest + len;
465  }
466 
467  buf_size -= len;
468  rptr += len;
469  }
470 
471  return 0;
472 }
473 
474 int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size,
475  void (*func)(void *, void *, int))
476 {
477  return av_fifo_generic_peek_at(f, dest, 0, buf_size, func);
478 }
479 
480 int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size,
481  void (*func)(void *, void *, int))
482 {
483  if (buf_size > av_fifo_size(f))
484  return AVERROR(EINVAL);
485 
486  do {
487  int len = FFMIN(f->end - f->rptr, buf_size);
488  if (func)
489  func(dest, f->rptr, len);
490  else {
491  memcpy(dest, f->rptr, len);
492  dest = (uint8_t *)dest + len;
493  }
494  av_fifo_drain(f, len);
495  buf_size -= len;
496  } while (buf_size > 0);
497  return 0;
498 }
499 
500 /** Discard data from the FIFO. */
502 {
504  f->rptr += size;
505  if (f->rptr >= f->end)
506  f->rptr -= f->end - f->buffer;
507  f->rndx += size;
508 }
510 #endif
av_fifo_alloc_array
AVFifoBuffer * av_fifo_alloc_array(size_t nmemb, size_t size)
Initialize an AVFifoBuffer.
Definition: fifo.c:299
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
av_fifo_drain2
void av_fifo_drain2(AVFifo *f, size_t size)
Discard the specified amount of data from an AVFifo.
Definition: fifo.c:266
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
av_fifo_can_write
size_t av_fifo_can_write(const AVFifo *f)
Definition: fifo.c:94
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
av_fifo_freep
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:334
AVFifo::is_empty
int is_empty
Definition: fifo.c:41
av_fifo_free
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
Definition: fifo.c:326
AVFifo::elem_size
size_t elem_size
Definition: fifo.c:38
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
OLD_FIFO_SIZE_MAX
#define OLD_FIFO_SIZE_MAX
Definition: fifo.c:297
av_fifo_auto_grow_limit
void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems)
Set the maximum size (in elements) to which the FIFO can be resized automatically.
Definition: fifo.c:77
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_fifo_drain
void av_fifo_drain(AVFifoBuffer *f, int size)
Discard data from the FIFO.
Definition: fifo.c:501
AVFifoBuffer
Definition: fifo.h:244
fifo.h
macros.h
av_fifo_write
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
Definition: fifo.c:188
av_fifo_grow2
int av_fifo_grow2(AVFifo *f, size_t inc)
Enlarge an AVFifo.
Definition: fifo.c:99
av_fifo_peek_to_cb
int av_fifo_peek_to_cb(AVFifo *f, AVFifoCB write_cb, void *opaque, size_t *nb_elems, size_t offset)
Feed data from a FIFO into a user-provided callback.
Definition: fifo.c:260
AVFifoCB
int AVFifoCB(void *opaque, void *buf, size_t *nb_elems)
Callback for writing or reading from a FIFO, passed to (and invoked from) the av_fifo_*_cb() function...
Definition: fifo.h:60
av_fifo_realloc2
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
Definition: fifo.c:358
avassert.h
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
av_fifo_generic_write
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
Definition: fifo.c:410
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:225
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVFifo::offset_w
size_t offset_w
Definition: fifo.c:39
AVFifo::flags
unsigned int flags
Definition: fifo.c:43
av_fifo_generic_peek
int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:474
av_fifo_grow
int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
Enlarge an AVFifoBuffer.
Definition: fifo.c:395
NULL
#define NULL
Definition: coverity.c:32
av_fifo_write_from_cb
int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb, void *opaque, size_t *nb_elems)
Write data from a user-provided callback into a FIFO.
Definition: fifo.c:193
av_realloc
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:153
av_fifo_can_read
size_t av_fifo_can_read(const AVFifo *f)
Definition: fifo.c:87
av_fifo_elem_size
size_t av_fifo_elem_size(const AVFifo *f)
Definition: fifo.c:82
error.h
av_fifo_reset2
void av_fifo_reset2(AVFifo *f)
Definition: fifo.c:280
f
f
Definition: af_crystalizer.c:122
av_fifo_read_to_cb
int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb, void *opaque, size_t *nb_elems)
Feed data from a FIFO into a user-provided callback.
Definition: fifo.c:247
AVFifo
Definition: fifo.c:35
AVFifo::nb_elems
size_t nb_elems
Definition: fifo.c:38
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:187
read_cb
static int read_cb(void *opaque, void *buf, size_t *nb_elems)
Definition: fifo.c:33
size
int size
Definition: twinvq_data.h:10344
AVFifo::offset_r
size_t offset_r
Definition: fifo.c:39
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
AVFifo::buffer
uint8_t * buffer
Definition: fifo.c:36
AUTO_GROW_DEFAULT_BYTES
#define AUTO_GROW_DEFAULT_BYTES
Definition: fifo.c:33
av_fifo_peek
int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset)
Read data from a FIFO without modifying FIFO state.
Definition: fifo.c:255
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:264
len
int len
Definition: vorbis_enc_data.h:426
fifo_write_common
static int fifo_write_common(AVFifo *f, const uint8_t *buf, size_t *nb_elems, AVFifoCB read_cb, void *opaque)
Definition: fifo.c:149
ret
ret
Definition: filter_design.txt:187
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
av_fifo_size
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
Definition: fifo.c:348
fifo_check_space
static int fifo_check_space(AVFifo *f, size_t to_write)
Definition: fifo.c:129
av_fifo_alloc
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:321
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
av_fifo_reset
void av_fifo_reset(AVFifoBuffer *f)
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
Definition: fifo.c:342
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
mem.h
fifo_peek_common
static int fifo_peek_common(const AVFifo *f, uint8_t *buf, size_t *nb_elems, size_t offset, AVFifoCB write_cb, void *opaque)
Definition: fifo.c:199
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_fifo_space
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
Definition: fifo.c:353
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_fifo_generic_read
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:480
write_cb
static int write_cb(void *opaque, void *buf, size_t *nb_elems)
Definition: fifo.c:53
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
av_fifo_generic_peek_at
int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void(*func)(void *, void *, int))
Feed data at specific position from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:441
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:67
AVFifo::auto_grow_limit
size_t auto_grow_limit
Definition: fifo.c:44