From patchwork Sat Apr 6 14:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Hill X-Patchwork-Id: 47884 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp1559824pzd; Sat, 6 Apr 2024 07:26:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUMI8zfVPwjKmnM4EUqTi9v8jxbInwb9I9vT71jfOjdCtLHpA8xMAuctoTGzotS22anlCHMDcW8fTVtxr4MJ4psxrDnZxprUfdHtQ== X-Google-Smtp-Source: AGHT+IEEhOgov4bhRdqi64c2E3QTMskz4c1nzJaeqVSa7razkwc2X0DyauQiBjhLLvI5j3VBN5zG X-Received: by 2002:a50:c348:0:b0:56e:2a7d:827c with SMTP id q8-20020a50c348000000b0056e2a7d827cmr3058301edb.18.1712413583014; Sat, 06 Apr 2024 07:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712413582; cv=none; d=google.com; s=arc-20160816; b=mKBCCYWo/vjv3FO00j4MgIb2HHC/35FvM8Pt9BZGyHbLjOcqb6V/g2/OIYUZcE9PzS lCy2u5UTrQ65UQTGSZ3EnSOGCqCm8MLJOh7anesA0DrBDYLgPJvLgtOU+CcOkbqQTMPV D0BSaK/ULU8g2xh1Dnx4+bOLrdd0DiM/2Y5AbFfBv46MWu0Qkjlgx6DnViviLFrDZFrw cYKly9NrwFtU+A6PpMXQIMn4NKjsNlRCuT1S1aLuuX1gDZtbtD0a4SjVws+zjfXmio37 GV/IYHkgv7JtFuwsYhhHVJLKlt0sGeAEy3KrsNc2v9Z8fMVYZIt5CIErr7EmQl+vTVex tZ+g== 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:in-reply-to:content-language:references:to:from :user-agent:mime-version:date:message-id:dkim-signature:delivered-to; bh=Hb2OXbR+ficrPN/EIpEtM/guNUi3odirBI0K1+574wE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=HP78D+WbI7zUyRPt/RRZu1nWJnNlyoWNjwVP3OjnhypsCbJP+TxL53KCcEPI4ghtDl MBkPu2oXkmgouGyM5COtXcpCoWK4aqSx4Oun7ihby/ceGY8bpUWWOyvQ2j14vT4GlqSJ XOhcz4VM9yKfaUvscGEBKTliiehzGZFU+6Qxef6qogoTe5RJm1CG1FBmp3TJD+j6COd+ MpRExmYgvMgSwVFzQdmzdtFX2taNuoN2ptJuhFZ0sfR7yRwo4OK7nFTsY7gaw01ONXGq KLPtitdpNGqZP3OXAZ/keilPzKzcvqpCxKBhjWcKsHOnO53pwSra1wj5fGEK1OHNLY6o dqjw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@geoffhill.org header.s=20220510 header.b=J+TEweDL; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=geoffhill.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z2-20020a5096c2000000b00568c14e5e31si1789848eda.428.2024.04.06.07.26.22; Sat, 06 Apr 2024 07:26:22 -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=@geoffhill.org header.s=20220510 header.b=J+TEweDL; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=geoffhill.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6DD3568D0F4; Sat, 6 Apr 2024 17:26:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from riki.gfrh.net (riki.gfrh.net [52.40.11.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BF46468D0AD for ; Sat, 6 Apr 2024 17:26:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geoffhill.org; s=20220510; t=1712413561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h1r2pWj3jaMHKzcL5fBwsIF1u4LuZhgREnE5JlaA7A8=; b=J+TEweDLRzdwbHE796YnenTK//zJQC/cBu/ebjZH7ar65wEk6Bbc+6dDhUl0Vwo//niqpc 3qC6TV7yD43Z9YQHtneRqMYg8m20W5CjZR6iWHb3BUnmLGtFF3jEBJgA7Lyn8fnS2SM9rg C8D+U1sCRrOHIrcgTFlM+yVNmwxfBKU= Received: by riki.gfrh.net (OpenSMTPD) with ESMTPSA id 9d9be2e7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sat, 6 Apr 2024 14:26:01 +0000 (UTC) Message-ID: Date: Sat, 6 Apr 2024 07:26:01 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Geoff Hill To: ffmpeg-devel@ffmpeg.org References: <51f7be0a-4267-47bf-ab0b-bd6585806da7@geoffhill.org> Content-Language: en-US In-Reply-To: <51f7be0a-4267-47bf-ab0b-bd6585806da7@geoffhill.org> Subject: [FFmpeg-devel] [PATCH v4 3/5] avcodec/ac3: Implement ac3_extract_exponents for aarch64 NEON 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: OkkytYOv2Ag3 Signed-off-by: Geoff Hill --- libavcodec/aarch64/ac3dsp_init_aarch64.c | 2 ++ libavcodec/aarch64/ac3dsp_neon.S | 14 +++++++++ tests/checkasm/ac3dsp.c | 38 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/libavcodec/aarch64/ac3dsp_init_aarch64.c b/libavcodec/aarch64/ac3dsp_init_aarch64.c index 8874b41393..1bdc215b51 100644 --- a/libavcodec/aarch64/ac3dsp_init_aarch64.c +++ b/libavcodec/aarch64/ac3dsp_init_aarch64.c @@ -26,6 +26,7 @@ #include "config.h" void ff_ac3_exponent_min_neon(uint8_t *exp, int num_reuse_blocks, int nb_coefs); +void ff_ac3_extract_exponents_neon(uint8_t *exp, int32_t *coef, int nb_coefs); void ff_float_to_fixed24_neon(int32_t *dst, const float *src, size_t len); av_cold void ff_ac3dsp_init_aarch64(AC3DSPContext *c) @@ -34,5 +35,6 @@ av_cold void ff_ac3dsp_init_aarch64(AC3DSPContext *c) if (!have_neon(cpu_flags)) return; c->ac3_exponent_min = ff_ac3_exponent_min_neon; + c->extract_exponents = ff_ac3_extract_exponents_neon; c->float_to_fixed24 = ff_float_to_fixed24_neon; } diff --git a/libavcodec/aarch64/ac3dsp_neon.S b/libavcodec/aarch64/ac3dsp_neon.S index f916c32538..c350c1f173 100644 --- a/libavcodec/aarch64/ac3dsp_neon.S +++ b/libavcodec/aarch64/ac3dsp_neon.S @@ -37,6 +37,20 @@ function ff_ac3_exponent_min_neon, export=1 3: ret endfunc +function ff_ac3_extract_exponents_neon, export=1 + movi v1.4s, #8 +1: ld1 {v0.4s}, [x1], #16 + abs v0.4s, v0.4s + clz v0.4s, v0.4s + sub v0.4s, v0.4s, v1.4s + xtn v0.4h, v0.4s + xtn v0.8b, v0.8h + st1 {v0.s}[0], [x0], #4 + subs w2, w2, #4 + b.gt 1b + ret +endfunc + function ff_float_to_fixed24_neon, export=1 1: ld1 {v0.4s, v1.4s}, [x1], #32 fcvtzs v0.4s, v0.4s, #24 diff --git a/tests/checkasm/ac3dsp.c b/tests/checkasm/ac3dsp.c index 06f31339f9..dc1b169e68 100644 --- a/tests/checkasm/ac3dsp.c +++ b/tests/checkasm/ac3dsp.c @@ -19,6 +19,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #include #include "libavutil/mem.h" @@ -36,6 +37,16 @@ } \ } while (0) +#define randomize_i24(buf, len) \ + do { \ + int i; \ + for (i = 0; i < len; i++) { \ + int32_t v = (int32_t)rnd(); \ + int32_t u = (v & 0xFFFFFF); \ + buf[i] = (v < 0) ? -u : u; \ + } \ + } while (0) + #define randomize_float(buf, len) \ do { \ int i; \ @@ -77,6 +88,32 @@ static void check_ac3_exponent_min(AC3DSPContext *c) { report("ac3_exponent_min"); } +static void check_ac3_extract_exponents(AC3DSPContext *c) { +#define MAX_EXPS 3072 + LOCAL_ALIGNED_16(int32_t, src, [MAX_EXPS]); + LOCAL_ALIGNED_16(uint8_t, v1, [MAX_EXPS]); + LOCAL_ALIGNED_16(uint8_t, v2, [MAX_EXPS]); + int n; + + declare_func(void, uint8_t *, int32_t *, int); + + for (n = 512; n <= MAX_EXPS; n += 256) { + if (check_func(c->extract_exponents, "ac3_extract_exponents_n%d", n)) { + randomize_i24(src, n); + + call_ref(v1, src, n); + call_new(v2, src, n); + + if (memcmp(v1, v2, n) != 0) + fail(); + + bench_new(v1, src, n); + } + } + + report("ac3_extract_exponents"); +} + static void check_float_to_fixed24(AC3DSPContext *c) { #define BUF_SIZE 1024 LOCAL_ALIGNED_32(float, src, [BUF_SIZE]); @@ -108,5 +145,6 @@ void checkasm_check_ac3dsp(void) ff_ac3dsp_init(&c); check_ac3_exponent_min(&c); + check_ac3_extract_exponents(&c); check_float_to_fixed24(&c); }