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 DC1B84498F for ; Wed, 28 Sep 2022 13:43:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C41DB68BCCF; Wed, 28 Sep 2022 16:43:27 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0141D68BC8D for ; Wed, 28 Sep 2022 16:43:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 66CB9240183; Wed, 28 Sep 2022 15:43:20 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id d_Mgj3t7qvUf; Wed, 28 Sep 2022 15:43:19 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id D249E2400F4; Wed, 28 Sep 2022 15:43:19 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id F19DE1601B2; Wed, 28 Sep 2022 15:43:19 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: =?utf-8?q?=3CGV1P250MB0737239BB086232B19900BAA8F529=40GV1P250MB?= =?utf-8?q?0737=2EEURP250=2EPROD=2EOUTLOOK=2ECOM=3E?= References: =?utf-8?q?=3CGV1P250MB073722E20166CCF2883487CF8F529=40GV1P250MB0?= =?utf-8?q?737=2EEURP250=2EPROD=2EOUTLOOK=2ECOM=3E_=3CGV1P250MB0737239BB0862?= =?utf-8?q?32B19900BAA8F529=40GV1P250MB0737=2EEURP250=2EPROD=2EOUTLOOK=2ECOM?= =?utf-8?q?=3E?= Mail-Followup-To: FFmpeg development discussions and patches , Andreas Rheinhardt Date: Wed, 28 Sep 2022 15:43:19 +0200 Message-ID: <166437259996.22057.15090804598058774563@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 2/5] avutil/pixdesc: Avoid direct access to pix fmt desc array 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: Andreas Rheinhardt 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: Quoting Andreas Rheinhardt (2022-09-26 21:58:55) > Instead use av_pix_fmt_desc_next(). It is still possible > to check its return values by comparing it with the > (currently) expected values and the code does so. > > Signed-off-by: Andreas Rheinhardt > --- > libavutil/pixdesc.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c > index c42a0242c5..f6755f41df 100644 > --- a/libavutil/pixdesc.c > +++ b/libavutil/pixdesc.c > @@ -2913,10 +2913,10 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt) > } > > void ff_check_pixfmt_descriptors(void){ > - int i, j; > + const AVPixFmtDescriptor *d, *last = NULL; > + int i; > > - for (i=0; i - const AVPixFmtDescriptor *d = &av_pix_fmt_descriptors[i]; > + for (i = AV_PIX_FMT_NONE, d = NULL; i++, d = av_pix_fmt_desc_next(d);) { > uint8_t fill[4][8+6+3] = {{0}}; > uint8_t *data[4] = {fill[0], fill[1], fill[2], fill[3]}; > int linesize[4] = {0,0,0,0}; > @@ -2927,9 +2927,15 @@ void ff_check_pixfmt_descriptors(void){ > av_assert0(d->log2_chroma_w <= 3); > av_assert0(d->log2_chroma_h <= 3); > av_assert0(d->nb_components <= 4); > - av_assert2(av_get_pix_fmt(d->name) == i); > + av_assert2(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); > + > + /* The following two checks as well as the one after the loop > + * would need to be changed if we changed the way the descriptors > + * are stored. */ > + av_assert0(i == av_pix_fmt_desc_get_id(d)); > + av_assert0(!last || last + 1 == d); Don't see last being set. -- Anton Khirnov _______________________________________________ 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".