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
1414
1515 API changes, most recent first:
1616
17+2022-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+
1725 2022-02-07 - xxxxxxxxxx - lavu 57.20.100 - fifo.h
1826 Add a new FIFO API, which allows setting a FIFO element size.
1927 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
287287 }
288288
289289
290+#if FF_API_FIFO_OLD_API
291+FF_DISABLE_DEPRECATION_WARNINGS
290292 #define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX)
291293
292294 AVFifoBuffer *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
499501 f->rptr -= f->end - f->buffer;
500502 f->rndx += size;
501503 }
504+FF_ENABLE_DEPRECATION_WARNINGS
505+#endif
libavutil/fifo.h+44−1
@@ -220,6 +220,7 @@ void av_fifo_reset2(AVFifo *f); · 219 unmodified lines
220220 void av_fifo_freep2(AVFifo **f);
221221
222222
223+#if FF_API_FIFO_OLD_API
223224 typedef struct AVFifoBuffer {
224225 uint8_t *buffer;
225226 uint8_t *rptr, *wptr, *end;
@@ -230,7 +231,9 @@ typedef struct AVFifoBuffer { · 4 unmodified lines
230231 * Initialize an AVFifoBuffer.
231232 * @param size of FIFO
232233 * @return AVFifoBuffer or NULL in case of memory allocation failure
234+ * @deprecated use av_fifo_alloc2()
233235 */
236+attribute_deprecated
234237 AVFifoBuffer *av_fifo_alloc(unsigned int size);
235238
236239 /**
@@ -238,25 +241,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); · 1 unmodified line
238241 * @param nmemb number of elements
239242 * @param size size of the single element
240243 * @return AVFifoBuffer or NULL in case of memory allocation failure
244+ * @deprecated use av_fifo_alloc2()
241245 */
246+attribute_deprecated
242247 AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
243248
244249 /**
245250 * Free an AVFifoBuffer.
246251 * @param f AVFifoBuffer to free
252+ * @deprecated use the AVFifo API with av_fifo_freep2()
247253 */
254+attribute_deprecated
248255 void av_fifo_free(AVFifoBuffer *f);
249256
250257 /**
251258 * Free an AVFifoBuffer and reset pointer to NULL.
252259 * @param f AVFifoBuffer to free
260+ * @deprecated use the AVFifo API with av_fifo_freep2()
253261 */
262+attribute_deprecated
254263 void av_fifo_freep(AVFifoBuffer **f);
255264
256265 /**
257266 * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
258267 * @param f AVFifoBuffer to reset
268+ * @deprecated use av_fifo_reset2() with the new AVFifo-API
259269 */
270+attribute_deprecated
260271 void av_fifo_reset(AVFifoBuffer *f);
261272
262273 /**
@@ -264,7 +275,9 @@ void av_fifo_reset(AVFifoBuffer *f); · 1 unmodified line
264275 * amount of data you can read from it.
265276 * @param f AVFifoBuffer to read from
266277 * @return size
278+ * @deprecated use av_fifo_can_read() with the new AVFifo-API
267279 */
280+attribute_deprecated
268281 int av_fifo_size(const AVFifoBuffer *f);
269282
270283 /**
@@ -272,7 +285,9 @@ int av_fifo_size(const AVFifoBuffer *f); · 1 unmodified line
272285 * amount of data you can write into it.
273286 * @param f AVFifoBuffer to write into
274287 * @return size
288+ * @deprecated use av_fifo_can_write() with the new AVFifo-API
275289 */
290+attribute_deprecated
276291 int av_fifo_space(const AVFifoBuffer *f);
277292
278293 /**
@@ -285,7 +300,11 @@ int av_fifo_space(const AVFifoBuffer *f); · 6 unmodified lines
285300 * @param dest data destination
286301 *
287302 * @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
288306 */
307+attribute_deprecated
289308 int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
290309
291310 /**
@@ -297,7 +316,11 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz · 5 unmodified lines
297316 * @param dest data destination
298317 *
299318 * @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
300322 */
323+attribute_deprecated
301324 int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
302325
303326 /**
@@ -308,7 +331,11 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func) · 4 unmodified lines
308331 * @param dest data destination
309332 *
310333 * @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
311337 */
338+attribute_deprecated
312339 int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
313340
314341 /**
@@ -323,7 +350,11 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) · 8 unmodified lines
323350 * indicate no more data available to write.
324351 * If func is NULL, src is interpreted as a simple byte array for source data.
325352 * @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
326356 */
357+attribute_deprecated
327358 int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
328359
329360 /**
@@ -333,7 +364,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void · 3 unmodified lines
333364 * @param f AVFifoBuffer to resize
334365 * @param size new AVFifoBuffer size in bytes
335366 * @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
336370 */
371+attribute_deprecated
337372 int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
338373
339374 /**
@@ -344,14 +379,21 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); · 4 unmodified lines
344379 * @param f AVFifoBuffer to resize
345380 * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
346381 * @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
347385 */
386+attribute_deprecated
348387 int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
349388
350389 /**
351390 * Read and discard the specified amount of data from an AVFifoBuffer.
352391 * @param f AVFifoBuffer to read from
353392 * @param size amount of data to read in bytes
393+ *
394+ * @deprecated use the new AVFifo-API with av_fifo_drain2()
354395 */
396+attribute_deprecated
355397 void av_fifo_drain(AVFifoBuffer *f, int size);
356398
357399 #if FF_API_FIFO_PEEK2
@@ -364,7 +406,7 @@ void av_fifo_drain(AVFifoBuffer *f, int size); · 6 unmodified lines
364406 * than the used buffer size or the returned pointer will
365407 * point outside to the buffer data.
366408 * 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()
368410 */
369411 attribute_deprecated
370412 static 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
377419 return ptr;
378420 }
379421 #endif
422+#endif
380423
381424 #endif /* AVUTIL_FIFO_H */
libavutil/version.h+2−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 57
82−#define LIBAVUTIL_VERSION_MINOR 20
82+#define LIBAVUTIL_VERSION_MINOR 21
8383 #define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -110,6 +110,7 @@ · 24 unmodified lines
110110 #define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58)
111111 #define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58)
112112 #define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58)
113+#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58)
113114
114115 /**
115116 * @}

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