aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2023-05-18 16:18:16 +0200
committerLynne <dev@lynne.ee>2023-05-20 20:07:21 +0200
commit783270bfd12d7a524056e01f98d3472a3bb2d487 (patch)
tree4b3f6beb88af38d06fa1158a9d1dea06a2c26b65
parenta62a3930c2d14acd3083af49f60741417d1d709f (diff)
downloadffmpeg-783270bfd12d7a524056e01f98d3472a3bb2d487.tar.gz
checkasm: add h264chroma tests
Checks all variants of put_h264_chroma and avg_h264_chroma.
-rw-r--r--tests/checkasm/Makefile1
-rw-r--r--tests/checkasm/checkasm.c3
-rw-r--r--tests/checkasm/checkasm.h1
-rw-r--r--tests/checkasm/h264chroma.c85
4 files changed, 90 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 64d3c00168..594db4df9d 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -5,6 +5,7 @@ AVCODECOBJS-$(CONFIG_BLOCKDSP) += blockdsp.o
AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o
AVCODECOBJS-$(CONFIG_G722DSP) += g722dsp.o
+AVCODECOBJS-$(CONFIG_H264CHROMA) += h264chroma.o
AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o
AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index d4df964d6b..7389ebaee9 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -105,6 +105,9 @@ static const struct {
#if CONFIG_G722DSP
{ "g722dsp", checkasm_check_g722dsp },
#endif
+ #if CONFIG_H264CHROMA
+ { "h264chroma", checkasm_check_h264chroma },
+ #endif
#if CONFIG_H264DSP
{ "h264dsp", checkasm_check_h264dsp },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 03b27efa27..117d4dd35c 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
void checkasm_check_float_dsp(void);
void checkasm_check_fmtconvert(void);
void checkasm_check_g722dsp(void);
+void checkasm_check_h264chroma(void);
void checkasm_check_h264dsp(void);
void checkasm_check_h264pred(void);
void checkasm_check_h264qpel(void);
diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c
new file mode 100644
index 0000000000..1aa28c2ee1
--- /dev/null
+++ b/tests/checkasm/h264chroma.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) Lynne
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <string.h>
+#include <stdint.h>
+#include "checkasm.h"
+#include "libavcodec/h264chroma.h"
+#include "libavutil/mem_internal.h"
+#include "libavutil/intreadwrite.h"
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+
+#define randomize_buffers(bit_depth) \
+ do { \
+ if (bit_depth == 8) { \
+ for (int i = 0; i < 16*18*2; i++) \
+ src[i] = rnd() & 0x3; \
+ } else { \
+ for (int i = 0; i < 16*18; i += 2) \
+ AV_WN16(&src[i], rnd() & 0xFF); \
+ } \
+ } while (0)
+
+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);
+
+ for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
+ ff_h264chroma_init(&h, bit_depth);
+ randomize_buffers(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 * 18 * SIZEOF_PIXEL); \
+ memcpy(dst1, src, 16 * 18 * 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_h264chroma(void)
+{
+ check_chroma_mc();
+ report("chroma_mc");
+}