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 179A3488D6 for ; Wed, 21 Feb 2024 01:17:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADBAC68D0CA; Wed, 21 Feb 2024 03:17:39 +0200 (EET) 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 3565468D085 for ; Wed, 21 Feb 2024 03:17:33 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id AF7BFFF803 for ; Wed, 21 Feb 2024 01:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1708478251; 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=0EyHf/NzYs/GbV2M9AIBItYkgDy2BgQdcgIM8asv6C0=; b=IWmq/KxV94q1CXI/GCtJLB+wNG+bXWqOaMmNJZ7igQ+N3aH9GvxhpkAlZB1TRUwzIC7gMY ypWaYYHnsc8AuUmwIcg77TLtGHZAjCF7HRCPAhLi5R33FCGC9vUaayh3akzcw4lPTOou3e MkoyhgrV7XeFajw+3nByCU9E2VXqjJamMYGv9EtPLEBwekdXv881L3cQjRcnMmEUbSZ88h 7sCJ5OiMMIBKyGTwrOsZjFSGfwtJd53aak9W28eYS7d3wqdZ97D7bi7pyanX9W4dFQovc+ C6yhTH59V+7CkcD6z7nOamfzSQHuYUx0sA1MbEJaazw5RP5+Uy5lzhalY1loag== Date: Wed, 21 Feb 2024 02:17:30 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240221011730.GX6420@pb2> References: <20240220024922.22779-1-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/3] tools: Add target_sws_fuzzer.c 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="===============3691571963515702409==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3691571963515702409== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YC5JE+7K2Mm0A0dc" Content-Disposition: inline --YC5JE+7K2Mm0A0dc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 20, 2024 at 12:41:57AM -0300, James Almer wrote: > On 2/19/2024 11:49 PM, Michael Niedermayer wrote: > > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { > > + int srcW=3D 48, srcH =3D 48; > > + int dstW=3D 48, dstH =3D 48; > > + int srcHShift, srcVShift; > > + int dstHShift, dstVShift; > > + unsigned flags =3D 1; > > + int srcStride[AV_VIDEO_MAX_PLANES] =3D {0}; > > + int dstStride[AV_VIDEO_MAX_PLANES] =3D {0}; > > + int ret; > > + const uint8_t *end =3D data + size; > > + enum AVPixelFormat srcFormat =3D AV_PIX_FMT_YUV420P; > > + enum AVPixelFormat dstFormat =3D AV_PIX_FMT_YUV420P; > > + uint8_t *src[AV_VIDEO_MAX_PLANES] =3D { 0 }; > > + uint8_t *dst[AV_VIDEO_MAX_PLANES] =3D { 0 }; > > + struct SwsContext *sws =3D NULL; > > + const AVPixFmtDescriptor *desc_src, *desc_dst; > > + > > + if (size > 128) { > > + GetByteContext gbc; > > + int64_t flags64; > > + > > + size -=3D 128; > > + bytestream2_init(&gbc, data + size, 128); > > + srcW =3D bytestream2_get_le32(&gbc) % 16384; > > + srcH =3D bytestream2_get_le32(&gbc) % 16384; > > + dstW =3D bytestream2_get_le32(&gbc) % 16384; > > + dstH =3D bytestream2_get_le32(&gbc) % 16384; >=20 > Might as well use bytestream2_get_le16 to save bytes from the input buffe= r. >=20 > > + > > + if (srcW * (uint64_t)srcH > 16384 || dstW * (uint64_t)dstH > 1= 6384) > > + return 0; // we avoid high res as its very slow >=20 > This will abort in a lot of cases. Would reading only xW then setting xH = to > 16384 / xW make sense? You can remove these checks if so. no that would reduce the number of tested resolutions to one for each width What we are trying to do here, is to map some flat random data into a resolution constraint to X > 0 Y > 0 X*Y <=3D 16484 and at the same time have each pair occur approximately as frequent as any = other that can be achieved in a few ways, ill use the following static void mapres(unsigned *r0, unsigned *r1) { double d =3D (double)(*r0*10ll - 9ll*UINT32_MAX) / UINT32_MAX; double a =3D exp(d) * 16384 / exp(1) ; int ai =3D (int)round(a); uint64_t maxb =3D 16384 / ai; *r0 =3D ai; *r1 =3D 1 + (*r1 * maxb) / UINT32_MAX; } this avoids all the aborts and is flat enough statically for this purpose will apply with that, but if you prefer the previous simpler code, dont hes= itate to replace it. Iam not sure this helps the fuzzer at all thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin --YC5JE+7K2Mm0A0dc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZdVPHwAKCRBhHseHBAsP qzK8AJ4mkWgGsqkC2F6P2VbiqYd8VUAgtgCeMsEW/YNKCaQ1GMqqJiGuYwRHWQE= =jTrT -----END PGP SIGNATURE----- --YC5JE+7K2Mm0A0dc-- --===============3691571963515702409== 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". --===============3691571963515702409==--