[FFmpeg-devel] [PATCH 2/3] checkasm: add test for yadif
James Darnley
jdarnley at obe.tv
Fri Feb 10 15:06:56 EET 2023
---
tests/checkasm/Makefile | 1 +
tests/checkasm/checkasm.c | 3 ++
tests/checkasm/checkasm.h | 1 +
tests/checkasm/vf_yadif.c | 62 +++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+)
create mode 100644 tests/checkasm/vf_yadif.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index a6f06c7007..fc65bdc77d 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -47,6 +47,7 @@ AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o
AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o
AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER) += vf_nlmeans.o
AVFILTEROBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o
+AVFILTEROBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o
CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes)
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index e96d84a7da..2bb72cf839 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -200,6 +200,9 @@ static const struct {
#if CONFIG_SOBEL_FILTER
{ "vf_sobel", checkasm_check_vf_sobel },
#endif
+ #if CONFIG_YADIF_FILTER
+ { "vf_yadif", checkasm_check_vf_yadif },
+ #endif
#endif
#if CONFIG_SWSCALE
{ "sw_gbrp", checkasm_check_sw_gbrp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 8744a81218..0b9a83b5b5 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -87,6 +87,7 @@ void checkasm_check_vf_gblur(void);
void checkasm_check_vf_hflip(void);
void checkasm_check_vf_threshold(void);
void checkasm_check_vf_sobel(void);
+void checkasm_check_vf_yadif(void);
void checkasm_check_vp8dsp(void);
void checkasm_check_vp9dsp(void);
void checkasm_check_videodsp(void);
diff --git a/tests/checkasm/vf_yadif.c b/tests/checkasm/vf_yadif.c
new file mode 100644
index 0000000000..cb58519c23
--- /dev/null
+++ b/tests/checkasm/vf_yadif.c
@@ -0,0 +1,62 @@
+/*
+ * 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 "checkasm.h"
+#include "libavcodec/internal.h"
+#include "libavfilter/yadif.h"
+
+#define WIDTH 256
+
+#define randomize_buffers(buf0, buf1, mask, count) \
+ for (size_t i; i < count; i++) \
+ buf0[i] = buf1[i] = rnd() & mask
+
+void checkasm_check_vf_yadif(void)
+{
+ YADIFContext ctx_8, ctx_10, ctx_16;
+
+ ff_yadif_init_filter_line(&ctx_8, 8);
+ ff_yadif_init_filter_line(&ctx_10, 10);
+ ff_yadif_init_filter_line(&ctx_16, 16);
+
+ if (check_func(ctx_8.filter_line, "yadif8")) {
+ uint8_t prev0[5*WIDTH + STRIDE_ALIGN], prev1[5*WIDTH + STRIDE_ALIGN];
+ uint8_t next0[5*WIDTH + STRIDE_ALIGN], next1[5*WIDTH + STRIDE_ALIGN];
+ uint8_t cur0[5*WIDTH + STRIDE_ALIGN], cur1[5*WIDTH + STRIDE_ALIGN];
+ uint8_t dst0[WIDTH + STRIDE_ALIGN], dst1[WIDTH + STRIDE_ALIGN];
+
+ declare_func(void, void *dst, void *prev, void *cur, void *next,
+ int w, int prefs, int mrefs, int parity, int mode);
+
+ randomize_buffers(prev0, prev1, 0xff, 5*WIDTH + STRIDE_ALIGN);
+ randomize_buffers(next0, next1, 0xff, 5*WIDTH + STRIDE_ALIGN);
+ randomize_buffers(cur0, cur1, 0xff, 5*WIDTH + STRIDE_ALIGN);
+
+ call_ref(dst0, prev0, cur0, next0, WIDTH, WIDTH, WIDTH, 0, 1);
+ call_new(dst1, prev1, cur1, next1, WIDTH, WIDTH, WIDTH, 0, 1);
+
+ if (memcmp(dst0, dst1, WIDTH)
+ || memcmp(prev0, prev1, sizeof prev0)
+ || memcmp(next0, next1, sizeof next0)
+ || memcmp(cur0, cur1, sizeof cur0))
+ fail();
+ bench_new(dst1, prev1, cur1, next1, WIDTH, WIDTH, WIDTH, 0, 1);
+ }
+ report("yadif8");
+}
--
2.39.1
More information about the ffmpeg-devel
mailing list