[FFmpeg-devel] [PATCH] checkasm: add vp9mc tests.
Ronald S. Bultje
rsbultje at gmail.com
Tue Sep 15 20:25:31 CEST 2015
---
tests/checkasm/Makefile | 1 +
tests/checkasm/checkasm.c | 3 ++
tests/checkasm/checkasm.h | 1 +
tests/checkasm/vp9mc.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 110 insertions(+)
create mode 100644 tests/checkasm/vp9mc.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 6aabcd7..e77889e 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -3,6 +3,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o
AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o
+AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9mc.o
CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 5fdf0a3..4061869 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -69,6 +69,9 @@ static const struct {
#if CONFIG_V210_ENCODER
{ "v210enc", checkasm_check_v210enc },
#endif
+#if CONFIG_VP9_DECODER
+ { "vp9mc", checkasm_check_vp9mc },
+#endif
{ NULL }
};
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index bf24d38..8f0f09e 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -33,6 +33,7 @@ void checkasm_check_bswapdsp(void);
void checkasm_check_h264pred(void);
void checkasm_check_h264qpel(void);
void checkasm_check_v210enc(void);
+void checkasm_check_vp9mc(void);
void *checkasm_check_func(void *func, const char *name, ...) av_printf_format(2, 3);
int checkasm_bench_func(void);
diff --git a/tests/checkasm/vp9mc.c b/tests/checkasm/vp9mc.c
new file mode 100644
index 0000000..4c035d3
--- /dev/null
+++ b/tests/checkasm/vp9mc.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje <rsbultje at gmail.com>
+ *
+ * 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/vp9dsp.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
+
+static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
+
+#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
+#define DST_BUF_SIZE (size * size * SIZEOF_PIXEL)
+#define SRC_BUF_STRIDE 72
+#define SRC_BUF_SIZE ((size + 7) * SRC_BUF_STRIDE * SIZEOF_PIXEL)
+#define src (buf + 3 * SIZEOF_PIXEL * (SRC_BUF_STRIDE + 1))
+
+#define randomize_buffers() \
+ do { \
+ uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \
+ int k; \
+ for (k = 0; k < SRC_BUF_SIZE; k += 4) { \
+ uint32_t r = rnd() & mask; \
+ AV_WN32A(buf + k, r); \
+ } \
+ if (op == 1) { \
+ for (k = 0; k < DST_BUF_SIZE; k += 4) { \
+ uint32_t r = rnd() & mask; \
+ AV_WN32A(dst0 + k, r); \
+ AV_WN32A(dst1 + k, r); \
+ } \
+ } \
+ } while (0)
+
+void checkasm_check_vp9mc(void)
+{
+ LOCAL_ALIGNED_32(uint8_t, buf, [72 * 72 * 2]);
+ LOCAL_ALIGNED_32(uint8_t, dst0, [64 * 64 * 2]);
+ LOCAL_ALIGNED_32(uint8_t, dst1, [64 * 64 * 2]);
+ VP9DSPContext dsp;
+ int op, hsize, bit_depth, filter, dx, dy;
+ declare_func(void, uint8_t *dst, ptrdiff_t dst_stride,
+ const uint8_t *ref, ptrdiff_t ref_stride,
+ int h, int mx, int my);
+ static const char *filter_names[4] = {
+ "8tap_smooth", "8tap_regular", "8tap_sharp", "bilin"
+ };
+ static const char *subpel_names[2][2] = { { "", "h" }, { "v", "hv" } };
+ static const char *op_names[2] = { "put", "avg" };
+
+ for (op = 0; op < 2; op++) {
+ for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) {
+ ff_vp9dsp_init(&dsp, bit_depth, 0);
+ for (hsize = 0; hsize < 5; hsize++) {
+ int size = 64 >> hsize;
+
+ for (filter = 0; filter < 4; filter++) {
+ for (dx = 0; dx < 2; dx++) {
+ for (dy = 0; dy < 2; dy++) {
+ vp9_mc_func mc = dsp.mc[hsize][filter][op][dx][dy];
+
+ if (check_func(mc, "vp9_%s_%s_%d%s_%dbpp",
+ op_names[op], filter_names[filter],
+ size, subpel_names[dy][dx], bit_depth)) {
+ int mx = dx ? 1 + (rnd() % 14) : 0;
+ int my = dy ? 1 + (rnd() % 14) : 0;
+ randomize_buffers();
+ call_ref(dst0, size * SIZEOF_PIXEL,
+ src, SRC_BUF_STRIDE * SIZEOF_PIXEL,
+ size, mx, my);
+ call_new(dst1, size * SIZEOF_PIXEL,
+ src, SRC_BUF_STRIDE * SIZEOF_PIXEL,
+ size, mx, my);
+ if (memcmp(dst0, dst1, DST_BUF_SIZE))
+ fail();
+ bench_new(dst1, size * SIZEOF_PIXEL,
+ src, SRC_BUF_STRIDE * SIZEOF_PIXEL,
+ size, mx, my);
+ }
+ }
+ }
+ }
+ }
+ }
+ report("%s", op_names[op]);
+ }
+}
--
2.1.2
More information about the ffmpeg-devel
mailing list