From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 1EFF34A731
	for <ffmpegdev@gitmailbox.com>; Thu,  4 Apr 2024 18:42:09 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C78268D0D9;
	Thu,  4 Apr 2024 21:42:07 +0300 (EEST)
Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net
 [217.70.183.199])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 079AF68C917
 for <ffmpeg-devel@ffmpeg.org>; Thu,  4 Apr 2024 21:42:00 +0300 (EEST)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 51493FF804
 for <ffmpeg-devel@ffmpeg.org>; Thu,  4 Apr 2024 18:42:00 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1712256120;
 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=z/D73xgnB4czwj9rlrHQxlfuw/FJSLxccTK+5evinNY=;
 b=MR5eDAwR0YFFCZnfCjzKZFaXoagzd9HCzeed5otiYRfFjsy7YlCPcRuXRHkL6muM39pkTV
 z3NYFvIbBA0O05qZfxVJcQ2fCeBBgi074MsiKEvESyrEya7b1mVr2PxXCbki6cuzDnstlA
 R7+9QVEMDYdW1OetafL06N6RoF06gfVXeRk/CphWStPXUcJeyzCZCIRxpIqHtudzAnV27C
 j+3NCUn5EQBMxEFKJB0Wq00BnfF3WjK95otYI6Km885/96TsB4dLttQwXJuKlzRQStiFNl
 2uXxuliMNcAT6GjuvXEDPTNOe0KdT5ZXyXyJrX1N3BVGeuB67Trer/EGOhAVRQ==
Date: Thu, 4 Apr 2024 20:41:59 +0200
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20240404184159.GA6420@pb2>
References: <20240403225134.31764-1-michael@niedermayer.cc>
 <20240403225134.31764-5-michael@niedermayer.cc>
 <956d190b-ccde-74af-aebc-77667f9108ca@passwd.hu>
MIME-Version: 1.0
In-Reply-To: <956d190b-ccde-74af-aebc-77667f9108ca@passwd.hu>
X-GND-Sasl: michael@niedermayer.cc
Subject: Re: [FFmpeg-devel] [PATCH 5/5] avformat/pcm: Use 64bit in bitrate
 computation
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: multipart/mixed; boundary="===============2268395004600790675=="
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20240404184159.GA6420@pb2/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--===============2268395004600790675==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="k1PASegzXAhdDqE8"
Content-Disposition: inline


--k1PASegzXAhdDqE8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Apr 04, 2024 at 07:12:40PM +0200, Marton Balint wrote:
>=20
>=20
> On Thu, 4 Apr 2024, Michael Niedermayer wrote:
>=20
> > Fixes: signed integer overflow: 65792 * 65312 cannot be represented in =
type 'int'
> > Fixes: 67819/clusterfuzz-testcase-minimized-ffmpeg_dem_WADY_fuzzer-5236=
100912185344
> >=20
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz=
/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavformat/pcm.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >=20
> > diff --git a/libavformat/pcm.c b/libavformat/pcm.c
> > index 051e86dd464..a774dbc3726 100644
> > --- a/libavformat/pcm.c
> > +++ b/libavformat/pcm.c
> > @@ -41,7 +41,7 @@ int ff_pcm_default_packet_size(AVCodecParameters *par)
> >     /* Don't trust the codecpar bitrate if we can calculate it ourselve=
s */
> >     if (bits_per_sample > 0 && par->sample_rate > 0 && par->ch_layout.n=
b_channels > 0)
> >         if ((int64_t)par->sample_rate * par->ch_layout.nb_channels < IN=
T64_MAX / bits_per_sample)
> > -            bitrate =3D bits_per_sample * par->sample_rate * par->ch_l=
ayout.nb_channels;
> > +            bitrate =3D bits_per_sample * (int64_t)par->sample_rate * =
par->ch_layout.nb_channels;
>=20
> LGTM, thanks.
>=20
> I wonder why we usually cast the second operand and not the first to 64 b=
it,
> since cast has higher precedence than multiplication, it should not matte=
r,
> should it?

If the reader isnt sure about the precedence, writing it as
a * (int64_t)b
has the advantage that precedence doesnt matter, so the code is easier to
understand and verify than

(int64_t)a * b

thx


[...]
--=20
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope

--k1PASegzXAhdDqE8
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZg70dAAKCRBhHseHBAsP
q0vUAJ9DRnd5Kdn3HDosgHM7cChnXe5+SgCfTvxH00ICzjjPXHtAC6MjkQEwMZE=
=WJmw
-----END PGP SIGNATURE-----

--k1PASegzXAhdDqE8--

--===============2268395004600790675==
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".

--===============2268395004600790675==--