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 <string.h> | ||
22 | #include "checkasm.h" | ||
23 | #include "libavcodec/h264dsp.h" | ||
24 | #include "libavcodec/h264data.h" | ||
25 | #include "libavcodec/h264_parse.h" | ||
26 | #include "libavutil/common.h" | ||
27 | #include "libavutil/intreadwrite.h" | ||
28 | #include "libavutil/mem_internal.h" | ||
29 | |||
30 | static const uint32_t pixel_mask[5] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff, 0x0fff0fff, 0x3fff3fff }; | ||
31 | static const uint32_t pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f }; | ||
32 | |||
33 | #define SIZEOF_PIXEL ((bit_depth + 7) / 8) | ||
34 | #define SIZEOF_COEF (2 * ((bit_depth + 7) / 8)) | ||
35 | #define PIXEL_STRIDE 16 | ||
36 | |||
37 | #define randomize_buffers(idx) \ | ||
38 | do { \ | ||
39 | int x, y; \ | ||
40 | uint32_t mask = pixel_mask[(idx)]; \ | ||
41 | for (y = 0; y < sz; y++) { \ | ||
42 | for (x = 0; x < PIXEL_STRIDE; x += 4) { \ | ||
43 | AV_WN32A(src + y * PIXEL_STRIDE + x, rnd() & mask); \ | ||
44 | AV_WN32A(dst + y * PIXEL_STRIDE + x, rnd() & mask); \ | ||
45 | } \ | ||
46 | for (x = 0; x < sz; x++) { \ | ||
47 | if (bit_depth == 8) { \ | ||
48 | coef[y * sz + x] = src[y * PIXEL_STRIDE + x] - \ | ||
49 | dst[y * PIXEL_STRIDE + x]; \ | ||
50 | } else { \ | ||
51 | ((int32_t *)coef)[y * sz + x] = \ | ||
52 | ((uint16_t *)src)[y * (PIXEL_STRIDE/2) + x] - \ | ||
53 | ((uint16_t *)dst)[y * (PIXEL_STRIDE/2) + x]; \ | ||
54 | } \ | ||
55 | } \ | ||
56 | } \ | ||
57 | } while (0) | ||
58 | |||
59 | #define dct4x4_impl(size, dctcoef) \ | ||
60 | static void dct4x4_##size(dctcoef *coef) \ | ||
61 | { \ | ||
62 | int i, y, x; \ | ||
63 | dctcoef tmp[16]; \ | ||
64 | for (i = 0; i < 4; i++) { \ | ||
65 | const int z0 = coef[i*4 + 0] + coef[i*4 + 3]; \ | ||
66 | const int z1 = coef[i*4 + 1] + coef[i*4 + 2]; \ | ||
67 | const int z2 = coef[i*4 + 0] - coef[i*4 + 3]; \ | ||
68 | const int z3 = coef[i*4 + 1] - coef[i*4 + 2]; \ | ||
69 | tmp[i + 4*0] = z0 + z1; \ | ||
70 | tmp[i + 4*1] = 2*z2 + z3; \ | ||
71 | tmp[i + 4*2] = z0 - z1; \ | ||
72 | tmp[i + 4*3] = z2 - 2*z3; \ | ||
73 | } \ | ||
74 | for (i = 0; i < 4; i++) { \ | ||
75 | const int z0 = tmp[i*4 + 0] + tmp[i*4 + 3]; \ | ||
76 | const int z1 = tmp[i*4 + 1] + tmp[i*4 + 2]; \ | ||
77 | const int z2 = tmp[i*4 + 0] - tmp[i*4 + 3]; \ | ||
78 | const int z3 = tmp[i*4 + 1] - tmp[i*4 + 2]; \ | ||
79 | coef[i*4 + 0] = z0 + z1; \ | ||
80 | coef[i*4 + 1] = 2*z2 + z3; \ | ||
81 | coef[i*4 + 2] = z0 - z1; \ | ||
82 | coef[i*4 + 3] = z2 - 2*z3; \ | ||
83 | } \ | ||
84 | for (y = 0; y < 4; y++) { \ | ||
85 | for (x = 0; x < 4; x++) { \ | ||
86 | const int64_t scale[] = { 13107 * 10, 8066 * 13, 5243 * 16 }; \ | ||
87 | const int idx = (y & 1) + (x & 1); \ | ||
88 | coef[y*4 + x] = (coef[y*4 + x] * scale[idx] + (1 << 14)) >> 15; \ | ||
89 | } \ | ||
90 | } \ | ||
91 | } | ||
92 | |||
93 | #define DCT8_1D(src, srcstride, dst, dststride) do { \ | ||
94 | const int a0 = (src)[srcstride * 0] + (src)[srcstride * 7]; \ | ||
95 | const int a1 = (src)[srcstride * 0] - (src)[srcstride * 7]; \ | ||
96 | const int a2 = (src)[srcstride * 1] + (src)[srcstride * 6]; \ | ||
97 | const int a3 = (src)[srcstride * 1] - (src)[srcstride * 6]; \ | ||
98 | const int a4 = (src)[srcstride * 2] + (src)[srcstride * 5]; \ | ||
99 | const int a5 = (src)[srcstride * 2] - (src)[srcstride * 5]; \ | ||
100 | const int a6 = (src)[srcstride * 3] + (src)[srcstride * 4]; \ | ||
101 | const int a7 = (src)[srcstride * 3] - (src)[srcstride * 4]; \ | ||
102 | const int b0 = a0 + a6; \ | ||
103 | const int b1 = a2 + a4; \ | ||
104 | const int b2 = a0 - a6; \ | ||
105 | const int b3 = a2 - a4; \ | ||
106 | const int b4 = a3 + a5 + (a1 + (a1 >> 1)); \ | ||
107 | const int b5 = a1 - a7 - (a5 + (a5 >> 1)); \ | ||
108 | const int b6 = a1 + a7 - (a3 + (a3 >> 1)); \ | ||
109 | const int b7 = a3 - a5 + (a7 + (a7 >> 1)); \ | ||
110 | (dst)[dststride * 0] = b0 + b1; \ | ||
111 | (dst)[dststride * 1] = b4 + (b7 >> 2); \ | ||
112 | (dst)[dststride * 2] = b2 + (b3 >> 1); \ | ||
113 | (dst)[dststride * 3] = b5 + (b6 >> 2); \ | ||
114 | (dst)[dststride * 4] = b0 - b1; \ | ||
115 | (dst)[dststride * 5] = b6 - (b5 >> 2); \ | ||
116 | (dst)[dststride * 6] = (b2 >> 1) - b3; \ | ||
117 | (dst)[dststride * 7] = (b4 >> 2) - b7; \ | ||
118 | } while (0) | ||
119 | |||
120 | #define dct8x8_impl(size, dctcoef) \ | ||
121 | static void dct8x8_##size(dctcoef *coef) \ | ||
122 | { \ | ||
123 | int i, x, y; \ | ||
124 | dctcoef tmp[64]; \ | ||
125 | for (i = 0; i < 8; i++) \ | ||
126 | DCT8_1D(coef + i, 8, tmp + i, 8); \ | ||
127 | \ | ||
128 | for (i = 0; i < 8; i++) \ | ||
129 | DCT8_1D(tmp + 8*i, 1, coef + i, 8); \ | ||
130 | \ | ||
131 | for (y = 0; y < 8; y++) { \ | ||
132 | for (x = 0; x < 8; x++) { \ | ||
133 | static const int scale[] = { \ | ||
134 | 13107 * 20, 11428 * 18, 20972 * 32, \ | ||
135 | 12222 * 19, 16777 * 25, 15481 * 24, \ | ||
136 | }; \ | ||
137 | static const int idxmap[] = { \ | ||
138 | 0, 3, 4, 3, \ | ||
139 | 3, 1, 5, 1, \ | ||
140 | 4, 5, 2, 5, \ | ||
141 | 3, 1, 5, 1, \ | ||
142 | }; \ | ||
143 | const int idx = idxmap[(y & 3) * 4 + (x & 3)]; \ | ||
144 | coef[y*8 + x] = ((int64_t)coef[y*8 + x] * \ | ||
145 | scale[idx] + (1 << 17)) >> 18; \ | ||
146 | } \ | ||
147 | } \ | ||
148 | } | ||
149 | |||
150 |
8/8✓ Branch 0 taken 1820 times.
✓ Branch 1 taken 455 times.
✓ Branch 2 taken 1820 times.
✓ Branch 3 taken 455 times.
✓ Branch 4 taken 7280 times.
✓ Branch 5 taken 1820 times.
✓ Branch 6 taken 1820 times.
✓ Branch 7 taken 455 times.
|
13195 | dct4x4_impl(16, int16_t) |
151 |
8/8✓ Branch 0 taken 3952 times.
✓ Branch 1 taken 988 times.
✓ Branch 2 taken 3952 times.
✓ Branch 3 taken 988 times.
✓ Branch 4 taken 15808 times.
✓ Branch 5 taken 3952 times.
✓ Branch 6 taken 3952 times.
✓ Branch 7 taken 988 times.
|
28652 | dct4x4_impl(32, int32_t) |
152 | |||
153 |
8/8✓ Branch 0 taken 728 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 91 times.
✓ Branch 4 taken 5824 times.
✓ Branch 5 taken 728 times.
✓ Branch 6 taken 728 times.
✓ Branch 7 taken 91 times.
|
8099 | dct8x8_impl(16, int16_t) |
154 |
8/8✓ Branch 0 taken 2080 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 2080 times.
✓ Branch 3 taken 260 times.
✓ Branch 4 taken 16640 times.
✓ Branch 5 taken 2080 times.
✓ Branch 6 taken 2080 times.
✓ Branch 7 taken 260 times.
|
23140 | dct8x8_impl(32, int32_t) |
155 | |||
156 | 1443 | static void dct4x4(int16_t *coef, int bit_depth) | |
157 | { | ||
158 |
2/2✓ Branch 0 taken 455 times.
✓ Branch 1 taken 988 times.
|
1443 | if (bit_depth == 8) |
159 | 455 | dct4x4_16(coef); | |
160 | else | ||
161 | 988 | dct4x4_32((int32_t *) coef); | |
162 | 1443 | } | |
163 | |||
164 | 351 | static void dct8x8(int16_t *coef, int bit_depth) | |
165 | { | ||
166 |
2/2✓ Branch 0 taken 91 times.
✓ Branch 1 taken 260 times.
|
351 | if (bit_depth == 8) { |
167 | 91 | dct8x8_16(coef); | |
168 | } else { | ||
169 | 260 | dct8x8_32((int32_t *) coef); | |
170 | } | ||
171 | 351 | } | |
172 | |||
173 | |||
174 | 13 | static void check_idct(void) | |
175 | { | ||
176 | static const int depths[5] = { 8, 9, 10, 12, 14 }; | ||
177 | 13 | LOCAL_ALIGNED_16(uint8_t, src, [8 * 8 * 2]); | |
178 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [8 * 8 * 2]); | |
179 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [8 * 8 * 2]); | |
180 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1_base, [8 * 8 * 2 + 32]); | |
181 | 13 | LOCAL_ALIGNED_16(int16_t, coef, [8 * 8 * 2]); | |
182 | 13 | LOCAL_ALIGNED_16(int16_t, subcoef0, [8 * 8 * 2]); | |
183 | 13 | LOCAL_ALIGNED_16(int16_t, subcoef1, [8 * 8 * 2]); | |
184 | H264DSPContext h; | ||
185 | int bit_depth, sz, align, dc, i; | ||
186 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *block, int stride); |
187 | |||
188 |
2/2✓ Branch 0 taken 65 times.
✓ Branch 1 taken 13 times.
|
78 | for (i = 0; i < FF_ARRAY_ELEMS(depths); i++) { |
189 | 65 | bit_depth = depths[i]; | |
190 | 65 | ff_h264dsp_init(&h, bit_depth, 1); | |
191 | |||
192 |
2/2✓ Branch 0 taken 195 times.
✓ Branch 1 taken 65 times.
|
260 | for (dc = 0; dc <= 2; dc++) { |
193 |
2/2✓ Branch 0 taken 390 times.
✓ Branch 1 taken 195 times.
|
585 | for (sz = 4; sz <= 8; sz += 4) { |
194 | 390 | void (*idct)(uint8_t *, int16_t *, int) = NULL; | |
195 | 390 | const char fmts[3][28] = { | |
196 | "h264_idct%d_add_%dbpp", "h264_idct%d_dc_add_%dbpp", | ||
197 | "h264_add_pixels%d_%dbpp", | ||
198 | }; | ||
199 | |||
200 |
8/8✓ Branch 2 taken 9360 times.
✓ Branch 3 taken 2340 times.
✓ Branch 4 taken 3120 times.
✓ Branch 5 taken 12480 times.
✓ Branch 6 taken 15600 times.
✓ Branch 7 taken 2340 times.
✓ Branch 8 taken 2340 times.
✓ Branch 9 taken 390 times.
|
27690 | randomize_buffers(i); |
201 | |||
202 |
2/2✓ Branch 0 taken 195 times.
✓ Branch 1 taken 195 times.
|
390 | if (sz == 4) |
203 | 195 | dct4x4(coef, bit_depth); | |
204 | else | ||
205 | 195 | dct8x8(coef, bit_depth); | |
206 | |||
207 |
6/7✓ Branch 0 taken 65 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
|
390 | switch ((sz << 2) | dc) { |
208 | 65 | case (4 << 2) | 0: idct = h.h264_idct_add; break; | |
209 | 65 | case (4 << 2) | 1: idct = h.h264_idct_dc_add; break; | |
210 | 65 | case (4 << 2) | 2: idct = h.h264_add_pixels4_clear; break; | |
211 | 65 | case (8 << 2) | 0: idct = h.h264_idct8_add; break; | |
212 | 65 | case (8 << 2) | 1: idct = h.h264_idct8_dc_add; break; | |
213 | 65 | case (8 << 2) | 2: idct = h.h264_add_pixels8_clear; break; | |
214 | } | ||
215 | |||
216 |
2/2✓ Branch 3 taken 44 times.
✓ Branch 4 taken 346 times.
|
390 | if (check_func(idct, fmts[dc], sz, bit_depth)) { |
217 |
2/2✓ Branch 0 taken 86 times.
✓ Branch 1 taken 44 times.
|
130 | for (align = 0; align < 16; align += sz * SIZEOF_PIXEL) { |
218 | 86 | uint8_t *dst1 = dst1_base + align; | |
219 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 34 times.
|
86 | if (dc) { |
220 | 52 | memset(subcoef0, 0, sz * sz * SIZEOF_COEF); | |
221 | 52 | memcpy(subcoef0, coef, SIZEOF_COEF); | |
222 | } else { | ||
223 | 34 | memcpy(subcoef0, coef, sz * sz * SIZEOF_COEF); | |
224 | } | ||
225 | 86 | memcpy(dst0, dst, sz * PIXEL_STRIDE); | |
226 | 86 | memcpy(dst1, dst, sz * PIXEL_STRIDE); | |
227 | 86 | memcpy(subcoef1, subcoef0, sz * sz * SIZEOF_COEF); | |
228 | 86 | call_ref(dst0, subcoef0, PIXEL_STRIDE); | |
229 | 86 | call_new(dst1, subcoef1, PIXEL_STRIDE); | |
230 |
1/2✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
|
86 | if (memcmp(dst0, dst1, sz * PIXEL_STRIDE) || |
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | memcmp(subcoef0, subcoef1, sz * sz * SIZEOF_COEF)) |
232 | ✗ | fail(); | |
233 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 86 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.
|
86 | bench_new(dst1, subcoef1, sz * SIZEOF_PIXEL); |
234 | } | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | 13 | } | |
240 | |||
241 | 13 | static void check_idct_multiple(void) | |
242 | { | ||
243 | 13 | LOCAL_ALIGNED_16(uint8_t, dst_full, [16 * 16 * 2]); | |
244 | 13 | LOCAL_ALIGNED_16(int16_t, coef_full, [16 * 16 * 2]); | |
245 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [16 * 16 * 2]); | |
246 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [16 * 16 * 2]); | |
247 | 13 | LOCAL_ALIGNED_16(int16_t, coef0, [16 * 16 * 2]); | |
248 | 13 | LOCAL_ALIGNED_16(int16_t, coef1, [16 * 16 * 2]); | |
249 | 13 | LOCAL_ALIGNED_16(uint8_t, nnzc, [15 * 8]); | |
250 | H264DSPContext h; | ||
251 | int bit_depth, i, y, func; | ||
252 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]); |
253 | |||
254 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
255 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
256 |
2/2✓ Branch 0 taken 117 times.
✓ Branch 1 taken 39 times.
|
156 | for (func = 0; func < 3; func++) { |
257 | 117 | void (*idct)(uint8_t *, const int *, int16_t *, int, const uint8_t[]) = NULL; | |
258 | const char *name; | ||
259 | 117 | int sz = 4, intra = 0; | |
260 | 117 | int block_offset[16] = { 0 }; | |
261 |
3/4✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
117 | switch (func) { |
262 | 39 | case 0: | |
263 | 39 | idct = h.h264_idct_add16; | |
264 | 39 | name = "h264_idct_add16"; | |
265 | 39 | break; | |
266 | 39 | case 1: | |
267 | 39 | idct = h.h264_idct_add16intra; | |
268 | 39 | name = "h264_idct_add16intra"; | |
269 | 39 | intra = 1; | |
270 | 39 | break; | |
271 | 39 | case 2: | |
272 | 39 | idct = h.h264_idct8_add4; | |
273 | 39 | name = "h264_idct8_add4"; | |
274 | 39 | sz = 8; | |
275 | 39 | break; | |
276 | } | ||
277 | 117 | memset(nnzc, 0, 15 * 8); | |
278 | 117 | memset(coef_full, 0, 16 * 16 * SIZEOF_COEF); | |
279 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 117 times.
|
1521 | for (i = 0; i < 16 * 16; i += sz * sz) { |
280 | uint8_t src[8 * 8 * 2]; | ||
281 | uint8_t dst[8 * 8 * 2]; | ||
282 | int16_t coef[8 * 8 * 2]; | ||
283 | 1404 | int index = i / sz; | |
284 | 1404 | int block_y = (index / 16) * sz; | |
285 | 1404 | int block_x = index % 16; | |
286 | 1404 | int offset = (block_y * 16 + block_x) * SIZEOF_PIXEL; | |
287 | 1404 | int nnz = rnd() % 3; | |
288 | |||
289 |
8/8✓ Branch 2 taken 24960 times.
✓ Branch 3 taken 6240 times.
✓ Branch 4 taken 9984 times.
✓ Branch 5 taken 19968 times.
✓ Branch 6 taken 29952 times.
✓ Branch 7 taken 6240 times.
✓ Branch 8 taken 6240 times.
✓ Branch 9 taken 1404 times.
|
62556 | randomize_buffers(bit_depth - 8); |
290 |
2/2✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 156 times.
|
1404 | if (sz == 4) |
291 | 1248 | dct4x4(coef, bit_depth); | |
292 | else | ||
293 | 156 | dct8x8(coef, bit_depth); | |
294 | |||
295 |
2/2✓ Branch 0 taken 6240 times.
✓ Branch 1 taken 1404 times.
|
7644 | for (y = 0; y < sz; y++) |
296 | 6240 | memcpy(&dst_full[offset + y * 16 * SIZEOF_PIXEL], | |
297 | 6240 | &dst[PIXEL_STRIDE * y], sz * SIZEOF_PIXEL); | |
298 | |||
299 |
2/2✓ Branch 0 taken 486 times.
✓ Branch 1 taken 918 times.
|
1404 | if (nnz > 1) |
300 | 486 | nnz = sz * sz; | |
301 | 1404 | memcpy(&coef_full[i * SIZEOF_COEF/sizeof(coef[0])], | |
302 | 1404 | coef, nnz * SIZEOF_COEF); | |
303 | |||
304 |
4/4✓ Branch 0 taken 624 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 435 times.
|
1404 | if (intra && nnz == 1) |
305 | 189 | nnz = 0; | |
306 | |||
307 | 1404 | nnzc[scan8[i / 16]] = nnz; | |
308 | 1404 | block_offset[i / 16] = offset; | |
309 | } | ||
310 | |||
311 |
2/2✓ Branch 3 taken 18 times.
✓ Branch 4 taken 99 times.
|
117 | if (check_func(idct, "%s_%dbpp", name, bit_depth)) { |
312 | 18 | memcpy(coef0, coef_full, 16 * 16 * SIZEOF_COEF); | |
313 | 18 | memcpy(coef1, coef_full, 16 * 16 * SIZEOF_COEF); | |
314 | 18 | memcpy(dst0, dst_full, 16 * 16 * SIZEOF_PIXEL); | |
315 | 18 | memcpy(dst1, dst_full, 16 * 16 * SIZEOF_PIXEL); | |
316 | 18 | call_ref(dst0, block_offset, coef0, 16 * SIZEOF_PIXEL, nnzc); | |
317 | 18 | call_new(dst1, block_offset, coef1, 16 * SIZEOF_PIXEL, nnzc); | |
318 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL) || |
319 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | memcmp(coef0, coef1, 16 * 16 * SIZEOF_COEF)) |
320 | ✗ | fail(); | |
321 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 18 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.
|
18 | bench_new(dst1, block_offset, coef1, 16 * SIZEOF_PIXEL, nnzc); |
322 | } | ||
323 | } | ||
324 | } | ||
325 | 13 | } | |
326 | |||
327 | |||
328 | 13 | static void check_loop_filter(void) | |
329 | { | ||
330 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [32 * 16 * 2]); | |
331 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [32 * 16 * 2]); | |
332 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [32 * 16 * 2]); | |
333 | H264DSPContext h; | ||
334 | int bit_depth; | ||
335 | int alphas[36], betas[36]; | ||
336 | int8_t tc0[36][4]; | ||
337 | |||
338 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *pix, ptrdiff_t stride, |
339 | int alpha, int beta, int8_t *tc0); | ||
340 | |||
341 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
342 | int i, j, a, c; | ||
343 | 39 | uint32_t mask = pixel_mask_lf[bit_depth - 8]; | |
344 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
345 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 39 times.
|
1443 | for (i = 35, a = 255, c = 250; i >= 0; i--) { |
346 | 1404 | alphas[i] = a << (bit_depth - 8); | |
347 | 1404 | betas[i] = (i + 1) / 2 << (bit_depth - 8); | |
348 | 1404 | tc0[i][0] = tc0[i][3] = (c + 6) / 10; | |
349 | 1404 | tc0[i][1] = (c + 7) / 15; | |
350 | 1404 | tc0[i][2] = (c + 9) / 20; | |
351 | 1404 | a = a*9/10; | |
352 | 1404 | c = c*9/10; | |
353 | } | ||
354 | |||
355 | #define CHECK_LOOP_FILTER(name, align, idc) \ | ||
356 | do { \ | ||
357 | if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \ | ||
358 | for (j = 0; j < 36; j++) { \ | ||
359 | intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \ | ||
360 | for (i = 0; i < 1024; i+=4) { \ | ||
361 | AV_WN32A(dst + i, rnd() & mask); \ | ||
362 | } \ | ||
363 | memcpy(dst0, dst, 32 * 16 * 2); \ | ||
364 | memcpy(dst1, dst, 32 * 16 * 2); \ | ||
365 | \ | ||
366 | call_ref(dst0 + off, 32, alphas[j], betas[j], tc0[j]); \ | ||
367 | call_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]); \ | ||
368 | if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \ | ||
369 | fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d " \ | ||
370 | "tc0:{%d,%d,%d,%d}\n", j, alphas[j], betas[j], \ | ||
371 | tc0[j][0], tc0[j][1], tc0[j][2], tc0[j][3]); \ | ||
372 | fail(); \ | ||
373 | } \ | ||
374 | bench_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]);\ | ||
375 | } \ | ||
376 | } \ | ||
377 | } while (0) | ||
378 | |||
379 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_v_loop_filter_luma, 1,); |
380 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_h_loop_filter_luma, 0,); |
381 |
8/16✓ Branch 3 taken 5 times.
✓ Branch 4 taken 34 times.
✓ Branch 6 taken 46080 times.
✓ Branch 7 taken 180 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 180 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 180 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 180 times.
✓ Branch 40 taken 5 times.
|
46299 | CHECK_LOOP_FILTER(h264_h_loop_filter_luma_mbaff, 0,); |
382 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_v_loop_filter_chroma, 1,); |
383 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma, 0,); |
384 |
8/16✓ Branch 3 taken 3 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 27648 times.
✓ Branch 7 taken 108 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 108 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 108 times.
✓ Branch 40 taken 3 times.
|
27795 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_mbaff, 0,); |
385 | |||
386 | 39 | ff_h264dsp_init(&h, bit_depth, 2); | |
387 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma, 0, 422); |
388 |
8/16✓ Branch 3 taken 3 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 27648 times.
✓ Branch 7 taken 108 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 108 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 108 times.
✓ Branch 40 taken 3 times.
|
27795 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_mbaff, 0, 422); |
389 | #undef CHECK_LOOP_FILTER | ||
390 | } | ||
391 | 13 | } | |
392 | |||
393 | 13 | static void check_loop_filter_intra(void) | |
394 | { | ||
395 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [32 * 16 * 2]); | |
396 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [32 * 16 * 2]); | |
397 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [32 * 16 * 2]); | |
398 | H264DSPContext h; | ||
399 | int bit_depth; | ||
400 | int alphas[36], betas[36]; | ||
401 | |||
402 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
|
13 | declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *pix, ptrdiff_t stride, |
403 | int alpha, int beta); | ||
404 | |||
405 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
406 | int i, j, a; | ||
407 | 39 | uint32_t mask = pixel_mask_lf[bit_depth - 8]; | |
408 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
409 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 39 times.
|
1443 | for (i = 35, a = 255; i >= 0; i--) { |
410 | 1404 | alphas[i] = a << (bit_depth - 8); | |
411 | 1404 | betas[i] = (i + 1) / 2 << (bit_depth - 8); | |
412 | 1404 | a = a*9/10; | |
413 | } | ||
414 | |||
415 | #define CHECK_LOOP_FILTER(name, align, idc) \ | ||
416 | do { \ | ||
417 | if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \ | ||
418 | for (j = 0; j < 36; j++) { \ | ||
419 | intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \ | ||
420 | for (i = 0; i < 1024; i+=4) { \ | ||
421 | AV_WN32A(dst + i, rnd() & mask); \ | ||
422 | } \ | ||
423 | memcpy(dst0, dst, 32 * 16 * 2); \ | ||
424 | memcpy(dst1, dst, 32 * 16 * 2); \ | ||
425 | \ | ||
426 | call_ref(dst0 + off, 32, alphas[j], betas[j]); \ | ||
427 | call_new(dst1 + off, 32, alphas[j], betas[j]); \ | ||
428 | if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \ | ||
429 | fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d\n", \ | ||
430 | j, alphas[j], betas[j]); \ | ||
431 | fail(); \ | ||
432 | } \ | ||
433 | bench_new(dst1 + off, 32, alphas[j], betas[j]); \ | ||
434 | } \ | ||
435 | } \ | ||
436 | } while (0) | ||
437 | |||
438 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_v_loop_filter_luma_intra, 1,); |
439 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_h_loop_filter_luma_intra, 0,); |
440 |
8/16✓ Branch 3 taken 3 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 27648 times.
✓ Branch 7 taken 108 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 108 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 108 times.
✓ Branch 40 taken 3 times.
|
27795 | CHECK_LOOP_FILTER(h264_h_loop_filter_luma_mbaff_intra, 0,); |
441 |
8/16✓ Branch 3 taken 7 times.
✓ Branch 4 taken 32 times.
✓ Branch 6 taken 64512 times.
✓ Branch 7 taken 252 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 252 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 252 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 252 times.
✓ Branch 40 taken 7 times.
|
64803 | CHECK_LOOP_FILTER(h264_v_loop_filter_chroma_intra, 1,); |
442 |
8/16✓ Branch 3 taken 5 times.
✓ Branch 4 taken 34 times.
✓ Branch 6 taken 46080 times.
✓ Branch 7 taken 180 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 180 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 180 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 180 times.
✓ Branch 40 taken 5 times.
|
46299 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_intra, 0,); |
443 |
8/16✓ Branch 3 taken 3 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 27648 times.
✓ Branch 7 taken 108 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 108 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 108 times.
✓ Branch 40 taken 3 times.
|
27795 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_mbaff_intra, 0,); |
444 | |||
445 | 39 | ff_h264dsp_init(&h, bit_depth, 2); | |
446 |
8/16✓ Branch 3 taken 5 times.
✓ Branch 4 taken 34 times.
✓ Branch 6 taken 46080 times.
✓ Branch 7 taken 180 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 180 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 180 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 180 times.
✓ Branch 40 taken 5 times.
|
46299 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_intra, 0, 422); |
447 |
8/16✓ Branch 3 taken 3 times.
✓ Branch 4 taken 36 times.
✓ Branch 6 taken 27648 times.
✓ Branch 7 taken 108 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 108 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 108 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✓ Branch 39 taken 108 times.
✓ Branch 40 taken 3 times.
|
27795 | CHECK_LOOP_FILTER(h264_h_loop_filter_chroma_mbaff_intra, 0, 422); |
448 | #undef CHECK_LOOP_FILTER | ||
449 | } | ||
450 | 13 | } | |
451 | |||
452 | 13 | void checkasm_check_h264dsp(void) | |
453 | { | ||
454 | 13 | check_idct(); | |
455 | 13 | check_idct_multiple(); | |
456 | 13 | report("idct"); | |
457 | |||
458 | 13 | check_loop_filter(); | |
459 | 13 | report("loop_filter"); | |
460 | |||
461 | 13 | check_loop_filter_intra(); | |
462 | 13 | report("loop_filter_intra"); | |
463 | 13 | } | |
464 |