[FFmpeg-devel] [PATCH v2] checkasm: vvc: Use checkasm_check for printing failing output

Martin Storsjö martin at martin.st
Tue Dec 10 00:02:04 EET 2024


Share the checkasm_check_pixel macro from hevc_pel in checkasm.h,
to allow other tests to use the same. (To use it in other tests,
those tests need to have a similar setup for high bitdepth pixels,
with a local variable named "bit_depth".)

This simplifies the code for checking the output, and can print
the failing output (including a map of matching/mismatching
elements) if checkasm is run with the -v/--verbose option.
---
v2: Moved the macro to checkasm.h and added a comment about where
it works and what it assumes. I checked that other checkasm tests
like vp9dsp also have a similarly matching bit_depth parameter,
so it might work quite well there too.
---
 tests/checkasm/checkasm.h | 12 ++++++++++++
 tests/checkasm/hevc_pel.c |  9 ---------
 tests/checkasm/vvc_alf.c  | 10 ++--------
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index a1bd19c54a..5d6183bd19 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -399,4 +399,16 @@ DECL_CHECKASM_CHECK_FUNC(int32_t);
 
 #define checkasm_check(prefix, ...) CONCAT(checkasm_check_, prefix)(__FILE__, __LINE__, __VA_ARGS__)
 
+/* This assumes that there is a local variable named "bit_depth".
+ * For tests that don't have that and only operate on a single
+ * bitdepth, just call checkasm_check(uint8_t, ...) directly. */
+#define checkasm_check_pixel(buf1, stride1, buf2, stride2, ...) \
+    ((bit_depth > 8) ?                                          \
+     checkasm_check(uint16_t, (const uint16_t*)buf1, stride1,   \
+                              (const uint16_t*)buf2, stride2,   \
+                              __VA_ARGS__) :                    \
+     checkasm_check(uint8_t,  (const uint8_t*) buf1, stride1,   \
+                              (const uint8_t*) buf2, stride2,   \
+                              __VA_ARGS__))
+
 #endif /* TESTS_CHECKASM_CHECKASM_H */
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
index d9fa56d420..b9417832e5 100644
--- a/tests/checkasm/hevc_pel.c
+++ b/tests/checkasm/hevc_pel.c
@@ -36,15 +36,6 @@ static const int offsets[] = {0, 255, -1 };
 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
 #define BUF_SIZE (2 * MAX_PB_SIZE * (2 * 4 + MAX_PB_SIZE))
 
-#define checkasm_check_pixel(buf1, stride1, buf2, stride2, ...) \
-    ((bit_depth > 8) ?                                          \
-     checkasm_check(uint16_t, (const uint16_t*)buf1, stride1,   \
-                              (const uint16_t*)buf2, stride2,   \
-                              __VA_ARGS__) :                    \
-     checkasm_check(uint8_t,  (const uint8_t*) buf1, stride1,   \
-                              (const uint8_t*) buf2, stride2,   \
-                              __VA_ARGS__))
-
 #define randomize_buffers()                          \
     do {                                             \
         uint32_t mask = pixel_mask[bit_depth - 8];   \
diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
index 15e79289cd..fcb9ca0bc0 100644
--- a/tests/checkasm/vvc_alf.c
+++ b/tests/checkasm/vvc_alf.c
@@ -108,10 +108,7 @@ static void check_alf_filter(VVCDSPContext *c, const int bit_depth)
                     memset(dst1, 0, DST_BUF_SIZE);
                     call_ref(dst0, dst_stride, src0 + offset, src_stride, w, h, filter, clip, vb_pos);
                     call_new(dst1, dst_stride, src1 + offset, src_stride, w, h, filter, clip, vb_pos);
-                    for (int i = 0; i < (h + 1); i++) {
-                        if (memcmp(dst0 + i * dst_stride, dst1 + i * dst_stride, (w + 1) * SIZEOF_PIXEL))
-                            fail();
-                    }
+                    checkasm_check_pixel(dst0, dst_stride, dst1, dst_stride, w + 1, h + 1, "dst");
                     // Bench only square sizes, and ones with dimensions being a power of two.
                     if (w == h && (w & (w - 1)) == 0)
                         bench_new(dst1, dst_stride, src1 + offset, src_stride, w, h, filter, clip, vb_pos);
@@ -125,10 +122,7 @@ static void check_alf_filter(VVCDSPContext *c, const int bit_depth)
                     memset(dst1, 0, DST_BUF_SIZE);
                     call_ref(dst0, dst_stride, src0 + offset, src_stride, w, h, filter, clip, vb_pos);
                     call_new(dst1, dst_stride, src1 + offset, src_stride, w, h, filter, clip, vb_pos);
-                    for (int i = 0; i < (h + 1); i++) {
-                        if (memcmp(dst0 + i * dst_stride, dst1 + i * dst_stride, (w + 1) * SIZEOF_PIXEL))
-                            fail();
-                    }
+                    checkasm_check_pixel(dst0, dst_stride, dst1, dst_stride, w + 1, h + 1, "dst");
                     if (w == h && (w & (w - 1)) == 0)
                         bench_new(dst1, dst_stride, src1 + offset, src_stride, w, h, filter, clip, vb_pos);
                 }
-- 
2.39.5 (Apple Git-154)



More information about the ffmpeg-devel mailing list