From patchwork Wed May 29 19:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49362 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6918:6418:b0:236:cb83:c33d with SMTP id y24csp45043ysl; Wed, 29 May 2024 12:42:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUu9NK9iTUw7Z2JPPz1cnDbYcxo75UnT/MNrzT2KBZiNOrC6w6xPYvo2tjCnItx1QHSRvpVaAhMI89EZ3gMWghVtVRBjulrnh1Ug== X-Google-Smtp-Source: AGHT+IHeWgvLhwb3Chesv01rdLK25VINdnUi2fGptEGwzBLHGWyQvmnK9h/WVGtZw6ko6lJD+WbD X-Received: by 2002:a2e:9a90:0:b0:2e1:d94a:773f with SMTP id 38308e7fff4ca-2e95b096d84mr102917051fa.11.1717011741644; Wed, 29 May 2024 12:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717011741; cv=none; d=google.com; s=arc-20160816; b=ecDgnvmpPsJ4+H0Of5BhKYCQ7raQNzlaUh33Pzo+Dk2ZKa1sI/SB1YJIQwLeagoMrm LjxpQOsKrdFbdb7GdvjCY5g+XWz2d+BkoY915eGPMCM27PHrzOGBRgmoQFC5JcutIDsV +IgoNVP1LfZ9moR4NGQd6PIGyJlMhRe15o2nz0Kf4/zwMtHrYyD/eNaqXbHlKnAepG+s 9X/Z6tt95hYHS0gn1DPTFz9YHs801dBoo7n8aPTFKGwoddCEAn0qb+dVXUR8jpkObfqr v6H2HV6n/YQZNG4aAkpvatNzRaWKK4FkcqFi2DMiKawxoxuxa/rVKD9otIsIekW97cod RnVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=W5OHGHbmanabIgt3gd6X929Gxx8GjKD97vGdmwerPJM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=ep41X/IkAA4FSEMAA7snsUOgxPG407LxO8ntFpAR4QjXUZJjfBSSm7NiQzfffdSfCe lh1BFqm8Z1QQ71727zWu/553+D+cZhDBlRWOMrboR9klelbqK8Kt7YJg5lKQ/D4KGJuW HiEKULlJxgcHE+Z2L5vsc5Zfy0031gjId53Tsk05B2xysVXSRXO1zo4iUyjKwWaVnPCW AkUWeEDpgmqlmW8p4AocjHo4Ixl+0kVf3jgafuPpGDIBk1wciyW52hmhnmNX/XcIuyGG vKOFlhYZXiH8HxxDU5mFuol9Mc5MTIRLsgfblAaG4ZfWN9k5x9LHJHH4JitdVPUDCM+a 2lyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 38308e7fff4ca-2ea820460a3si1456971fa.362.2024.05.29.12.42.20; Wed, 29 May 2024 12:42:21 -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; 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 4D49768D494; Wed, 29 May 2024 22:42:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 400A668D39C for ; Wed, 29 May 2024 22:42:02 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id D712CC006D for ; Wed, 29 May 2024 22:42:01 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 May 2024 22:42:01 +0300 Message-ID: <20240529194201.63737-1-remi@remlab.net> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHv4] checkasm/lpc: test compute_autocorr 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jNk+dOXWU1Ud Also restrict length to even values, matching real uses. This test is disabled, known broken, on x86. --- tests/checkasm/lpc.c | 57 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 592e34c03d..cb15e8245b 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "libavutil/avassert.h" #include "libavutil/mem_internal.h" #include "libavcodec/lpc.h" @@ -30,7 +31,7 @@ } \ } while (0) -#define EPS 0.005 +#define EPS 0.0001 static void test_window(int len) { @@ -57,10 +58,51 @@ static void test_window(int len) bench_new(src, len, dst1); } +#if !ARCH_X86 +static void test_compute_autocorr(ptrdiff_t len, int lag) +{ + const double eps = EPS * (double)len; + LOCAL_ALIGNED(32, double, src, [5000 + 2 + MAX_LPC_ORDER]); + LOCAL_ALIGNED(16, double, dst0, [MAX_LPC_ORDER + 1]); + LOCAL_ALIGNED(16, double, dst1, [MAX_LPC_ORDER + 1]); + + declare_func(void, const double *in, ptrdiff_t len, int lag, double *out); + + av_assert0(lag >= 0 && lag <= MAX_LPC_ORDER); + + for (int i = 0; i < MAX_LPC_ORDER; i++) + src[i] = 0.; + + src += MAX_LPC_ORDER; + + for (int i = 0; i < 5000 + 2; i++) { + src[i] = (double)rnd() / (double)UINT_MAX; + } + + call_ref(src, len, lag, dst0); + call_new(src, len, lag, dst1); + + for (size_t i = 0; i <= lag; i++) { + if (!double_near_abs_eps(dst0[i], dst1[i], eps)) { + fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n", + i, dst0[i], dst1[i], dst0[i] - dst1[i]); + fail(); + break; + } + } + + bench_new(src, 4608, lag, dst1); +} +#endif + void checkasm_check_lpc(void) { LPCContext ctx; - int len = rnd() % 5000; + int len = 2000 + (rnd() % 1500) * 2; +#if !ARCH_X86 + static const int lags[] = { 8, 12, }; +#endif + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { @@ -72,6 +114,15 @@ void checkasm_check_lpc(void) test_window(len | 1); } report("apply_welch_window_odd"); - ff_lpc_end(&ctx); + +#if !ARCH_X86 + for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) { + ff_lpc_init(&ctx, len, lags[i], FF_LPC_TYPE_DEFAULT); + if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i])) + test_compute_autocorr(len, lags[i]); + ff_lpc_end(&ctx); + } + report("compute_autocorr"); +#endif }