PR #25805 opened by Kilian (lusoris)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25805
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25805.patch

For bit depths above 8, the `scene_sad` checkasm test initializes and checks 
with a 128-element width, but `bench_new()` still passed `WIDTH` (256). The 
benchmark then read up to byte offset 65,791 of each buffer, while only the 
first 65,536 bytes were initialized. The reads stay inside the 131,072-byte 
buffers, so nothing crashed, but the benchmark measured uninitialized data.

This passes the same depth-adjusted `width` to `bench_new()` as to `call_ref()` 
and `call_new()`.

Found by the review of #25481 (review 11036), where it was flagged as 
pre-existing. The change applies cleanly both on master and on top of #25481.

Tested on master 7bc3576910:

- a standalone replay of the `ff_scene_sad16_c()` index pattern: before, the 
benchmark reaches byte 65,791 for depths 10, 12, 14, 15 and 16; after, byte 
65,535 for every depth
- `checkasm --test=scene_sad` and `checkasm --test=scene_sad --bench`: 11 
passed, rc 0
- `make fate-source`: rc 0



>From f975d9c7c3689ca26e2368565814404b63896807 Mon Sep 17 00:00:00 2001
From: lusoris <[email protected]>
Date: Fri, 6 Nov 2026 03:59:25 +0100
Subject: [PATCH] checkasm/scene_sad: bench with the initialized width

The 16-bit C reference interprets strides as bytes, then converts them
to uint16_t elements. checkasm initializes 65,536 bytes of each buffer
for every depth, but the benchmark passed a 256-element width for
depths above 8 and read up to byte offset 65,791: still inside the
131,072-byte buffers, but past the initialized data.

Pass the depth-adjusted width used by the correctness calls. The
benchmark now stops at byte offset 65,535 for every tested depth.

Signed-off-by: lusoris <[email protected]>
---
 tests/checkasm/scene_sad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/scene_sad.c b/tests/checkasm/scene_sad.c
index bc33c428c63..b15df3087cb 100644
--- a/tests/checkasm/scene_sad.c
+++ b/tests/checkasm/scene_sad.c
@@ -59,7 +59,7 @@ static void check_scene_sad(int depth)
                     depth, (unsigned long long) sum1, (unsigned long long) 
sum2);
             fail();
         }
-        bench_new(src1, STRIDE, src2, STRIDE, WIDTH, HEIGHT, &sum2);
+        bench_new(src1, STRIDE, src2, STRIDE, width, HEIGHT, &sum2);
     }
 }
 
-- 
2.54.0

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

Reply via email to