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 ECD59498B6 for ; Wed, 21 Feb 2024 02:33:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E889F68D081; Wed, 21 Feb 2024 04:33:24 +0200 (EET) Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F9C168CD8D for ; Wed, 21 Feb 2024 04:33:18 +0200 (EET) Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-59f7d59d3f1so65517eaf.1 for ; Tue, 20 Feb 2024 18:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708482795; x=1709087595; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=pQ17g4LIG58CtxHbYlkRMtjSQMyMTYDnSHEiwr7huZY=; b=UxEXQ+KaAYMR2sAlt+Ho9DwwnBD/gMKG4wco675oDN+45vQxxETFZk8cpAfnt6ta8Z HCOs7OAR+62C5WUJ81q/NTh+poTIkFmswBPXiMF53ra/pkmETiPGmwb6qTe61iZYq3Oj YeGjjC7QFseHBkAHUx7oRDN4ZOJB5xGLcKfVB+BcqKV/HY7pV6uhDFT7HQqdIs0Tay/c P3AtpR5h35eC0/aXHBbfg2b/xlNImHGUB1DJMV4XR+OTmEMCn+FrvSb0+Q8bk1JI1djS B1AbqIqGXG9rN5tBEfNGzXqNKWlQ2NclD8oYLMD/JRKpBpuWAH05v9ctNwyPVbdST7Pq af3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708482795; x=1709087595; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pQ17g4LIG58CtxHbYlkRMtjSQMyMTYDnSHEiwr7huZY=; b=nFyiiKf7IbhdqR1aYPB4RlJ7rFpoLxfZbAX4Z6kz3+LjA0pcFx25CffL9osstDKWug QS6S2P094KZwjJNXluu8yniG2OG0K30o5oDtBn9PlHYrJE19wfb/nzQCA+mn/NcZvkBj 3p76zmysCLbmzTNlGEA/dfgDzZqoAmQQkIDx6yN9ZLJcrMDbUPLiNfMZthiY/67qzfkG 7+yosiILHyI2UnhC0IX60J6p9edYEG3L66dlv1hRIVs0Ph7er4b8lCz2mDEzdkxMP/3v 9f2FM4NxK9BpKysNUyWo3+k7DDk+RfBbPTq8B1Tcbn0e+5uDTzur/K2EMB5JtX6joq1G ItPw== X-Gm-Message-State: AOJu0YxtnfAS9WvkbskXo9ZQUQtrW2/XZLvk2V6QdFIvnzJfHtOBenW2 hGFijkkfwauq4SCN2MoavMdPtSuYomi0GYEuF6NHaGdhqHMb2IPx1NXLJU1H X-Google-Smtp-Source: AGHT+IHvTJXWr/kuPuBnh5Kl1vHO6xC3MvkCoVCncoGx3lSvqygalDavpu6B7i3YRRYJeea+7bQUzQ== X-Received: by 2002:a05:6359:411f:b0:178:de46:783c with SMTP id kh31-20020a056359411f00b00178de46783cmr20938093rwc.16.1708482795408; Tue, 20 Feb 2024 18:33:15 -0800 (PST) Received: from [192.168.0.11] ([190.194.169.124]) by smtp.gmail.com with ESMTPSA id du22-20020a056a002b5600b006e45d5f0645sm5303254pfb.101.2024.02.20.18.33.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 18:33:14 -0800 (PST) Message-ID: Date: Tue, 20 Feb 2024 23:33:18 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240220024922.22779-1-michael@niedermayer.cc> <20240221011730.GX6420@pb2> From: James Almer In-Reply-To: <20240221011730.GX6420@pb2> 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 2/20/2024 10:17 PM, Michael Niedermayer wrote: > 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= 48, srcH = 48; >>> + int dstW= 48, dstH = 48; >>> + int srcHShift, srcVShift; >>> + int dstHShift, dstVShift; >>> + unsigned flags = 1; >>> + int srcStride[AV_VIDEO_MAX_PLANES] = {0}; >>> + int dstStride[AV_VIDEO_MAX_PLANES] = {0}; >>> + int ret; >>> + const uint8_t *end = data + size; >>> + enum AVPixelFormat srcFormat = AV_PIX_FMT_YUV420P; >>> + enum AVPixelFormat dstFormat = AV_PIX_FMT_YUV420P; >>> + uint8_t *src[AV_VIDEO_MAX_PLANES] = { 0 }; >>> + uint8_t *dst[AV_VIDEO_MAX_PLANES] = { 0 }; >>> + struct SwsContext *sws = NULL; >>> + const AVPixFmtDescriptor *desc_src, *desc_dst; >>> + >>> + if (size > 128) { >>> + GetByteContext gbc; >>> + int64_t flags64; >>> + >>> + size -= 128; >>> + bytestream2_init(&gbc, data + size, 128); >>> + srcW = bytestream2_get_le32(&gbc) % 16384; >>> + srcH = bytestream2_get_le32(&gbc) % 16384; >>> + dstW = bytestream2_get_le32(&gbc) % 16384; >>> + dstH = bytestream2_get_le32(&gbc) % 16384; >> >> Might as well use bytestream2_get_le16 to save bytes from the input buffer. >> >>> + >>> + if (srcW * (uint64_t)srcH > 16384 || dstW * (uint64_t)dstH > 16384) >>> + return 0; // we avoid high res as its very slow >> >> 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 <= 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 = (double)(*r0*10ll - 9ll*UINT32_MAX) / UINT32_MAX; > double a = exp(d) * 16384 / exp(1) ; > int ai = (int)round(a); > uint64_t maxb = 16384 / ai; > *r0 = ai; > *r1 = 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 hesitate > to replace it. Iam not sure this helps the fuzzer at all No, you know this better than i do. _______________________________________________ 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".