From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Anton Khirnov <anton@khirnov.net> Subject: [FFmpeg-devel] [PATCH v2 31/31] avutil/fifo: Deprecate old FIFO API Date: Mon, 24 Jan 2022 15:46:16 +0100 Message-ID: <AM7PR03MB6660ACF9285DBCCC7BFA09608F5E9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) In-Reply-To: <AM7PR03MB666072F4E7572C4D4DB462358F5E9@AM7PR03MB6660.eurprd03.prod.outlook.com> From: Anton Khirnov <anton@khirnov.net> 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(). --- doc/APIchanges | 8 ++++++++ libavutil/fifo.c | 4 ++++ libavutil/fifo.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- libavutil/version.h | 3 ++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 75e0b1f49a..db6b2ab809 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,14 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-01-xx - xxxxxxxxxx - lavu 57.20.100 - fifo.h + Deprecate AVFifoBuffer and the API around it, namely av_fifo_alloc(), + av_fifo_alloc_array(), av_fifo_free(), av_fifo_freep(), av_fifo_reset(), + av_fifo_size(), av_fifo_space(), av_fifo_generic_peek_at(), + av_fifo_generic_peek(), av_fifo_generic_read(), av_fifo_generic_write(), + av_fifo_realloc2(), av_fifo_grow(), av_fifo_drain() and av_fifo_peek2(). + Users should switch to the AVFifo-API. + 2022-01-xx - xxxxxxxxxx - lavu 57.19.100 - fifo.h Add a new FIFO API, which allows setting a FIFO element size. This API operates on these elements rather than on bytes. diff --git a/libavutil/fifo.c b/libavutil/fifo.c index 5a09dd3877..818e39694b 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -285,6 +285,8 @@ void av_fifo_freep2(AVFifo **f) } +#if FF_API_FIFO_OLD_API +FF_DISABLE_DEPRECATION_WARNINGS #define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX) AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) @@ -497,3 +499,5 @@ void av_fifo_drain(AVFifoBuffer *f, int size) f->rptr -= f->end - f->buffer; f->rndx += size; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif diff --git a/libavutil/fifo.h b/libavutil/fifo.h index 55548fbeb4..40852c0f70 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -220,6 +220,7 @@ void av_fifo_reset2(AVFifo *f); void av_fifo_freep2(AVFifo **f); +#if FF_API_FIFO_OLD_API typedef struct AVFifoBuffer { uint8_t *buffer; uint8_t *rptr, *wptr, *end; @@ -230,7 +231,9 @@ typedef struct AVFifoBuffer { * Initialize an AVFifoBuffer. * @param size of FIFO * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc(unsigned int size); /** @@ -238,25 +241,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); * @param nmemb number of elements * @param size size of the single element * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size); /** * Free an AVFifoBuffer. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_free(AVFifoBuffer *f); /** * Free an AVFifoBuffer and reset pointer to NULL. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_freep(AVFifoBuffer **f); /** * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * @param f AVFifoBuffer to reset + * @deprecated use av_fifo_reset2() with the new AVFifo-API */ +attribute_deprecated void av_fifo_reset(AVFifoBuffer *f); /** @@ -264,7 +275,9 @@ void av_fifo_reset(AVFifoBuffer *f); * amount of data you can read from it. * @param f AVFifoBuffer to read from * @return size + * @deprecated use av_fifo_can_read() with the new AVFifo-API */ +attribute_deprecated int av_fifo_size(const AVFifoBuffer *f); /** @@ -272,7 +285,9 @@ int av_fifo_size(const AVFifoBuffer *f); * amount of data you can write into it. * @param f AVFifoBuffer to write into * @return size + * @deprecated use av_fifo_can_write() with the new AVFifo-API */ +attribute_deprecated int av_fifo_space(const AVFifoBuffer *f); /** @@ -285,7 +300,11 @@ int av_fifo_space(const AVFifoBuffer *f); * @param dest data destination * * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int)); /** @@ -297,7 +316,11 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz * @param dest data destination * * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -308,7 +331,11 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * @param dest data destination * * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL, + * av_fifo_read_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -323,7 +350,11 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * indicate no more data available to write. * If func is NULL, src is interpreted as a simple byte array for source data. * @return the number of bytes written to the FIFO or a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_write() when func == NULL, + * av_fifo_write_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); /** @@ -333,7 +364,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void * @param f AVFifoBuffer to resize * @param size new AVFifoBuffer size in bytes * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size, + * decreasing FIFO size is not supported */ +attribute_deprecated int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); /** @@ -344,14 +379,21 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); * @param f AVFifoBuffer to resize * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size() * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike + * this function it adds to the allocated size, rather than to the used size */ +attribute_deprecated int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space); /** * Read and discard the specified amount of data from an AVFifoBuffer. * @param f AVFifoBuffer to read from * @param size amount of data to read in bytes + * + * @deprecated use the new AVFifo-API with av_fifo_drain2() */ +attribute_deprecated void av_fifo_drain(AVFifoBuffer *f, int size); #if FF_API_FIFO_PEEK2 @@ -364,7 +406,7 @@ void av_fifo_drain(AVFifoBuffer *f, int size); * than the used buffer size or the returned pointer will * point outside to the buffer data. * The used buffer size can be checked with av_fifo_size(). - * @deprecated use av_fifo_generic_peek_at() + * @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb() */ attribute_deprecated 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) return ptr; } #endif +#endif #endif /* AVUTIL_FIFO_H */ diff --git a/libavutil/version.h b/libavutil/version.h index 331b8f6ea9..5e47f61fe6 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 19 +#define LIBAVUTIL_VERSION_MINOR 20 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -110,6 +110,7 @@ #define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58) /** * @} -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-01-24 14:52 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-24 14:44 [FFmpeg-devel] [PATCH v2 00/31] New " Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 01/31] avutil/fifo: Use av_fifo_generic_peek_at() for av_fifo_generic_peek() Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 02/31] lavu/fifo: disallow overly large fifo sizes Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 03/31] lavu/fifo: Add new AVFifo API based upon the notion of element size Andreas Rheinhardt 2022-02-05 7:55 ` Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 04/31] lavu/fifo: add a flag for automatically growing the FIFO as needed Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 05/31] lavu/tests/fifo: switch to the new API Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 06/31] lavc/avcodec: switch to new FIFO API Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 07/31] lavc/amfenc: " Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 08/31] lavc/cuviddec: do not reallocate the fifo unnecessarily Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 09/31] lavc/cuviddec: convert to the new FIFO API Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 10/31] lavc/libvorbisenc: switch to " Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 11/31] lavc/libvpxenc: switch to the " Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 12/31] lavc/libvpxenc: remove unneeded context variable Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 13/31] lavc/nvenc: switch to the new FIFO API Andreas Rheinhardt 2022-01-24 14:45 ` [FFmpeg-devel] [PATCH v2 14/31] lavc/qsvdec: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 15/31] lavc/qsvenc: switch to " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 16/31] avcodec/qsvenc: Reindent after the previous commit Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 17/31] lavf/dvenc: return an error on audio/video desync Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 18/31] lavf/dvenc: switch to new FIFO API Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 19/31] lavf/mpegenc: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 20/31] lavf/swfenc: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 21/31] lavf/udp: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 22/31] lavf/async: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 23/31] lavd/jack: switch to the " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 24/31] lavu/audio_fifo: drop an unnecessary include Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 25/31] lavu/audio_fifo: switch to new FIFO API Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 26/31] lavu/threadmessage: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 27/31] lavfi/qsvvpp: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 28/31] lavfi/vf_deshake_opencl: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 29/31] ffplay: " Andreas Rheinhardt 2022-01-24 14:46 ` [FFmpeg-devel] [PATCH v2 30/31] ffmpeg: " Andreas Rheinhardt 2022-01-24 14:46 ` Andreas Rheinhardt [this message] 2022-02-01 10:16 [FFmpeg-devel] [PATCH v2 31/31] avutil/fifo: Deprecate old " Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AM7PR03MB6660ACF9285DBCCC7BFA09608F5E9@AM7PR03MB6660.eurprd03.prod.outlook.com \ --to=andreas.rheinhardt@outlook.com \ --cc=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git