Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Geoff Hill <geoff@geoffhill.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v4 2/5] avcodec/ac3: Implement ac3_exponent_min for aarch64 NEON
Date: Sat, 6 Apr 2024 07:25:56 -0700
Message-ID: <7594175d-da69-4483-9073-74d5235266b4@geoffhill.org> (raw)
In-Reply-To: <51f7be0a-4267-47bf-ab0b-bd6585806da7@geoffhill.org>

Signed-off-by: Geoff Hill <geoff@geoffhill.org>
---
 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".

  parent reply	other threads:[~2024-04-06 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06 14:23 [FFmpeg-devel] [PATCH v4 0/5] avcodec/ac3: Add aarch64 NEON DSP Geoff Hill
2024-04-06 14:25 ` [FFmpeg-devel] [PATCH v4 1/5] avcodec/ac3: Implement float_to_fixed24 for aarch64 NEON Geoff Hill
2024-04-06 14:25 ` Geoff Hill [this message]
2024-04-06 14:26 ` [FFmpeg-devel] [PATCH v4 3/5] avcodec/ac3: Implement ac3_extract_exponents " Geoff Hill
2024-04-06 14:26 ` [FFmpeg-devel] [PATCH v4 4/5] avcodec/ac3: Implement sum_square_butterfly_int32 " Geoff Hill
2024-04-06 14:26 ` [FFmpeg-devel] [PATCH v4 5/5] avcodec/ac3: Implement sum_square_butterfly_float " Geoff Hill
2024-04-08 10:47 ` [FFmpeg-devel] [PATCH v4 0/5] avcodec/ac3: Add aarch64 NEON DSP Martin Storsjö

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7594175d-da69-4483-9073-74d5235266b4@geoffhill.org \
    --to=geoff@geoffhill.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git