From patchwork Thu Aug 18 08:16:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 37345 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp175293pzh; Thu, 18 Aug 2022 01:16:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5QpRJ8YEzuEyiNy1FgjZ2j5zQD/9fGMyIagMsNMBHkBleJkaZguixXFmkI9Q5+DvBBZ8n0 X-Received: by 2002:a17:907:8a09:b0:731:610:ff8d with SMTP id sc9-20020a1709078a0900b007310610ff8dmr1156753ejc.399.1660810618175; Thu, 18 Aug 2022 01:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660810618; cv=none; d=google.com; s=arc-20160816; b=L22cmdqs47IZlMObtZv9Qu8a5ZEAhAudxbmoqVGEgN28DMTg0XQwN5ZqH7sq0NQ6DK 3xZwlwTczSb9JdMEh/VJHYP5jHmYHkKFB3GAlKm/So0a0umT61HB+Ae4jr0KV3LNURlX xrcioT2Zcy8veK+UqXYJkzaoo6ujg35tFyyjcR1I7ARo+jE+cIkA1scpzKDb5YnSRXRs v2u9DRbDb07s2c1prTMYWar2X0CrUjyVY9Nn+dx336I1Zxxfr2n+D6TkIXMyWIkD+hid rBIfTt2mVVt9UKZuIjsx2ZN42E7remmsHNVa1babkLi+Pwr9IjYpnlA84EOMVYKptR9j nhzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=O8DXrTFz+EzjxsJMJejHmq53HIJ7WOf1Kfaz93kEdtQ=; b=mZs0N92+DDs+hIx8MJ42HPyC6L2Xgnr3owQD9T23Zda1Ii7bIIKoiLvDnu9pj3vI34 y3OCkssvtW9SiLI1qi3qVGDzfxrbLuk9Aq7JN4xCjJRVrgUgTicMd8ppvkEiG2YI5/tg Lx1WEbi943QHf95fdOwdvPARDCMoLMDcSRdKN/efU8pzZG60DwEMRREV9wQD6Gs7X9BO I1cAlMrPpEoWAPEQSGbmIoZ/aS1akNaLHlubs8rGjLMQqYU/bazKNwhmvE5V0Bb6XjpI 9GxrNYt5PY39M8zjK54JIreszyvSYXK3zFw8F8CKSJ/pXSKZqwNQOzdaaBEYqw89AvAO 8C8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=ADOB58zR; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n13-20020a05640205cd00b004461892a984si470852edx.282.2022.08.18.01.16.57; Thu, 18 Aug 2022 01:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=ADOB58zR; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C2EB268B992; Thu, 18 Aug 2022 11:16:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9ED6B68B8A0 for ; Thu, 18 Aug 2022 11:16:47 +0300 (EEST) Received: by mail-lf1-f41.google.com with SMTP id l1so657511lfk.8 for ; Thu, 18 Aug 2022 01:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=Raijn0kitue9/NjFPs6Jfai9YZav34Hq9N6mCjR+LLk=; b=ADOB58zRGFwgD5/7Hh+9iHBQGkw+zBre3I1kQtDeVSCIwK1komr4Ox/A22B/WmuXjB X0eglJnLtxcHpLMJCllRWQFvvWVbWhmX9sDrpuRL2ggbzUHT8pgIIL766BVS8mHesD+I fF7IK9Ttrtyaqlg0YKA4O3OEU2YdUCuRP3lA7AuBd006QqGXqQCtBM7Chut8hOoF5TTu VT3zx5fNVtDVPhvkNfyztSqERHIVu1KoOvvmbcniV312LSui2iZl541pJZtqB40/fLI2 k4ZFefz9P8ffOYsHXdewexHGhzRf+sOUkt0Rj7mF6tbYVoocvM+srAbGpyt4DsSbTucN Aydw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=Raijn0kitue9/NjFPs6Jfai9YZav34Hq9N6mCjR+LLk=; b=XU+i8nEEkV9ZFeQHwaIM2adWk96solR0UrGhig4q7Cu543oJU7CBFznPp6lfL9M9S2 K3WKzVXf66ovvESGwmFXS9Fn3uGQnDjJu2XfnQsCu7UksOKHvRqD0WaikpiYh2kxE8/O D4c37bnssmXdLysxLONBVWD+krr40oyqa2x/ZNUSB6RrrW6pNbAcsc2BuCP8Itd5XiyK 6Ge2OnM85VUp92LJkNMP/canvppqI/URorpTsbXdGbTJR0f87zDbfCuNUH60xyOFjT2j wh07XsaEcomNEhZW9/6qUldS3hK2Ou+IyTKhBxgvq9MSx//r/XRTHqSI82D7eQ76/saV hc+g== X-Gm-Message-State: ACgBeo3l/G0CHGXdTQtwEPMqwrv8pcD+otpuYl9qLQ6hf09KfHCry3r0 vxtNM861H5yBA5wRSvoffD4byrCVcRTAuuzA X-Received: by 2002:a05:6512:2216:b0:48b:3a34:d14a with SMTP id h22-20020a056512221600b0048b3a34d14amr644400lfu.158.1660810606879; Thu, 18 Aug 2022 01:16:46 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id u11-20020ac248ab000000b00491dda41e4bsm129964lfg.172.2022.08.18.01.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 01:16:46 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 18 Aug 2022 11:16:45 +0300 Message-Id: <20220818081645.3352481-1-martin@martin.st> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] checkasm: sw_scale: Produce more realistic test filter coefficients for yuv2yuvX 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 Cc: rsbultje@gmail.com, =?utf-8?q?Martin_Storsj=C3=B6?= , alankelly@google.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JuQ23Wq1Sl0L This avoids triggering overflows in the filters, and avoids stray test failures in the approximate functions on x86; due to rounding differences, one implementation might overflow while another one doesn't. Signed-off-by: Martin Storsjö --- FWIW, this modification runs successfully with over 1000 different seeds in checkasm. --- tests/checkasm/sw_scale.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index d72506ed86..ec06eafebe 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -188,7 +188,6 @@ static void check_yuv2yuvX(int accurate) uint8_t d_val = rnd(); memset(dither, d_val, LARGEST_INPUT_SIZE); randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t)); - randomize_buffers((uint8_t*)filter_coeff, LARGEST_FILTER * sizeof(int16_t)); ctx = sws_alloc_context(); if (accurate) ctx->flags |= SWS_ACCURATE_RND; @@ -202,6 +201,21 @@ static void check_yuv2yuvX(int accurate) if (dstW <= osi) continue; for (fsi = 0; fsi < FILTER_SIZES; ++fsi) { + // Generate filter coefficients for the given filter size, + // with some properties: + // - The coefficients add up to the intended sum (4096, 1<<12) + // - The coefficients contain negative values + // - The filter intermediates don't overflow for worst case + // inputs (all positive coefficients are coupled with + // input_max and all negative coefficients with input_min, + // or vice versa). + // Produce a filter with all coefficients set to + // -((1<<12)/(filter_size-1)) except for one (randomly chosen) + // which is set to ((1<<13)-1). + for (i = 0; i < filter_sizes[fsi]; ++i) + filter_coeff[i] = -((1 << 12) / (filter_sizes[fsi] - 1)); + filter_coeff[rnd() % filter_sizes[fsi]] = (1 << 13) - 1; + src = av_malloc(sizeof(int16_t*) * filter_sizes[fsi]); vFilterData = av_malloc((filter_sizes[fsi] + 2) * sizeof(union VFilterData)); memset(vFilterData, 0, (filter_sizes[fsi] + 2) * sizeof(union VFilterData));