From patchwork Sun Nov 12 19:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 44642 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp951767pzg; Sun, 12 Nov 2023 11:46:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3E4cN4QRQ3LLk0lLD0yxsm0Pd85BWfTuFRKrwNKx2SY7djxdM9OJs3d5sho4PcWcJ+11D X-Received: by 2002:a17:906:514:b0:9de:32bb:fa95 with SMTP id j20-20020a170906051400b009de32bbfa95mr3492188eja.35.1699818365308; Sun, 12 Nov 2023 11:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699818365; cv=none; d=google.com; s=arc-20160816; b=BrbvVjyUitRejzuM+I7LwrdGL8i/JyEUPoSoOU/wGZfp+NJtbqyIgAvMjkUpHo1UyF kj2sn6RI7OxHhQO2/iFknp0EL5BqgpY+2slPLzy28X15tkpey8oMBrvpoVJkNvPGRt8q 7sRt0nHtzEVAKxEl27zoqtBcvfN14aUuLm8xbt6FguPd/IhVob/tLXkRqoY+fGtFm9x0 Cl8bsayW72bvb8EGEgqCLxifBvkCpa1QciGR97lPsNtq6KzbGlWTVUVJA1VmUQ0Ur4gD 1FOPFqSqoxdGZPx76rSoT9StOPgxLTJYOXymSBkXFjASpF5fnZm5RVsJDvDP0LAhe2cB 2hNg== 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=ZISgo2eztwktJ/2ma0OeHaisOGB45eMcSSMiF1DT8qk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=CLrPIVs8YeSGPz6CWq2qYdeK/FbiPhBzur30aX5Tl3LcRdqIfjhAHb/H8tpg7uv7/9 gvtEZ1XdsXyecan+CCd2gxxTMrCMoLMYZdfQdZYoITxVOG24Sgyy5xBod2NKQUltjYSJ pf+hympNpCGkLPtrCKozV/uGG0wvouXthXjQuNqin9JULQ2Mu+4NyOe2JWxFm+Ospdo0 kI5HuovpPHNSLv1e/17dM7K1tGhot5l5+YJvcK524wGBS1fxVVudkvNCqIX7p5/lkFh0 zd8ZVcUXS8DL1YC2oo2hhYuqFfQTQrHgxECuKhMWwFR2+LmfZF2CFmcjM/S/mPKjzR6e X+wA== 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 le30-20020a170907171e00b009e42844ab5esi1855246ejc.60.2023.11.12.11.46.04; Sun, 12 Nov 2023 11:46:05 -0800 (PST) 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 219EF68CC67; Sun, 12 Nov 2023 21:46:01 +0200 (EET) 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 F0F4468C987 for ; Sun, 12 Nov 2023 21:45:53 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 5C88FC006F for ; Sun, 12 Nov 2023 21:45:53 +0200 (EET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2023 21:45:52 +0200 Message-ID: <20231112194553.23248-1-remi@remlab.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] checkasm: add lossless audio DSP 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: g7Dz/Jcd4vZ7 --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + tests/checkasm/llauddsp.c | 115 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 tests/checkasm/llauddsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 594db4df9d..8bc241d29b 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -10,6 +10,7 @@ AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o AVCODECOBJS-$(CONFIG_IDCTDSP) += idctdsp.o +AVCODECOBJS-$(CONFIG_LLAUDDSP) += llauddsp.o AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o AVCODECOBJS-$(CONFIG_LPC) += lpc.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 51e97686cb..0cff1c45cb 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -143,6 +143,9 @@ static const struct { #if CONFIG_JPEG2000_DECODER { "jpeg2000dsp", checkasm_check_jpeg2000dsp }, #endif + #if CONFIG_LLAUDDSP + { "llauddsp", checkasm_check_llauddsp }, + #endif #if CONFIG_HUFFYUVDSP { "llviddsp", checkasm_check_llviddsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 5638a7fa87..c379ac3c0c 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -70,6 +70,7 @@ void checkasm_check_hevc_sao(void); void checkasm_check_huffyuvdsp(void); void checkasm_check_idctdsp(void); void checkasm_check_jpeg2000dsp(void); +void checkasm_check_llauddsp(void); void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); void checkasm_check_lpc(void); diff --git a/tests/checkasm/llauddsp.c b/tests/checkasm/llauddsp.c new file mode 100644 index 0000000000..e6eab589b2 --- /dev/null +++ b/tests/checkasm/llauddsp.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2016 Alexandra Hájková + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" +#include "libavutil/mem_internal.h" + +#include "libavcodec/lossless_audiodsp.h" + +#include "checkasm.h" + +#define randomize_buf(buf, len) \ + do { \ + for (int i = 0; i < len; i++) \ + buf[i] = rnd(); \ + } while (0) + +static void check_scalarproduct_and_madd_int16(LLAudDSPContext *c) +{ +#define BUF_SIZE 1088 // multiple of 16 + LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]); + LOCAL_ALIGNED_16(int16_t, v2, [BUF_SIZE]); + LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]); + int mul; + + declare_func(int32_t, int16_t *, const int16_t *, const int16_t *, + int, int); + + randomize_buf(v1, BUF_SIZE); + randomize_buf(v2, BUF_SIZE); + randomize_buf(v3, BUF_SIZE); + mul = rnd(); + + if (check_func(c->scalarproduct_and_madd_int16, + "scalarproduct_and_madd_int16")) { + LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]); + int ref, val; + + memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE); + memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE); + ref = call_ref(dst0, v2, v3, BUF_SIZE, mul); + val = call_new(dst1, v2, v3, BUF_SIZE, mul); + if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val) + fail(); + + bench_new(v1, v2, v3, BUF_SIZE, mul); + } + + report("scalarproduct_and_madd_int16"); +} + +static void check_scalarproduct_and_madd_int32(LLAudDSPContext *c) +{ +#define BUF_SIZE 1088 // multiple of 16 + LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]); + LOCAL_ALIGNED_16(int32_t, v2, [BUF_SIZE]); + LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]); + int mul; + + declare_func(int32_t, int16_t *, const int32_t *, const int16_t *, + int, int); + + randomize_buf(v1, BUF_SIZE); + randomize_buf(v2, BUF_SIZE); + randomize_buf(v3, BUF_SIZE); + mul = rnd(); + + if (check_func(c->scalarproduct_and_madd_int32, + "scalarproduct_and_madd_int32")) { + LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]); + int ref, val; + + memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE); + memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE); + ref = call_ref(dst0, v2, v3, BUF_SIZE, mul); + val = call_new(dst1, v2, v3, BUF_SIZE, mul); + if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val) + fail(); + + bench_new(v1, v2, v3, BUF_SIZE, mul); + } + + report("scalarproduct_and_madd_int32"); +} + +void checkasm_check_llauddsp(void) +{ + LLAudDSPContext c; + + ff_llauddsp_init(&c); + check_scalarproduct_and_madd_int16(&c); + check_scalarproduct_and_madd_int32(&c); +}