Commit 3f77ce4dee for ffmpeg

commit 3f77ce4deed82a98be15451b7aa79c899113deaa
Author: Zuxy Meng <zuxy.meng@gmail.com>
Date:   Fri Sep 4 21:18:41 2026 -0700

    avcodec/ppc/h264dsp: Fix edge cases for bi-weight on ppc

    S16 saturating sum must be computed dot-product-first. The Altivec code
    added the offset to the first product before adding the second product,
    so an intermediate saturation could corrupt the result even when the
    true sum fits.

    Swap the two vec_adds to form the dot product first. This fixes
    bi-weight checkasm test for PPC.

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

diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
index d832e7f01c..c558dafa0b 100644
--- a/libavcodec/ppc/h264dsp.c
+++ b/libavcodec/ppc/h264dsp.c
@@ -749,16 +749,16 @@ void biweight_h264_W_altivec(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h
             v0 = vec_mladd(v0, vweightd, zero_s16v);
             v2 = vec_mladd(v2, vweights, zero_s16v);

-            v0 = vec_adds(v0, voffset);
             v0 = vec_adds(v0, v2);
+            v0 = vec_adds(v0, voffset);
             v0 = vec_sra(v0, vlog2_denom);
         }
         if (w == 16 || !dst_aligned) {
             v1 = vec_mladd(v1, vweightd, zero_s16v);
             v3 = vec_mladd(v3, vweights, zero_s16v);

-            v1 = vec_adds(v1, voffset);
             v1 = vec_adds(v1, v3);
+            v1 = vec_adds(v1, voffset);
             v1 = vec_sra(v1, vlog2_denom);
         }
         vdst = vec_packsu(v0, v1);
diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c
index a38ee32d9c..61839b13d6 100644
--- a/tests/checkasm/h264dsp.c
+++ b/tests/checkasm/h264dsp.c
@@ -544,8 +544,8 @@ static void check_weight(void)
     }
 }

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

 #if H264_CHECK_BIWEIGHT
 static void check_biweight(void)