Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2016 Martin Storsjo | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <stdbool.h> | ||
22 | #include <string.h> | ||
23 | |||
24 | #include "config_components.h" | ||
25 | #include "libavcodec/vp8dsp.h" | ||
26 | |||
27 | #include "libavutil/common.h" | ||
28 | #include "libavutil/intreadwrite.h" | ||
29 | #include "libavutil/mem_internal.h" | ||
30 | |||
31 | #include "checkasm.h" | ||
32 | |||
33 | #define PIXEL_STRIDE 16 | ||
34 | |||
35 | #define randomize_buffers(src, dst, stride, coef) \ | ||
36 | do { \ | ||
37 | int x, y; \ | ||
38 | for (y = 0; y < 4; y++) { \ | ||
39 | AV_WN32A((src) + y * (stride), rnd()); \ | ||
40 | AV_WN32A((dst) + y * (stride), rnd()); \ | ||
41 | for (x = 0; x < 4; x++) \ | ||
42 | (coef)[y * 4 + x] = (src)[y * (stride) + x] - \ | ||
43 | (dst)[y * (stride) + x]; \ | ||
44 | } \ | ||
45 | } while (0) | ||
46 | |||
47 | 466 | static void dct4x4(int16_t *coef) | |
48 | { | ||
49 | int i; | ||
50 |
2/2✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 466 times.
|
2330 | for (i = 0; i < 4; i++) { |
51 | 1864 | const int a1 = (coef[i*4 + 0] + coef[i*4 + 3]) * 8; | |
52 | 1864 | const int b1 = (coef[i*4 + 1] + coef[i*4 + 2]) * 8; | |
53 | 1864 | const int c1 = (coef[i*4 + 1] - coef[i*4 + 2]) * 8; | |
54 | 1864 | const int d1 = (coef[i*4 + 0] - coef[i*4 + 3]) * 8; | |
55 | 1864 | coef[i*4 + 0] = a1 + b1; | |
56 | 1864 | coef[i*4 + 1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12; | |
57 | 1864 | coef[i*4 + 2] = a1 - b1; | |
58 | 1864 | coef[i*4 + 3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12; | |
59 | } | ||
60 |
2/2✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 466 times.
|
2330 | for (i = 0; i < 4; i++) { |
61 | 1864 | const int a1 = coef[i + 0*4] + coef[i + 3*4]; | |
62 | 1864 | const int b1 = coef[i + 1*4] + coef[i + 2*4]; | |
63 | 1864 | const int c1 = coef[i + 1*4] - coef[i + 2*4]; | |
64 | 1864 | const int d1 = coef[i + 0*4] - coef[i + 3*4]; | |
65 | 1864 | coef[i + 0*4] = (a1 + b1 + 7) >> 4; | |
66 | 1864 | coef[i + 1*4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + !!d1; | |
67 | 1864 | coef[i + 2*4] = (a1 - b1 + 7) >> 4; | |
68 | 1864 | coef[i + 3*4] = (d1 * 2217 - c1 * 5352 + 51000) >> 16; | |
69 | } | ||
70 | 466 | } | |
71 | |||
72 | 26 | static void wht4x4(int16_t *coef) | |
73 | { | ||
74 | int i; | ||
75 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
|
130 | for (i = 0; i < 4; i++) { |
76 | 104 | int a1 = coef[0 * 4 + i]; | |
77 | 104 | int b1 = coef[1 * 4 + i]; | |
78 | 104 | int c1 = coef[2 * 4 + i]; | |
79 | 104 | int d1 = coef[3 * 4 + i]; | |
80 | int e1; | ||
81 | 104 | a1 += b1; | |
82 | 104 | d1 -= c1; | |
83 | 104 | e1 = (a1 - d1) >> 1; | |
84 | 104 | b1 = e1 - b1; | |
85 | 104 | c1 = e1 - c1; | |
86 | 104 | a1 -= c1; | |
87 | 104 | d1 += b1; | |
88 | 104 | coef[0 * 4 + i] = a1; | |
89 | 104 | coef[1 * 4 + i] = c1; | |
90 | 104 | coef[2 * 4 + i] = d1; | |
91 | 104 | coef[3 * 4 + i] = b1; | |
92 | } | ||
93 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
|
130 | for (i = 0; i < 4; i++) { |
94 | 104 | int a1 = coef[i * 4 + 0]; | |
95 | 104 | int b1 = coef[i * 4 + 1]; | |
96 | 104 | int c1 = coef[i * 4 + 2]; | |
97 | 104 | int d1 = coef[i * 4 + 3]; | |
98 | int e1; | ||
99 | 104 | a1 += b1; | |
100 | 104 | d1 -= c1; | |
101 | 104 | e1 = (a1 - d1) >> 1; | |
102 | 104 | b1 = e1 - b1; | |
103 | 104 | c1 = e1 - c1; | |
104 | 104 | a1 -= c1; | |
105 | 104 | d1 += b1; | |
106 | 104 | coef[i * 4 + 0] = a1 * 2; | |
107 | 104 | coef[i * 4 + 1] = c1 * 2; | |
108 | 104 | coef[i * 4 + 2] = d1 * 2; | |
109 | 104 | coef[i * 4 + 3] = b1 * 2; | |
110 | } | ||
111 | 26 | } | |
112 | |||
113 | 26 | static void check_idct(VP8DSPContext *d, bool is_vp7) | |
114 | { | ||
115 | 26 | LOCAL_ALIGNED_16(uint8_t, src, [4 * 4]); | |
116 | 26 | LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4]); | |
117 | 26 | LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4]); | |
118 | 26 | LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4]); | |
119 | 26 | LOCAL_ALIGNED_16(int16_t, coef, [4 * 4]); | |
120 | 26 | LOCAL_ALIGNED_16(int16_t, subcoef0, [4 * 4]); | |
121 | 26 | LOCAL_ALIGNED_16(int16_t, subcoef1, [4 * 4]); | |
122 | int dc; | ||
123 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2 times.
|
26 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *block, ptrdiff_t stride); |
124 | |||
125 |
4/4✓ Branch 2 taken 416 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 26 times.
|
546 | randomize_buffers(src, dst, 4, coef); |
126 | |||
127 | 26 | dct4x4(coef); | |
128 | |||
129 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (dc = 0; dc <= 1; dc++) { |
130 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? d->vp8_idct_dc_add : d->vp8_idct_add; |
131 | |||
132 |
4/4✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 45 times.
|
52 | if (check_func(idct, "vp%d_idct_%sadd", 8 - is_vp7, dc ? "dc_" : "")) { |
133 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
|
7 | if (dc) { |
134 | 4 | memset(subcoef0, 0, 4 * 4 * sizeof(int16_t)); | |
135 | 4 | subcoef0[0] = coef[0]; | |
136 | } else { | ||
137 | 3 | memcpy(subcoef0, coef, 4 * 4 * sizeof(int16_t)); | |
138 | } | ||
139 | 7 | memcpy(dst0, dst, 4 * 4); | |
140 | 7 | memcpy(dst1, dst, 4 * 4); | |
141 | 7 | memcpy(subcoef1, subcoef0, 4 * 4 * sizeof(int16_t)); | |
142 | // Note, this uses a pixel stride of 4, even though the real decoder uses a stride as a | ||
143 | // multiple of 16. If optimizations want to take advantage of that, this test needs to be | ||
144 | // updated to make it more like the h264dsp tests. | ||
145 | 7 | call_ref(dst0, subcoef0, 4); | |
146 | 7 | call_new(dst1, subcoef1, 4); | |
147 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if (memcmp(dst0, dst1, 4 * 4) || |
148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | memcmp(subcoef0, subcoef1, 4 * 4 * sizeof(int16_t))) |
149 | ✗ | fail(); | |
150 | |||
151 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 7 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.
|
7 | bench_new(dst1, subcoef1, 4); |
152 | } | ||
153 | } | ||
154 | 26 | } | |
155 | |||
156 | 26 | static void check_idct_dc4(VP8DSPContext *d, bool is_vp7) | |
157 | { | ||
158 | 26 | LOCAL_ALIGNED_16(uint8_t, src, [4 * 4 * 4]); | |
159 | 26 | LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4 * 4]); | |
160 | 26 | LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4 * 4]); | |
161 | 26 | LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4 * 4]); | |
162 | 26 | LOCAL_ALIGNED_16(int16_t, coef, [4], [4 * 4]); | |
163 | 26 | LOCAL_ALIGNED_16(int16_t, subcoef0, [4], [4 * 4]); | |
164 | 26 | LOCAL_ALIGNED_16(int16_t, subcoef1, [4], [4 * 4]); | |
165 | int i, chroma; | ||
166 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2 times.
|
26 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t block[4][16], ptrdiff_t stride); |
167 | |||
168 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (chroma = 0; chroma <= 1; chroma++) { |
169 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? d->vp8_idct_dc_add4uv : d->vp8_idct_dc_add4y; |
170 |
4/4✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 46 times.
|
52 | if (check_func(idct4dc, "vp%d_idct_dc_add4%s", 8 - is_vp7, chroma ? "uv" : "y")) { |
171 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | ptrdiff_t stride = chroma ? 8 : 16; |
172 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | int w = chroma ? 2 : 4; |
173 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
|
30 | for (i = 0; i < 4; i++) { |
174 | 24 | int blockx = 4 * (i % w); | |
175 | 24 | int blocky = 4 * (i / w); | |
176 |
4/4✓ Branch 2 taken 384 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 96 times.
✓ Branch 5 taken 24 times.
|
504 | randomize_buffers(src + stride * blocky + blockx, dst + stride * blocky + blockx, stride, coef[i]); |
177 | 24 | dct4x4(coef[i]); | |
178 | 24 | memset(&coef[i][1], 0, 15 * sizeof(int16_t)); | |
179 | } | ||
180 | |||
181 | 6 | memcpy(dst0, dst, 4 * 4 * 4); | |
182 | 6 | memcpy(dst1, dst, 4 * 4 * 4); | |
183 | 6 | memcpy(subcoef0, coef, 4 * 4 * 4 * sizeof(int16_t)); | |
184 | 6 | memcpy(subcoef1, coef, 4 * 4 * 4 * sizeof(int16_t)); | |
185 | 6 | call_ref(dst0, subcoef0, stride); | |
186 | 6 | call_new(dst1, subcoef1, stride); | |
187 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (memcmp(dst0, dst1, 4 * 4 * 4) || |
188 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | memcmp(subcoef0, subcoef1, 4 * 4 * 4 * sizeof(int16_t))) |
189 | ✗ | fail(); | |
190 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 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.
|
6 | bench_new(dst1, subcoef1, stride); |
191 | } | ||
192 | } | ||
193 | |||
194 | 26 | } | |
195 | |||
196 | 26 | static void check_luma_dc_wht(VP8DSPContext *d, bool is_vp7) | |
197 | { | ||
198 | 26 | LOCAL_ALIGNED_16(int16_t, dc, [4 * 4]); | |
199 | 26 | LOCAL_ALIGNED_16(int16_t, dc0, [4 * 4]); | |
200 | 26 | LOCAL_ALIGNED_16(int16_t, dc1, [4 * 4]); | |
201 | int16_t block[4][4][16]; | ||
202 | 26 | LOCAL_ALIGNED_16(int16_t, block0, [4], [4][16]); | |
203 | 26 | LOCAL_ALIGNED_16(int16_t, block1, [4], [4][16]); | |
204 | int dc_only; | ||
205 | int blockx, blocky; | ||
206 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2 times.
|
26 | declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t block[4][4][16], int16_t dc[16]); |
207 | |||
208 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
|
130 | for (blocky = 0; blocky < 4; blocky++) { |
209 |
2/2✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
|
520 | for (blockx = 0; blockx < 4; blockx++) { |
210 | uint8_t src[16], dst[16]; | ||
211 |
4/4✓ Branch 2 taken 6656 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 1664 times.
✓ Branch 5 taken 416 times.
|
8736 | randomize_buffers(src, dst, 4, block[blocky][blockx]); |
212 | |||
213 | 416 | dct4x4(block[blocky][blockx]); | |
214 | 416 | dc[blocky * 4 + blockx] = block[blocky][blockx][0]; | |
215 | 416 | block[blocky][blockx][0] = rnd(); | |
216 | } | ||
217 | } | ||
218 | 26 | wht4x4(dc); | |
219 | |||
220 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (dc_only = 0; dc_only <= 1; dc_only++) { |
221 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? d->vp8_luma_dc_wht_dc : d->vp8_luma_dc_wht; |
222 | |||
223 |
4/4✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 47 times.
|
52 | if (check_func(idct, "vp%d_luma_dc_wht%s", 8 - is_vp7, dc_only ? "_dc" : "")) { |
224 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | if (dc_only) { |
225 | 2 | memset(dc0, 0, 16 * sizeof(int16_t)); | |
226 | 2 | dc0[0] = dc[0]; | |
227 | } else { | ||
228 | 3 | memcpy(dc0, dc, 16 * sizeof(int16_t)); | |
229 | } | ||
230 | 5 | memcpy(dc1, dc0, 16 * sizeof(int16_t)); | |
231 | 5 | memcpy(block0, block, 4 * 4 * 16 * sizeof(int16_t)); | |
232 | 5 | memcpy(block1, block, 4 * 4 * 16 * sizeof(int16_t)); | |
233 | 5 | call_ref(block0, dc0); | |
234 | 5 | call_new(block1, dc1); | |
235 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (memcmp(block0, block1, 4 * 4 * 16 * sizeof(int16_t)) || |
236 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | memcmp(dc0, dc1, 16 * sizeof(int16_t))) |
237 | ✗ | fail(); | |
238 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 5 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.
|
5 | bench_new(block1, dc1); |
239 | } | ||
240 | } | ||
241 | 26 | } | |
242 | |||
243 | #define SRC_BUF_STRIDE 32 | ||
244 | #define SRC_BUF_SIZE (((size << (size < 16)) + 5) * SRC_BUF_STRIDE) | ||
245 | // The mc subpixel interpolation filter needs the 2 previous pixels in either | ||
246 | // direction, the +1 is to make sure the actual load addresses always are | ||
247 | // unaligned. | ||
248 | #define src (buf + 2 * SRC_BUF_STRIDE + 2 + 1) | ||
249 | |||
250 | #undef randomize_buffers | ||
251 | #define randomize_buffers() \ | ||
252 | do { \ | ||
253 | int k; \ | ||
254 | for (k = 0; k < SRC_BUF_SIZE; k += 4) { \ | ||
255 | AV_WN32A(buf + k, rnd()); \ | ||
256 | } \ | ||
257 | } while (0) | ||
258 | |||
259 | 13 | static void check_mc(VP8DSPContext *d) | |
260 | { | ||
261 | 13 | LOCAL_ALIGNED_16(uint8_t, buf, [32 * 32]); | |
262 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [16 * 16]); | |
263 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [16 * 16]); | |
264 | int type, k, dx, dy; | ||
265 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, |
266 | const uint8_t *, ptrdiff_t, int, int, int); | ||
267 | |||
268 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (type = 0; type < 2; type++) { |
269 |
2/2✓ Branch 0 taken 182 times.
✓ Branch 1 taken 26 times.
|
208 | for (k = 1; k < 8; k++) { |
270 | 182 | int hsize = k / 3; | |
271 | 182 | int size = 16 >> hsize; | |
272 | 182 | int height = (size << 1) >> (k % 3); | |
273 |
2/2✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
|
728 | for (dy = 0; dy < 3; dy++) { |
274 |
2/2✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 546 times.
|
2184 | for (dx = 0; dx < 3; dx++) { |
275 | char str[100]; | ||
276 |
2/2✓ Branch 0 taken 819 times.
✓ Branch 1 taken 819 times.
|
1638 | vp8_mc_func func = (type ? d->put_vp8_bilinear_pixels_tab : d->put_vp8_epel_pixels_tab)[hsize][dy][dx]; |
277 | |||
278 |
4/4✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1092 times.
✓ Branch 2 taken 364 times.
✓ Branch 3 taken 182 times.
|
1638 | if (dx || dy) { |
279 |
2/2✓ Branch 0 taken 728 times.
✓ Branch 1 taken 728 times.
|
1456 | if (type == 0) { |
280 | static const char *dx_names[] = { "", "h4", "h6" }; | ||
281 | static const char *dy_names[] = { "", "v4", "v6" }; | ||
282 | 728 | snprintf(str, sizeof(str), "epel%d_%s%s", size, dx_names[dx], dy_names[dy]); | |
283 | } else { | ||
284 |
4/4✓ Branch 0 taken 546 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 546 times.
✓ Branch 3 taken 182 times.
|
728 | snprintf(str, sizeof(str), "bilin%d_%s%s", size, dx ? "h" : "", dy ? "v" : ""); |
285 | } | ||
286 | } else { | ||
287 | 182 | snprintf(str, sizeof(str), "pixels%d", size); | |
288 | } | ||
289 | |||
290 |
2/2✓ Branch 3 taken 94 times.
✓ Branch 4 taken 1544 times.
|
1638 | if (check_func(func, "vp8_put_%s", str)) { |
291 | int mx, my; | ||
292 | int i; | ||
293 |
2/2✓ Branch 0 taken 67 times.
✓ Branch 1 taken 27 times.
|
94 | if (type == 0) { |
294 |
4/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 21 times.
|
67 | mx = dx == 2 ? 2 + 2 * (rnd() % 3) : dx == 1 ? 1 + 2 * (rnd() % 4) : 0; |
295 |
4/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 21 times.
|
67 | my = dy == 2 ? 2 + 2 * (rnd() % 3) : dy == 1 ? 1 + 2 * (rnd() % 4) : 0; |
296 | } else { | ||
297 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | mx = dx ? 1 + (rnd() % 7) : 0; |
298 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
|
27 | my = dy ? 1 + (rnd() % 7) : 0; |
299 | } | ||
300 |
2/2✓ Branch 1 taken 13616 times.
✓ Branch 2 taken 94 times.
|
13710 | randomize_buffers(); |
301 |
2/2✓ Branch 0 taken 564 times.
✓ Branch 1 taken 94 times.
|
658 | for (i = -2; i <= 3; i++) { |
302 |
4/4✓ Branch 0 taken 470 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 376 times.
|
564 | int val = (i == -1 || i == 2) ? 0 : 0xff; |
303 | // Set pixels in the first row and column to the maximum pattern, | ||
304 | // to test for potential overflows in the filter. | ||
305 | 564 | src[i ] = val; | |
306 | 564 | src[i * SRC_BUF_STRIDE] = val; | |
307 | } | ||
308 | 94 | call_ref(dst0, size, src, SRC_BUF_STRIDE, height, mx, my); | |
309 | 94 | call_new(dst1, size, src, SRC_BUF_STRIDE, height, mx, my); | |
310 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
|
94 | if (memcmp(dst0, dst1, size * height)) |
311 | ✗ | fail(); | |
312 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 94 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.
|
94 | bench_new(dst1, size, src, SRC_BUF_STRIDE, height, mx, my); |
313 | } | ||
314 | } | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | 13 | } | |
319 | |||
320 | #undef randomize_buffers | ||
321 | |||
322 | #define setpx(a, b, c) buf[(a) + (b) * jstride] = av_clip_uint8(c) | ||
323 | // Set the pixel to c +/- [0,d] | ||
324 | #define setdx(a, b, c, d) setpx(a, b, c - (d) + (rnd() % ((d) * 2 + 1))) | ||
325 | // Set the pixel to c +/- [d,d+e] (making sure it won't be clipped) | ||
326 | #define setdx2(a, b, o, c, d, e) setpx(a, b, o = c + ((d) + (rnd() % (e))) * (c >= 128 ? -1 : 1)) | ||
327 | |||
328 | 290 | static void randomize_loopfilter_buffers(int lineoff, int str, | |
329 | int dir, int flim_E, int flim_I, | ||
330 | int hev_thresh, uint8_t *buf, | ||
331 | int force_hev) | ||
332 | { | ||
333 | 290 | uint32_t mask = 0xff; | |
334 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 136 times.
|
290 | int off = dir ? lineoff : lineoff * str; |
335 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 136 times.
|
290 | int istride = dir ? 1 : str; |
336 |
2/2✓ Branch 0 taken 136 times.
✓ Branch 1 taken 154 times.
|
290 | int jstride = dir ? str : 1; |
337 | int i; | ||
338 |
2/2✓ Branch 0 taken 1160 times.
✓ Branch 1 taken 290 times.
|
1450 | for (i = 0; i < 8; i += 2) { |
339 | // Row 0 will trigger hev for q0/q1, row 2 will trigger hev for p0/p1, | ||
340 | // rows 4 and 6 will not trigger hev. | ||
341 | // force_hev 1 will make sure all rows trigger hev, while force_hev -1 | ||
342 | // makes none of them trigger it. | ||
343 | 1160 | int idx = off + i * istride, p2, p1, p0, q0, q1, q2; | |
344 | 1160 | setpx(idx, 0, q0 = rnd() & mask); | |
345 |
6/6✓ Branch 0 taken 290 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 752 times.
|
1160 | if (i == 0 && force_hev >= 0 || force_hev > 0) |
346 |
2/2✓ Branch 1 taken 206 times.
✓ Branch 2 taken 202 times.
|
408 | setdx2(idx, 1, q1, q0, hev_thresh + 1, flim_I - hev_thresh - 1); |
347 | else | ||
348 | 752 | setdx(idx, 1, q1 = q0, hev_thresh); | |
349 | 1160 | setdx(idx, 2, q2 = q1, flim_I); | |
350 | 1160 | setdx(idx, 3, q2, flim_I); | |
351 | 1160 | setdx(idx, -1, p0 = q0, flim_E >> 2); | |
352 |
6/6✓ Branch 0 taken 290 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 752 times.
|
1160 | if (i == 2 && force_hev >= 0 || force_hev > 0) |
353 |
2/2✓ Branch 1 taken 197 times.
✓ Branch 2 taken 211 times.
|
408 | setdx2(idx, -2, p1, p0, hev_thresh + 1, flim_I - hev_thresh - 1); |
354 | else | ||
355 | 752 | setdx(idx, -2, p1 = p0, hev_thresh); | |
356 | 1160 | setdx(idx, -3, p2 = p1, flim_I); | |
357 | 1160 | setdx(idx, -4, p2, flim_I); | |
358 | } | ||
359 | 290 | } | |
360 | |||
361 | // Fill the buffer with random pixels | ||
362 | 213 | static void fill_loopfilter_buffers(uint8_t *buf, ptrdiff_t stride, int w, int h) | |
363 | { | ||
364 | int x, y; | ||
365 |
2/2✓ Branch 0 taken 3408 times.
✓ Branch 1 taken 213 times.
|
3621 | for (y = 0; y < h; y++) |
366 |
2/2✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 3408 times.
|
57936 | for (x = 0; x < w; x++) |
367 | 54528 | buf[y * stride + x] = rnd() & 0xff; | |
368 | 213 | } | |
369 | |||
370 | #define randomize_buffers(buf, lineoff, str, force_hev) \ | ||
371 | randomize_loopfilter_buffers(lineoff, str, dir, flim_E, flim_I, hev_thresh, buf, force_hev) | ||
372 | |||
373 | 26 | static void check_loopfilter_16y(VP8DSPContext *d, bool is_vp7) | |
374 | { | ||
375 | 26 | LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]); | |
376 | 26 | LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]); | |
377 | int dir, edge, force_hev; | ||
378 | 26 | int flim_E = 20, flim_I = 10, hev_thresh = 7; | |
379 | 26 | declare_func(void, uint8_t *, ptrdiff_t, int, int, int); | |
380 | |||
381 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (dir = 0; dir < 2; dir++) { |
382 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff = dir ? 4 * 16 : 4; |
383 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff_aligned = dir ? 4 * 16 : 16; |
384 | 52 | uint8_t *buf0 = base0 + midoff_aligned; | |
385 | 52 | uint8_t *buf1 = base1 + midoff_aligned; | |
386 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 52 times.
|
156 | for (edge = 0; edge < 2; edge++) { |
387 | 104 | void (*func)(uint8_t *, ptrdiff_t, int, int, int) = NULL; | |
388 |
4/5✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
|
104 | switch (dir << 1 | edge) { |
389 | 26 | case (0 << 1) | 0: func = d->vp8_h_loop_filter16y; break; | |
390 | 26 | case (1 << 1) | 0: func = d->vp8_v_loop_filter16y; break; | |
391 | 26 | case (0 << 1) | 1: func = d->vp8_h_loop_filter16y_inner; break; | |
392 | 26 | case (1 << 1) | 1: func = d->vp8_v_loop_filter16y_inner; break; | |
393 | } | ||
394 |
6/6✓ Branch 2 taken 52 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 52 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 87 times.
|
104 | if (check_func(func, "vp%d_loop_filter16y%s_%s", 8 - is_vp7, edge ? "_inner" : "", dir ? "v" : "h")) { |
395 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 17 times.
|
68 | for (force_hev = -1; force_hev <= 1; force_hev++) { |
396 | 51 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
397 | 51 | randomize_buffers(buf0, 0, 16, force_hev); | |
398 | 51 | randomize_buffers(buf0, 8, 16, force_hev); | |
399 | 51 | memcpy(buf1 - midoff, buf0 - midoff, 16 * 16); | |
400 | 51 | call_ref(buf0, 16, flim_E, flim_I, hev_thresh); | |
401 | 51 | call_new(buf1, 16, flim_E, flim_I, hev_thresh); | |
402 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16)) |
403 | ✗ | fail(); | |
404 | } | ||
405 | 17 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
406 | 17 | randomize_buffers(buf0, 0, 16, 0); | |
407 | 17 | randomize_buffers(buf0, 8, 16, 0); | |
408 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 17 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.
|
17 | bench_new(buf0, 16, flim_E, flim_I, hev_thresh); |
409 | } | ||
410 | } | ||
411 | } | ||
412 | 26 | } | |
413 | |||
414 | 26 | static void check_loopfilter_8uv(VP8DSPContext *d, bool is_vp7) | |
415 | { | ||
416 | 26 | LOCAL_ALIGNED_16(uint8_t, base0u, [32 + 16 * 16]); | |
417 | 26 | LOCAL_ALIGNED_16(uint8_t, base0v, [32 + 16 * 16]); | |
418 | 26 | LOCAL_ALIGNED_16(uint8_t, base1u, [32 + 16 * 16]); | |
419 | 26 | LOCAL_ALIGNED_16(uint8_t, base1v, [32 + 16 * 16]); | |
420 | int dir, edge, force_hev; | ||
421 | 26 | int flim_E = 20, flim_I = 10, hev_thresh = 7; | |
422 | 26 | declare_func(void, uint8_t *, uint8_t *, ptrdiff_t, int, int, int); | |
423 | |||
424 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (dir = 0; dir < 2; dir++) { |
425 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff = dir ? 4 * 16 : 4; |
426 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff_aligned = dir ? 4 * 16 : 16; |
427 | 52 | uint8_t *buf0u = base0u + midoff_aligned; | |
428 | 52 | uint8_t *buf0v = base0v + midoff_aligned; | |
429 | 52 | uint8_t *buf1u = base1u + midoff_aligned; | |
430 | 52 | uint8_t *buf1v = base1v + midoff_aligned; | |
431 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 52 times.
|
156 | for (edge = 0; edge < 2; edge++) { |
432 | 104 | void (*func)(uint8_t *, uint8_t *, ptrdiff_t, int, int, int) = NULL; | |
433 |
4/5✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
|
104 | switch (dir << 1 | edge) { |
434 | 26 | case (0 << 1) | 0: func = d->vp8_h_loop_filter8uv; break; | |
435 | 26 | case (1 << 1) | 0: func = d->vp8_v_loop_filter8uv; break; | |
436 | 26 | case (0 << 1) | 1: func = d->vp8_h_loop_filter8uv_inner; break; | |
437 | 26 | case (1 << 1) | 1: func = d->vp8_v_loop_filter8uv_inner; break; | |
438 | } | ||
439 |
6/6✓ Branch 2 taken 52 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 52 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 87 times.
|
104 | if (check_func(func, "vp%d_loop_filter8uv%s_%s", 8 - is_vp7, edge ? "_inner" : "", dir ? "v" : "h")) { |
440 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 17 times.
|
68 | for (force_hev = -1; force_hev <= 1; force_hev++) { |
441 | 51 | fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16); | |
442 | 51 | fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16); | |
443 | 51 | randomize_buffers(buf0u, 0, 16, force_hev); | |
444 | 51 | randomize_buffers(buf0v, 0, 16, force_hev); | |
445 | 51 | memcpy(buf1u - midoff, buf0u - midoff, 16 * 16); | |
446 | 51 | memcpy(buf1v - midoff, buf0v - midoff, 16 * 16); | |
447 | |||
448 | 51 | call_ref(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh); | |
449 | 51 | call_new(buf1u, buf1v, 16, flim_E, flim_I, hev_thresh); | |
450 |
1/2✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
|
51 | if (memcmp(buf0u - midoff, buf1u - midoff, 16 * 16) || |
451 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
|
51 | memcmp(buf0v - midoff, buf1v - midoff, 16 * 16)) |
452 | ✗ | fail(); | |
453 | } | ||
454 | 17 | fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16); | |
455 | 17 | fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16); | |
456 | 17 | randomize_buffers(buf0u, 0, 16, 0); | |
457 | 17 | randomize_buffers(buf0v, 0, 16, 0); | |
458 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 17 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.
|
17 | bench_new(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh); |
459 | } | ||
460 | } | ||
461 | } | ||
462 | 26 | } | |
463 | |||
464 | 26 | static void check_loopfilter_simple(VP8DSPContext *d, bool is_vp7) | |
465 | { | ||
466 | 26 | LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]); | |
467 | 26 | LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]); | |
468 | int dir; | ||
469 | 26 | int flim_E = 20, flim_I = 30, hev_thresh = 0; | |
470 | 26 | declare_func(void, uint8_t *, ptrdiff_t, int); | |
471 | |||
472 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
|
78 | for (dir = 0; dir < 2; dir++) { |
473 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff = dir ? 4 * 16 : 4; |
474 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | int midoff_aligned = dir ? 4 * 16 : 16; |
475 | 52 | uint8_t *buf0 = base0 + midoff_aligned; | |
476 | 52 | uint8_t *buf1 = base1 + midoff_aligned; | |
477 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
|
52 | void (*func)(uint8_t *, ptrdiff_t, int) = dir ? d->vp8_v_loop_filter_simple : d->vp8_h_loop_filter_simple; |
478 |
4/4✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 43 times.
|
52 | if (check_func(func, "vp%d_loop_filter_simple_%s", 8 - is_vp7, dir ? "v" : "h")) { |
479 | 9 | fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16); | |
480 | 9 | randomize_buffers(buf0, 0, 16, -1); | |
481 | 9 | randomize_buffers(buf0, 8, 16, -1); | |
482 | 9 | memcpy(buf1 - midoff, buf0 - midoff, 16 * 16); | |
483 | 9 | call_ref(buf0, 16, flim_E); | |
484 | 9 | call_new(buf1, 16, flim_E); | |
485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16)) |
486 | ✗ | fail(); | |
487 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 9 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.
|
9 | bench_new(buf0, 16, flim_E); |
488 | } | ||
489 | } | ||
490 | 26 | } | |
491 | |||
492 | 26 | static void checkasm_check_vp78dsp(VP8DSPContext *d, bool is_vp7) | |
493 | { | ||
494 | #if CONFIG_VP7_DECODER | ||
495 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
|
26 | if (is_vp7) |
496 | 13 | ff_vp7dsp_init(d); | |
497 | else | ||
498 | #endif | ||
499 | 13 | ff_vp8dsp_init(d); | |
500 | 26 | check_idct(d, is_vp7); | |
501 | 26 | check_idct_dc4(d, is_vp7); | |
502 | 26 | check_luma_dc_wht(d, is_vp7); | |
503 | 26 | report("idct"); | |
504 | 26 | check_loopfilter_16y(d, is_vp7); | |
505 | 26 | check_loopfilter_8uv(d, is_vp7); | |
506 | 26 | check_loopfilter_simple(d, is_vp7); | |
507 | 26 | report("loopfilter"); | |
508 | 26 | } | |
509 | |||
510 | 13 | void checkasm_check_vp8dsp(void) | |
511 | { | ||
512 | VP8DSPContext d; | ||
513 | |||
514 | 13 | ff_vp78dsp_init(&d); | |
515 | 13 | check_mc(&d); | |
516 | 13 | report("mc"); | |
517 | 13 | checkasm_check_vp78dsp(&d, false); | |
518 | #if CONFIG_VP7_DECODER | ||
519 | 13 | checkasm_check_vp78dsp(&d, true); | |
520 | #endif | ||
521 | 13 | } | |
522 |