Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * This file is part of FFmpeg. | ||
3 | * | ||
4 | * FFmpeg is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * FFmpeg is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | */ | ||
18 | |||
19 | #include <string.h> | ||
20 | #include "checkasm.h" | ||
21 | |||
22 | #include "libavfilter/vf_blackdetect.h" | ||
23 | #include "libavutil/mem_internal.h" | ||
24 | |||
25 | #define WIDTH 256 | ||
26 | #define HEIGHT 16 | ||
27 | #define STRIDE (WIDTH + 32) | ||
28 | |||
29 | 26 | static void check_blackdetect(int depth) | |
30 | { | ||
31 | 26 | LOCAL_ALIGNED_32(uint8_t, in, [HEIGHT * STRIDE]); | |
32 | |||
33 | 26 | declare_func(unsigned, const uint8_t *in, ptrdiff_t stride, | |
34 | ptrdiff_t width, ptrdiff_t height, | ||
35 | unsigned threshold); | ||
36 | |||
37 | 26 | memset(in, 0, HEIGHT * STRIDE); | |
38 |
2/2✓ Branch 0 taken 416 times.
✓ Branch 1 taken 26 times.
|
442 | for (int y = 0; y < HEIGHT; y++) { |
39 |
2/2✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 416 times.
|
106912 | for (int x = 0; x < WIDTH; x++) |
40 | 106496 | in[y * STRIDE + x] = rnd() & 0xFF; | |
41 | } | ||
42 | |||
43 | 26 | const unsigned threshold = 16 << (depth - 8); | |
44 | |||
45 | 26 | int w = WIDTH; | |
46 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
|
26 | if (depth == 16) |
47 | 13 | w /= 2; | |
48 | |||
49 |
2/2✓ Branch 4 taken 4 times.
✓ Branch 5 taken 22 times.
|
26 | if (check_func(ff_blackdetect_get_fn(depth), "blackdetect%d", depth)) { |
50 | /* Ensure odd tail is handled correctly */ | ||
51 | 4 | unsigned count_ref = call_ref(in, STRIDE, w - 8, HEIGHT, threshold); | |
52 | 4 | unsigned count_new = call_new(in, STRIDE, w - 8, HEIGHT, threshold); | |
53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (count_ref != count_new) { |
54 | ✗ | fprintf(stderr, "blackdetect%d: count mismatch: %u != %u\n", | |
55 | depth, count_ref, count_new); | ||
56 | ✗ | fail(); | |
57 | } | ||
58 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
4 | bench_new(in, STRIDE, w, HEIGHT, 16); |
59 | } | ||
60 | 26 | } | |
61 | |||
62 | 13 | void checkasm_check_blackdetect(void) | |
63 | { | ||
64 | 13 | check_blackdetect(8); | |
65 | 13 | report("blackdetect8"); | |
66 | |||
67 | 13 | check_blackdetect(16); | |
68 | 13 | report("blackdetect16"); | |
69 | 13 | } | |
70 |