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 de18feb0f0 avutil/aarch64: add pixelutils 32x32 SAD NEON implementation
de18feb0f0 is described below

commit de18feb0f099154e6ccb6d3746881030d2f53fa1
Author:     Jeongkeun Kim <[email protected]>
AuthorDate: Sat Apr 4 20:20:13 2026 +0900
Commit:     Martin Storsjö <[email protected]>
CommitDate: Sun Apr 19 19:27:55 2026 +0000

    avutil/aarch64: add pixelutils 32x32 SAD NEON implementation
    
    This adds a NEON-optimized function for computing 32x32 Sum of Absolute
    Differences (SAD) on AArch64, addressing a gap where x86 had SSE2/AVX2
    implementations but AArch64 lacked equivalent coverage.
    
    The implementation mirrors the existing sad8 and sad16 NEON functions,
    employing a 4-row unrolled loop with UABAL and UABAL2 instructions for
    efficient load-compute interleaving, and four 8x16-bit accumulators to
    handle the wider 32-byte rows.
    
    Benchmarks on AWS Graviton3 (Neoverse V1, c7g.xlarge) using checkasm:
      sad_32x32_0: C 146.4 cycles -> NEON  98.1 cycles (1.49x speedup)
      sad_32x32_1: C 141.4 cycles -> NEON  98.9 cycles (1.43x speedup)
      sad_32x32_2: C 140.7 cycles -> NEON  95.0 cycles (1.48x speedup)
    
    Signed-off-by: Jeongkeun Kim <[email protected]>
---
 libavutil/aarch64/pixelutils.h      |  5 +++-
 libavutil/aarch64/pixelutils_neon.S | 47 +++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/libavutil/aarch64/pixelutils.h b/libavutil/aarch64/pixelutils.h
index e969ee81ed..02d22ab692 100644
--- a/libavutil/aarch64/pixelutils.h
+++ b/libavutil/aarch64/pixelutils.h
@@ -27,9 +27,11 @@
 #include "libavutil/cpu.h"
 #include "libavutil/pixelutils.h"
 
+int ff_pixelutils_sad8_neon (const uint8_t *src1, ptrdiff_t stride1,
+                             const uint8_t *src2, ptrdiff_t stride2);
 int ff_pixelutils_sad16_neon(const uint8_t *src1, ptrdiff_t stride1,
                              const uint8_t *src2, ptrdiff_t stride2);
-int ff_pixelutils_sad8_neon (const uint8_t *src1, ptrdiff_t stride1,
+int ff_pixelutils_sad32_neon(const uint8_t *src1, ptrdiff_t stride1,
                              const uint8_t *src2, ptrdiff_t stride2);
 
 static inline av_cold void ff_pixelutils_sad_init_aarch64(av_pixelutils_sad_fn 
*sad, int aligned)
@@ -39,6 +41,7 @@ static inline av_cold void 
ff_pixelutils_sad_init_aarch64(av_pixelutils_sad_fn *
     if (have_neon(cpu_flags)) {
         sad[2] = ff_pixelutils_sad8_neon;
         sad[3] = ff_pixelutils_sad16_neon;
+        sad[4] = ff_pixelutils_sad32_neon;
     }
 }
 #endif
diff --git a/libavutil/aarch64/pixelutils_neon.S 
b/libavutil/aarch64/pixelutils_neon.S
index 6e5178adb3..4b5c4d5414 100644
--- a/libavutil/aarch64/pixelutils_neon.S
+++ b/libavutil/aarch64/pixelutils_neon.S
@@ -86,3 +86,50 @@ function ff_pixelutils_sad8_neon, export=1
 
         ret
 endfunc
+
+function ff_pixelutils_sad32_neon, export=1
+        // x0           uint8_t *pix1
+        // x1           ptrdiff_t stride1
+        // x2           uint8_t *pix2
+        // x3           ptrdiff_t stride2
+        movi            v16.8h, #0                  // clear result accumulator
+        movi            v17.8h, #0                  // clear result accumulator
+        movi            v18.8h, #0                  // clear result accumulator
+        movi            v19.8h, #0                  // clear result accumulator
+        mov             w4, 32
+1:
+        ld1             {v0.16b, v1.16b}, [x0], x1  // load pix1
+        ld1             {v4.16b, v5.16b}, [x2], x3  // load pix2
+        ld1             {v2.16b, v3.16b}, [x0], x1  // load pix1
+        ld1             {v6.16b, v7.16b}, [x2], x3  // load pix2
+        uabal           v16.8h, v0.8b, v4.8b        // absolute difference 
accumulate
+        uabal2          v17.8h, v0.16b, v4.16b
+        uabal           v18.8h, v1.8b, v5.8b
+        uabal2          v19.8h, v1.16b, v5.16b
+        ld1             {v0.16b, v1.16b}, [x0], x1  // load pix1
+        ld1             {v4.16b, v5.16b}, [x2], x3  // load pix2
+        uabal           v16.8h, v2.8b, v6.8b        // absolute difference 
accumulate
+        uabal2          v17.8h, v2.16b, v6.16b
+        uabal           v18.8h, v3.8b, v7.8b
+        uabal2          v19.8h, v3.16b, v7.16b
+        ld1             {v2.16b, v3.16b}, [x0], x1
+        ld1             {v6.16b, v7.16b}, [x2], x3
+        uabal           v16.8h, v0.8b, v4.8b
+        uabal2          v17.8h, v0.16b, v4.16b
+        uabal           v18.8h, v1.8b, v5.8b
+        uabal2          v19.8h, v1.16b, v5.16b
+        subs            w4, w4, #4                  // h -= 4
+        uabal           v16.8h, v2.8b, v6.8b
+        uabal2          v17.8h, v2.16b, v6.16b
+        uabal           v18.8h, v3.8b, v7.8b
+        uabal2          v19.8h, v3.16b, v7.16b
+
+        b.gt            1b                          // if h > 0, loop
+
+        add             v16.8h, v16.8h, v17.8h
+        add             v18.8h, v18.8h, v19.8h
+        add             v16.8h, v16.8h, v18.8h
+        uaddlv          s16, v16.8h                 // add up everything in 
v16 accumulator
+        fmov            w0, s16                     // copy result to general 
purpose register
+        ret
+endfunc

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to