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[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff }; | ||
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() \ | ||
38 | do { \ | ||
39 | int x, y; \ | ||
40 | uint32_t mask = pixel_mask[bit_depth - 8]; \ | ||
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 | static const int 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 1716 times.
✓ Branch 1 taken 429 times.
✓ Branch 2 taken 1716 times.
✓ Branch 3 taken 429 times.
✓ Branch 4 taken 6864 times.
✓ Branch 5 taken 1716 times.
✓ Branch 6 taken 1716 times.
✓ Branch 7 taken 429 times.
|
12441 | dct4x4_impl(16, int16_t) |
151 |
8/8✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 3432 times.
✓ Branch 3 taken 858 times.
✓ Branch 4 taken 13728 times.
✓ Branch 5 taken 3432 times.
✓ Branch 6 taken 3432 times.
✓ Branch 7 taken 858 times.
|
24882 | dct4x4_impl(32, int32_t) |
152 | |||
153 |
8/8✓ Branch 0 taken 520 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 4160 times.
✓ Branch 5 taken 520 times.
✓ Branch 6 taken 520 times.
✓ Branch 7 taken 65 times.
|
5785 | dct8x8_impl(16, int16_t) |
154 |
8/8✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 130 times.
✓ Branch 4 taken 8320 times.
✓ Branch 5 taken 1040 times.
✓ Branch 6 taken 1040 times.
✓ Branch 7 taken 130 times.
|
11570 | dct8x8_impl(32, int32_t) |
155 | |||
156 | 1287 | static void dct4x4(int16_t *coef, int bit_depth) | |
157 | { | ||
158 |
2/2✓ Branch 0 taken 429 times.
✓ Branch 1 taken 858 times.
|
1287 | if (bit_depth == 8) |
159 | 429 | dct4x4_16(coef); | |
160 | else | ||
161 | 858 | dct4x4_32((int32_t *) coef); | |
162 | 1287 | } | |
163 | |||
164 | 195 | static void dct8x8(int16_t *coef, int bit_depth) | |
165 | { | ||
166 |
2/2✓ Branch 0 taken 65 times.
✓ Branch 1 taken 130 times.
|
195 | if (bit_depth == 8) { |
167 | 65 | dct8x8_16(coef); | |
168 | } else { | ||
169 | 130 | dct8x8_32((int32_t *) coef); | |
170 | } | ||
171 | 195 | } | |
172 | |||
173 | |||
174 | 13 | static void check_idct(void) | |
175 | { | ||
176 | 13 | LOCAL_ALIGNED_16(uint8_t, src, [8 * 8 * 2]); | |
177 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [8 * 8 * 2]); | |
178 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [8 * 8 * 2]); | |
179 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1_base, [8 * 8 * 2 + 32]); | |
180 | 13 | LOCAL_ALIGNED_16(int16_t, coef, [8 * 8 * 2]); | |
181 | 13 | LOCAL_ALIGNED_16(int16_t, subcoef0, [8 * 8 * 2]); | |
182 | 13 | LOCAL_ALIGNED_16(int16_t, subcoef1, [8 * 8 * 2]); | |
183 | H264DSPContext h; | ||
184 | int bit_depth, sz, align, dc; | ||
185 |
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); |
186 | |||
187 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
188 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
189 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 39 times.
|
117 | for (sz = 4; sz <= 8; sz += 4) { |
190 |
8/8✓ Branch 2 taken 1872 times.
✓ Branch 3 taken 468 times.
✓ Branch 4 taken 1040 times.
✓ Branch 5 taken 2080 times.
✓ Branch 6 taken 3120 times.
✓ Branch 7 taken 468 times.
✓ Branch 8 taken 468 times.
✓ Branch 9 taken 78 times.
|
5538 | randomize_buffers(); |
191 | |||
192 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
|
78 | if (sz == 4) |
193 | 39 | dct4x4(coef, bit_depth); | |
194 | else | ||
195 | 39 | dct8x8(coef, bit_depth); | |
196 | |||
197 |
2/2✓ Branch 0 taken 156 times.
✓ Branch 1 taken 78 times.
|
234 | for (dc = 0; dc <= 1; dc++) { |
198 | 156 | void (*idct)(uint8_t *, int16_t *, int) = NULL; | |
199 |
4/5✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
|
156 | switch ((sz << 1) | dc) { |
200 | 39 | case (4 << 1) | 0: idct = h.h264_idct_add; break; | |
201 | 39 | case (4 << 1) | 1: idct = h.h264_idct_dc_add; break; | |
202 | 39 | case (8 << 1) | 0: idct = h.h264_idct8_add; break; | |
203 | 39 | case (8 << 1) | 1: idct = h.h264_idct8_dc_add; break; | |
204 | } | ||
205 |
4/4✓ Branch 2 taken 78 times.
✓ Branch 3 taken 78 times.
✓ Branch 5 taken 26 times.
✓ Branch 6 taken 130 times.
|
156 | if (check_func(idct, "h264_idct%d_add%s_%dbpp", sz, dc ? "_dc" : "", bit_depth)) { |
206 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 26 times.
|
82 | for (align = 0; align < 16; align += sz * SIZEOF_PIXEL) { |
207 | 56 | uint8_t *dst1 = dst1_base + align; | |
208 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 28 times.
|
56 | if (dc) { |
209 | 28 | memset(subcoef0, 0, sz * sz * SIZEOF_COEF); | |
210 | 28 | memcpy(subcoef0, coef, SIZEOF_COEF); | |
211 | } else { | ||
212 | 28 | memcpy(subcoef0, coef, sz * sz * SIZEOF_COEF); | |
213 | } | ||
214 | 56 | memcpy(dst0, dst, sz * PIXEL_STRIDE); | |
215 | 56 | memcpy(dst1, dst, sz * PIXEL_STRIDE); | |
216 | 56 | memcpy(subcoef1, subcoef0, sz * sz * SIZEOF_COEF); | |
217 | 56 | call_ref(dst0, subcoef0, PIXEL_STRIDE); | |
218 | 56 | call_new(dst1, subcoef1, PIXEL_STRIDE); | |
219 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
56 | if (memcmp(dst0, dst1, sz * PIXEL_STRIDE) || |
220 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
|
56 | memcmp(subcoef0, subcoef1, sz * sz * SIZEOF_COEF)) |
221 | ✗ | fail(); | |
222 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 56 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.
|
56 | bench_new(dst1, subcoef1, sz * SIZEOF_PIXEL); |
223 | } | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | 13 | } | |
229 | |||
230 | 13 | static void check_idct_multiple(void) | |
231 | { | ||
232 | 13 | LOCAL_ALIGNED_16(uint8_t, dst_full, [16 * 16 * 2]); | |
233 | 13 | LOCAL_ALIGNED_16(int16_t, coef_full, [16 * 16 * 2]); | |
234 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [16 * 16 * 2]); | |
235 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [16 * 16 * 2]); | |
236 | 13 | LOCAL_ALIGNED_16(int16_t, coef0, [16 * 16 * 2]); | |
237 | 13 | LOCAL_ALIGNED_16(int16_t, coef1, [16 * 16 * 2]); | |
238 | 13 | LOCAL_ALIGNED_16(uint8_t, nnzc, [15 * 8]); | |
239 | H264DSPContext h; | ||
240 | int bit_depth, i, y, func; | ||
241 |
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]); |
242 | |||
243 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
244 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
245 |
2/2✓ Branch 0 taken 117 times.
✓ Branch 1 taken 39 times.
|
156 | for (func = 0; func < 3; func++) { |
246 | 117 | void (*idct)(uint8_t *, const int *, int16_t *, int, const uint8_t[]) = NULL; | |
247 | const char *name; | ||
248 | 117 | int sz = 4, intra = 0; | |
249 | 117 | int block_offset[16] = { 0 }; | |
250 |
3/4✓ Branch 0 taken 39 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
117 | switch (func) { |
251 | 39 | case 0: | |
252 | 39 | idct = h.h264_idct_add16; | |
253 | 39 | name = "h264_idct_add16"; | |
254 | 39 | break; | |
255 | 39 | case 1: | |
256 | 39 | idct = h.h264_idct_add16intra; | |
257 | 39 | name = "h264_idct_add16intra"; | |
258 | 39 | intra = 1; | |
259 | 39 | break; | |
260 | 39 | case 2: | |
261 | 39 | idct = h.h264_idct8_add4; | |
262 | 39 | name = "h264_idct8_add4"; | |
263 | 39 | sz = 8; | |
264 | 39 | break; | |
265 | } | ||
266 | 117 | memset(nnzc, 0, 15 * 8); | |
267 | 117 | memset(coef_full, 0, 16 * 16 * SIZEOF_COEF); | |
268 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 117 times.
|
1521 | for (i = 0; i < 16 * 16; i += sz * sz) { |
269 | uint8_t src[8 * 8 * 2]; | ||
270 | uint8_t dst[8 * 8 * 2]; | ||
271 | int16_t coef[8 * 8 * 2]; | ||
272 | 1404 | int index = i / sz; | |
273 | 1404 | int block_y = (index / 16) * sz; | |
274 | 1404 | int block_x = index % 16; | |
275 | 1404 | int offset = (block_y * 16 + block_x) * SIZEOF_PIXEL; | |
276 | 1404 | int nnz = rnd() % 3; | |
277 | |||
278 |
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(); |
279 |
2/2✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 156 times.
|
1404 | if (sz == 4) |
280 | 1248 | dct4x4(coef, bit_depth); | |
281 | else | ||
282 | 156 | dct8x8(coef, bit_depth); | |
283 | |||
284 |
2/2✓ Branch 0 taken 6240 times.
✓ Branch 1 taken 1404 times.
|
7644 | for (y = 0; y < sz; y++) |
285 | 6240 | memcpy(&dst_full[offset + y * 16 * SIZEOF_PIXEL], | |
286 | 6240 | &dst[PIXEL_STRIDE * y], sz * SIZEOF_PIXEL); | |
287 | |||
288 |
2/2✓ Branch 0 taken 432 times.
✓ Branch 1 taken 972 times.
|
1404 | if (nnz > 1) |
289 | 432 | nnz = sz * sz; | |
290 | 1404 | memcpy(&coef_full[i * SIZEOF_COEF/sizeof(coef[0])], | |
291 | 1404 | coef, nnz * SIZEOF_COEF); | |
292 | |||
293 |
4/4✓ Branch 0 taken 624 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 199 times.
✓ Branch 3 taken 425 times.
|
1404 | if (intra && nnz == 1) |
294 | 199 | nnz = 0; | |
295 | |||
296 | 1404 | nnzc[scan8[i / 16]] = nnz; | |
297 | 1404 | block_offset[i / 16] = offset; | |
298 | } | ||
299 | |||
300 |
2/2✓ Branch 3 taken 18 times.
✓ Branch 4 taken 99 times.
|
117 | if (check_func(idct, "%s_%dbpp", name, bit_depth)) { |
301 | 18 | memcpy(coef0, coef_full, 16 * 16 * SIZEOF_COEF); | |
302 | 18 | memcpy(coef1, coef_full, 16 * 16 * SIZEOF_COEF); | |
303 | 18 | memcpy(dst0, dst_full, 16 * 16 * SIZEOF_PIXEL); | |
304 | 18 | memcpy(dst1, dst_full, 16 * 16 * SIZEOF_PIXEL); | |
305 | 18 | call_ref(dst0, block_offset, coef0, 16 * SIZEOF_PIXEL, nnzc); | |
306 | 18 | call_new(dst1, block_offset, coef1, 16 * SIZEOF_PIXEL, nnzc); | |
307 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL) || |
308 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | memcmp(coef0, coef1, 16 * 16 * SIZEOF_COEF)) |
309 | ✗ | fail(); | |
310 |
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); |
311 | } | ||
312 | } | ||
313 | } | ||
314 | 13 | } | |
315 | |||
316 | |||
317 | 13 | static void check_loop_filter(void) | |
318 | { | ||
319 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [32 * 16 * 2]); | |
320 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [32 * 16 * 2]); | |
321 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [32 * 16 * 2]); | |
322 | H264DSPContext h; | ||
323 | int bit_depth; | ||
324 | int alphas[36], betas[36]; | ||
325 | int8_t tc0[36][4]; | ||
326 | |||
327 |
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, |
328 | int alpha, int beta, int8_t *tc0); | ||
329 | |||
330 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
331 | int i, j, a, c; | ||
332 | 39 | uint32_t mask = pixel_mask_lf[bit_depth - 8]; | |
333 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
334 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 39 times.
|
1443 | for (i = 35, a = 255, c = 250; i >= 0; i--) { |
335 | 1404 | alphas[i] = a << (bit_depth - 8); | |
336 | 1404 | betas[i] = (i + 1) / 2 << (bit_depth - 8); | |
337 | 1404 | tc0[i][0] = tc0[i][3] = (c + 6) / 10; | |
338 | 1404 | tc0[i][1] = (c + 7) / 15; | |
339 | 1404 | tc0[i][2] = (c + 9) / 20; | |
340 | 1404 | a = a*9/10; | |
341 | 1404 | c = c*9/10; | |
342 | } | ||
343 | |||
344 | #define CHECK_LOOP_FILTER(name, align, idc) \ | ||
345 | do { \ | ||
346 | if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \ | ||
347 | for (j = 0; j < 36; j++) { \ | ||
348 | intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \ | ||
349 | for (i = 0; i < 1024; i+=4) { \ | ||
350 | AV_WN32A(dst + i, rnd() & mask); \ | ||
351 | } \ | ||
352 | memcpy(dst0, dst, 32 * 16 * 2); \ | ||
353 | memcpy(dst1, dst, 32 * 16 * 2); \ | ||
354 | \ | ||
355 | call_ref(dst0 + off, 32, alphas[j], betas[j], tc0[j]); \ | ||
356 | call_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]); \ | ||
357 | if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \ | ||
358 | fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d " \ | ||
359 | "tc0:{%d,%d,%d,%d}\n", j, alphas[j], betas[j], \ | ||
360 | tc0[j][0], tc0[j][1], tc0[j][2], tc0[j][3]); \ | ||
361 | fail(); \ | ||
362 | } \ | ||
363 | bench_new(dst1, 32, alphas[j], betas[j], tc0[j]); \ | ||
364 | } \ | ||
365 | } \ | ||
366 | } while (0) | ||
367 | |||
368 |
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,); |
369 |
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,); |
370 |
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,); |
371 |
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,); |
372 |
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,); |
373 |
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,); |
374 | |||
375 | 39 | ff_h264dsp_init(&h, bit_depth, 2); | |
376 |
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); |
377 |
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); |
378 | #undef CHECK_LOOP_FILTER | ||
379 | } | ||
380 | 13 | } | |
381 | |||
382 | 13 | static void check_loop_filter_intra(void) | |
383 | { | ||
384 | 13 | LOCAL_ALIGNED_16(uint8_t, dst, [32 * 16 * 2]); | |
385 | 13 | LOCAL_ALIGNED_16(uint8_t, dst0, [32 * 16 * 2]); | |
386 | 13 | LOCAL_ALIGNED_16(uint8_t, dst1, [32 * 16 * 2]); | |
387 | H264DSPContext h; | ||
388 | int bit_depth; | ||
389 | int alphas[36], betas[36]; | ||
390 | |||
391 |
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, |
392 | int alpha, int beta); | ||
393 | |||
394 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 13 times.
|
52 | for (bit_depth = 8; bit_depth <= 10; bit_depth++) { |
395 | int i, j, a; | ||
396 | 39 | uint32_t mask = pixel_mask_lf[bit_depth - 8]; | |
397 | 39 | ff_h264dsp_init(&h, bit_depth, 1); | |
398 |
2/2✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 39 times.
|
1443 | for (i = 35, a = 255; i >= 0; i--) { |
399 | 1404 | alphas[i] = a << (bit_depth - 8); | |
400 | 1404 | betas[i] = (i + 1) / 2 << (bit_depth - 8); | |
401 | 1404 | a = a*9/10; | |
402 | } | ||
403 | |||
404 | #define CHECK_LOOP_FILTER(name, align, idc) \ | ||
405 | do { \ | ||
406 | if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \ | ||
407 | for (j = 0; j < 36; j++) { \ | ||
408 | intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \ | ||
409 | for (i = 0; i < 1024; i+=4) { \ | ||
410 | AV_WN32A(dst + i, rnd() & mask); \ | ||
411 | } \ | ||
412 | memcpy(dst0, dst, 32 * 16 * 2); \ | ||
413 | memcpy(dst1, dst, 32 * 16 * 2); \ | ||
414 | \ | ||
415 | call_ref(dst0 + off, 32, alphas[j], betas[j]); \ | ||
416 | call_new(dst1 + off, 32, alphas[j], betas[j]); \ | ||
417 | if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \ | ||
418 | fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d\n", \ | ||
419 | j, alphas[j], betas[j]); \ | ||
420 | fail(); \ | ||
421 | } \ | ||
422 | bench_new(dst1, 32, alphas[j], betas[j]); \ | ||
423 | } \ | ||
424 | } \ | ||
425 | } while (0) | ||
426 | |||
427 |
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,); |
428 |
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,); |
429 |
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,); |
430 |
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,); |
431 |
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,); |
432 |
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,); |
433 | |||
434 | 39 | ff_h264dsp_init(&h, bit_depth, 2); | |
435 |
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); |
436 |
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); |
437 | #undef CHECK_LOOP_FILTER | ||
438 | } | ||
439 | 13 | } | |
440 | |||
441 | 13 | void checkasm_check_h264dsp(void) | |
442 | { | ||
443 | 13 | check_idct(); | |
444 | 13 | check_idct_multiple(); | |
445 | 13 | report("idct"); | |
446 | |||
447 | 13 | check_loop_filter(); | |
448 | 13 | report("loop_filter"); | |
449 | |||
450 | 13 | check_loop_filter_intra(); | |
451 | 13 | report("loop_filter_intra"); | |
452 | 13 | } | |
453 |