FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/ops_tmpl_common.c
Date: 2025-09-09 12:47:06
Exec Total Coverage
Lines: 65 65 100.0%
Functions: 114 154 74.0%
Branches: 64 70 91.4%

Line Branch Exec Source
1 /**
2 * Copyright (C) 2025 Niklas Haas
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 #include "ops_backend.h"
22
23 #ifndef BIT_DEPTH
24 # error Should only be included from ops_tmpl_*.c!
25 #endif
26
27 #define WRAP_CONVERT_UINT(N) \
28 DECL_PATTERN(convert_uint##N) \
29 { \
30 u##N##block_t xu, yu, zu, wu; \
31 \
32 SWS_LOOP \
33 for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \
34 if (X) \
35 xu[i] = x[i]; \
36 if (Y) \
37 yu[i] = y[i]; \
38 if (Z) \
39 zu[i] = z[i]; \
40 if (W) \
41 wu[i] = w[i]; \
42 } \
43 \
44 CONTINUE(u##N##block_t, xu, yu, zu, wu); \
45 } \
46 \
47 WRAP_COMMON_PATTERNS(convert_uint##N, \
48 .op = SWS_OP_CONVERT, \
49 .convert.to = SWS_PIXEL_U##N, \
50 );
51
52 #if BIT_DEPTH != 8
53
9/10
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✓ Branch 3 taken 2304 times.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2304 times.
✓ Branch 7 taken 2304 times.
✓ Branch 8 taken 4608 times.
✓ Branch 9 taken 144 times.
9792 WRAP_CONVERT_UINT(8)
54 #endif
55
56 #if BIT_DEPTH != 16
57
9/10
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✓ Branch 3 taken 2304 times.
✓ Branch 4 taken 2304 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2304 times.
✓ Branch 7 taken 2304 times.
✓ Branch 8 taken 4608 times.
✓ Branch 9 taken 144 times.
9792 WRAP_CONVERT_UINT(16)
58 #endif
59
60 #if BIT_DEPTH != 32 || defined(IS_FLOAT)
61
9/10
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2048 times.
✓ Branch 3 taken 2048 times.
✓ Branch 4 taken 2048 times.
✓ Branch 5 taken 2048 times.
✓ Branch 6 taken 2048 times.
✓ Branch 7 taken 2048 times.
✓ Branch 8 taken 4096 times.
✓ Branch 9 taken 128 times.
8704 WRAP_CONVERT_UINT(32)
62 #endif
63
64 632 DECL_PATTERN(clear)
65 {
66 SWS_LOOP
67
2/2
✓ Branch 0 taken 10112 times.
✓ Branch 1 taken 316 times.
20856 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
68
2/2
✓ Branch 0 taken 4352 times.
✓ Branch 1 taken 5760 times.
20224 if (!X)
69 8704 x[i] = impl->priv.px[0];
70
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 3712 times.
20224 if (!Y)
71 12800 y[i] = impl->priv.px[1];
72
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 3712 times.
20224 if (!Z)
73 12800 z[i] = impl->priv.px[2];
74
2/2
✓ Branch 0 taken 7680 times.
✓ Branch 1 taken 2432 times.
20224 if (!W)
75 15360 w[i] = impl->priv.px[3];
76 }
77
78 632 CONTINUE(block_t, x, y, z, w);
79 632 }
80
81 #define WRAP_CLEAR(X, Y, Z, W) \
82 DECL_IMPL(clear##_##X##Y##Z##W) \
83 { \
84 CALL(clear, X, Y, Z, W); \
85 } \
86 \
87 DECL_ENTRY(clear##_##X##Y##Z##W, \
88 .setup = ff_sws_setup_q4, \
89 .op = SWS_OP_CLEAR, \
90 .flexible = true, \
91 .unused = { !X, !Y, !Z, !W }, \
92 );
93
94 40 WRAP_CLEAR(1, 1, 1, 0) /* rgba alpha */
95 32 WRAP_CLEAR(0, 1, 1, 1) /* argb alpha */
96
97 40 WRAP_CLEAR(0, 0, 1, 1) /* vuya chroma */
98 40 WRAP_CLEAR(1, 0, 0, 1) /* yuva chroma */
99 40 WRAP_CLEAR(1, 1, 0, 0) /* ayuv chroma */
100 40 WRAP_CLEAR(0, 1, 0, 1) /* uyva chroma */
101 40 WRAP_CLEAR(1, 0, 1, 0) /* xvyu chroma */
102
103 200 WRAP_CLEAR(1, 0, 0, 0) /* gray -> yuva */
104 80 WRAP_CLEAR(0, 1, 0, 0) /* gray -> ayuv */
105 80 WRAP_CLEAR(0, 0, 1, 0) /* gray -> vuya */
106
107 288 DECL_PATTERN(min)
108 {
109 SWS_LOOP
110
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 144 times.
9504 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
111
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
9216 if (X)
112 9216 x[i] = FFMIN(x[i], impl->priv.px[0]);
113
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (Y)
114 4608 y[i] = FFMIN(y[i], impl->priv.px[1]);
115
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (Z)
116 4608 z[i] = FFMIN(z[i], impl->priv.px[2]);
117
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (W)
118 4608 w[i] = FFMIN(w[i], impl->priv.px[3]);
119 }
120
121 288 CONTINUE(block_t, x, y, z, w);
122 288 }
123
124 288 DECL_PATTERN(max)
125 {
126 SWS_LOOP
127
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 144 times.
9504 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
128
1/2
✓ Branch 0 taken 4608 times.
✗ Branch 1 not taken.
9216 if (X)
129 9216 x[i] = FFMAX(x[i], impl->priv.px[0]);
130
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (Y)
131 4608 y[i] = FFMAX(y[i], impl->priv.px[1]);
132
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (Z)
133 4608 z[i] = FFMAX(z[i], impl->priv.px[2]);
134
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2304 times.
9216 if (W)
135 4608 w[i] = FFMAX(w[i], impl->priv.px[3]);
136 }
137
138 288 CONTINUE(block_t, x, y, z, w);
139 288 }
140
141 288 WRAP_COMMON_PATTERNS(min,
142 .op = SWS_OP_MIN,
143 .setup = ff_sws_setup_q4,
144 .flexible = true,
145 );
146
147 288 WRAP_COMMON_PATTERNS(max,
148 .op = SWS_OP_MAX,
149 .setup = ff_sws_setup_q4,
150 .flexible = true,
151 );
152
153 96 DECL_PATTERN(scale)
154 {
155 96 const pixel_t scale = impl->priv.px[0];
156
157 SWS_LOOP
158
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 48 times.
3168 for (int i = 0; i < SWS_BLOCK_SIZE; i++) {
159
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
3072 if (X)
160 3072 x[i] *= scale;
161
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 768 times.
3072 if (Y)
162 1536 y[i] *= scale;
163
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 768 times.
3072 if (Z)
164 1536 z[i] *= scale;
165
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 768 times.
3072 if (W)
166 1536 w[i] *= scale;
167 }
168
169 96 CONTINUE(block_t, x, y, z, w);
170 96 }
171
172 96 WRAP_COMMON_PATTERNS(scale,
173 .op = SWS_OP_SCALE,
174 .setup = ff_sws_setup_q,
175 .flexible = true,
176 );
177