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 E13ED49202 for ; Sat, 6 Apr 2024 14:26:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 398B168D092; Sat, 6 Apr 2024 17:26:07 +0300 (EEST) Received: from riki.gfrh.net (riki.gfrh.net [52.40.11.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C6A8068CFF4 for ; Sat, 6 Apr 2024 17:26:00 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geoffhill.org; s=20220510; t=1712413556; 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=mhJpYDWi0axt24WZ+LYomuO0VlHYE6m5vQlBto53dUM=; b=cUM6NFU8fZmCBPZzVGhYI4lHKcOOzAgOXvniPD3rMWA1xKrgRlzxPAG0GdRBywKIzmUv52 /r3QdUKAf/rc4e8t8rh6E5671aHM9iEclEXuk4epf6JqP1qYk594oXDECSkPosf9DVNp2P OU4V4DPy0pHkSKdGFb2PwqbG5pz1U0M= Received: by riki.gfrh.net (OpenSMTPD) with ESMTPSA id 2eec3a5d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sat, 6 Apr 2024 14:25:56 +0000 (UTC) Message-ID: <7594175d-da69-4483-9073-74d5235266b4@geoffhill.org> Date: Sat, 6 Apr 2024 07:25:56 -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 2/5] avcodec/ac3: Implement ac3_exponent_min 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Geoff Hill --- libavcodec/aarch64/ac3dsp_init_aarch64.c | 2 ++ libavcodec/aarch64/ac3dsp_neon.S | 16 +++++++++ tests/checkasm/ac3dsp.c | 41 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/libavcodec/aarch64/ac3dsp_init_aarch64.c b/libavcodec/aarch64/ac3dsp_init_aarch64.c index e3320de0f5..8874b41393 100644 --- a/libavcodec/aarch64/ac3dsp_init_aarch64.c +++ b/libavcodec/aarch64/ac3dsp_init_aarch64.c @@ -25,6 +25,7 @@ #include "libavcodec/ac3dsp.h" #include "config.h" +void ff_ac3_exponent_min_neon(uint8_t *exp, int num_reuse_blocks, 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) @@ -32,5 +33,6 @@ av_cold void ff_ac3dsp_init_aarch64(AC3DSPContext *c) int cpu_flags = av_get_cpu_flags(); if (!have_neon(cpu_flags)) return; + c->ac3_exponent_min = ff_ac3_exponent_min_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 c4d204b51a..f916c32538 100644 --- a/libavcodec/aarch64/ac3dsp_neon.S +++ b/libavcodec/aarch64/ac3dsp_neon.S @@ -21,6 +21,22 @@ #include "libavutil/aarch64/asm.S" +function ff_ac3_exponent_min_neon, export=1 + cbz w1, 3f +1: ld1 {v0.16b}, [x0] + mov w3, w1 + add x4, x0, #256 +2: ld1 {v1.16b}, [x4] + umin v0.16b, v0.16b, v1.16b + add x4, x4, #256 + subs w3, w3, #1 + b.gt 2b + st1 {v0.16b}, [x0], #16 + subs w2, w2, #16 + b.gt 1b +3: 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 b1064fccb4..06f31339f9 100644 --- a/tests/checkasm/ac3dsp.c +++ b/tests/checkasm/ac3dsp.c @@ -28,6 +28,14 @@ #include "checkasm.h" +#define randomize_exp(buf, len) \ + do { \ + int i; \ + for (i = 0; i < len; i++) { \ + buf[i] = (uint8_t)rnd(); \ + } \ + } while (0) + #define randomize_float(buf, len) \ do { \ int i; \ @@ -37,6 +45,38 @@ } \ } while (0) +static void check_ac3_exponent_min(AC3DSPContext *c) { +#define MAX_COEFS 256 +#define MAX_CTXT 6 +#define EXP_SIZE (MAX_CTXT * MAX_COEFS) + + LOCAL_ALIGNED_16(uint8_t, src, [EXP_SIZE]); + LOCAL_ALIGNED_16(uint8_t, v1, [EXP_SIZE]); + LOCAL_ALIGNED_16(uint8_t, v2, [EXP_SIZE]); + int n; + + declare_func(void, uint8_t *, int, int); + + for (n = 0; n < MAX_CTXT; ++n) { + if (check_func(c->ac3_exponent_min, "ac3_exponent_min_reuse%d", n)) { + randomize_exp(src, EXP_SIZE); + + memcpy(v1, src, EXP_SIZE); + memcpy(v2, src, EXP_SIZE); + + call_ref(v1, n, MAX_COEFS); + call_new(v2, n, MAX_COEFS); + + if (memcmp(v1, v2, EXP_SIZE) != 0) + fail(); + + bench_new(v2, n, MAX_COEFS); + } + } + + report("ac3_exponent_min"); +} + static void check_float_to_fixed24(AC3DSPContext *c) { #define BUF_SIZE 1024 LOCAL_ALIGNED_32(float, src, [BUF_SIZE]); @@ -67,5 +107,6 @@ void checkasm_check_ac3dsp(void) AC3DSPContext c; ff_ac3dsp_init(&c); + check_ac3_exponent_min(&c); check_float_to_fixed24(&c); } -- 2.42.0 _______________________________________________ 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".