Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * This file is part of FFmpeg. | ||
3 | * | ||
4 | * FFmpeg is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (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 GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with FFmpeg; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #ifndef AVFILTER_BLACKDETECT_H | ||
20 | #define AVFILTER_BLACKDETECT_H | ||
21 | |||
22 | #include <stddef.h> | ||
23 | #include <stdint.h> | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | typedef unsigned (*ff_blackdetect_fn)(const uint8_t *src, ptrdiff_t stride, | ||
28 | ptrdiff_t width, ptrdiff_t height, | ||
29 | unsigned threshold); | ||
30 | |||
31 | ff_blackdetect_fn ff_blackdetect_get_fn_x86(int depth); | ||
32 | |||
33 | 3 | static unsigned count_pixels8_c(const uint8_t *src, ptrdiff_t stride, | |
34 | ptrdiff_t width, ptrdiff_t height, | ||
35 | unsigned threshold) | ||
36 | { | ||
37 | 3 | unsigned int counter = 0; | |
38 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
|
51 | while (height--) { |
39 |
2/2✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 48 times.
|
11952 | for (int x = 0; x < width; x++) |
40 | 11904 | counter += src[x] <= threshold; | |
41 | 48 | src += stride; | |
42 | } | ||
43 | 3 | return counter; | |
44 | } | ||
45 | |||
46 | 3 | static unsigned count_pixels16_c(const uint8_t *src, ptrdiff_t stride, | |
47 | ptrdiff_t width, ptrdiff_t height, | ||
48 | unsigned threshold) | ||
49 | { | ||
50 | 3 | unsigned int counter = 0; | |
51 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
|
51 | while (height--) { |
52 | 48 | const uint16_t *src16 = (const uint16_t *) src; | |
53 |
2/2✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 48 times.
|
5808 | for (int x = 0; x < width; x++) |
54 | 5760 | counter += src16[x] <= threshold; | |
55 | 48 | src += stride; | |
56 | } | ||
57 | 3 | return counter; | |
58 | } | ||
59 | |||
60 | |||
61 | 26 | static inline ff_blackdetect_fn ff_blackdetect_get_fn(int depth) | |
62 | { | ||
63 | 26 | ff_blackdetect_fn fn = NULL; | |
64 | #if ARCH_X86 | ||
65 | 26 | fn = ff_blackdetect_get_fn_x86(depth); | |
66 | #endif | ||
67 | |||
68 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2 times.
|
26 | if (!fn) |
69 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
|
24 | fn = depth == 8 ? count_pixels8_c : count_pixels16_c; |
70 | 26 | return fn; | |
71 | } | ||
72 | |||
73 | #endif /* AVFILTER_BLACKDETECT_H */ | ||
74 |