Commit 82d767e969 for ffmpeg

commit 82d767e969d30f9f6db24ef67576890cf3f487ba
Author: gnattu <gnattuoc@me.com>
Date:   Tue Oct 27 23:41:45 2026 +0800

    avfilter/x86/scene_sad: fix unaligned input in SSE2

    Cropped frames can have unaligned data pointers, but the SSE2 PSADBW
    memory operand requires 16-byte alignment. Use an unaligned load to
    avoid crashes in scene detection.

    Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25538
    Signed-off-by: gnattu <gnattuoc@me.com>
    Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>

diff --git a/libavfilter/x86/scene_sad.asm b/libavfilter/x86/scene_sad.asm
index 181c290893..3ed201843e 100644
--- a/libavfilter/x86/scene_sad.asm
+++ b/libavfilter/x86/scene_sad.asm
@@ -41,7 +41,9 @@ cglobal scene_sad%1, 6, 7, 3, src1, stride1, src2, stride2, width, end, x

 %macro PSADQ 4 ; depth, dst, [src2], tmp
 %if %1 == 8
-        psadbw %2, %3
+        ; PSADBW requires an aligned memory operand.
+        movu   %4, %3
+        psadbw %2, %4
 %else
         psubw     %2, %3
         pabsw     %2, %2
diff --git a/tests/checkasm/scene_sad.c b/tests/checkasm/scene_sad.c
index b15df3087c..c67f2fb103 100644
--- a/tests/checkasm/scene_sad.c
+++ b/tests/checkasm/scene_sad.c
@@ -59,6 +59,26 @@ static void check_scene_sad(int depth)
                     depth, (unsigned long long) sum1, (unsigned long long) sum2);
             fail();
         }
+        if (depth == 8) {
+            for (int offset1 = 0; offset1 < 16; offset1++) {
+                for (int offset2 = 0; offset2 < 16; offset2++) {
+                    /* Odd strides also exercise unaligned rows. */
+                    call_ref(src1 + offset1, STRIDE - 1,
+                             src2 + offset2, STRIDE - 3,
+                             width - 17, HEIGHT, &sum1);
+                    call_new(src1 + offset1, STRIDE - 1,
+                             src2 + offset2, STRIDE - 3,
+                             width - 17, HEIGHT, &sum2);
+                    if (sum1 != sum2) {
+                        fprintf(stderr, "scene_sad8: sum mismatch at offsets "
+                                "%d/%d: %llu != %llu\n", offset1, offset2,
+                                (unsigned long long) sum1,
+                                (unsigned long long) sum2);
+                        fail();
+                    }
+                }
+            }
+        }
         bench_new(src1, STRIDE, src2, STRIDE, width, HEIGHT, &sum2);
     }
 }