From 001abdaa534ccb601aa8ee1431c04e33913401a2 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 18 May 2023 16:18:16 +0200 Subject: [PATCH] checkasm/h264dsp: add chroma_mc checkasm test Checks all variants of put_h264_chroma and avg_h264_chroma. --- tests/checkasm/h264dsp.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c index 3c95f9d74d..e1f8e21ca2 100644 --- a/tests/checkasm/h264dsp.c +++ b/tests/checkasm/h264dsp.c @@ -22,6 +22,7 @@ #include "checkasm.h" #include "libavcodec/avcodec.h" #include "libavcodec/h264dsp.h" +#include "libavcodec/h264chroma.h" #include "libavcodec/h264data.h" #include "libavcodec/h264_parse.h" #include "libavutil/common.h" @@ -440,6 +441,47 @@ static void check_loop_filter_intra(void) } } +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_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src, + ptrdiff_t stride, int h, int x, int y); + + memset(src, 3, 16*18*2); + + for (int bit_depth = 8; bit_depth <= 10; bit_depth++) { + ff_h264chroma_init(&h, bit_depth); + for (int size = 0; size < 4; size++) { + +#define CHECK_CHROMA_MC(name) \ + do { \ + if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << size, bit_depth)) { \ + for (int x = 0; x < 2; x++) { \ + for (int y = 0; y < 2; y++) { \ + memcpy(dst0, src, 16 * 16 * SIZEOF_PIXEL); \ + memcpy(dst1, src, 16 * 16 * SIZEOF_PIXEL); \ + 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); \ + fail(); \ + } \ + bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \ + } \ + } \ + } \ + } while (0) + + CHECK_CHROMA_MC(put_h264_chroma); + CHECK_CHROMA_MC(avg_h264_chroma); + } + } +} + void checkasm_check_h264dsp(void) { check_idct(); @@ -451,4 +493,7 @@ void checkasm_check_h264dsp(void) check_loop_filter_intra(); report("loop_filter_intra"); + + check_chroma_mc(); + report("chroma_mc"); } -- 2.40.0