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

Git pushed a commit to branch master
in repository ffmpeg.

commit 1a9c345ee89e6b8f9099953b699430439adcd11a
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Thu Mar 5 11:19:47 2026 +0100
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Mon Mar 9 10:17:26 2026 +0100

    avutil/mips: Add msa optimizations for pixelutils
    
    Adapted from the corresponding me_cmp code. Only the width 16 function
    has been adapted, because it seems that the width 8 function actually
    reads 16 bytes per line.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavutil/mips/Makefile                            |  2 +
 .../mips/pixelutils.h                              | 21 ++++++----
 libavutil/mips/pixelutils_msa.c                    | 48 ++++++++++++++++++++++
 libavutil/pixelutils.c                             |  4 ++
 4 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/libavutil/mips/Makefile b/libavutil/mips/Makefile
index 5f8c9b64e9..be4900faad 100644
--- a/libavutil/mips/Makefile
+++ b/libavutil/mips/Makefile
@@ -1 +1,3 @@
 OBJS += mips/float_dsp_mips.o mips/cpu.o
+
+MSA-OBJS-$(CONFIG_PIXELUTILS) += mips/pixelutils_msa.o
diff --git a/libavcodec/arm/lossless_audiodsp_init_arm.c 
b/libavutil/mips/pixelutils.h
similarity index 66%
copy from libavcodec/arm/lossless_audiodsp_init_arm.c
copy to libavutil/mips/pixelutils.h
index 981a39aff9..fce3b4e5e9 100644
--- a/libavcodec/arm/lossless_audiodsp_init_arm.c
+++ b/libavutil/mips/pixelutils.h
@@ -1,6 +1,4 @@
 /*
- * Copyright (c) 2011 Mans Rullgard <[email protected]>
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -18,21 +16,26 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifndef AVUTIL_MIPS_PIXELUTILS_H
+#define AVUTIL_MIPS_PIXELUTILS_H
+
+#include <stddef.h>
 #include <stdint.h>
 
+#include "cpu.h"
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavutil/arm/cpu.h"
-#include "libavcodec/lossless_audiodsp.h"
+#include "libavutil/pixelutils.h"
 
-int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, const int16_t *v2,
-                                             const int16_t *v3, int len, int 
mul);
+int ff_pixelutils_sad16_msa(const uint8_t *src1, ptrdiff_t stride1,
+                            const uint8_t *src2, ptrdiff_t stride2);
 
-av_cold void ff_llauddsp_init_arm(LLAudDSPContext *c)
+static inline av_cold void ff_pixelutils_sad_init_mips(av_pixelutils_sad_fn 
*sad, int aligned)
 {
     int cpu_flags = av_get_cpu_flags();
 
-    if (have_neon(cpu_flags)) {
-        c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_neon;
+    if (have_msa(cpu_flags)) {
+        sad[3] = ff_pixelutils_sad16_msa;
     }
 }
+#endif
diff --git a/libavutil/mips/pixelutils_msa.c b/libavutil/mips/pixelutils_msa.c
new file mode 100644
index 0000000000..a67c6065d9
--- /dev/null
+++ b/libavutil/mips/pixelutils_msa.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 Parag Salasakar ([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 <stddef.h>
+#include <stdint.h>
+
+#include "generic_macros_msa.h"
+#include "pixelutils.h"
+
+int ff_pixelutils_sad16_msa(const uint8_t *src, ptrdiff_t src_stride,
+                            const uint8_t *ref, ptrdiff_t ref_stride)
+{
+    int32_t ht_cnt = 16/4;
+    v16u8 src0, src1, ref0, ref1;
+    v8u16 sad = { 0 };
+
+    for (; ht_cnt--; ) {
+        LD_UB2(src, src_stride, src0, src1);
+        src += (2 * src_stride);
+        LD_UB2(ref, ref_stride, ref0, ref1);
+        ref += (2 * ref_stride);
+        sad += SAD_UB2_UH(src0, src1, ref0, ref1);
+
+        LD_UB2(src, src_stride, src0, src1);
+        src += (2 * src_stride);
+        LD_UB2(ref, ref_stride, ref0, ref1);
+        ref += (2 * ref_stride);
+        sad += SAD_UB2_UH(src0, src1, ref0, ref1);
+    }
+    return (HADD_UH_U32(sad));
+}
diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c
index d7803a4e93..869af809eb 100644
--- a/libavutil/pixelutils.c
+++ b/libavutil/pixelutils.c
@@ -32,6 +32,8 @@
 #include "aarch64/pixelutils.h"
 #elif ARCH_ARM && HAVE_ARMV6
 #include "arm/pixelutils.h"
+#elif ARCH_MIPS && HAVE_MSA
+#include "mips/pixelutils.h"
 #elif ARCH_RISCV
 #include "riscv/pixelutils.h"
 #elif ARCH_X86 && HAVE_X86ASM
@@ -98,6 +100,8 @@ av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, 
int h_bits, int aligne
     ff_pixelutils_sad_init_aarch64(sad, aligned);
 #elif ARCH_ARM
     ff_pixelutils_sad_init_arm(sad, aligned);
+#elif ARCH_MIPS && HAVE_MSA
+    ff_pixelutils_sad_init_mips(sad, aligned);
 #elif ARCH_RISCV
     ff_pixelutils_init_riscv(sad, aligned);
 #elif ARCH_X86 && HAVE_X86ASM

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

Reply via email to