PR #22279 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22279
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22279.patch


>From 6f10bf5149f30695d5c761776d0fe02be4f15042 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 24 Feb 2026 18:33:44 +0100
Subject: [PATCH 1/3] tests/checkasm/h264chroma: Fix initialization, range of
 values

This commit fixes four related bugs:
1. The >8bpp codepath only initializes half the buffer.
The remaining half used leftover samples from the 8bpp codepath
which initialized the complete buffer.
2. The 8bpp codepath tests only 2 bit inputs (&3). This means
that the second half of the buffer only uses 10 bits (in fact,
only values of the form 000000xx000000xxb) when treated as uint16_t
in the >8bpp test. Due to 1., using more bits in the 8bpp test
would make the >8bpp tests fail (the intermediates would no longer
fit into 16bits).
3. For the >8bpp tests, the first half of the buffer would
only be tested with 8bpp input.
4. The 8bpp codepath initializes the whole buffer, but only
uses half of it.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/h264chroma.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
index 52aa220152..b5b8d64855 100644
--- a/tests/checkasm/h264chroma.c
+++ b/tests/checkasm/h264chroma.c
@@ -30,11 +30,12 @@
 #define randomize_buffers(bit_depth)             \
     do {                                         \
         if (bit_depth == 8) {                    \
-            for (int i = 0; i < 16*18*2; i++)    \
-                src[i] = rnd() & 0x3;            \
+            for (int i = 0; i < 16*18; i++)      \
+                src[i] = rnd();                  \
         } else {                                 \
-            for (int i = 0; i < 16*18; i += 2)   \
-                AV_WN16(&src[i], rnd() & 0xFF);  \
+            unsigned mask = (1 << bit_depth) - 1;\
+            for (int i = 0; i < 16*18*2; i += 2) \
+                AV_WN16A(&src[i], rnd() & mask); \
         }                                        \
     } while (0)
 
-- 
2.52.0


>From cb5bb4e66bd37b73908fc5fb6d89a138aaa34b46 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 24 Feb 2026 18:53:22 +0100
Subject: [PATCH 2/3] tests/checkasm/h264chroma: Add bit depth to error output

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

diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
index b5b8d64855..8a96d1b973 100644
--- a/tests/checkasm/h264chroma.c
+++ b/tests/checkasm/h264chroma.c
@@ -64,7 +64,7 @@ static void check_chroma_mc(void)
                             call_ref(dst0, src, 16 * SIZEOF_PIXEL, 16, x, y);  
                           \
                             call_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y);  
                           \
                             if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) {  
                           \
-                                fprintf(stderr, #name ": x:%i, y:%i\n", x, y); 
                           \
+                                fprintf(stderr, #name "_%d: x:%i, y:%i\n", 
bit_depth, x, y);              \
                                 fail();                                        
                           \
                             }                                                  
                           \
                             bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); 
                           \
-- 
2.52.0


>From 4c1e72ac273fddc0846304db728d593688eb95d4 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 24 Feb 2026 18:57:27 +0100
Subject: [PATCH 3/3] tests/checkasm/h264chroma: Don't overalign

The input only need to have natural alignment
(i.e. 1 in the 8bpp case, 2 otherwise), the output
need only have 16 (namely in the width 8 >8bpp case).

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/h264chroma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
index 8a96d1b973..732e992983 100644
--- a/tests/checkasm/h264chroma.c
+++ b/tests/checkasm/h264chroma.c
@@ -42,9 +42,9 @@
 static void check_chroma_mc(void)
 {
     H264ChromaContext h;
-    LOCAL_ALIGNED_32(uint8_t, src,  [16 * 18 * 2]);
-    LOCAL_ALIGNED_32(uint8_t, dst0, [16 * 18 * 2]);
-    LOCAL_ALIGNED_32(uint8_t, dst1, [16 * 18 * 2]);
+    DECLARE_ALIGNED_4(uint8_t, src) [16 * 18 * 2];
+    DECLARE_ALIGNED_16(uint8_t, dst0)[16 * 18 * 2];
+    DECLARE_ALIGNED_16(uint8_t, dst1)[16 * 18 * 2];
 
     declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
                       ptrdiff_t stride, int h, int x, int y);
-- 
2.52.0

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

Reply via email to