Commit d5bbc8c598 for ffmpeg

commit d5bbc8c59859e367ed7003cc00e3428c68629ef4
Author: Zuxy Meng <zuxy.meng@gmail.com>
Date:   Fri Sep 4 21:21:45 2026 -0700

    avcodec/mips/h264dsp_mmi: Fix edge cases for bi-weight on MMI

    S16 saturating sum must be computed dot-product-first. The MMI code added
    the offset to the first product before adding the second product.

    Swap the paddsh pairs in biweight_pixels16/8/4_8_mmi to form the dot
    product first. This fixes bi-weight checkasm test for MIPS as MSA
    already handles these cases.

    Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>

diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
index bee4e84e37..c42a5ad98b 100644
--- a/libavcodec/mips/h264dsp_mmi.c
+++ b/libavcodec/mips/h264dsp_mmi.c
@@ -1170,10 +1170,10 @@ void ff_h264_biweight_pixels16_8_mmi(uint8_t *dst, uint8_t *src,
             "pmullh     %[ftmp8],   %[ftmp8],       %[ftmp4]            \n\t"
             "pmullh     %[ftmp1],   %[ftmp1],       %[ftmp3]            \n\t"
             "pmullh     %[ftmp2],   %[ftmp2],       %[ftmp4]            \n\t"
-            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
-            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp8]            \n\t"
             "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp2]            \n\t"
+            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
+            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "psrah      %[ftmp7],   %[ftmp7],       %[ftmp6]            \n\t"
             "psrah      %[ftmp1],   %[ftmp1],       %[ftmp6]            \n\t"
             "packushb   %[ftmp1],   %[ftmp1],       %[ftmp7]            \n\t"
@@ -1188,10 +1188,10 @@ void ff_h264_biweight_pixels16_8_mmi(uint8_t *dst, uint8_t *src,
             "pmullh     %[ftmp8],   %[ftmp8],       %[ftmp4]            \n\t"
             "pmullh     %[ftmp1],   %[ftmp1],       %[ftmp3]            \n\t"
             "pmullh     %[ftmp2],   %[ftmp2],       %[ftmp4]            \n\t"
-            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
-            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp8]            \n\t"
             "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp2]            \n\t"
+            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
+            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "psrah      %[ftmp7],   %[ftmp7],       %[ftmp6]            \n\t"
             "psrah      %[ftmp1],   %[ftmp1],       %[ftmp6]            \n\t"
             "packushb   %[ftmp1],   %[ftmp1],       %[ftmp7]            \n\t"
@@ -1284,10 +1284,10 @@ void ff_h264_biweight_pixels8_8_mmi(uint8_t *dst, uint8_t *src,
             "pmullh     %[ftmp8],   %[ftmp8],       %[ftmp4]            \n\t"
             "pmullh     %[ftmp1],   %[ftmp1],       %[ftmp3]            \n\t"
             "pmullh     %[ftmp2],   %[ftmp2],       %[ftmp4]            \n\t"
-            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
-            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp8]            \n\t"
             "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp2]            \n\t"
+            "paddsh     %[ftmp7],   %[ftmp7],       %[ftmp5]            \n\t"
+            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "psrah      %[ftmp7],   %[ftmp7],       %[ftmp6]            \n\t"
             "psrah      %[ftmp1],   %[ftmp1],       %[ftmp6]            \n\t"
             "packushb   %[ftmp1],   %[ftmp1],       %[ftmp7]            \n\t"
@@ -1370,8 +1370,8 @@ void ff_h264_biweight_pixels4_8_mmi(uint8_t *dst, uint8_t *src,
             "punpcklbh  %[ftmp2],   %[ftmp2],       %[ftmp0]            \n\t"
             "pmullh     %[ftmp1],   %[ftmp1],       %[ftmp3]            \n\t"
             "pmullh     %[ftmp2],   %[ftmp2],       %[ftmp4]            \n\t"
-            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp2]            \n\t"
+            "paddsh     %[ftmp1],   %[ftmp1],       %[ftmp5]            \n\t"
             "psrah      %[ftmp1],   %[ftmp1],       %[ftmp6]            \n\t"
             "packushb   %[ftmp1],   %[ftmp1],       %[ftmp0]            \n\t"
             MMI_SWC1(%[ftmp1], %[dst], 0x00)
diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index 61839b13d6..6cdc44b5ef 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -545,7 +545,7 @@ static void check_weight(void)
 }

 // only archs that can pass test
-#define H264_CHECK_BIWEIGHT (ARCH_X86 || ARCH_PPC)
+#define H264_CHECK_BIWEIGHT (ARCH_X86 || ARCH_PPC || ARCH_MIPS)

 #if H264_CHECK_BIWEIGHT
 static void check_biweight(void)