History

avutil/fifo: Deprecate old FIFO API

Users should switch to the superior AVFifo API. Unfortunately AVFifoBuffer fields cannot be marked as deprecated because it would trigger a warning wherever fifo.h is #included, due to inlined av_fifo_peek2().

Anton Khirnov committed 4 years ago

Commit a10f1ae1 parent e6469e64 files · +58 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +8 −0
  2. libavutil/fifo.c +4 −0
  3. libavutil/fifo.h +44 −1
  4. libavutil/version.h +2 −1
doc/APIchanges+8−0
@@ -14,6 +14,14 @@ libavutil: 2021-04-27 · 13 unmodified lines
14 14
15API changes, most recent first:15API changes, most recent first:
16 16
172022-02-07 - xxxxxxxxxx - lavu 57.21.100 - fifo.h
18 Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(),
19 av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(),
20 av_fifo_size(), av_fifo_space(), av_fifo_generic_peek_at(),
21 av_fifo_generic_peek(), av_fifo_generic_read(), av_fifo_generic_write(),
22 av_fifo_realloc2(), av_fifo_grow(), av_fifo_drain() and av_fifo_peek2().
23 Users should switch to the AVFifo-API.
24
172022-02-07 - xxxxxxxxxx - lavu 57.20.100 - fifo.h252022-02-07 - xxxxxxxxxx - lavu 57.20.100 - fifo.h
18 Add a new FIFO API, which allows setting a FIFO element size.26 Add a new FIFO API, which allows setting a FIFO element size.
19 This API operates on these elements rather than on bytes.27 This API operates on these elements rather than on bytes.
libavutil/fifo.c+4−0
@@ -287,6 +287,8 @@ void av_fifo_freep2(AVFifo **f) · 286 unmodified lines
287}287}
288 288
289 289
290#if FF_API_FIFO_OLD_API
291FF_DISABLE_DEPRECATION_WARNINGS
290#define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX)292#define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX)
291 293
292AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size)294AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size)
@@ -499,3 +501,5 @@ void av_fifo_drain(AVFifoBuffer *f, int size) · 206 unmodified lines
499 f->rptr -= f->end - f->buffer;501 f->rptr -= f->end - f->buffer;
500 f->rndx += size;502 f->rndx += size;
501}503}
504FF_ENABLE_DEPRECATION_WARNINGS
505#endif
libavutil/fifo.h+44−1
@@ -220,6 +220,7 @@ void av_fifo_reset2(AVFifo *f); · 219 unmodified lines
220void av_fifo_freep2(AVFifo **f);220void av_fifo_freep2(AVFifo **f);
221 221
222 222
223#if FF_API_FIFO_OLD_API
223typedef struct AVFifoBuffer {224typedef struct AVFifoBuffer {
224 uint8_t *buffer;225 uint8_t *buffer;
225 uint8_t *rptr, *wptr, *end;226 uint8_t *rptr, *wptr, *end;
@@ -230,7 +231,9 @@ typedef struct AVFifoBuffer { · 4 unmodified lines
230 * Initialize an AVFifoBuffer.231 * Initialize an AVFifoBuffer.
231 * @param size of FIFO232 * @param size of FIFO
232 * @return AVFifoBuffer or NULL in case of memory allocation failure233 * @return AVFifoBuffer or NULL in case of memory allocation failure
234 * @deprecated use av_fifo_alloc2()
233 */235 */
236attribute_deprecated
234AVFifoBuffer *av_fifo_alloc(unsigned int size);237AVFifoBuffer *av_fifo_alloc(unsigned int size);
235 238
236/**239/**
@@ -238,25 +241,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); · 1 unmodified line
238 * @param nmemb number of elements241 * @param nmemb number of elements
239 * @param size size of the single element242 * @param size size of the single element
240 * @return AVFifoBuffer or NULL in case of memory allocation failure243 * @return AVFifoBuffer or NULL in case of memory allocation failure
244 * @deprecated use av_fifo_alloc2()
241 */245 */
246attribute_deprecated
242AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);247AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
243 248
244/**249/**
245 * Free an AVFifoBuffer.250 * Free an AVFifoBuffer.
246 * @param f AVFifoBuffer to free251 * @param f AVFifoBuffer to free
252 * @deprecated use the AVFifo API with av_fifo_freep2()
247 */253 */
254attribute_deprecated
248void av_fifo_free(AVFifoBuffer *f);255void av_fifo_free(AVFifoBuffer *f);
249 256
250/**257/**
251 * Free an AVFifoBuffer and reset pointer to NULL.258 * Free an AVFifoBuffer and reset pointer to NULL.
252 * @param f AVFifoBuffer to free259 * @param f AVFifoBuffer to free
260 * @deprecated use the AVFifo API with av_fifo_freep2()
253 */261 */
262attribute_deprecated
254void av_fifo_freep(AVFifoBuffer **f);263void av_fifo_freep(AVFifoBuffer **f);
255 264
256/**265/**
257 * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.266 * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
258 * @param f AVFifoBuffer to reset267 * @param f AVFifoBuffer to reset
268 * @deprecated use av_fifo_reset2() with the new AVFifo-API
259 */269 */
270attribute_deprecated
260void av_fifo_reset(AVFifoBuffer *f);271void av_fifo_reset(AVFifoBuffer *f);
261 272
262/**273/**
@@ -264,7 +275,9 @@ void av_fifo_reset(AVFifoBuffer *f); · 1 unmodified line
264 * amount of data you can read from it.275 * amount of data you can read from it.
265 * @param f AVFifoBuffer to read from276 * @param f AVFifoBuffer to read from
266 * @return size277 * @return size
278 * @deprecated use av_fifo_can_read() with the new AVFifo-API
267 */279 */
280attribute_deprecated
268int av_fifo_size(const AVFifoBuffer *f);281int av_fifo_size(const AVFifoBuffer *f);
269 282
270/**283/**
@@ -272,7 +285,9 @@ int av_fifo_size(const AVFifoBuffer *f); · 1 unmodified line
272 * amount of data you can write into it.285 * amount of data you can write into it.
273 * @param f AVFifoBuffer to write into286 * @param f AVFifoBuffer to write into
274 * @return size287 * @return size
288 * @deprecated use av_fifo_can_write() with the new AVFifo-API
275 */289 */
290attribute_deprecated
276int av_fifo_space(const AVFifoBuffer *f);291int av_fifo_space(const AVFifoBuffer *f);
277 292
278/**293/**
@@ -285,7 +300,11 @@ int av_fifo_space(const AVFifoBuffer *f); · 6 unmodified lines
285 * @param dest data destination300 * @param dest data destination
286 *301 *
287 * @return a non-negative number on success, a negative error code on failure302 * @return a non-negative number on success, a negative error code on failure
303 *
304 * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
305 * av_fifo_peek_to_cb() otherwise
288 */306 */
307attribute_deprecated
289int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));308int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
290 309
291/**310/**
@@ -297,7 +316,11 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz · 5 unmodified lines
297 * @param dest data destination316 * @param dest data destination
298 *317 *
299 * @return a non-negative number on success, a negative error code on failure318 * @return a non-negative number on success, a negative error code on failure
319 *
320 * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL,
321 * av_fifo_peek_to_cb() otherwise
300 */322 */
323attribute_deprecated
301int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));324int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
302 325
303/**326/**
@@ -308,7 +331,11 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func) · 4 unmodified lines
308 * @param dest data destination331 * @param dest data destination
309 *332 *
310 * @return a non-negative number on success, a negative error code on failure333 * @return a non-negative number on success, a negative error code on failure
334 *
335 * @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL,
336 * av_fifo_read_to_cb() otherwise
311 */337 */
338attribute_deprecated
312int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));339int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
313 340
314/**341/**
@@ -323,7 +350,11 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) · 8 unmodified lines
323 * indicate no more data available to write.350 * indicate no more data available to write.
324 * If func is NULL, src is interpreted as a simple byte array for source data.351 * If func is NULL, src is interpreted as a simple byte array for source data.
325 * @return the number of bytes written to the FIFO or a negative error code on failure352 * @return the number of bytes written to the FIFO or a negative error code on failure
353 *
354 * @deprecated use the new AVFifo-API with av_fifo_write() when func == NULL,
355 * av_fifo_write_from_cb() otherwise
326 */356 */
357attribute_deprecated
327int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));358int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
328 359
329/**360/**
@@ -333,7 +364,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void · 3 unmodified lines
333 * @param f AVFifoBuffer to resize364 * @param f AVFifoBuffer to resize
334 * @param size new AVFifoBuffer size in bytes365 * @param size new AVFifoBuffer size in bytes
335 * @return <0 for failure, >=0 otherwise366 * @return <0 for failure, >=0 otherwise
367 *
368 * @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size,
369 * decreasing FIFO size is not supported
336 */370 */
371attribute_deprecated
337int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);372int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
338 373
339/**374/**
@@ -344,14 +379,21 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); · 4 unmodified lines
344 * @param f AVFifoBuffer to resize379 * @param f AVFifoBuffer to resize
345 * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()380 * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
346 * @return <0 for failure, >=0 otherwise381 * @return <0 for failure, >=0 otherwise
382 *
383 * @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike
384 * this function it adds to the allocated size, rather than to the used size
347 */385 */
386attribute_deprecated
348int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);387int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
349 388
350/**389/**
351 * Read and discard the specified amount of data from an AVFifoBuffer.390 * Read and discard the specified amount of data from an AVFifoBuffer.
352 * @param f AVFifoBuffer to read from391 * @param f AVFifoBuffer to read from
353 * @param size amount of data to read in bytes392 * @param size amount of data to read in bytes
393 *
394 * @deprecated use the new AVFifo-API with av_fifo_drain2()
354 */395 */
396attribute_deprecated
355void av_fifo_drain(AVFifoBuffer *f, int size);397void av_fifo_drain(AVFifoBuffer *f, int size);
356 398
357#if FF_API_FIFO_PEEK2399#if FF_API_FIFO_PEEK2
@@ -364,7 +406,7 @@ void av_fifo_drain(AVFifoBuffer *f, int size); · 6 unmodified lines
364 * than the used buffer size or the returned pointer will406 * than the used buffer size or the returned pointer will
365 * point outside to the buffer data.407 * point outside to the buffer data.
366 * The used buffer size can be checked with av_fifo_size().408 * The used buffer size can be checked with av_fifo_size().
367 * @deprecated use av_fifo_generic_peek_at()409 * @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb()
368 */410 */
369attribute_deprecated411attribute_deprecated
370static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)412static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
@@ -377,5 +419,6 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) · 6 unmodified lines
377 return ptr;419 return ptr;
378}420}
379#endif421#endif
422#endif
380 423
381#endif /* AVUTIL_FIFO_H */424#endif /* AVUTIL_FIFO_H */
libavutil/version.h+2−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5781#define LIBAVUTIL_VERSION_MAJOR 57
82#define LIBAVUTIL_VERSION_MINOR 2082#define LIBAVUTIL_VERSION_MINOR 21
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -110,6 +110,7 @@ · 24 unmodified lines
110#define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58)110#define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58)
111#define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58)111#define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58)
112#define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58)112#define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58)
113#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58)
113 114
114/**115/**
115 * @}116 * @}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t