FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/vf_threshold_init.h
Date: 2022-12-05 03:11:11
Exec Total Coverage
Lines: 33 33 100.0%
Functions: 3 3 100.0%
Branches: 14 14 100.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2016 Paul B Mahol
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef AVFILTER_THRESHOLD_INIT_H
22 #define AVFILTER_THRESHOLD_INIT_H
23
24 #include <stdint.h>
25 #include <stddef.h>
26
27 #include "config.h"
28 #include "libavutil/attributes.h"
29 #include "threshold.h"
30
31 3 static void threshold8(const uint8_t *in, const uint8_t *threshold,
32 const uint8_t *min, const uint8_t *max,
33 uint8_t *out,
34 ptrdiff_t ilinesize, ptrdiff_t tlinesize,
35 ptrdiff_t flinesize, ptrdiff_t slinesize,
36 ptrdiff_t olinesize,
37 int w, int h)
38 {
39
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for (int y = 0; y < h; y++) {
40
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for (int x = 0; x < w; x++)
41
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 397 times.
768 out[x] = in[x] <= threshold[x] ? min[x] : max[x];
42
43 3 in += ilinesize;
44 3 threshold += tlinesize;
45 3 min += flinesize;
46 3 max += slinesize;
47 3 out += olinesize;
48 }
49 3 }
50
51 3 static void threshold16(const uint8_t *iin, const uint8_t *tthreshold,
52 const uint8_t *ffirst, const uint8_t *ssecond,
53 uint8_t *oout,
54 ptrdiff_t ilinesize, ptrdiff_t tlinesize,
55 ptrdiff_t flinesize, ptrdiff_t slinesize,
56 ptrdiff_t olinesize,
57 int w, int h)
58 {
59 3 const uint16_t *in = (const uint16_t *)iin;
60 3 const uint16_t *threshold = (const uint16_t *)tthreshold;
61 3 const uint16_t *min = (const uint16_t *)ffirst;
62 3 const uint16_t *max = (const uint16_t *)ssecond;
63 3 uint16_t *out = (uint16_t *)oout;
64
65
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for (int y = 0; y < h; y++) {
66
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 3 times.
387 for (int x = 0; x < w; x++)
67
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 199 times.
384 out[x] = in[x] <= threshold[x] ? min[x] : max[x];
68
69 3 in += ilinesize / 2;
70 3 threshold += tlinesize / 2;
71 3 min += flinesize / 2;
72 3 max += slinesize / 2;
73 3 out += olinesize / 2;
74 }
75 3 }
76
77 26 static av_unused void ff_threshold_init(ThresholdContext *s)
78 {
79
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 if (s->depth == 8) {
80 13 s->threshold = threshold8;
81 13 s->bpc = 1;
82 } else {
83 13 s->threshold = threshold16;
84 13 s->bpc = 2;
85 }
86
87 #if ARCH_X86
88 26 ff_threshold_init_x86(s);
89 #endif
90 26 }
91
92 #endif /* AVFILTER_THRESHOLD_INIT_H */
93