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 A1B7643466 for ; Thu, 10 Nov 2022 19:42:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A249068B896; Thu, 10 Nov 2022 21:42:18 +0200 (EET) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6672C68B796 for ; Thu, 10 Nov 2022 21:42:11 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 5463560008 for ; Thu, 10 Nov 2022 19:42:09 +0000 (UTC) Date: Thu, 10 Nov 2022 20:42:08 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20221110194208.GB1814017@pb2> References: <20221106123430.1668-1-michael@niedermayer.cc> <20221106123430.1668-2-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/7] avcodec/bonk: Simplify read_uint_max() 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: multipart/mixed; boundary="===============9114995029459090339==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============9114995029459090339== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BKMA2OjimIttCqMD" Content-Disposition: inline --BKMA2OjimIttCqMD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 06, 2022 at 07:30:24PM +0100, Paul B Mahol wrote: > On 11/6/22, Michael Niedermayer wrote: > > The max =3D=3D 0 case can be removed too but i left it as 50% of the ca= ses use > > it > > > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/bonk.c | 11 ++--------- > > 1 file changed, 2 insertions(+), 9 deletions(-) > > > > diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c > > index 9e8892e4db..04ea4def2f 100644 > > --- a/libavcodec/bonk.c > > +++ b/libavcodec/bonk.c > > @@ -132,7 +132,6 @@ static av_cold int bonk_init(AVCodecContext *avctx) > > static unsigned read_uint_max(BonkContext *s, uint32_t max) > > { > > unsigned value =3D 0; > > - int i, bits; > > > > if (max =3D=3D 0) > > return 0; > > @@ -140,15 +139,9 @@ static unsigned read_uint_max(BonkContext *s, uint= 32_t > > max) > > if (max >> 31) > > return 32; > > > > - bits =3D 32 - ff_clz(max); > > - > > - for (i =3D 0; i < bits - 1; i++) > > - if (get_bits1(&s->gb)) > > - value +=3D 1 << i; > > - > > - if ((value | (1 << (bits - 1))) <=3D max) > > + for (unsigned i =3D 1; i <=3D max - value; i+=3Di) > > if (get_bits1(&s->gb)) > > - value +=3D 1 << (bits - 1); > > + value +=3D i; > > > > return value; > > } > > -- > > 2.17.1 > > >=20 > probably ok. will apply thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship: All citizens are under surveillance, all their steps and actions recorded, for the politicians to enforce control. Democracy: All politicians are under surveillance, all their steps and actions recorded, for the citizens to enforce control. --BKMA2OjimIttCqMD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY21UEAAKCRBhHseHBAsP q3p7AJ4p+vgGi3gBGJy65stLV+npNyxsMACfTq7Dl3s7yWFLET/cmfVqxyXtDPM= =wMcU -----END PGP SIGNATURE----- --BKMA2OjimIttCqMD-- --===============9114995029459090339== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============9114995029459090339==--