../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
21 / 21
100.0%
Branches:
42 / 124
33.9%
Functions:
1 / 1
100.0%

tests/checkasm/pixblockdsp.c
Line Branch Exec Source
1 /*
2 * Copyright (c) 2015 Tiancheng "Timothy" Gu
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/pixblockdsp.h"
24 #include "libavutil/common.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem_internal.h"
28
29 #define BUF_UNITS 8
30 #define BUF_SIZE (BUF_UNITS * 128 + 8 * BUF_UNITS)
31
32 #define randomize_buffers() \
33 do { \
34 int i; \
35 for (i = 0; i < BUF_SIZE; i += 4) { \
36 uint32_t r = rnd(); \
37 AV_WN32A(src10 + i, r); \
38 AV_WN32A(src11 + i, r); \
39 r = rnd(); \
40 AV_WN32A(src20 + i, r); \
41 AV_WN32A(src21 + i, r); \
42 r = rnd(); \
43 AV_WN32A(dst0_ + i, r); \
44 AV_WN32A(dst1_ + i, r); \
45 } \
46 } while (0)
47
48 #define check_get_pixels(type, aligned) \
49 do { \
50 int i; \
51 declare_func(void, int16_t *block, const uint8_t *pixels, ptrdiff_t line_size); \
52 \
53 for (i = 0; i < BUF_UNITS; i++) { \
54 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i; \
55 int dst_offset = i * 64; /* dst must be aligned */ \
56 randomize_buffers(); \
57 call_ref(dst0 + dst_offset, src10 + src_offset, 8); \
58 call_new(dst1 + dst_offset, src11 + src_offset, 8); \
59 if (memcmp(src10, src11, BUF_SIZE)|| memcmp(dst0, dst1, BUF_SIZE)) \
60 fail(); \
61 bench_new(dst1 + dst_offset, src11 + src_offset, 8); \
62 } \
63 } while (0)
64
65 #define check_diff_pixels(type, aligned) \
66 do { \
67 int i; \
68 declare_func(void, int16_t *restrict block, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride); \
69 \
70 for (i = 0; i < BUF_UNITS; i++) { \
71 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i; \
72 int dst_offset = i * 64; /* dst must be aligned */ \
73 randomize_buffers(); \
74 call_ref(dst0 + dst_offset, src10 + src_offset, src20 + src_offset, 8); \
75 call_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
76 if (memcmp(src10, src11, BUF_SIZE) || memcmp(src20, src21, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) \
77 fail(); \
78 bench_new(dst1 + dst_offset, src11 + src_offset, src21 + src_offset, 8); \
79 } \
80 } while (0)
81
82 14 void checkasm_check_pixblockdsp(void)
83 {
84 14 LOCAL_ALIGNED_16(uint8_t, src10, [BUF_SIZE]);
85 14 LOCAL_ALIGNED_16(uint8_t, src11, [BUF_SIZE]);
86 14 LOCAL_ALIGNED_16(uint8_t, src20, [BUF_SIZE]);
87 14 LOCAL_ALIGNED_16(uint8_t, src21, [BUF_SIZE]);
88 14 LOCAL_ALIGNED_16(uint8_t, dst0_, [BUF_SIZE]);
89 14 LOCAL_ALIGNED_16(uint8_t, dst1_, [BUF_SIZE]);
90 14 uint16_t *dst0 = (uint16_t *)dst0_;
91 14 uint16_t *dst1 = (uint16_t *)dst1_;
92 PixblockDSPContext h;
93
94 14 ff_pixblockdsp_init(&h, 8);
95
96
2/2
✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 88 taken 12 times.
14 if (check_func(h.get_pixels, "get_pixels"))
97
8/28
✓ Branch 11 → 7 taken 4352 times.
✓ Branch 11 → 12 taken 16 times.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 16 times.
✓ Branch 20 → 21 taken 16 times.
✗ Branch 20 → 22 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 16 times.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 83 taken 16 times.
✗ Branch 27 → 28 not taken.
✗ Branch 27 → 70 not taken.
✗ Branch 63 → 64 not taken.
✗ Branch 63 → 67 not taken.
✗ Branch 64 → 65 not taken.
✗ Branch 64 → 66 not taken.
✗ Branch 65 → 66 not taken.
✗ Branch 65 → 67 not taken.
✗ Branch 68 → 29 not taken.
✗ Branch 68 → 69 not taken.
✗ Branch 74 → 72 not taken.
✗ Branch 74 → 75 not taken.
✗ Branch 76 → 77 not taken.
✗ Branch 76 → 78 not taken.
✗ Branch 80 → 26 not taken.
✗ Branch 80 → 81 not taken.
✓ Branch 87 → 6 taken 16 times.
✓ Branch 87 → 88 taken 2 times.
4370 check_get_pixels(uint8_t, 1);
98
2/2
✓ Branch 89 → 90 taken 2 times.
✓ Branch 89 → 173 taken 12 times.
14 if (check_func(h.get_pixels_unaligned, "get_pixels_unaligned"))
99
8/28
✓ Branch 96 → 92 taken 4352 times.
✓ Branch 96 → 97 taken 16 times.
✗ Branch 99 → 100 not taken.
✓ Branch 99 → 101 taken 16 times.
✓ Branch 105 → 106 taken 16 times.
✗ Branch 105 → 107 not taken.
✗ Branch 106 → 107 not taken.
✓ Branch 106 → 108 taken 16 times.
✗ Branch 109 → 110 not taken.
✓ Branch 109 → 168 taken 16 times.
✗ Branch 112 → 113 not taken.
✗ Branch 112 → 155 not taken.
✗ Branch 148 → 149 not taken.
✗ Branch 148 → 152 not taken.
✗ Branch 149 → 150 not taken.
✗ Branch 149 → 151 not taken.
✗ Branch 150 → 151 not taken.
✗ Branch 150 → 152 not taken.
✗ Branch 153 → 114 not taken.
✗ Branch 153 → 154 not taken.
✗ Branch 159 → 157 not taken.
✗ Branch 159 → 160 not taken.
✗ Branch 161 → 162 not taken.
✗ Branch 161 → 163 not taken.
✗ Branch 165 → 111 not taken.
✗ Branch 165 → 166 not taken.
✓ Branch 172 → 91 taken 16 times.
✓ Branch 172 → 173 taken 2 times.
4370 check_get_pixels(uint8_t, 0);
100
101 14 report("get_pixels");
102
103
2/2
✓ Branch 175 → 176 taken 2 times.
✓ Branch 175 → 260 taken 12 times.
14 if (check_func(h.diff_pixels, "diff_pixels"))
104
9/30
✓ Branch 182 → 178 taken 4352 times.
✓ Branch 182 → 183 taken 16 times.
✗ Branch 185 → 186 not taken.
✓ Branch 185 → 187 taken 16 times.
✓ Branch 191 → 192 taken 16 times.
✗ Branch 191 → 194 not taken.
✓ Branch 192 → 193 taken 16 times.
✗ Branch 192 → 194 not taken.
✗ Branch 193 → 194 not taken.
✓ Branch 193 → 195 taken 16 times.
✗ Branch 196 → 197 not taken.
✓ Branch 196 → 255 taken 16 times.
✗ Branch 199 → 200 not taken.
✗ Branch 199 → 242 not taken.
✗ Branch 235 → 236 not taken.
✗ Branch 235 → 239 not taken.
✗ Branch 236 → 237 not taken.
✗ Branch 236 → 238 not taken.
✗ Branch 237 → 238 not taken.
✗ Branch 237 → 239 not taken.
✗ Branch 240 → 201 not taken.
✗ Branch 240 → 241 not taken.
✗ Branch 246 → 244 not taken.
✗ Branch 246 → 247 not taken.
✗ Branch 248 → 249 not taken.
✗ Branch 248 → 250 not taken.
✗ Branch 252 → 198 not taken.
✗ Branch 252 → 253 not taken.
✓ Branch 259 → 177 taken 16 times.
✓ Branch 259 → 260 taken 2 times.
4370 check_diff_pixels(uint8_t, 1);
105
2/2
✓ Branch 261 → 262 taken 2 times.
✓ Branch 261 → 346 taken 12 times.
14 if (check_func(h.diff_pixels_unaligned, "diff_pixels_unaligned"))
106
9/30
✓ Branch 268 → 264 taken 4352 times.
✓ Branch 268 → 269 taken 16 times.
✗ Branch 271 → 272 not taken.
✓ Branch 271 → 273 taken 16 times.
✓ Branch 277 → 278 taken 16 times.
✗ Branch 277 → 280 not taken.
✓ Branch 278 → 279 taken 16 times.
✗ Branch 278 → 280 not taken.
✗ Branch 279 → 280 not taken.
✓ Branch 279 → 281 taken 16 times.
✗ Branch 282 → 283 not taken.
✓ Branch 282 → 341 taken 16 times.
✗ Branch 285 → 286 not taken.
✗ Branch 285 → 328 not taken.
✗ Branch 321 → 322 not taken.
✗ Branch 321 → 325 not taken.
✗ Branch 322 → 323 not taken.
✗ Branch 322 → 324 not taken.
✗ Branch 323 → 324 not taken.
✗ Branch 323 → 325 not taken.
✗ Branch 326 → 287 not taken.
✗ Branch 326 → 327 not taken.
✗ Branch 332 → 330 not taken.
✗ Branch 332 → 333 not taken.
✗ Branch 334 → 335 not taken.
✗ Branch 334 → 336 not taken.
✗ Branch 338 → 284 not taken.
✗ Branch 338 → 339 not taken.
✓ Branch 345 → 263 taken 16 times.
✓ Branch 345 → 346 taken 2 times.
4370 check_diff_pixels(uint8_t, 0);
107
108 14 report("diff_pixels");
109 14 }
110