From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 82C3E43064 for ; Thu, 13 Jan 2022 14:22:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 99F1068B7C8; Thu, 13 Jan 2022 16:22:46 +0200 (EET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2102.outbound.protection.outlook.com [40.92.91.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49F5068B77A for ; Thu, 13 Jan 2022 16:22:40 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwS3Exu90CsvqhokPJps0Tc43Q0zF0T5XjM2+6PuV86YGsDIOIylpixlZ0QX4hA5TwkSjnucIwRdhmqu7RbKz2glTUv9E0V+ybYu0ykMZXzlWnK/M9yengU1dIpRojpnAZhNpcpqj+HGo+KYt2KxPV7+myJ9Ur18va/MVTN1LKPrQpljJJuQPlOBCFToKLc/dFqNj6YQ2gbWySt2S7pAe7bASH4OngaWmuycDi0J8HhcTPav3bBsnZr9614fB2sZCEb7+frse+u2FivT1ILGS7eD3NGD0ldk72MWnhqmZFefiOd/Wts48Ztt0tSRdNNzfUA8cY4qobBxNCXCd0tPCQ== 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=/D4syVGPP8Y9NUHOA3KtxVad3HzCSlzWl2C5TwTZbcc=; b=cVKBMSXZeOhzlUYBA5dHsrJ+G+rWvc77h28d4ohl0eelzyiLnJdFtZKvcAR78iJTHRgoKj3NPup3iE8XNg8wTmPF+T9AxlfA5r/m5mxpNMQsQ7NqzdeE17sfqXIgjuJF4qWRbQWu5uuNSxAAXXW9xh7WwzFLG7PNCqbmSHeThYaCFh5SPDKPp4AFUkmoFs4F5xuqsfYoDv00aRg6TPsdNQleFE9uRMZiofEFWf8OhM5W0wHmIxjOCJefSN8GKLIjYPqpSzegQrOz1NumDrBE7FegAvb9u33ihc+O+FZUc/Y1kjlr81wP4XHoUP8vP6kmUFy8BI2yJt+YKWRPVEwqmg== 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=/D4syVGPP8Y9NUHOA3KtxVad3HzCSlzWl2C5TwTZbcc=; b=H/+s4sttqw3GZKphTf65tTmycC7NZw71VReXcjStR2ShLm9quTejrKWvwZPk0qplBQF9K0aIR8n3moeLx3LF3DOJ8YycBWPvUMu02Zxce5pY7kyNuimu6E0Bw7RFZnJ5jMrRSNE0RR1skIXrc//GuH29H6Ss4M8SI9sELNkCmd8hpVpiuO5WCJ3Dd/B9FHSP8MnUWb7lOuIj3+D6s3d13XICk1X5l24LmCjaBRGfOo2A3bLdUKIvdW46M5Eticda4/QdtN8QDDL8AgDVpfsPIsWFYIV2h7gNhtEIRQ+YxUSBG2YZdmi919OvmINuiQQKndmNd6h8GvbUKL8aJ2Cklg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB3PR0302MB3338.eurprd03.prod.outlook.com (2603:10a6:8:b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Thu, 13 Jan 2022 14:22:10 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4888.010; Thu, 13 Jan 2022 14:22:10 +0000 Message-ID: Date: Thu, 13 Jan 2022 15:22:09 +0100 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220111204610.14262-1-anton@khirnov.net> <20220111204610.14262-2-anton@khirnov.net> From: Andreas Rheinhardt In-Reply-To: <20220111204610.14262-2-anton@khirnov.net> X-TMN: [wjbuQ/kaUcGkFh8LM7IFpnMuQ0podKzx] X-ClientProxiedBy: AS9PR06CA0234.eurprd06.prod.outlook.com (2603:10a6:20b:45e::31) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <46848a34-4f7b-fc68-728c-547e26700b8d@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3ec824d-37f0-44db-0f3a-08d9d6a015e8 X-MS-TrafficTypeDiagnostic: DB3PR0302MB3338:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4b72XbBxSwRTzPRSQvEDKGTlA9Gxq8T01Z8RW7MB8MmpAUyPZz5xUwVrQBc/jUhf2iMgy1LrYMUpgqm7X3iKjIasU013vc/broC5qyrWgTd9/iPDLOIzwHn+RrkiTbPNas4v6yPMDeORx1lzQRPndW+eYs7BTfpri78TGLnjiC9XDj+kG8BKLDph2ORyzNPuDzA9yAVL91ucg9SXeetXBg9n6en2lMN3JtnN6J7p952wUsjQP9aG1OljuFk4RwVDDCqm1AX/M5ctIgkGhaUv2k6rzhk0tDKr9JAjfJH0Y0OqbeIT2PzFtEUXF+Wc/+vF5AlvpMWVttKU5TwUTSWeTig4je61Rn5gx+jqjTUG1Zn0cO58sZ1QX3km3wuGzWP0fxASH3VhfuGf4tIgLxk3akNklyogblEmmPrLmjRI+VC69CvM9azTTlDaDAJzkxdAknsQQ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c2tSTE0vTk9S?= =?utf-8?B?RWdla081clQvbTlzb3NlcGNtcWpnYWIwUWpWNk5xd2lQMlhETlJ1b3djeGJ6?= =?utf-8?B?Zk5KdzVFR0ZBcEJiWUNaZUYydnpteHo0b2VLMFo1eEYvMCtEQ0RkTGZZN0pL?= =?utf-8?B?Z3I1M3FXL2xzZHlwbDNrT3luMEVRbXVZVExGVEtJWWxGcEJrR25MeGpXSFJu?= =?utf-8?B?OS9SdW5jTFgyYmsydGRRSUV6cHlXNXpzUkhZaDNFU1piTW1ZLzBGNjlFbGhB?= =?utf-8?B?dnRUQ2FSUlVsL2pablA4d0txcjl2TlYzRE1RejZQZGc3MGtrWVh6UUpPTzI5?= =?utf-8?B?WlVUbGs1aFNNSlhob1d0Vy82czRCTWwyNUczdm0zUll5NzBCS3VMbHo0TGYv?= =?utf-8?B?VlN1V2x3ZmpYQTJGTXBrRGxqV245b2RiOGFlc2p2Z2ZSem1aR2t6ZVJRZFhH?= =?utf-8?B?NzA1NFdJNThwVHlsVURkMHM3c2x6RWZxY2p0ZmVOQWpoT013K2hxc2FDSytn?= =?utf-8?B?VGZKQ0VtaVdyZUMvNkg4bXkzU0JtQVQ3VjZoYmhxOFk4aC9CVUlOUkp5Rmx6?= =?utf-8?B?UiswbXZ4SWNYTVNNTDNUVU9Uc3hITzc4RGRsTFk3VDBTOFpodz09?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3ec824d-37f0-44db-0f3a-08d9d6a015e8 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 14:22:10.2932 (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: DB3PR0302MB3338 Subject: Re: [FFmpeg-devel] [PATCH 02/35] lavu/fifo: make the contents of AVFifoBuffer private on next major bump 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Anton Khirnov: > There should be no good reason for the callers to access any of its > contents. > > Define a new type for the internal struct that currently matches > AVFifoBuffer. This will allow adding new private fields without waiting > for the major bump and will be useful in the following commits. > > 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 | 4 ++++ > libavutil/fifo.c | 23 +++++++++++++++++++---- > libavutil/fifo.h | 14 ++++++++++++-- > libavutil/tests/fifo.c | 2 +- > libavutil/version.h | 1 + > 5 files changed, 37 insertions(+), 7 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 8df0364e4c..21fa02ae9d 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,10 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2022-01-xx - xxxxxxxxxx - lavu fifo.h > + Access to all AVFifoBuffer members is deprecated. The struct will > + become an incomplete type in a future major libavutil version. > + > 2022-01-04 - 78dc21b123e - lavu 57.16.100 - frame.h > Add AV_FRAME_DATA_DOVI_METADATA. > > diff --git a/libavutil/fifo.c b/libavutil/fifo.c > index f2f046b1f3..aaade01333 100644 > --- a/libavutil/fifo.c > +++ b/libavutil/fifo.c > @@ -28,9 +28,24 @@ > > #define FIFO_SIZE_MAX FFMIN3((uint64_t)INT_MAX, (uint64_t)UINT32_MAX, (uint64_t)SIZE_MAX) > > +#if FF_API_FIFO_PUBLIC > +# define CTX_STRUCT_NAME FifoBuffer > +#else > +# define CTX_STRUCT_NAME AVFifoBuffer This is invalid in pre-C11 (and will lead to compilation failures on old GCC versions): Pre-C11, typedefs were subject to the ODR, yet you already typedef AVFifoBuffer in fifo.h. > +#endif > + > +typedef struct CTX_STRUCT_NAME { > + // These fields must match then contents of AVFifoBuffer in fifo.h the contents > + // until FF_API_FIFO_PUBLIC is removed The actual spec-compliant way for this is to add an AVFifoBuffer at the start of this struct; it will also avoid the casts from FifoBuffer to AVFifoBuffer. This will make the accesses to it a bit more cumbersome and will mean more changes when FF_API_FIFO_PUBLIC is removed. (This would not be an issue if we required support for anonymous structs (mandatory in C11, supported by GCC and others long before that).) > + uint8_t *buffer; > + uint8_t *rptr, *wptr, *end; > + uint32_t rndx, wndx; > + ///////////////////////////////////////// > +} FifoBuffer; > + > AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) > { > - AVFifoBuffer *f; > + FifoBuffer *f; > void *buffer; > > if (nmemb > FIFO_SIZE_MAX / size) > @@ -39,15 +54,15 @@ AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) > buffer = av_realloc_array(NULL, nmemb, size); > if (!buffer) > return NULL; > - f = av_mallocz(sizeof(AVFifoBuffer)); > + f = av_mallocz(sizeof(*f)); > if (!f) { > av_free(buffer); > return NULL; > } > f->buffer = buffer; > f->end = f->buffer + nmemb * size; > - av_fifo_reset(f); > - return f; > + av_fifo_reset((AVFifoBuffer*)f); > + return (AVFifoBuffer*)f; > } > > AVFifoBuffer *av_fifo_alloc(unsigned int size) > diff --git a/libavutil/fifo.h b/libavutil/fifo.h > index f4fd291e59..ca4e7fe060 100644 > --- a/libavutil/fifo.h > +++ b/libavutil/fifo.h > @@ -28,11 +28,21 @@ > #include "avutil.h" > #include "attributes.h" > > -typedef struct AVFifoBuffer { > +#if FF_API_FIFO_PUBLIC > +/** > + * The contents of the struct are private and should not be accessed by the > + * callers in any way. > + */ > +#endif > +typedef struct AVFifoBuffer > +#if FF_API_FIFO_PUBLIC > +{ > uint8_t *buffer; > uint8_t *rptr, *wptr, *end; > uint32_t rndx, wndx; > -} AVFifoBuffer; > +} > +#endif > +AVFifoBuffer; > > /** > * Initialize an AVFifoBuffer. > diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c > index a17d913233..e5aa88d252 100644 > --- a/libavutil/tests/fifo.c > +++ b/libavutil/tests/fifo.c > @@ -18,7 +18,7 @@ > > #include > #include > -#include "libavutil/fifo.h" > +#include "libavutil/fifo.c" > > int main(void) > { > diff --git a/libavutil/version.h b/libavutil/version.h > index 953aac9d94..7c031f547e 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -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_PUBLIC (LIBAVUTIL_VERSION_MAJOR < 58) > > /** > * @} > _______________________________________________ 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".