From patchwork Mon Jan 24 14:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33793 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:e71a:0:0:0:0:0 with SMTP id b26csp390140ioh; Mon, 24 Jan 2022 06:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxV/Rw5waEXTnADWm8YJ90m5KIYUmBCVvf5OUQvjPzwm2m281NiOhe4NpFDJ2b395fBKGLH X-Received: by 2002:a05:6402:3591:: with SMTP id y17mr16260910edc.386.1643035930456; Mon, 24 Jan 2022 06:52:10 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dd19si9696281ejc.610.2022.01.24.06.52.07; Mon, 24 Jan 2022 06:52:10 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=V7lTneMC; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3888668B1B9; Mon, 24 Jan 2022 16:48:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073058.outbound.protection.outlook.com [40.92.73.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8C4968B1B0 for ; Mon, 24 Jan 2022 16:48:57 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e0o8W15dYcz6ae+E+CEda8nPfI/eaWjtIDdJswZR80oKOEcb4wf6rNhaRrJ3RoN7ZCdEUaytThKzBTlPM0PSstRFd138Jc04cL/b/nEUauhTui5BrszcZZ6boz2E8wmzAT8JzWnYmPYSIm6gdriNLSq53E6ADF2700ZnVz2MlnJAFij9UTxFURLAMRGsWrrtvzDtE+jguvn9cKwtUxKIRXKxpVEj8/q1wcXIAvC7H1hTocJo2lbV7X50IefKfNDFChlWpe064EBbRXknXwYu8c6BdmGC2mPfGDeIDfLE8chdM9bjJ2wokgcYlg4FTgT2nj6AHSid2w+zQQw2TYhxRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dQf4K0O5tWaZGkoyseMvnvbaQHbFBEKzm/ObkMPwta4=; b=cCiS/lsG9DW3OvaQs2Z6Kt7kgqPxwARmaiIScttdyShvG8N0ol4/cXrLBClVwuCcJsc3ZM35QJ2Lh+Ki14b3hObHCVvz9GhY3002AULTD+QhLZN8ZshvXIGrNQdecvpPuaKq+PLfLuldXtxASeVxTSOpfVcCPP+3/7TeoCyLDPGS3e3+iAkCcR+EtzycGD7BnpVIVfLBfvK53/c6kJU2VB2fUkBU1v+dB/I7qAAMn9ofHxqrWu6gvWbk1275TPj06W6s4zA9Jofpcw4qzntwvMFd4EApdCDH8zA/NAdgC8Hlm1BXc9fkBFtfxwU/ENF/MlQEoOIqbimjJ3TdnHcyOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dQf4K0O5tWaZGkoyseMvnvbaQHbFBEKzm/ObkMPwta4=; b=V7lTneMCHzPS5imeP9e384QJ4bvAnWPNhS8EMiVwbL65brXVT8N/xTz1huXUVKh2Y11KvENL1REnr8fAgaEKpF0G9OdvJMBQz5KIgg6VmGGKM3KrdQyxu7D+7iHDtYn9CJG/VEcfWISvUSDvxRtBHiDZ2OT5k9TnCIHdDk2+b0ckYK24a5jMSkbSVJi5HT1+Ck6FhUldog6M8YNtFtWpCJn8u0KfXt1Qcqgc1cHFxOjWwUdx6SKSff00FxZYFYfnv5jWwPLWg2UGVxvDRLSVKTGjuVrntr2HYvzrvVnwvbqLLE/JvpkBsjv6iHeaeP5VVM5ZTPMOSndxfMkbkaCGUw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR03MB3000.eurprd03.prod.outlook.com (2603:10a6:6:36::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17; Mon, 24 Jan 2022 14:48:56 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%4]) with mapi id 15.20.4909.017; Mon, 24 Jan 2022 14:48:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jan 2022 15:46:16 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [YxXDysxscN529Jt0vqmYx2ZHd+UDxhZP] X-ClientProxiedBy: AM5PR0201CA0016.eurprd02.prod.outlook.com (2603:10a6:203:3d::26) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220124144616.559446-31-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d46a484-da97-4ca0-c702-08d9df48a59f X-MS-TrafficTypeDiagnostic: DB6PR03MB3000:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2aoC8BogCFHQU2tgxeeQPRYvOAqo6A+4zJF0qGc4D3ZisOrZiRy1c2hP0yAofcX/v5CQK0kq0OpzY+QMiPfRz/5G5n34IYS1a4MHOSIrc7INZyYxW3fo+Hw2DXz2LAkL70Oq/z9h/GgNyiHNa+PTKge2d5KfA+44MxBgnBkAT854AUrIrgk/Miq47DUZunePmWcL7bYihRDwoP0KIXTRdBYRFeBQmTFdDY4oFQ1qrh1XwSpIhWWVeC6d7DI+PANj8J+ql+4Q3vLRSat4qg+DEPdOOZt19Y3Y26VBKCpto1Q3EaQZuCaMiziIpU0KilUzOhNxnlvsW3i2cxhyr8UCZFvR8XH0Z5ZuXgnmNphVtv3R66eVlXiFsCdx0SixAHXFxF04yolxVJXb19BGp2zMIcBSmotZHxnKBwFkMECZ0CARBzwp2tuh1FEExalzQbdqFlwlqQAFzJpuUODxfZX9OjjX3GxG7ya7Q+2s3paScplJYugwB8oreWsMTcfOmBcODUlmrEZQnKGU7el1KBMgULAqGTIFjOQtD6hg3Sytr9GZhjA11L2p7yQ3/JE9/m4YBg2VkCg9RGdYg2OZprI2Xw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vl9nwYU6oxuXPRj0yzFt1wke/RE0wBfslyqeZx9TJ2hvcmhrpORDmeHyjjNHvtBjK3uTmJXJRPtSRF3mMXkOFDyKLresp6s/IQgmo0A0A7M4kgZCP+JfsgsC414SLlTuCF+YmKnyZB4TndGc1a/FyCBKjaJilnqUcTcOylbZsgfGhjIXIQswgSHLni6kb7jTJ2GLy2EzDX/rX+z0wqHGleyX30g/rlMCwfUvXi2s+LsNOoveEqMRJoAXMMl25R1TvMgPtjkHWYKBWMRziVImizn+tq4FQQFIv/J+QkGUVDKOQnIBJ6BzBoBU8EXwy99l9d7wfl1w4b4vLQOx9jQzHEurnn7S+C/ooCl7m3WTEBPEl/xkeTdBWfwyT9JvrKfrU/hE2PzXd7ITReuv2hPiqZ8Enzg2pC3U1tkS/2OG8I1f40kJrOFrrHG5W1+9Qp8b1bSQb772apO/i4zFanZ0DuNiJBVtP+aiHCvwvm6uJNy2V+a4p63j5xrlj+rWatpKReK5JhVRTgMs/8/G+xyJYyJKDu2dEcjYV0I5lvHhPhKR5Ua8ds3407eJP4TUkvSLSsgLNLGE/3pSqBxN/lJxXwtShZ/KZzeyQQiZHHu33vCsjUJekv6DFZTGqv5QR4C/dW7HJHPn7WJ9FbJcWcpNe2yYuGUKZJ/gPBCXZu05cjGw0gBda8nRZ22XM7i5/jKRhihHcz9Cnfa1MelhLDIQQcI7sGDL89CxsHqxBhLMvfn2W9ooZ/scBiTYaCCgszjalQNyUKmFcvA4e3IdGyxkrXEBJ1BURiJObkh3uTwsWGeOBUOXjd0TbYNrkCT200avetrZr1GKA5HdYEwoJRO52SG3TGnoPdm+hZr2YZl3/z8nF8xQyAS1dUQYI8wqSbS4SzWNTxDlT2vmTdLaWAt7eOMO6fnx/qVry3whlAi5U3Qj2wWqxWzjgvZB9pU5rveIvsanAJeNxHup4qXSG0SA6w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d46a484-da97-4ca0-c702-08d9df48a59f X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2022 14:48:56.1017 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR03MB3000 Subject: [FFmpeg-devel] [PATCH v2 31/31] avutil/fifo: Deprecate old FIFO API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Anton Khirnov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nep+2iU4tz8D From: Anton Khirnov 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) /** * @}