History

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

bwang30 committed 4 years ago

Commit 3ab11dc1 parent 2d25f339 files · +362 −78Browse files

Unified · Split

9 files
  1. libavfilter/convolution.h +74 −0
  2. libavfilter/vf_convolution.c +13 −78
  3. libavfilter/x86/vf_convolution.asm +147 −0
  4. libavfilter/x86/vf_convolution_init.c +18 −0
  5. tests/checkasm/Makefile +1 −0
  6. tests/checkasm/checkasm.c +3 −0
  7. tests/checkasm/checkasm.h +1 −0
  8. tests/checkasm/vf_convolution.c +104 −0
  9. tests/fate/checkasm.mak +1 −0
libavfilter/convolution.h+74−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #ifndef AVFILTER_CONVOLUTION_H
2222 #define AVFILTER_CONVOLUTION_H
2323 #include "avfilter.h"
24+#include "libavutil/intreadwrite.h"
2425
2526 enum MatrixMode {
2627 MATRIX_SQUARE,
@@ -61,4 +62,77 @@ typedef struct ConvolutionContext { · 34 unmodified lines
6162 } ConvolutionContext;
6263
6364 void ff_convolution_init_x86(ConvolutionContext *s);
65+void ff_sobel_init_x86(ConvolutionContext *s, int depth, int nb_planes);
66+
67+static void setup_3x3(int radius, const uint8_t *c[], const uint8_t *src, int stride,
68+ int x, int w, int y, int h, int bpc)
69+{
70+ int i;
71+
72+ for (i = 0; i < 9; i++) {
73+ int xoff = FFABS(x + ((i % 3) - 1));
74+ int yoff = FFABS(y + (i / 3) - 1);
75+
76+ xoff = xoff >= w ? 2 * w - 1 - xoff : xoff;
77+ yoff = yoff >= h ? 2 * h - 1 - yoff : yoff;
78+
79+ c[i] = src + xoff * bpc + yoff * stride;
80+ }
81+}
82+
83+static void filter_sobel(uint8_t *dst, int width,
84+ float scale, float delta, const int *const matrix,
85+ const uint8_t *c[], int peak, int radius,
86+ int dstride, int stride, int size)
87+{
88+ const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
89+ const uint8_t *c3 = c[3], *c5 = c[5];
90+ const uint8_t *c6 = c[6], *c7 = c[7], *c8 = c[8];
91+ int x;
92+
93+ for (x = 0; x < width; x++) {
94+ float suma = c0[x] * -1 + c1[x] * -2 + c2[x] * -1 +
95+ c6[x] * 1 + c7[x] * 2 + c8[x] * 1;
96+ float sumb = c0[x] * -1 + c2[x] * 1 + c3[x] * -2 +
97+ c5[x] * 2 + c6[x] * -1 + c8[x] * 1;
98+
99+ dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale + delta);
100+ }
101+}
102+
103+static void filter16_sobel(uint8_t *dstp, int width,
104+ float scale, float delta, const int *const matrix,
105+ const uint8_t *c[], int peak, int radius,
106+ int dstride, int stride, int size)
107+{
108+ uint16_t *dst = (uint16_t *)dstp;
109+ int x;
110+
111+ for (x = 0; x < width; x++) {
112+ float suma = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[1][2 * x]) * -2 + AV_RN16A(&c[2][2 * x]) * -1 +
113+ AV_RN16A(&c[6][2 * x]) * 1 + AV_RN16A(&c[7][2 * x]) * 2 + AV_RN16A(&c[8][2 * x]) * 1;
114+ float sumb = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[2][2 * x]) * 1 + AV_RN16A(&c[3][2 * x]) * -2 +
115+ AV_RN16A(&c[5][2 * x]) * 2 + AV_RN16A(&c[6][2 * x]) * -1 + AV_RN16A(&c[8][2 * x]) * 1;
116+
117+ dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale + delta, 0, peak);
118+ }
119+}
120+
121+static av_unused void ff_sobel_init(ConvolutionContext *s, int depth, int nb_planes)
122+{
123+ for (int i = 0; i < 4; i++) {
124+ s->filter[i] = filter_sobel;
125+ s->copy[i] = !((1 << i) & s->planes);
126+ s->size[i] = 3;
127+ s->setup[i] = setup_3x3;
128+ s->rdiv[i] = s->scale;
129+ s->bias[i] = s->delta;
130+ }
131+ if (s->depth > 8)
132+ for (int i = 0; i < 4; i++)
133+ s->filter[i] = filter16_sobel;
134+#if ARCH_X86_64
135+ ff_sobel_init_x86(s, depth, nb_planes);
136+#endif
137+}
64138 #endif
libavfilter/vf_convolution.c+13−78
@@ -139,24 +139,6 @@ static void filter16_roberts(uint8_t *dstp, int width, · 138 unmodified lines
139139 }
140140 }
141141
142−static void filter16_sobel(uint8_t *dstp, int width,
143− float scale, float delta, const int *const matrix,
144− const uint8_t *c[], int peak, int radius,
145− int dstride, int stride, int size)
146−{
147− uint16_t *dst = (uint16_t *)dstp;
148− int x;
149−
150− for (x = 0; x < width; x++) {
151− float suma = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[1][2 * x]) * -2 + AV_RN16A(&c[2][2 * x]) * -1 +
152− AV_RN16A(&c[6][2 * x]) * 1 + AV_RN16A(&c[7][2 * x]) * 2 + AV_RN16A(&c[8][2 * x]) * 1;
153− float sumb = AV_RN16A(&c[0][2 * x]) * -1 + AV_RN16A(&c[2][2 * x]) * 1 + AV_RN16A(&c[3][2 * x]) * -2 +
154− AV_RN16A(&c[5][2 * x]) * 2 + AV_RN16A(&c[6][2 * x]) * -1 + AV_RN16A(&c[8][2 * x]) * 1;
155−
156− dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale + delta, 0, peak);
157− }
158−}
159−
160142 static void filter16_scharr(uint8_t *dstp, int width,
161143 float scale, float delta, const int *const matrix,
162144 const uint8_t *c[], int peak, int radius,
@@ -261,26 +243,6 @@ static void filter_roberts(uint8_t *dst, int width, · 98 unmodified lines
261243 }
262244 }
263245
264−static void filter_sobel(uint8_t *dst, int width,
265− float scale, float delta, const int *const matrix,
266− const uint8_t *c[], int peak, int radius,
267− int dstride, int stride, int size)
268−{
269− const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
270− const uint8_t *c3 = c[3], *c5 = c[5];
271− const uint8_t *c6 = c[6], *c7 = c[7], *c8 = c[8];
272− int x;
273−
274− for (x = 0; x < width; x++) {
275− float suma = c0[x] * -1 + c1[x] * -2 + c2[x] * -1 +
276− c6[x] * 1 + c7[x] * 2 + c8[x] * 1;
277− float sumb = c0[x] * -1 + c2[x] * 1 + c3[x] * -2 +
278− c5[x] * 2 + c6[x] * -1 + c8[x] * 1;
279−
280− dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale + delta);
281− }
282−}
283−
284246 static void filter_scharr(uint8_t *dst, int width,
285247 float scale, float delta, const int *const matrix,
286248 const uint8_t *c[], int peak, int radius,
@@ -552,22 +514,6 @@ static void filter_column(uint8_t *dst, int height, · 265 unmodified lines
552514 }
553515 }
554516
555−static void setup_3x3(int radius, const uint8_t *c[], const uint8_t *src, int stride,
556− int x, int w, int y, int h, int bpc)
557−{
558− int i;
559−
560− for (i = 0; i < 9; i++) {
561− int xoff = FFABS(x + ((i % 3) - 1));
562− int yoff = FFABS(y + (i / 3) - 1);
563−
564− xoff = xoff >= w ? 2 * w - 1 - xoff : xoff;
565− yoff = yoff >= h ? 2 * h - 1 - yoff : yoff;
566−
567− c[i] = src + xoff * bpc + yoff * stride;
568− }
569−}
570−
571517 static void setup_5x5(int radius, const uint8_t *c[], const uint8_t *src, int stride,
572518 int x, int w, int y, int h, int bpc)
573519 {
@@ -708,6 +654,18 @@ static int param_init(AVFilterContext *ctx) · 134 unmodified lines
708654 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
709655 int p, i;
710656
657+ s->depth = desc->comp[0].depth;
658+ s->max = (1 << s->depth) - 1;
659+
660+ s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
661+ s->planewidth[0] = s->planewidth[3] = inlink->w;
662+ s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
663+ s->planeheight[0] = s->planeheight[3] = inlink->h;
664+
665+ s->nb_planes = av_pix_fmt_count_planes(inlink->format);
666+ s->nb_threads = ff_filter_get_nb_threads(ctx);
667+ s->bpc = (s->depth + 7) / 8;
668+
711669 if (!strcmp(ctx->filter->name, "convolution")) {
712670 for (i = 0; i < 4; i++) {
713671 int *matrix = (int *)s->matrix[i];
@@ -804,14 +762,7 @@ static int param_init(AVFilterContext *ctx) · 90 unmodified lines
804762 s->bias[i] = s->delta;
805763 }
806764 } else if (!strcmp(ctx->filter->name, "sobel")) {
807− for (i = 0; i < 4; i++) {
808− s->filter[i] = filter_sobel;
809− s->copy[i] = !((1 << i) & s->planes);
810− s->size[i] = 3;
811− s->setup[i] = setup_3x3;
812− s->rdiv[i] = s->scale;
813− s->bias[i] = s->delta;
814− }
765+ ff_sobel_init(s, s->depth, s->nb_planes);
815766 } else if (!strcmp(ctx->filter->name, "kirsch")) {
816767 for (i = 0; i < 4; i++) {
817768 s->filter[i] = filter_kirsch;
@@ -832,18 +783,6 @@ static int param_init(AVFilterContext *ctx) · 14 unmodified lines
832783 }
833784 }
834785
835− s->depth = desc->comp[0].depth;
836− s->max = (1 << s->depth) - 1;
837−
838− s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
839− s->planewidth[0] = s->planewidth[3] = inlink->w;
840− s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
841− s->planeheight[0] = s->planeheight[3] = inlink->h;
842−
843− s->nb_planes = av_pix_fmt_count_planes(inlink->format);
844− s->nb_threads = ff_filter_get_nb_threads(ctx);
845− s->bpc = (s->depth + 7) / 8;
846−
847786 if (!strcmp(ctx->filter->name, "convolution")) {
848787 if (s->depth > 8) {
849788 for (p = 0; p < s->nb_planes; p++) {
@@ -870,10 +809,6 @@ static int param_init(AVFilterContext *ctx) · 20 unmodified lines
870809 if (s->depth > 8)
871810 for (p = 0; p < s->nb_planes; p++)
872811 s->filter[p] = filter16_roberts;
873− } else if (!strcmp(ctx->filter->name, "sobel")) {
874− if (s->depth > 8)
875− for (p = 0; p < s->nb_planes; p++)
876− s->filter[p] = filter16_sobel;
877812 } else if (!strcmp(ctx->filter->name, "kirsch")) {
878813 if (s->depth > 8)
879814 for (p = 0; p < s->nb_planes; p++)
libavfilter/x86/vf_convolution.asm+147−0
@@ -22,6 +22,18 @@ · 21 unmodified lines
2222
2323 SECTION_RODATA
2424 half: dd 0.5
25+data_p1: dd 1
26+data_n1: dd -1
27+data_p2: dd 2
28+data_n2: dd -2
29+
30+ALIGN 64
31+sobel_perm: db 0, 16, 32, 48, 1, 17, 33, 49, 2, 18, 34, 50, 3, 19, 35, 51
32+ db 4, 20, 36, 52, 5, 21, 37, 53, 6, 22, 38, 54, 7, 23, 39, 55
33+ db 8, 24, 40, 56, 9, 25, 41, 57, 10, 26, 42, 58, 11, 27, 43, 59
34+ db 12, 28, 44, 60, 13, 29, 45, 61, 14, 30, 46, 62, 15, 31, 47, 63
35+sobel_mulA: db -1, 1, -2, 2
36+sobel_mulB: db 1, -1, 2, -2
2537
2638 SECTION .text
2739
@@ -154,3 +166,138 @@ cglobal filter_3x3, 4, 15, 7, dst, width, rdiv, bias, matrix, ptr, c0, c1, c2, c · 126 unmodified lines
154166 INIT_XMM sse4
155167 FILTER_3X3
156168 %endif
169+
170+%macro SOBEL_MUL 2
171+ movzx ptrd, byte [c%1q + xq]
172+ imul ptrd, [%2]
173+ add rd, ptrd
174+%endmacro
175+
176+%macro SOBEL_ADD 1
177+ movzx ptrd, byte [c%1q + xq]
178+ add rd, ptrd
179+%endmacro
180+
181+; void filter_sobel_avx512(uint8_t *dst, int width,
182+; float scale, float delta, const int *const matrix,
183+; const uint8_t *c[], int peak, int radius,
184+; int dstride, int stride)
185+%macro FILTER_SOBEL 0
186+%if UNIX64
187+cglobal filter_sobel, 4, 15, 7, dst, width, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
188+%else
189+cglobal filter_sobel, 4, 15, 7, dst, width, rdiv, bias, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
190+%endif
191+%if WIN64
192+ SWAP xmm0, xmm2
193+ SWAP xmm1, xmm3
194+ mov r2q, matrixmp
195+ mov r3q, ptrmp
196+ DEFINE_ARGS dst, width, matrix, ptr, c0, c1, c2, c3, c4, c5, c6, c7, c8, r, x
197+%endif
198+ movsxdifnidn widthq, widthd
199+ VBROADCASTSS m0, xmm0
200+ VBROADCASTSS m1, xmm1
201+ pxor m6, m6
202+ mov c0q, [ptrq + 0*gprsize]
203+ mov c1q, [ptrq + 1*gprsize]
204+ mov c2q, [ptrq + 2*gprsize]
205+ mov c3q, [ptrq + 3*gprsize]
206+ mov c4q, [ptrq + 4*gprsize]
207+ mov c5q, [ptrq + 5*gprsize]
208+ mov c6q, [ptrq + 6*gprsize]
209+ mov c7q, [ptrq + 7*gprsize]
210+ mov c8q, [ptrq + 8*gprsize]
211+
212+ xor xq, xq
213+ cmp widthq, mmsize/4
214+ jl .loop2
215+
216+ mov rq, widthq
217+ and rq, mmsize/4-1
218+ sub widthq, rq
219+
220+ mova m6, [sobel_perm]
221+.loop1:
222+ movu xm3, [c2q + xq]
223+ pmovzxbd m5, [c0q + xq]
224+ vinserti32x4 ym3, [c6q + xq], 1
225+ pmovzxbd m4, [c8q + xq]
226+ vinserti32x4 m2, m3, [c1q + xq], 2
227+ vinserti32x4 m3, [c5q + xq], 2
228+ vinserti32x4 m2, [c7q + xq], 3
229+ vinserti32x4 m3, [c3q + xq], 3
230+ vpermb m2, m6, m2
231+ psubd m4, m5
232+ vpermb m3, m6, m3
233+ mova m5, m4
234+ vpdpbusd m4, m2, [sobel_mulA] {1to16}
235+ vpdpbusd m5, m3, [sobel_mulB] {1to16}
236+
237+ cvtdq2ps m4, m4
238+ mulps m4, m4
239+
240+ cvtdq2ps m5, m5
241+ VFMADD231PS m4, m5, m5
242+
243+ sqrtps m4, m4
244+ fmaddps m4, m4, m0, m1
245+ cvttps2dq m4, m4
246+ vpmovusdb [dstq + xq], m4
247+
248+ add xq, mmsize/4
249+ cmp xq, widthq
250+ jl .loop1
251+
252+ add widthq, rq
253+ cmp xq, widthq
254+ jge .end
255+
256+.loop2:
257+ xor rd, rd
258+ pxor m4, m4
259+
260+ ;Gx
261+ SOBEL_MUL 0, data_n1
262+ SOBEL_MUL 1, data_n2
263+ SOBEL_MUL 2, data_n1
264+ SOBEL_ADD 6
265+ SOBEL_MUL 7, data_p2
266+ SOBEL_ADD 8
267+
268+ cvtsi2ss xmm4, rd
269+ mulss xmm4, xmm4
270+
271+ xor rd, rd
272+ ;Gy
273+ SOBEL_MUL 0, data_n1
274+ SOBEL_ADD 2
275+ SOBEL_MUL 3, data_n2
276+ SOBEL_MUL 5, data_p2
277+ SOBEL_MUL 6, data_n1
278+ SOBEL_ADD 8
279+
280+ cvtsi2ss xmm5, rd
281+ fmaddss xmm4, xmm5, xmm5, xmm4
282+
283+ sqrtps xmm4, xmm4
284+ fmaddss xmm4, xmm4, xmm0, xmm1 ;sum = sum * rdiv + bias
285+ cvttps2dq xmm4, xmm4 ; trunc to integer
286+ packssdw xmm4, xmm4
287+ packuswb xmm4, xmm4
288+ movd rd, xmm4
289+ mov [dstq + xq], rb
290+
291+ add xq, 1
292+ cmp xq, widthq
293+ jl .loop2
294+.end:
295+ RET
296+%endmacro
297+
298+%if ARCH_X86_64
299+%if HAVE_AVX512ICL_EXTERNAL
300+INIT_ZMM avx512icl
301+FILTER_SOBEL
302+%endif
303+%endif
libavfilter/x86/vf_convolution_init.c+18−0
@@ -29,6 +29,11 @@ void ff_filter_3x3_sse4(uint8_t *dst, int width, · 28 unmodified lines
2929 const uint8_t *c[], int peak, int radius,
3030 int dstride, int stride, int size);
3131
32+void ff_filter_sobel_avx512icl(uint8_t *dst, int width,
33+ float scale, float delta, const int *const matrix,
34+ const uint8_t *c[], int peak, int radius,
35+ int dstride, int stride, int size);
36+
3237 av_cold void ff_convolution_init_x86(ConvolutionContext *s)
3338 {
3439 #if ARCH_X86_64
@@ -44,3 +49,16 @@ av_cold void ff_convolution_init_x86(ConvolutionContext *s) · 9 unmodified lines
4449 }
4550 #endif
4651 }
52+
53+av_cold void ff_sobel_init_x86(ConvolutionContext *s, int depth, int nb_planes)
54+{
55+#if ARCH_X86_64
56+ int cpu_flags = av_get_cpu_flags();
57+ for (int i = 0; i < nb_planes; i++) {
58+ if (depth == 8) {
59+ if (EXTERNAL_AVX512ICL(cpu_flags))
60+ s->filter[i] = ff_filter_sobel_avx512icl;
61+ }
62+ }
63+#endif
64+}
tests/checkasm/Makefile+1−0
@@ -46,6 +46,7 @@ AVFILTEROBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o · 45 unmodified lines
4646 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o
4747 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o
4848 AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER) += vf_nlmeans.o
49+AVFILTEROBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o
4950
5051 CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes)
5152
tests/checkasm/checkasm.c+3−0
@@ -197,6 +197,9 @@ static const struct { · 196 unmodified lines
197197 #if CONFIG_THRESHOLD_FILTER
198198 { "vf_threshold", checkasm_check_vf_threshold },
199199 #endif
200+ #if CONFIG_SOBEL_FILTER
201+ { "vf_sobel", checkasm_check_vf_sobel },
202+ #endif
200203 #endif
201204 #if CONFIG_SWSCALE
202205 { "sw_gbrp", checkasm_check_sw_gbrp },
tests/checkasm/checkasm.h+1−0
@@ -86,6 +86,7 @@ void checkasm_check_vf_eq(void); · 85 unmodified lines
8686 void checkasm_check_vf_gblur(void);
8787 void checkasm_check_vf_hflip(void);
8888 void checkasm_check_vf_threshold(void);
89+void checkasm_check_vf_sobel(void);
8990 void checkasm_check_vp8dsp(void);
9091 void checkasm_check_vp9dsp(void);
9192 void checkasm_check_videodsp(void);
tests/checkasm/vf_convolution.c+104−0
@@ -0,0 +1,104 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * FFmpeg is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; either version 2 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * FFmpeg is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License along
15+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17+ */
18+
19+#include <string.h>
20+#include "checkasm.h"
21+#include "libavfilter/avfilter.h"
22+#include "libavfilter/convolution.h"
23+#include "libavutil/intreadwrite.h"
24+#include "libavutil/mem_internal.h"
25+
26+#define WIDTH 512
27+#define HEIGHT 512
28+#define SRC_STRIDE 512
29+#define PIXELS (WIDTH * HEIGHT)
30+
31+#define randomize_buffers(buf, size) \
32+ do { \
33+ int j; \
34+ uint8_t *tmp_buf = (uint8_t *)buf;\
35+ for (j = 0; j< size; j++) \
36+ tmp_buf[j] = rnd() & 0xFF; \
37+ } while (0)
38+
39+static void check_sobel(const char * report_name)
40+{
41+ LOCAL_ALIGNED_32(uint8_t, src, [PIXELS]);
42+ LOCAL_ALIGNED_32(uint8_t, dst_ref, [PIXELS]);
43+ LOCAL_ALIGNED_32(uint8_t, dst_new, [PIXELS]);
44+ const int height = WIDTH;
45+ const int width = HEIGHT;
46+ const int stride = SRC_STRIDE;
47+ const int dstride = SRC_STRIDE;
48+ int mode = 0;
49+ const uint8_t *c[49];
50+ const int radius = 1;
51+ const int bpc = 1;
52+ const int step = mode == MATRIX_COLUMN ? 16 : 1;
53+ const int slice_start = 0;
54+ const int slice_end = height;
55+ int y;
56+ const int sizew = mode == MATRIX_COLUMN ? height : width;
57+ float scale = 2;
58+ float delta = 10;
59+
60+ ConvolutionContext s;
61+
62+ declare_func(void, uint8_t *dst, int width, float scale, float delta, const int *const matrix,
63+ const uint8_t *c[], int peak, int radius, int dstride, int stride, int size);
64+
65+ s.scale = scale;
66+ s.delta = delta;
67+ s.depth = 8;
68+ s.nb_planes = 3;
69+ s.planes = 15;
70+ ff_sobel_init(&s, s.depth, s.nb_planes);
71+
72+ memset(dst_ref, 0, PIXELS);
73+ memset(dst_new, 0, PIXELS);
74+ randomize_buffers(src, PIXELS);
75+
76+ if (check_func(s.filter[0], "%s", report_name)) {
77+ for (y = slice_start; y < slice_end; y += step) {
78+ const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc;
79+ const int yoff = mode == MATRIX_COLUMN ? radius * dstride : 0;
80+
81+ s.setup[0](radius, c, src, stride, radius, width, y, height, bpc);
82+ call_ref(dst_ref + yoff + xoff, sizew - 2 * radius,
83+ scale, delta, NULL, c, 0, radius,
84+ dstride, stride, slice_end - step);
85+ call_new(dst_new + yoff + xoff, sizew - 2 * radius,
86+ scale, delta, NULL, c, 0, radius,
87+ dstride, stride, slice_end - step);
88+ if (memcmp(dst_ref + yoff + xoff, dst_new + yoff + xoff, slice_end - step))
89+ fail();
90+ bench_new(dst_new + yoff + xoff, sizew - 2 * radius,
91+ scale, delta, NULL, c, 0, radius,
92+ dstride, stride, slice_end - step);
93+ if (mode != MATRIX_COLUMN)
94+ dst_ref += dstride;
95+ }
96+ }
97+
98+}
99+
100+void checkasm_check_vf_sobel(void)
101+{
102+ check_sobel("sobel");
103+ report("convolution:sobel");
104+}
tests/fate/checkasm.mak+1−0
@@ -43,6 +43,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ · 42 unmodified lines
4343 fate-checkasm-vf_hflip \
4444 fate-checkasm-vf_nlmeans \
4545 fate-checkasm-vf_threshold \
46+ fate-checkasm-vf_sobel \
4647 fate-checkasm-videodsp \
4748 fate-checkasm-vorbisdsp \
4849 fate-checkasm-vp8dsp \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t