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

Git pushed a commit to branch release/9.1
in repository ffmpeg.

commit 056bb51a5bc2e41e35815f6cf07e1629d12e7cbc
Author:     gnattu <[email protected]>
AuthorDate: Tue Oct 27 23:41:45 2026 +0800
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Thu Nov 19 14:55:35 2026 +0100

    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 <[email protected]>
    Signed-off-by: Baptiste Coudurier <[email protected]>
    (cherry picked from commit 82d767e969d30f9f6db24ef67576890cf3f487ba)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/x86/scene_sad.asm |  4 +++-
 tests/checkasm/scene_sad.c    | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

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 bc33c428c6..8c0454955c 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);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to