summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbwang30 <bin.wang@intel.com>2022-11-04 16:29:25 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2022-11-14 10:04:16 +0800
commit3ab11dc5bb6eec9b645da45fe28b1b2c29e92eed (patch)
tree6bf018840c1556550c9ac787aea286adbc61dd7b /tests
parent2d25f33a7ed36003de9a62c9cb165db183663d1c (diff)
downloadffmpeg-3ab11dc5bb6eec9b645da45fe28b1b2c29e92eed.tar.gz
libavfilter/x86/vf_convolution: add sobel filter optimization and unit test with intel AVX512 VNNI
This commit enabled assembly code with intel AVX512 VNNI and added unit test for sobel filter sobel_c: 4537 sobel_avx512icl 2136 Signed-off-by: bwang30 <bin.wang@intel.com> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Diffstat (limited to 'tests')
-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/vf_convolution.c104
-rw-r--r--tests/fate/checkasm.mak1
5 files changed, 110 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 62d6616faf..a6f06c7007 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -46,6 +46,7 @@ AVFILTEROBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o
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
CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes)
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index c3d77cb6af..e96d84a7da 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -197,6 +197,9 @@ static const struct {
#if CONFIG_THRESHOLD_FILTER
{ "vf_threshold", checkasm_check_vf_threshold },
#endif
+ #if CONFIG_SOBEL_FILTER
+ { "vf_sobel", checkasm_check_vf_sobel },
+ #endif
#endif
#if CONFIG_SWSCALE
{ "sw_gbrp", checkasm_check_sw_gbrp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 5f68115035..8744a81218 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -86,6 +86,7 @@ void checkasm_check_vf_eq(void);
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_vp8dsp(void);
void checkasm_check_vp9dsp(void);
void checkasm_check_videodsp(void);
diff --git a/tests/checkasm/vf_convolution.c b/tests/checkasm/vf_convolution.c
new file mode 100644
index 0000000000..007865863e
--- /dev/null
+++ b/tests/checkasm/vf_convolution.c
@@ -0,0 +1,104 @@
+/*
+ * 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 "libavfilter/avfilter.h"
+#include "libavfilter/convolution.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+#define WIDTH 512
+#define HEIGHT 512
+#define SRC_STRIDE 512
+#define PIXELS (WIDTH * HEIGHT)
+
+#define randomize_buffers(buf, size) \
+ do { \
+ int j; \
+ uint8_t *tmp_buf = (uint8_t *)buf;\
+ for (j = 0; j< size; j++) \
+ tmp_buf[j] = rnd() & 0xFF; \
+ } while (0)
+
+static void check_sobel(const char * report_name)
+{
+ LOCAL_ALIGNED_32(uint8_t, src, [PIXELS]);
+ LOCAL_ALIGNED_32(uint8_t, dst_ref, [PIXELS]);
+ LOCAL_ALIGNED_32(uint8_t, dst_new, [PIXELS]);
+ const int height = WIDTH;
+ const int width = HEIGHT;
+ const int stride = SRC_STRIDE;
+ const int dstride = SRC_STRIDE;
+ int mode = 0;
+ const uint8_t *c[49];
+ const int radius = 1;
+ const int bpc = 1;
+ const int step = mode == MATRIX_COLUMN ? 16 : 1;
+ const int slice_start = 0;
+ const int slice_end = height;
+ int y;
+ const int sizew = mode == MATRIX_COLUMN ? height : width;
+ float scale = 2;
+ float delta = 10;
+
+ ConvolutionContext s;
+
+ declare_func(void, uint8_t *dst, int width, float scale, float delta, const int *const matrix,
+ const uint8_t *c[], int peak, int radius, int dstride, int stride, int size);
+
+ s.scale = scale;
+ s.delta = delta;
+ s.depth = 8;
+ s.nb_planes = 3;
+ s.planes = 15;
+ ff_sobel_init(&s, s.depth, s.nb_planes);
+
+ memset(dst_ref, 0, PIXELS);
+ memset(dst_new, 0, PIXELS);
+ randomize_buffers(src, PIXELS);
+
+ if (check_func(s.filter[0], "%s", report_name)) {
+ for (y = slice_start; y < slice_end; y += step) {
+ const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc;
+ const int yoff = mode == MATRIX_COLUMN ? radius * dstride : 0;
+
+ s.setup[0](radius, c, src, stride, radius, width, y, height, bpc);
+ call_ref(dst_ref + yoff + xoff, sizew - 2 * radius,
+ scale, delta, NULL, c, 0, radius,
+ dstride, stride, slice_end - step);
+ call_new(dst_new + yoff + xoff, sizew - 2 * radius,
+ scale, delta, NULL, c, 0, radius,
+ dstride, stride, slice_end - step);
+ if (memcmp(dst_ref + yoff + xoff, dst_new + yoff + xoff, slice_end - step))
+ fail();
+ bench_new(dst_new + yoff + xoff, sizew - 2 * radius,
+ scale, delta, NULL, c, 0, radius,
+ dstride, stride, slice_end - step);
+ if (mode != MATRIX_COLUMN)
+ dst_ref += dstride;
+ }
+ }
+
+}
+
+void checkasm_check_vf_sobel(void)
+{
+ check_sobel("sobel");
+ report("convolution:sobel");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index aa9b288e12..a4e95541f5 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -43,6 +43,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \
fate-checkasm-vf_hflip \
fate-checkasm-vf_nlmeans \
fate-checkasm-vf_threshold \
+ fate-checkasm-vf_sobel \
fate-checkasm-videodsp \
fate-checkasm-vorbisdsp \
fate-checkasm-vp8dsp \