This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new d943d90925 avcodec/aarch64/audiodsp: add NEON vector_clip_int32 and 
vector_clipf
d943d90925 is described below

commit d943d90925393b61b89b487778ce615cc3b98f7c
Author:     Patryk Darmofalski <[email protected]>
AuthorDate: Tue Nov 3 01:54:15 2026 +0100
Commit:     Martin Storsjö <[email protected]>
CommitDate: Tue Nov 3 18:26:07 2026 +0000

    avcodec/aarch64/audiodsp: add NEON vector_clip_int32 and vector_clipf
    
    vector_clip_int32 is based on the 32-bit ARM NEON version. Unrolling to
    16 or 32 elements per iteration gave no measurable improvement over 8.
    
    vector_clipf applies fmin before fmaxnm, so any NaN input, including a
    signaling one, yields min as in C and as documented for av_clipf.
    
    checkasm --bench on Apple M4:
    vector_clip_int32_c:      1029.6
    vector_clip_int32_neon:    180.7 ( 5.38x)
    vector_clipf_c:            682.9
    vector_clipf_neon:         190.8 ( 3.34x)
    
    Signed-off-by: Patryk Darmofalski <[email protected]>
---
 libavcodec/aarch64/Makefile                        |  2 +
 .../audiodsp_init.c}                               | 21 ++++-----
 libavcodec/aarch64/audiodsp_neon.S                 | 52 ++++++++++++++++++++++
 libavcodec/audiodsp.c                              |  4 +-
 libavcodec/audiodsp.h                              |  1 +
 5 files changed, 69 insertions(+), 11 deletions(-)

diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 06bbb9152f..551c45b055 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -1,5 +1,6 @@
 # subsystems
 OBJS-$(CONFIG_AC3DSP)                   += aarch64/ac3dsp_init_aarch64.o
+OBJS-$(CONFIG_AUDIODSP)                 += aarch64/audiodsp_init.o
 OBJS-$(CONFIG_FDCTDSP)                  += aarch64/fdctdsp_init_aarch64.o
 OBJS-$(CONFIG_H264CHROMA)               += aarch64/h264chroma_init_aarch64.o
 OBJS-$(CONFIG_H264DSP)                  += aarch64/h264dsp_init_aarch64.o
@@ -47,6 +48,7 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP)           += aarch64/videodsp.o
 NEON-OBJS-$(CONFIG_AAC_DECODER)         += aarch64/sbrdsp_neon.o
 NEON-OBJS-$(CONFIG_AAC_ENCODER)         += aarch64/aacencdsp_neon.o
 NEON-OBJS-$(CONFIG_AC3DSP)              += aarch64/ac3dsp_neon.o
+NEON-OBJS-$(CONFIG_AUDIODSP)            += aarch64/audiodsp_neon.o
 NEON-OBJS-$(CONFIG_FDCTDSP)             += aarch64/fdctdsp_neon.o
 NEON-OBJS-$(CONFIG_H264CHROMA)          += aarch64/h264cmc_neon.o
 NEON-OBJS-$(CONFIG_H264DSP)             += aarch64/h264dsp_neon.o              
\
diff --git a/libavcodec/arm/audiodsp_init_neon.c 
b/libavcodec/aarch64/audiodsp_init.c
similarity index 70%
copy from libavcodec/arm/audiodsp_init_neon.c
copy to libavcodec/aarch64/audiodsp_init.c
index 6902db86b4..07b48ae70a 100644
--- a/libavcodec/arm/audiodsp_init_neon.c
+++ b/libavcodec/aarch64/audiodsp_init.c
@@ -1,6 +1,5 @@
 /*
- * ARM NEON optimised audio functions
- * Copyright (c) 2008 Mans Rullgard <[email protected]>
+ * Copyright (c) 2026 Patryk Darmofalski <[email protected]>
  *
  * This file is part of FFmpeg.
  *
@@ -22,19 +21,21 @@
 #include <stdint.h>
 
 #include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/aarch64/cpu.h"
 #include "libavcodec/audiodsp.h"
-#include "audiodsp_arm.h"
 
-void ff_vector_clipf_neon(float *dst, const float *src, int len, float min, 
float max);
 void ff_vector_clip_int32_neon(int32_t *dst, const int32_t *src, int32_t min,
                                int32_t max, unsigned int len);
+void ff_vector_clipf_neon(float *dst, const float *src, int len, float min,
+                          float max);
 
-int32_t ff_scalarproduct_int16_neon(const int16_t *v1, const int16_t *v2, int 
len);
-
-av_cold void ff_audiodsp_init_neon(AudioDSPContext *c)
+av_cold void ff_audiodsp_init_aarch64(AudioDSPContext *c)
 {
-    c->vector_clip_int32 = ff_vector_clip_int32_neon;
-    c->vector_clipf      = ff_vector_clipf_neon;
+    int cpu_flags = av_get_cpu_flags();
 
-    c->scalarproduct_int16 = ff_scalarproduct_int16_neon;
+    if (have_neon(cpu_flags)) {
+        c->vector_clip_int32 = ff_vector_clip_int32_neon;
+        c->vector_clipf      = ff_vector_clipf_neon;
+    }
 }
diff --git a/libavcodec/aarch64/audiodsp_neon.S 
b/libavcodec/aarch64/audiodsp_neon.S
new file mode 100644
index 0000000000..59131c3084
--- /dev/null
+++ b/libavcodec/aarch64/audiodsp_neon.S
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2008 Mans Rullgard <[email protected]>
+ * Copyright (c) 2026 Patryk Darmofalski <[email protected]>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "libavutil/aarch64/asm.S"
+
+function ff_vector_clip_int32_neon, export=1
+        dup             v0.4s, w2
+        dup             v1.4s, w3
+1:
+        ld1             {v2.4s, v3.4s}, [x1], #32
+        smin            v2.4s, v2.4s, v1.4s
+        smin            v3.4s, v3.4s, v1.4s
+        smax            v2.4s, v2.4s, v0.4s
+        smax            v3.4s, v3.4s, v0.4s
+        subs            w4, w4, #8
+        st1             {v2.4s, v3.4s}, [x0], #32
+        b.ne            1b
+        ret
+endfunc
+
+function ff_vector_clipf_neon, export=1
+        dup             v0.4s, v0.s[0]
+        dup             v1.4s, v1.s[0]
+1:
+        ld1             {v2.4s, v3.4s}, [x1], #32
+        fmin            v2.4s, v2.4s, v1.4s
+        fmin            v3.4s, v3.4s, v1.4s
+        fmaxnm          v2.4s, v2.4s, v0.4s
+        fmaxnm          v3.4s, v3.4s, v0.4s
+        subs            w2, w2, #8
+        st1             {v2.4s, v3.4s}, [x0], #32
+        b.gt            1b
+        ret
+endfunc
diff --git a/libavcodec/audiodsp.c b/libavcodec/audiodsp.c
index a4758bb4c3..6bd9e719fa 100644
--- a/libavcodec/audiodsp.c
+++ b/libavcodec/audiodsp.c
@@ -68,7 +68,9 @@ av_cold void ff_audiodsp_init(AudioDSPContext *c)
     c->vector_clip_int32   = vector_clip_int32_c;
     c->vector_clipf        = vector_clipf_c;
 
-#if ARCH_ARM
+#if ARCH_AARCH64
+    ff_audiodsp_init_aarch64(c);
+#elif ARCH_ARM
     ff_audiodsp_init_arm(c);
 #elif ARCH_PPC
     ff_audiodsp_init_ppc(c);
diff --git a/libavcodec/audiodsp.h b/libavcodec/audiodsp.h
index 485b512839..764f23cd57 100644
--- a/libavcodec/audiodsp.h
+++ b/libavcodec/audiodsp.h
@@ -53,6 +53,7 @@ typedef struct AudioDSPContext {
 } AudioDSPContext;
 
 void ff_audiodsp_init(AudioDSPContext *c);
+void ff_audiodsp_init_aarch64(AudioDSPContext *c);
 void ff_audiodsp_init_arm(AudioDSPContext *c);
 void ff_audiodsp_init_ppc(AudioDSPContext *c);
 void ff_audiodsp_init_riscv(AudioDSPContext *c);

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to