Line | Branch | Exec | Source |
---|---|---|---|
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/bwdifdsp.h" | ||
22 | #include "libavutil/mem_internal.h" | ||
23 | |||
24 | #define WIDTH 256 | ||
25 | |||
26 | #define randomize_buffers(buf0, buf1, mask, count) \ | ||
27 | for (size_t i = 0; i < count; i++) \ | ||
28 | buf0[i] = buf1[i] = rnd() & mask | ||
29 | |||
30 | #define randomize_overflow_check(buf0, buf1, mask, count) \ | ||
31 | for (size_t i = 0; i < count; i++) \ | ||
32 | buf0[i] = buf1[i] = (rnd() & 1) != 0 ? mask : 0; | ||
33 | |||
34 | #define BODY(type, depth) \ | ||
35 | do { \ | ||
36 | type prev0[9*WIDTH], prev1[9*WIDTH]; \ | ||
37 | type next0[9*WIDTH], next1[9*WIDTH]; \ | ||
38 | type cur0[9*WIDTH], cur1[9*WIDTH]; \ | ||
39 | type dst0[WIDTH], dst1[WIDTH]; \ | ||
40 | const int stride = WIDTH; \ | ||
41 | const int mask = (1<<depth)-1; \ | ||
42 | \ | ||
43 | declare_func(void, void *dst, const void *prev, const void *cur, const void *next, \ | ||
44 | int w, int prefs, int mrefs, int prefs2, int mrefs2, \ | ||
45 | int prefs3, int mrefs3, int prefs4, int mrefs4, \ | ||
46 | int parity, int clip_max); \ | ||
47 | \ | ||
48 | randomize_buffers(prev0, prev1, mask, 9*WIDTH); \ | ||
49 | randomize_buffers(next0, next1, mask, 9*WIDTH); \ | ||
50 | randomize_buffers( cur0, cur1, mask, 9*WIDTH); \ | ||
51 | \ | ||
52 | call_ref(dst0, prev0 + 4*WIDTH, cur0 + 4*WIDTH, next0 + 4*WIDTH, \ | ||
53 | WIDTH, stride, -stride, 2*stride, -2*stride, \ | ||
54 | 3*stride, -3*stride, 4*stride, -4*stride, \ | ||
55 | 0, mask); \ | ||
56 | call_new(dst1, prev1 + 4*WIDTH, cur1 + 4*WIDTH, next1 + 4*WIDTH, \ | ||
57 | WIDTH, stride, -stride, 2*stride, -2*stride, \ | ||
58 | 3*stride, -3*stride, 4*stride, -4*stride, \ | ||
59 | 0, mask); \ | ||
60 | \ | ||
61 | if (memcmp(dst0, dst1, sizeof dst0) \ | ||
62 | || memcmp(prev0, prev1, sizeof prev0) \ | ||
63 | || memcmp(next0, next1, sizeof next0) \ | ||
64 | || memcmp( cur0, cur1, sizeof cur0)) \ | ||
65 | fail(); \ | ||
66 | bench_new(dst1, prev1 + 4*WIDTH, cur1 + 4*WIDTH, next1 + 4*WIDTH, \ | ||
67 | WIDTH, stride, -stride, 2*stride, -2*stride, \ | ||
68 | 3*stride, -3*stride, 4*stride, -4*stride, \ | ||
69 | 0, mask); \ | ||
70 | } while (0) | ||
71 | |||
72 | 13 | void checkasm_check_vf_bwdif(void) | |
73 | { | ||
74 | BWDIFDSPContext ctx_8, ctx_10; | ||
75 | |||
76 | 13 | ff_bwdif_init_filter_line(&ctx_8, 8); | |
77 | 13 | ff_bwdif_init_filter_line(&ctx_10, 10); | |
78 | |||
79 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
|
13 | if (check_func(ctx_8.filter_line, "bwdif8")) { |
80 |
11/22✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 9216 times.
✓ Branch 5 taken 4 times.
✓ Branch 7 taken 9216 times.
✓ Branch 8 taken 4 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
|
27652 | BODY(uint8_t, 8); |
81 | 4 | report("bwdif8"); | |
82 | } | ||
83 | |||
84 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
|
13 | if (check_func(ctx_10.filter_line, "bwdif10")) { |
85 |
11/22✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 4 times.
✓ Branch 4 taken 9216 times.
✓ Branch 5 taken 4 times.
✓ Branch 7 taken 9216 times.
✓ Branch 8 taken 4 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
|
27652 | BODY(uint16_t, 10); |
86 | 4 | report("bwdif10"); | |
87 | } | ||
88 | |||
89 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | if (!ctx_8.filter_line3) |
90 | 13 | ctx_8.filter_line3 = ff_bwdif_filter_line3_c; | |
91 | |||
92 | { | ||
93 | 13 | LOCAL_ALIGNED_16(uint8_t, prev0, [11*WIDTH]); | |
94 | 13 | LOCAL_ALIGNED_16(uint8_t, prev1, [11*WIDTH]); | |
95 | 13 | LOCAL_ALIGNED_16(uint8_t, next0, [11*WIDTH]); | |
96 | 13 | LOCAL_ALIGNED_16(uint8_t, next1, [11*WIDTH]); | |
97 | 13 | LOCAL_ALIGNED_16(uint8_t, cur0, [11*WIDTH]); | |
98 | 13 | LOCAL_ALIGNED_16(uint8_t, cur1, [11*WIDTH]); | |
99 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [WIDTH*3]); | |
100 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [WIDTH*3]); | |
101 | 13 | const int stride = WIDTH; | |
102 | 13 | const int mask = (1<<8)-1; | |
103 | int parity; | ||
104 | |||
105 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (parity = 0; parity != 2; ++parity) { |
106 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24 times.
|
26 | if (check_func(ctx_8.filter_line3, "bwdif8.line3.rnd.p%d", parity)) { |
107 | |||
108 | 2 | declare_func(void, void * dst1, int d_stride, | |
109 | const void * prev1, const void * cur1, const void * next1, int prefs, | ||
110 | int w, int parity, int clip_max); | ||
111 | |||
112 |
2/2✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 2 times.
|
5634 | randomize_buffers(prev0, prev1, mask, 11*WIDTH); |
113 |
2/2✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 2 times.
|
5634 | randomize_buffers(next0, next1, mask, 11*WIDTH); |
114 |
2/2✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 2 times.
|
5634 | randomize_buffers( cur0, cur1, mask, 11*WIDTH); |
115 | |||
116 | 2 | call_ref(dst0, stride, | |
117 | prev0 + stride * 4, cur0 + stride * 4, next0 + stride * 4, stride, | ||
118 | WIDTH, parity, mask); | ||
119 | 2 | call_new(dst1, stride, | |
120 | prev1 + stride * 4, cur1 + stride * 4, next1 + stride * 4, stride, | ||
121 | WIDTH, parity, mask); | ||
122 | |||
123 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (memcmp(dst0, dst1, WIDTH*3) |
124 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | || memcmp(prev0, prev1, WIDTH*11) |
125 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | || memcmp(next0, next1, WIDTH*11) |
126 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | || memcmp( cur0, cur1, WIDTH*11)) |
127 | ✗ | fail(); | |
128 | |||
129 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
2 | bench_new(dst1, stride, |
130 | prev1 + stride * 4, cur1 + stride * 4, next1 + stride * 4, stride, | ||
131 | WIDTH, parity, mask); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | // Use just 0s and ~0s to try to provoke bad cropping or overflow | ||
136 | // Parity makes no difference to this test so just test 0 | ||
137 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 4 taken 12 times.
|
13 | if (check_func(ctx_8.filter_line3, "bwdif8.line3.overflow")) { |
138 | |||
139 | 1 | declare_func(void, void * dst1, int d_stride, | |
140 | const void * prev1, const void * cur1, const void * next1, int prefs, | ||
141 | int w, int parity, int clip_max); | ||
142 | |||
143 |
4/4✓ Branch 1 taken 1427 times.
✓ Branch 2 taken 1389 times.
✓ Branch 3 taken 2816 times.
✓ Branch 4 taken 1 times.
|
2817 | randomize_overflow_check(prev0, prev1, mask, 11*WIDTH); |
144 |
4/4✓ Branch 1 taken 1410 times.
✓ Branch 2 taken 1406 times.
✓ Branch 3 taken 2816 times.
✓ Branch 4 taken 1 times.
|
2817 | randomize_overflow_check(next0, next1, mask, 11*WIDTH); |
145 |
4/4✓ Branch 1 taken 1401 times.
✓ Branch 2 taken 1415 times.
✓ Branch 3 taken 2816 times.
✓ Branch 4 taken 1 times.
|
2817 | randomize_overflow_check( cur0, cur1, mask, 11*WIDTH); |
146 | |||
147 | 1 | call_ref(dst0, stride, | |
148 | prev0 + stride * 4, cur0 + stride * 4, next0 + stride * 4, stride, | ||
149 | WIDTH, 0, mask); | ||
150 | 1 | call_new(dst1, stride, | |
151 | prev1 + stride * 4, cur1 + stride * 4, next1 + stride * 4, stride, | ||
152 | WIDTH, 0, mask); | ||
153 | |||
154 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (memcmp(dst0, dst1, WIDTH*3) |
155 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || memcmp(prev0, prev1, WIDTH*11) |
156 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | || memcmp(next0, next1, WIDTH*11) |
157 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | || memcmp( cur0, cur1, WIDTH*11)) |
158 | ✗ | fail(); | |
159 | |||
160 | // No point to benching | ||
161 | } | ||
162 | |||
163 | 13 | report("bwdif8.line3"); | |
164 | } | ||
165 | |||
166 | { | ||
167 | 13 | LOCAL_ALIGNED_16(uint8_t, prev0, [11*WIDTH]); | |
168 | 13 | LOCAL_ALIGNED_16(uint8_t, prev1, [11*WIDTH]); | |
169 | 13 | LOCAL_ALIGNED_16(uint8_t, next0, [11*WIDTH]); | |
170 | 13 | LOCAL_ALIGNED_16(uint8_t, next1, [11*WIDTH]); | |
171 | 13 | LOCAL_ALIGNED_16(uint8_t, cur0, [11*WIDTH]); | |
172 | 13 | LOCAL_ALIGNED_16(uint8_t, cur1, [11*WIDTH]); | |
173 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [WIDTH*3]); | |
174 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [WIDTH*3]); | |
175 | 13 | const int stride = WIDTH; | |
176 | 13 | const int mask = (1<<8)-1; | |
177 | int spat; | ||
178 | int parity; | ||
179 | |||
180 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (spat = 0; spat != 2; ++spat) { |
181 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (parity = 0; parity != 2; ++parity) { |
182 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 48 times.
|
52 | if (check_func(ctx_8.filter_edge, "bwdif8.edge.s%d.p%d", spat, parity)) { |
183 | |||
184 | 4 | declare_func(void, void *dst1, const void *prev1, const void *cur1, const void *next1, | |
185 | int w, int prefs, int mrefs, int prefs2, int mrefs2, | ||
186 | int parity, int clip_max, int spat); | ||
187 | |||
188 |
2/2✓ Branch 1 taken 11264 times.
✓ Branch 2 taken 4 times.
|
11268 | randomize_buffers(prev0, prev1, mask, 11*WIDTH); |
189 |
2/2✓ Branch 1 taken 11264 times.
✓ Branch 2 taken 4 times.
|
11268 | randomize_buffers(next0, next1, mask, 11*WIDTH); |
190 |
2/2✓ Branch 1 taken 11264 times.
✓ Branch 2 taken 4 times.
|
11268 | randomize_buffers( cur0, cur1, mask, 11*WIDTH); |
191 | 4 | memset(dst0, 0xba, WIDTH * 3); | |
192 | 4 | memset(dst1, 0xba, WIDTH * 3); | |
193 | |||
194 | 4 | call_ref(dst0 + stride, | |
195 | prev0 + stride * 4, cur0 + stride * 4, next0 + stride * 4, WIDTH, | ||
196 | stride, -stride, stride * 2, -stride * 2, | ||
197 | parity, mask, spat); | ||
198 | 4 | call_new(dst1 + stride, | |
199 | prev1 + stride * 4, cur1 + stride * 4, next1 + stride * 4, WIDTH, | ||
200 | stride, -stride, stride * 2, -stride * 2, | ||
201 | parity, mask, spat); | ||
202 | |||
203 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (memcmp(dst0, dst1, WIDTH*3) |
204 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | || memcmp(prev0, prev1, WIDTH*11) |
205 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | || memcmp(next0, next1, WIDTH*11) |
206 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | || memcmp( cur0, cur1, WIDTH*11)) |
207 | ✗ | fail(); | |
208 | |||
209 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
4 | bench_new(dst1 + stride, |
210 | prev1 + stride * 4, cur1 + stride * 4, next1 + stride * 4, WIDTH, | ||
211 | stride, -stride, stride * 2, -stride * 2, | ||
212 | parity, mask, spat); | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | |||
217 | 13 | report("bwdif8.edge"); | |
218 | } | ||
219 | |||
220 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 4 taken 12 times.
|
13 | if (check_func(ctx_8.filter_intra, "bwdif8.intra")) { |
221 | 1 | LOCAL_ALIGNED_16(uint8_t, cur0, [11*WIDTH]); | |
222 | 1 | LOCAL_ALIGNED_16(uint8_t, cur1, [11*WIDTH]); | |
223 | 1 | LOCAL_ALIGNED_16(uint8_t, dst0, [WIDTH*3]); | |
224 | 1 | LOCAL_ALIGNED_16(uint8_t, dst1, [WIDTH*3]); | |
225 | 1 | const int stride = WIDTH; | |
226 | 1 | const int mask = (1<<8)-1; | |
227 | |||
228 | 1 | declare_func(void, void *dst1, const void *cur1, int w, int prefs, int mrefs, | |
229 | int prefs3, int mrefs3, int parity, int clip_max); | ||
230 | |||
231 |
2/2✓ Branch 1 taken 2816 times.
✓ Branch 2 taken 1 times.
|
2817 | randomize_buffers( cur0, cur1, mask, 11*WIDTH); |
232 | 1 | memset(dst0, 0xba, WIDTH * 3); | |
233 | 1 | memset(dst1, 0xba, WIDTH * 3); | |
234 | |||
235 | 1 | call_ref(dst0 + stride, | |
236 | cur0 + stride * 4, WIDTH, | ||
237 | stride, -stride, stride * 3, -stride * 3, | ||
238 | 0, mask); | ||
239 | 1 | call_new(dst1 + stride, | |
240 | cur0 + stride * 4, WIDTH, | ||
241 | stride, -stride, stride * 3, -stride * 3, | ||
242 | 0, mask); | ||
243 | |||
244 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (memcmp(dst0, dst1, WIDTH*3) |
245 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | || memcmp( cur0, cur1, WIDTH*11)) |
246 | ✗ | fail(); | |
247 | |||
248 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
1 | bench_new(dst1 + stride, |
249 | cur0 + stride * 4, WIDTH, | ||
250 | stride, -stride, stride * 3, -stride * 3, | ||
251 | 0, mask); | ||
252 | |||
253 | 1 | report("bwdif8.intra"); | |
254 | } | ||
255 | 13 | } | |
256 |