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 D1E934BCCD for ; Tue, 16 Jul 2024 13:26:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A2A668D9D0; Tue, 16 Jul 2024 16:26:06 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C82D68D774 for ; Tue, 16 Jul 2024 16:26:00 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7D75E1BF206 for ; Tue, 16 Jul 2024 13:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1721136359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=S5X6jUa03iDrD04AZKs9TDu8lnrpch97WqrueRR63F0=; b=pew78iHIqPn7o9qvZlYUmmfhXVGweiOVFy+/Fc8zkFA83CoUvujHNUIuP3u4C+yZ5xCny7 VAzfhhHPQjC0XyU8gExFaps0X/CDrBTeqC6MhrUfDGoWyXjPj3PRrbs4xfydz6c92bUe3f M61YNtICP6KlqtQMdYs04iF+uB3+OXUR0l+TxflhNOeyUSIfQk9VOwb1Gb9KACbje+Kq9g b5His12rl9PlMBwIfdZpEEsCP4mhTLZe/HsUnqJKQXUtE1AxopSZGl1/b4GnR9iLrVfiwS lsZ/Y2Oadk5Z7IlFgiv/AQjdMxilFqGSnY0r4XaGJUk1yp53vqfqk5I0H+vukg== Date: Tue, 16 Jul 2024 15:25:58 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240716132558.GN4991@pb2> References: <20240620193504.2310780-1-michael@niedermayer.cc> <20240621210945.GU4991@pb2> MIME-Version: 1.0 In-Reply-To: <20240621210945.GU4991@pb2> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/4] avcodec/j2kenc: Merge dwt_norm into lambda 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="===============2194223742270081364==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2194223742270081364== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vtbYPoC95O61holF" Content-Disposition: inline --vtbYPoC95O61holF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 21, 2024 at 11:09:45PM +0200, Michael Niedermayer wrote: > On Fri, Jun 21, 2024 at 11:38:46AM +0200, Andreas Rheinhardt wrote: > > Michael Niedermayer: > > > This moves computations out of a loop > > >=20 > > > Fixes: signed integer overflow: 31665934879948800 * 9998 cannot be re= presented in type 'long' > > > Fixes: 69024/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG20= 00_fuzzer-5949662967169024 > > >=20 > > > Found-by: continuous fuzzing process https://github.com/google/oss-fu= zz/tree/master/projects/ffmpeg > > > Signed-off-by: Michael Niedermayer > > > --- > > > libavcodec/j2kenc.c | 9 +++++---- > > > 1 file changed, 5 insertions(+), 4 deletions(-) > > >=20 > > > diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c > > > index 8cf82f7216c..91e66d81048 100644 > > > --- a/libavcodec/j2kenc.c > > > +++ b/libavcodec/j2kenc.c > > > @@ -1349,7 +1349,7 @@ static void makelayers(Jpeg2000EncoderContext *= s, Jpeg2000Tile *tile) > > > } > > > } > > > =20 > > > -static int getcut(Jpeg2000Cblk *cblk, uint64_t lambda, int dwt_norm) > > > +static int getcut(Jpeg2000Cblk *cblk, uint64_t lambda) > > > { > > > int passno, res =3D 0; > > > for (passno =3D 0; passno < cblk->npasses; passno++){ > > > @@ -1361,7 +1361,7 @@ static int getcut(Jpeg2000Cblk *cblk, uint64_t = lambda, int dwt_norm) > > > dd =3D cblk->passes[passno].disto > > > - (res ? cblk->passes[res-1].disto : 0); > > > =20 > > > - if (((dd * dwt_norm) >> WMSEDEC_SHIFT) * dwt_norm >=3D dr * = lambda) > > > + if (dd >=3D dr * lambda) > > > res =3D passno+1; > > > } > > > return res; > > > @@ -1384,11 +1384,12 @@ static void truncpasses(Jpeg2000EncoderContex= t *s, Jpeg2000Tile *tile) > > > Jpeg2000Band *band =3D reslevel->band + bandno; > > > Jpeg2000Prec *prec =3D band->prec + precno; > > > =20 > > > + int64_t dwt_norm =3D dwt_norms[codsty->transform= =3D=3D FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 15; > > > + int64_t lambda_prime =3D av_rescale(s->lambda, 1= << WMSEDEC_SHIFT, dwt_norm * dwt_norm); > > > for (cblkno =3D 0; cblkno < prec->nb_codeblocks_= height * prec->nb_codeblocks_width; cblkno++){ > > > Jpeg2000Cblk *cblk =3D prec->cblk + cblkno; > > > =20 > > > - cblk->ninclpasses =3D getcut(cblk, s->lambda, > > > - (int64_t)dwt_norms[codsty->transform= =3D=3D FF_DWT53][bandpos][lev] * (int64_t)band->i_stepsize >> 15); > > > + cblk->ninclpasses =3D getcut(cblk, lambda_pr= ime); > > > cblk->layers[0].data_start =3D cblk->data; > > > cblk->layers[0].cum_passes =3D cblk->ninclpa= sses; > > > cblk->layers[0].npasses =3D cblk->ninclpasse= s; > >=20 > > Does this also fix the UB in the vsynth*-jpeg2000-yuva444p16 tests? >=20 > we will find out when this is applied, it looks like it might added a note that this may fix UB in these tests to teh commit message and will apply thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle --vtbYPoC95O61holF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZpZ04AAKCRBhHseHBAsP q+70AJ0fs+Fohem4IkCIW1EYtu7yp6r2uACfYpY2/S8DNCQrsrwGj326wOngAqg= =WytR -----END PGP SIGNATURE----- --vtbYPoC95O61holF-- --===============2194223742270081364== 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". --===============2194223742270081364==--