FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswscale/ops.c
Date: 2026-10-30 17:37:53
Exec Total Coverage
Lines: 646 713 90.6%
Functions: 37 38 97.4%
Branches: 474 586 80.9%

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 "libavutil/attributes.h"
22 #include "libavutil/avassert.h"
23 #include "libavutil/avstring.h"
24 #include "libavutil/bprint.h"
25 #include "libavutil/bswap.h"
26 #include "libavutil/mem.h"
27 #include "libavutil/rational.h"
28 #include "libavutil/refstruct.h"
29
30 #include "format.h"
31 #include "ops.h"
32 #include "ops_internal.h"
33
34 extern const SwsOpBackend backend_c;
35 extern const SwsOpBackend backend_murder;
36 extern const SwsOpBackend backend_aarch64;
37 extern const SwsOpBackend backend_x86;
38 #if CONFIG_SWSCALE_VULKAN
39 extern const SwsOpBackend backend_spirv;
40 #endif
41
42 const SwsOpBackend * const ff_sws_op_backends[] = {
43 &backend_murder,
44 #if ARCH_AARCH64 && HAVE_NEON
45 &backend_aarch64,
46 #elif ARCH_X86_64 && HAVE_X86ASM
47 &backend_x86,
48 #endif
49 &backend_c,
50 #if CONFIG_SWSCALE_VULKAN
51 &backend_spirv,
52 #endif
53 NULL
54 };
55
56 2544873 const char *ff_sws_pixel_type_name(SwsPixelType type)
57 {
58
4/7
✓ Branch 0 taken 345553 times.
✓ Branch 1 taken 877385 times.
✓ Branch 2 taken 165063 times.
✓ Branch 3 taken 1156872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
2544873 switch (type) {
59 345553 case SWS_PIXEL_U8: return "u8";
60 877385 case SWS_PIXEL_U16: return "u16";
61 165063 case SWS_PIXEL_U32: return "u32";
62 1156872 case SWS_PIXEL_F32: return "f32";
63 ✗ case SWS_PIXEL_NONE: return "none";
64 ✗ case SWS_PIXEL_TYPE_NB: break;
65 }
66
67 ✗ av_unreachable("Invalid pixel type!");
68 return "ERR";
69 }
70
71 661663 const char *ff_sws_op_type_name(SwsOpType op)
72 {
73
15/21
✓ Branch 0 taken 127656 times.
✓ Branch 1 taken 136078 times.
✓ Branch 2 taken 53796 times.
✓ Branch 3 taken 37881 times.
✓ Branch 4 taken 13694 times.
✓ Branch 5 taken 13798 times.
✓ Branch 6 taken 5726 times.
✓ Branch 7 taken 5280 times.
✓ Branch 8 taken 24172 times.
✓ Branch 9 taken 84098 times.
✓ Branch 10 taken 38172 times.
✓ Branch 11 taken 18652 times.
✓ Branch 12 taken 22024 times.
✓ Branch 13 taken 43320 times.
✓ Branch 14 taken 37316 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
661663 switch (op) {
74 127656 case SWS_OP_READ: return "SWS_OP_READ";
75 136078 case SWS_OP_WRITE: return "SWS_OP_WRITE";
76 53796 case SWS_OP_SWAP_BYTES: return "SWS_OP_SWAP_BYTES";
77 37881 case SWS_OP_SWIZZLE: return "SWS_OP_SWIZZLE";
78 13694 case SWS_OP_UNPACK: return "SWS_OP_UNPACK";
79 13798 case SWS_OP_PACK: return "SWS_OP_PACK";
80 5726 case SWS_OP_LSHIFT: return "SWS_OP_LSHIFT";
81 5280 case SWS_OP_RSHIFT: return "SWS_OP_RSHIFT";
82 24172 case SWS_OP_CLEAR: return "SWS_OP_CLEAR";
83 84098 case SWS_OP_CONVERT: return "SWS_OP_CONVERT";
84 38172 case SWS_OP_MIN: return "SWS_OP_MIN";
85 18652 case SWS_OP_MAX: return "SWS_OP_MAX";
86 22024 case SWS_OP_SCALE: return "SWS_OP_SCALE";
87 43320 case SWS_OP_LINEAR: return "SWS_OP_LINEAR";
88 37316 case SWS_OP_DITHER: return "SWS_OP_DITHER";
89 ✗ case SWS_OP_FILTER_H: return "SWS_OP_FILTER_H";
90 ✗ case SWS_OP_FILTER_V: return "SWS_OP_FILTER_V";
91 ✗ case SWS_OP_LUT_3D: return "SWS_OP_LUT_3D";
92 ✗ case SWS_OP_INVALID: return "SWS_OP_INVALID";
93 ✗ case SWS_OP_TYPE_NB: break;
94 }
95
96 ✗ av_unreachable("Invalid operation type!");
97 return "ERR";
98 }
99
100 1560042 SwsCompMask ff_sws_comp_mask_q4(const AVRational64 q[4])
101 {
102 1560042 SwsCompMask mask = 0;
103
2/2
✓ Branch 0 taken 6240168 times.
✓ Branch 1 taken 1560042 times.
7800210 for (int i = 0; i < 4; i++) {
104
2/2
✓ Branch 0 taken 4610585 times.
✓ Branch 1 taken 1629583 times.
6240168 if (q[i].den)
105 4610585 mask |= SWS_COMP(i);
106 }
107 1560042 return mask;
108 }
109
110 322867 void ff_sws_comp_mask_swizzle(SwsCompMask *mask, const SwsSwizzleOp *swiz)
111 {
112 322867 const SwsCompMask orig = *mask;
113 322867 SwsCompMask res = 0;
114
2/2
✓ Branch 0 taken 1291468 times.
✓ Branch 1 taken 322867 times.
1614335 for (int i = 0; i < 4; i++) {
115 1291468 const int src = swiz->in[i];
116
2/2
✓ Branch 0 taken 501665 times.
✓ Branch 1 taken 789803 times.
1291468 if (SWS_COMP_TEST(orig, src))
117 501665 res |= SWS_COMP(i);
118 }
119
120 322867 *mask = res;
121 322867 }
122
123 128414580 SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
124 {
125 128414580 SwsCompMask mask = 0;
126
2/2
✓ Branch 0 taken 513658320 times.
✓ Branch 1 taken 128414580 times.
642072900 for (int i = 0; i < 4; i++) {
127
2/2
✓ Branch 0 taken 340347308 times.
✓ Branch 1 taken 173311012 times.
513658320 if (SWS_OP_NEEDED(op, i))
128 340347308 mask |= SWS_COMP(i);
129 }
130 128414580 return mask;
131 }
132
133 7382326 int ff_sws_rw_op_planes(const SwsOp *op)
134 {
135 av_assert2(op->op == SWS_OP_READ || op->op == SWS_OP_WRITE);
136
3/4
✓ Branch 0 taken 5281453 times.
✓ Branch 1 taken 2085165 times.
✓ Branch 2 taken 15708 times.
✗ Branch 3 not taken.
7382326 switch (op->rw.mode) {
137 5281453 case SWS_RW_PLANAR: return op->rw.elems;
138 2085165 case SWS_RW_PACKED: return 1;
139 15708 case SWS_RW_PALETTE: return 2;
140 }
141
142 ✗ av_unreachable("Invalid read/write mode!");
143 return 0;
144 }
145
146 333995774 static inline int op_index(const SwsOp *op)
147 {
148 333995774 SwsOpList *ops = op->ops;
149 av_assert1(op >= ops->ops && op < ops->ops + ops->num_ops);
150 333995774 return op - ops->ops;
151 }
152
153 333995774 const SwsOp *ff_sws_op_prev(const SwsOp *op)
154 {
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333995774 times.
333995774 if (!op)
156 ✗ return NULL;
157 333995774 SwsOpList *ops = op->ops;
158 333995774 const int idx = op_index(op);
159
2/2
✓ Branch 0 taken 306576485 times.
✓ Branch 1 taken 27419289 times.
333995774 return idx > 0 ? &ops->ops[idx - 1] : NULL;
160 }
161
162 ✗ const SwsOp *ff_sws_op_next(const SwsOp *op)
163 {
164 ✗ if (!op)
165 ✗ return NULL;
166 ✗ SwsOpList *ops = op->ops;
167 ✗ const int idx = op_index(op);
168 ✗ return idx < ops->num_ops - 1 ? &ops->ops[idx + 1] : NULL;
169 }
170
171 27178041 SwsPixelType ff_sws_op_output_type(const SwsOp *op)
172 {
173 27178041 SwsPixelType type = SWS_PIXEL_NONE;
174
4/4
✓ Branch 0 taken 135239870 times.
✓ Branch 1 taken 130067 times.
✓ Branch 2 taken 108191896 times.
✓ Branch 3 taken 27047974 times.
135369937 for (int i = 0; op && i < 4; i++) {
175
3/4
✓ Branch 0 taken 77651313 times.
✓ Branch 1 taken 30540583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77651313 times.
108191896 if (!SWS_OP_NEEDED(op, i) || !op->outputs[i].type)
176 30540583 continue;
177
2/2
✓ Branch 0 taken 27033358 times.
✓ Branch 1 taken 50617955 times.
77651313 else if (!type)
178 27033358 type = op->outputs[i].type;
179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50617955 times.
50617955 else if (op->outputs[i].type != type)
180 ✗ return SWS_PIXEL_NONE;
181 }
182
183 27178041 return type;
184 }
185
186 27178041 SwsPixelType ff_sws_op_input_type(const SwsOp *op)
187 {
188 27178041 return ff_sws_op_output_type(ff_sws_op_prev(op));
189 }
190
191 /* biased towards `a` */
192 185733252 static AVRational64 av_min_q64(AVRational64 a, AVRational64 b)
193 {
194
2/2
✓ Branch 1 taken 42060208 times.
✓ Branch 2 taken 143673044 times.
185733252 return ff_cmp_q64(a, b) == 1 ? b : a;
195 }
196
197 153005092 static AVRational64 av_max_q64(AVRational64 a, AVRational64 b)
198 {
199
2/2
✓ Branch 1 taken 21650104 times.
✓ Branch 2 taken 131354988 times.
153005092 return ff_cmp_q64(a, b) == -1 ? b : a;
200 }
201
202 438014288 void ff_sws_apply_op_q(const SwsOp *op, AVRational64 x[4])
203 {
204 uint64_t mask[4];
205 int shift[4];
206
207
13/17
✓ Branch 0 taken 106765990 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8908644 times.
✓ Branch 3 taken 83302 times.
✓ Branch 4 taken 29162738 times.
✓ Branch 5 taken 3814963 times.
✓ Branch 6 taken 3384342 times.
✓ Branch 7 taken 69880271 times.
✓ Branch 8 taken 74756121 times.
✓ Branch 9 taken 164705 times.
✓ Branch 10 taken 46433313 times.
✓ Branch 11 taken 38251273 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12728204 times.
✓ Branch 14 taken 43680422 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
438014288 switch (op->op) {
208 106765990 case SWS_OP_READ:
209 case SWS_OP_WRITE:
210 106765990 return;
211 ✗ case SWS_OP_UNPACK: {
212 ✗ ff_sws_pack_decode(op->pack.pattern, mask, shift);
213 ✗ unsigned val = x[0].num;
214 ✗ for (int i = 0; i < 4; i++)
215 ✗ x[i] = Q((val >> shift[i]) & mask[i]);
216 ✗ return;
217 }
218 8908644 case SWS_OP_PACK: {
219 8908644 ff_sws_pack_decode(op->pack.pattern, mask, shift);
220 8908644 unsigned val = 0;
221
2/2
✓ Branch 0 taken 35634576 times.
✓ Branch 1 taken 8908644 times.
44543220 for (int i = 0; i < 4; i++)
222 35634576 val |= (x[i].num & mask[i]) << shift[i];
223 8908644 x[0] = Q(val);
224 8908644 return;
225 }
226 83302 case SWS_OP_SWAP_BYTES:
227
1/3
✓ Branch 1 taken 83302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83302 switch (ff_sws_op_input_type(op)) {
228 83302 case SWS_PIXEL_U16:
229
2/2
✓ Branch 0 taken 333208 times.
✓ Branch 1 taken 83302 times.
416510 for (int i = 0; i < 4; i++) {
230 av_assert2(x[i].num >= 0 && x[i].num <= UINT16_MAX);
231 333208 x[i].num = av_bswap16(x[i].num);
232 }
233 83302 return;
234 ✗ case SWS_PIXEL_U32:
235 ✗ for (int i = 0; i < 4; i++) {
236 av_assert2(x[i].num >= 0 && x[i].num <= UINT32_MAX);
237 ✗ x[i].num = av_bswap32(x[i].num);
238 }
239 ✗ return;
240 }
241 ✗ av_unreachable("Invalid pixel type for SWS_OP_SWAP_BYTES!");
242 return;
243 29162738 case SWS_OP_CLEAR:
244
2/2
✓ Branch 0 taken 116650952 times.
✓ Branch 1 taken 29162738 times.
145813690 for (int i = 0; i < 4; i++) {
245
2/2
✓ Branch 0 taken 34435168 times.
✓ Branch 1 taken 82215784 times.
116650952 if (SWS_COMP_TEST(op->clear.mask, i))
246 34435168 x[i] = op->clear.value[i];
247 }
248 29162738 return;
249 3814963 case SWS_OP_LSHIFT: {
250 3814963 AVRational64 mult = Q(1 << op->shift.amount);
251
2/2
✓ Branch 0 taken 15259852 times.
✓ Branch 1 taken 3814963 times.
19074815 for (int i = 0; i < 4; i++)
252
2/2
✓ Branch 0 taken 12295793 times.
✓ Branch 1 taken 2964059 times.
15259852 x[i] = x[i].den ? ff_mul_q64(x[i], mult) : x[i];
253 3814963 return;
254 }
255 3384342 case SWS_OP_RSHIFT: {
256
2/2
✓ Branch 0 taken 13537368 times.
✓ Branch 1 taken 3384342 times.
16921710 for (int i = 0; i < 4; i++)
257
2/2
✓ Branch 0 taken 9860954 times.
✓ Branch 1 taken 3676414 times.
13537368 x[i] = x[i].den ? Q((x[i].num / x[i].den) >> op->shift.amount) : x[i];
258 3384342 return;
259 }
260 69880271 case SWS_OP_SWIZZLE: {
261 69880271 const AVRational64 orig[4] = { x[0], x[1], x[2], x[3] };
262
2/2
✓ Branch 0 taken 279521084 times.
✓ Branch 1 taken 69880271 times.
349401355 for (int i = 0; i < 4; i++)
263 279521084 x[i] = orig[op->swizzle.in[i]];
264 69880271 return;
265 }
266 74756121 case SWS_OP_CONVERT:
267
2/2
✓ Branch 0 taken 58616777 times.
✓ Branch 1 taken 16139344 times.
74756121 if (ff_sws_pixel_type_is_int(op->convert.to)) {
268
2/2
✓ Branch 0 taken 234467108 times.
✓ Branch 1 taken 58616777 times.
293083885 for (int i = 0; i < 4; i++)
269
2/2
✓ Branch 0 taken 196521591 times.
✓ Branch 1 taken 37945517 times.
234467108 x[i] = x[i].den ? Q(x[i].num / x[i].den) : x[i];
270 }
271 74756121 return;
272 164705 case SWS_OP_DITHER:
273
2/2
✓ Branch 0 taken 658820 times.
✓ Branch 1 taken 164705 times.
823525 for (int i = 0; i < 4; i++) {
274
3/4
✓ Branch 0 taken 419590 times.
✓ Branch 1 taken 239230 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419590 times.
658820 if (op->dither.y_offset[i] >= 0 && x[i].den)
275 ✗ x[i] = ff_add_q64(x[i], ff_make_q64(1, 2));
276 }
277 164705 return;
278 46433313 case SWS_OP_MIN:
279
2/2
✓ Branch 0 taken 185733252 times.
✓ Branch 1 taken 46433313 times.
232166565 for (int i = 0; i < 4; i++)
280 185733252 x[i] = av_min_q64(x[i], op->clamp.limit[i]);
281 46433313 return;
282 38251273 case SWS_OP_MAX:
283
2/2
✓ Branch 0 taken 153005092 times.
✓ Branch 1 taken 38251273 times.
191256365 for (int i = 0; i < 4; i++)
284 153005092 x[i] = av_max_q64(x[i], op->clamp.limit[i]);
285 38251273 return;
286 ✗ case SWS_OP_LINEAR: {
287 ✗ const AVRational64 orig[4] = { x[0], x[1], x[2], x[3] };
288 ✗ for (int i = 0; i < 4; i++) {
289 ✗ AVRational64 sum = op->lin.m[i][4];
290 ✗ for (int j = 0; j < 4; j++)
291 ✗ sum = ff_add_q64(sum, ff_mul_q64(orig[j], op->lin.m[i][j]));
292 ✗ x[i] = sum;
293 }
294 ✗ return;
295 }
296 12728204 case SWS_OP_SCALE:
297
2/2
✓ Branch 0 taken 50912816 times.
✓ Branch 1 taken 12728204 times.
63641020 for (int i = 0; i < 4; i++)
298
2/2
✓ Branch 0 taken 33646008 times.
✓ Branch 1 taken 17266808 times.
50912816 x[i] = x[i].den ? ff_mul_q64(x[i], op->scale.factor) : x[i];
299 12728204 return;
300 43680422 case SWS_OP_FILTER_H:
301 case SWS_OP_FILTER_V:
302 /* Filters have normalized energy by definition, so they don't
303 * conceptually modify individual components */
304 43680422 return;
305 ✗ case SWS_OP_LUT_3D:
306 /* 3D LUTs are treated as a black box, so set those values to NaN */
307 ✗ for (int i = 0; i < 3; i++)
308 ✗ x[i] = (AVRational64) {0};
309 ✗ return;
310 }
311
312 ✗ av_unreachable("Invalid operation type!");
313 }
314
315 enum {
316 SWS_COMP_IDENTITY = SWS_COMP_ZERO | SWS_COMP_EXACT |
317 SWS_COMP_COPY | SWS_COMP_CONST,
318
319 SWS_COMP_DIRTY = ~(SWS_COMP_COPY | SWS_COMP_CONST),
320 };
321
322 /* merge_comp_flags() forms a monoid with SWS_COMP_IDENTITY as the null element */
323 1232808605 static SwsCompFlags merge_comp_flags(SwsCompFlags a, SwsCompFlags b)
324 {
325 1232808605 const SwsCompFlags flags_or = SWS_COMP_SWAPPED;
326 1232808605 const SwsCompFlags flags_and = SWS_COMP_IDENTITY;
327 1232808605 return ((a & b) & flags_and) | ((a | b) & flags_or);
328 }
329
330 101045097 static void apply_filter_weights(SwsOpPad *pad, const SwsFilterWeights *weights)
331 {
332 101045097 const AVRational64 posw = { weights->sum_positive, SWS_FILTER_SCALE };
333 101045097 const AVRational64 negw = { weights->sum_negative, SWS_FILTER_SCALE };
334
335 /* Only point sampling preserves exactness */
336
2/2
✓ Branch 0 taken 98749315 times.
✓ Branch 1 taken 2295782 times.
101045097 if (weights->filter_size != 1)
337 98749315 pad->flags &= ~SWS_COMP_EXACT;
338
339 /* Update min/max assuming extremes */
340 101045097 const AVRational64 min = pad->min, max = pad->max;
341 101045097 pad->min = ff_add_q64(ff_mul_q64(min, posw), ff_mul_q64(max, negw));
342 101045097 pad->max = ff_add_q64(ff_mul_q64(min, negw), ff_mul_q64(max, posw));
343 101045097 }
344
345 303627245 static void update_output_pads(SwsOpList *ops, SwsOp *op)
346 {
347 static const SwsOpPad dummy[4] = {0};
348 303627245 const SwsOp *prev = ff_sws_op_prev(op);
349
2/2
✓ Branch 0 taken 276338023 times.
✓ Branch 1 taken 27289222 times.
303627245 const SwsOpPad *in = prev ? prev->outputs : dummy;
350 303627245 SwsOpPad *out = op->outputs;
351 303627245 SwsCompMask invalid = 0;
352
2/2
✓ Branch 0 taken 1214508980 times.
✓ Branch 1 taken 303627245 times.
1518136225 for (int i = 0; i < 4; i++) {
353 1214508980 out[i].type = SWS_PIXEL_NONE;
354 1214508980 out[i].flags = SWS_COMP_IDENTITY;
355 1214508980 out[i].dep_in = SWS_COMP_NONE;
356 }
357
358
2/2
✓ Branch 0 taken 85183453 times.
✓ Branch 1 taken 218443792 times.
303627245 switch (op->op) {
359 85183453 case SWS_OP_LINEAR:
360 case SWS_OP_DITHER:
361 case SWS_OP_SWAP_BYTES:
362 case SWS_OP_UNPACK:
363 case SWS_OP_LUT_3D:
364 85183453 break; /* special cases, handled below */
365 218443792 default: {
366 AVRational64 min[4], max[4];
367
2/2
✓ Branch 0 taken 873775168 times.
✓ Branch 1 taken 218443792 times.
1092218960 for (int i = 0; i < 4; i++) {
368 873775168 min[i] = in[i].min;
369 873775168 max[i] = in[i].max;
370 }
371
372 218443792 ff_sws_apply_op_q(op, min);
373 218443792 ff_sws_apply_op_q(op, max);
374
2/2
✓ Branch 0 taken 873775168 times.
✓ Branch 1 taken 218443792 times.
1092218960 for (int i = 0; i < 4; i++) {
375 873775168 out[i].min = min[i];
376 873775168 out[i].max = max[i];
377 }
378 218443792 break;
379 }
380 }
381
382 #define FORWARD(I, J, EXPR) do { \
383 SwsOpPad *dst = &out[I]; \
384 const SwsOpPad *src = &in[J]; \
385 SwsCompFlags flags = src->flags; \
386 if (!src->type || dst->type && dst->type != src->type) \
387 invalid |= SWS_COMP(I); \
388 dst->flags = merge_comp_flags(dst->flags, (EXPR)); \
389 dst->dep_in |= src->dep_in; \
390 dst->type = src->type; \
391 } while (0)
392
393 #define RESET(I) do { \
394 SwsOpPad *dst = &out[I]; \
395 dst->type = SWS_PIXEL_NONE; \
396 dst->flags = 0; \
397 dst->min = dst->max = (AVRational64) {0}; \
398 dst->dep_in = SWS_COMP_NONE; \
399 } while (0)
400
401
15/16
✓ Branch 0 taken 26093773 times.
✓ Branch 1 taken 18268990 times.
✓ Branch 2 taken 27289222 times.
✓ Branch 3 taken 3596567 times.
✓ Branch 4 taken 42205743 times.
✓ Branch 5 taken 15912958 times.
✓ Branch 6 taken 4389926 times.
✓ Branch 7 taken 4454322 times.
✓ Branch 8 taken 14581369 times.
✓ Branch 9 taken 34778702 times.
✓ Branch 10 taken 37239781 times.
✓ Branch 11 taken 40729607 times.
✓ Branch 12 taken 6364102 times.
✓ Branch 13 taken 21840211 times.
✓ Branch 14 taken 5881972 times.
✗ Branch 15 not taken.
303627245 switch (op->op) {
402 26093773 case SWS_OP_READ:
403 /* Active components are taken from the user-provided values,
404 * other components are explicitly stripped */
405
2/2
✓ Branch 0 taken 65997171 times.
✓ Branch 1 taken 26093773 times.
92090944 for (int i = 0; i < op->rw.elems; i++) {
406 65997171 int idx = 0;
407
3/4
✓ Branch 0 taken 480420 times.
✓ Branch 1 taken 25385503 times.
✓ Branch 2 taken 40131248 times.
✗ Branch 3 not taken.
65997171 switch (op->rw.mode) {
408 480420 case SWS_RW_PALETTE: idx = i; break;
409 25385503 case SWS_RW_PACKED: idx = i; break;
410 40131248 case SWS_RW_PLANAR: idx = ops->plane_src[i]; break;
411 }
412
413 65997171 SwsOpPad *src = &ops->inputs[idx];
414 65997171 SwsOpPad *dst = &out[i];
415 65997171 dst->type = op->rw.type;
416 65997171 dst->flags = src->flags & SWS_COMP_DIRTY;
417 65997171 dst->min = src->min;
418 65997171 dst->max = src->max;
419 65997171 dst->dep_in = SWS_COMP(i);
420
421
2/2
✓ Branch 0 taken 13684253 times.
✓ Branch 1 taken 52312918 times.
65997171 if (op->rw.filter.op) {
422 13684253 apply_filter_weights(dst, op->rw.filter.kernel);
423 13684253 dst->type = op->rw.filter.type;
424
4/4
✓ Branch 0 taken 26446995 times.
✓ Branch 1 taken 25865923 times.
✓ Branch 2 taken 26031663 times.
✓ Branch 3 taken 415332 times.
52312918 } else if (op->rw.mode == SWS_RW_PLANAR && !op->rw.frac) {
425 /* Don't mark packed or fractional reads as a copy, because
426 * the read operation implicitly unpacks the data into
427 * separate components. The only case in which op lists
428 * involving such reads can be refcopies is in the case of
429 * a true no-op, which is covered by the no-op check. */
430 26031663 dst->flags |= SWS_COMP_COPY;
431 }
432 }
433
434 /* Forward unused/untouched components */
435
2/2
✓ Branch 0 taken 38377921 times.
✓ Branch 1 taken 26093773 times.
64471694 for (int i = op->rw.elems; i < 4; i++)
436
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38377921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38377921 FORWARD(i, i, flags);
437 26093773 break;
438 18268990 case SWS_OP_SWAP_BYTES:
439
2/2
✓ Branch 0 taken 73075960 times.
✓ Branch 1 taken 18268990 times.
91344950 for (int i = 0; i < 4; i++) {
440
3/6
✓ Branch 0 taken 48616632 times.
✓ Branch 1 taken 24459328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48616632 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
73075960 FORWARD(i, i, (flags ^ SWS_COMP_SWAPPED) & SWS_COMP_DIRTY);
441 73075960 out[i].min = in[i].min;
442 73075960 out[i].max = in[i].max;
443 }
444 18268990 break;
445 27289222 case SWS_OP_WRITE:
446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27289222 times.
27289222 av_assert0(op->rw.elems <= 4);
447
2/2
✓ Branch 0 taken 71302774 times.
✓ Branch 1 taken 27289222 times.
98591996 for (int i = 0; i < op->rw.elems; i++)
448 av_assert1(in[i].type == op->rw.type);
449
2/2
✓ Branch 0 taken 109156888 times.
✓ Branch 1 taken 27289222 times.
136446110 for (int i = 0; i < 4; i++)
450
3/6
✓ Branch 0 taken 83472713 times.
✓ Branch 1 taken 25684175 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83472713 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109156888 FORWARD(i, i, flags);
451 27289222 break;
452 3596567 case SWS_OP_LSHIFT:
453 case SWS_OP_RSHIFT:
454
2/2
✓ Branch 0 taken 14386268 times.
✓ Branch 1 taken 3596567 times.
17982835 for (int i = 0; i < 4; i++)
455
3/6
✓ Branch 0 taken 11507533 times.
✓ Branch 1 taken 2878735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11507533 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14386268 FORWARD(i, i, flags & SWS_COMP_DIRTY);
456 3596567 break;
457 42205743 case SWS_OP_MIN:
458 case SWS_OP_MAX: {
459
2/2
✓ Branch 0 taken 168822972 times.
✓ Branch 1 taken 42205743 times.
211028715 for (int i = 0; i < 4; i++) {
460 168822972 SwsOpPad *dst = &out[i];
461
3/6
✓ Branch 0 taken 146452020 times.
✓ Branch 1 taken 22370952 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 146452020 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
168822972 FORWARD(i, i, flags);
462
2/2
✓ Branch 0 taken 138515763 times.
✓ Branch 1 taken 30307209 times.
168822972 if (op->clamp.limit[i].den)
463 138515763 dst->flags &= SWS_COMP_DIRTY;
464
465 /* Reset undefined bounds to known range */
466
2/2
✓ Branch 0 taken 92539328 times.
✓ Branch 1 taken 76283644 times.
168822972 AVRational64 *bound = op->op == SWS_OP_MIN ? &dst->max : &dst->min;
467
2/2
✓ Branch 0 taken 36611692 times.
✓ Branch 1 taken 132211280 times.
168822972 if (!bound->den)
468 36611692 *bound = op->clamp.limit[i];
469 }
470 42205743 break;
471 }
472 15912958 case SWS_OP_DITHER:
473
2/2
✓ Branch 0 taken 63651832 times.
✓ Branch 1 taken 15912958 times.
79564790 for (int i = 0; i < 4; i++) {
474
3/6
✓ Branch 0 taken 53173108 times.
✓ Branch 1 taken 10478724 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53173108 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63651832 FORWARD(i, i, flags);
475 63651832 out[i].min = in[i].min;
476 63651832 out[i].max = in[i].max;
477
2/2
✓ Branch 0 taken 10259976 times.
✓ Branch 1 taken 53391856 times.
63651832 if (op->dither.y_offset[i] < 0)
478 10259976 continue;
479 /* Strip zero flag because of the nonzero dithering offset */
480 53391856 out[i].flags &= ~SWS_COMP_ZERO & SWS_COMP_DIRTY;
481 53391856 out[i].min = ff_add_q64(out[i].min, op->dither.min);
482 53391856 out[i].max = ff_add_q64(out[i].max, op->dither.max);
483 }
484 15912958 break;
485 4389926 case SWS_OP_UNPACK:
486
2/2
✓ Branch 0 taken 17559704 times.
✓ Branch 1 taken 4389926 times.
21949630 for (int i = 0; i < 4; i++) {
487 17559704 const int pattern = op->pack.pattern[i];
488
2/2
✓ Branch 0 taken 14682184 times.
✓ Branch 1 taken 2877520 times.
17559704 if (pattern) {
489 av_assert1(pattern < 32);
490
3/6
✓ Branch 0 taken 14548872 times.
✓ Branch 1 taken 133312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14548872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14682184 FORWARD(i, 0, flags & SWS_COMP_DIRTY);
491 14682184 out[i].min = Q(0);
492 14682184 out[i].max = Q((1ULL << pattern) - 1);
493 } else
494 2877520 RESET(i);
495 }
496 4389926 break;
497 4454322 case SWS_OP_PACK:
498
2/2
✓ Branch 0 taken 17817288 times.
✓ Branch 1 taken 4454322 times.
22271610 for (int i = 0; i < 4; i++) {
499
2/2
✓ Branch 0 taken 14899668 times.
✓ Branch 1 taken 2917620 times.
17817288 if (op->pack.pattern[i])
500
4/6
✓ Branch 0 taken 14899668 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10445346 times.
✓ Branch 3 taken 4454322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10445346 times.
14899668 FORWARD(0, i, flags & SWS_COMP_DIRTY);
501
2/2
✓ Branch 0 taken 13362966 times.
✓ Branch 1 taken 4454322 times.
17817288 if (i > 0) /* clear remaining pads for sanity */
502 13362966 RESET(i);
503 }
504 4454322 break;
505 14581369 case SWS_OP_CLEAR:
506
2/2
✓ Branch 0 taken 58325476 times.
✓ Branch 1 taken 14581369 times.
72906845 for (int i = 0; i < 4; i++) {
507
2/2
✓ Branch 0 taken 17217584 times.
✓ Branch 1 taken 41107892 times.
58325476 if (SWS_COMP_TEST(op->clear.mask, i)) {
508 17217584 out[i].type = op->clear.type[i];
509 17217584 out[i].flags = SWS_COMP_CONST;
510
2/2
✓ Branch 0 taken 9939389 times.
✓ Branch 1 taken 7278195 times.
17217584 if (op->clear.value[i].num == 0)
511 9939389 out[i].flags |= SWS_COMP_ZERO;
512
1/2
✓ Branch 0 taken 17217584 times.
✗ Branch 1 not taken.
17217584 if (op->clear.value[i].den == 1)
513 17217584 out[i].flags |= SWS_COMP_EXACT;
514 } else {
515
3/6
✓ Branch 0 taken 36513389 times.
✓ Branch 1 taken 4594503 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36513389 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
41107892 FORWARD(i, i, flags);
516 }
517 }
518 14581369 break;
519 34778702 case SWS_OP_SWIZZLE:
520
2/2
✓ Branch 0 taken 139114808 times.
✓ Branch 1 taken 34778702 times.
173893510 for (int i = 0; i < 4; i++)
521
3/6
✓ Branch 0 taken 118329859 times.
✓ Branch 1 taken 20784949 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118329859 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139114808 FORWARD(i, op->swizzle.in[i], flags);
522 34778702 break;
523 37239781 case SWS_OP_CONVERT:
524
2/2
✓ Branch 0 taken 148959124 times.
✓ Branch 1 taken 37239781 times.
186198905 for (int i = 0; i < 4; i++) {
525
3/6
✓ Branch 0 taken 127270998 times.
✓ Branch 1 taken 21688126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127270998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
148959124 FORWARD(i, i, flags);
526 148959124 out[i].type = op->convert.to;
527
2/2
✓ Branch 0 taken 96924938 times.
✓ Branch 1 taken 52034186 times.
148959124 if (!(in[i].flags & SWS_COMP_EXACT))
528 96924938 out[i].flags &= SWS_COMP_DIRTY;
529
2/2
✓ Branch 0 taken 116680436 times.
✓ Branch 1 taken 32278688 times.
148959124 if (ff_sws_pixel_type_is_int(op->convert.to))
530 116680436 out[i].flags |= SWS_COMP_EXACT;
531 }
532 37239781 break;
533 40729607 case SWS_OP_LINEAR:
534
2/2
✓ Branch 0 taken 162918428 times.
✓ Branch 1 taken 40729607 times.
203648035 for (int i = 0; i < 4; i++) {
535 162918428 SwsOpPad *dst = &out[i];
536 162918428 bool first = true;
537 162918428 dst->type = op->lin.type[i];
538 162918428 dst->min = dst->max = Q(0);
539
2/2
✓ Branch 0 taken 651673712 times.
✓ Branch 1 taken 162918428 times.
814592140 for (int j = 0; j < 4; j++) {
540 651673712 const SwsOpPad *src = &in[j];
541 651673712 const AVRational64 k = op->lin.m[i][j];
542 651673712 AVRational64 mink = ff_mul_q64(src->min, k);
543 651673712 AVRational64 maxk = ff_mul_q64(src->max, k);
544
2/2
✓ Branch 0 taken 416737596 times.
✓ Branch 1 taken 234936116 times.
651673712 if (!k.num)
545 416737596 continue;
546
4/6
✓ Branch 0 taken 216640322 times.
✓ Branch 1 taken 18295794 times.
✓ Branch 2 taken 216640322 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 216640322 times.
234936116 FORWARD(i, j, flags);
547
2/2
✓ Branch 0 taken 141458239 times.
✓ Branch 1 taken 93477877 times.
234936116 if (k.den != 1) /* fractional coefficient */
548 141458239 dst->flags &= ~SWS_COMP_EXACT;
549
2/2
✓ Branch 0 taken 42490547 times.
✓ Branch 1 taken 192445569 times.
234936116 if (k.num < 0)
550 42490547 FFSWAP(AVRational64, mink, maxk);
551 234936116 dst->min = ff_add_q64(dst->min, mink);
552 234936116 dst->max = ff_add_q64(dst->max, maxk);
553
4/4
✓ Branch 0 taken 162849914 times.
✓ Branch 1 taken 72086202 times.
✓ Branch 3 taken 103759535 times.
✓ Branch 4 taken 59090379 times.
234936116 if (!first || ff_cmp_q64(k, Q(1)))
554 175845737 dst->flags &= SWS_COMP_DIRTY;
555 234936116 first = false;
556 }
557
2/2
✓ Branch 0 taken 42046414 times.
✓ Branch 1 taken 120872014 times.
162918428 if (op->lin.m[i][4].num) { /* nonzero offset */
558 42046414 dst->flags &= ~SWS_COMP_ZERO & SWS_COMP_DIRTY;
559
2/2
✓ Branch 0 taken 16764088 times.
✓ Branch 1 taken 25282326 times.
42046414 if (op->lin.m[i][4].den != 1) /* fractional offset */
560 16764088 dst->flags &= ~SWS_COMP_EXACT;
561 42046414 dst->min = ff_add_q64(dst->min, op->lin.m[i][4]);
562 42046414 dst->max = ff_add_q64(dst->max, op->lin.m[i][4]);
563 }
564 }
565 40729607 break;
566 6364102 case SWS_OP_SCALE:
567
2/2
✓ Branch 0 taken 25456408 times.
✓ Branch 1 taken 6364102 times.
31820510 for (int i = 0; i < 4; i++) {
568
3/6
✓ Branch 0 taken 18848776 times.
✓ Branch 1 taken 6607632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18848776 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25456408 FORWARD(i, i, flags & SWS_COMP_DIRTY);
569
2/2
✓ Branch 0 taken 20259692 times.
✓ Branch 1 taken 5196716 times.
25456408 if (op->scale.factor.den != 1) /* fractional scale */
570 20259692 out[i].flags &= ~SWS_COMP_EXACT;
571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25456408 times.
25456408 if (op->scale.factor.num < 0)
572 ✗ FFSWAP(AVRational64, out[i].min, out[i].max);
573 }
574 6364102 break;
575 21840211 case SWS_OP_FILTER_H:
576 case SWS_OP_FILTER_V: {
577
2/2
✓ Branch 0 taken 87360844 times.
✓ Branch 1 taken 21840211 times.
109201055 for (int i = 0; i < 4; i++) {
578
3/6
✓ Branch 0 taken 72841939 times.
✓ Branch 1 taken 14518905 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72841939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87360844 FORWARD(i, i, flags & SWS_COMP_DIRTY);
579 87360844 apply_filter_weights(&out[i], op->filter.kernel);
580 87360844 out[i].type = op->filter.type;
581 }
582 21840211 break;
583 }
584 5881972 case SWS_OP_LUT_3D:
585
2/2
✓ Branch 0 taken 17645916 times.
✓ Branch 1 taken 5881972 times.
23527888 for (int i = 0; i < 3; i++) {
586 /* 3x3 dependency matrix; strip all information */
587
2/2
✓ Branch 0 taken 52937748 times.
✓ Branch 1 taken 17645916 times.
70583664 for (int j = 0; j < 3; j++)
588
5/6
✓ Branch 0 taken 52869852 times.
✓ Branch 1 taken 67896 times.
✓ Branch 2 taken 35246568 times.
✓ Branch 3 taken 17623284 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 35246568 times.
52937748 FORWARD(i, j, flags & 0);
589 /* LUT output domain is always scaled to full 16-bit range */
590 17645916 out[i].min = Q(0);
591 17645916 out[i].max = Q(UINT16_MAX);
592 }
593 /* Pass through alpha channel untouched */
594
3/6
✓ Branch 0 taken 3414392 times.
✓ Branch 1 taken 2467580 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3414392 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5881972 FORWARD(3, 3, flags);
595 5881972 out[3].min = in[3].min;
596 5881972 out[3].max = in[3].max;
597 5881972 break;
598 case SWS_OP_INVALID:
599 case SWS_OP_TYPE_NB:
600 av_unreachable("Invalid operation type!");
601 }
602
603
2/2
✓ Branch 0 taken 1214508980 times.
✓ Branch 1 taken 303627245 times.
1518136225 for (int i = 0; i < 4; i++) {
604
4/4
✓ Branch 0 taken 1021902963 times.
✓ Branch 1 taken 192606017 times.
✓ Branch 2 taken 36207031 times.
✓ Branch 3 taken 985695932 times.
1214508980 if (!out[i].type || SWS_COMP_TEST(invalid, i))
605 228813048 RESET(i);
606 }
607
608 #undef FORWARD
609 #undef RESET
610 303627245 }
611
612 303627245 static void update_input_pads(SwsOpList *ops, SwsOp *op, SwsCompMask need_out[4])
613 {
614 303627245 SwsCompMask need_in[4] = {0};
615
616
2/2
✓ Branch 0 taken 1214508980 times.
✓ Branch 1 taken 303627245 times.
1518136225 for (int i = 0; i < 4; i++)
617 1214508980 op->outputs[i].dep_out = need_out[i];
618
619
8/9
✓ Branch 0 taken 53382995 times.
✓ Branch 1 taken 145428352 times.
✓ Branch 2 taken 4389926 times.
✓ Branch 3 taken 4454322 times.
✓ Branch 4 taken 14581369 times.
✓ Branch 5 taken 34778702 times.
✓ Branch 6 taken 40729607 times.
✓ Branch 7 taken 5881972 times.
✗ Branch 8 not taken.
303627245 switch (op->op) {
620 53382995 case SWS_OP_READ:
621 case SWS_OP_WRITE:
622
2/2
✓ Branch 0 taken 137299945 times.
✓ Branch 1 taken 53382995 times.
190682940 for (int i = 0; i < op->rw.elems; i++)
623
2/2
✓ Branch 0 taken 71302774 times.
✓ Branch 1 taken 65997171 times.
137299945 need_in[i] = (op->op == SWS_OP_WRITE) ? SWS_COMP(i) : 0;
624
2/2
✓ Branch 0 taken 76232035 times.
✓ Branch 1 taken 53382995 times.
129615030 for (int i = op->rw.elems; i < 4; i++)
625 76232035 need_in[i] = need_out[i];
626 53382995 break;
627 145428352 case SWS_OP_SWAP_BYTES:
628 case SWS_OP_LSHIFT:
629 case SWS_OP_RSHIFT:
630 case SWS_OP_CONVERT:
631 case SWS_OP_DITHER:
632 case SWS_OP_MIN:
633 case SWS_OP_MAX:
634 case SWS_OP_SCALE:
635 case SWS_OP_FILTER_H:
636 case SWS_OP_FILTER_V:
637
2/2
✓ Branch 0 taken 581713408 times.
✓ Branch 1 taken 145428352 times.
727141760 for (int i = 0; i < 4; i++)
638 581713408 need_in[i] = need_out[i];
639 145428352 break;
640 4389926 case SWS_OP_UNPACK:
641
4/4
✓ Branch 0 taken 17559704 times.
✓ Branch 1 taken 1512406 times.
✓ Branch 2 taken 14682184 times.
✓ Branch 3 taken 2877520 times.
19072110 for (int i = 0; i < 4 && op->pack.pattern[i]; i++)
642 14682184 need_in[0] |= need_out[i];
643 4389926 break;
644 4454322 case SWS_OP_PACK:
645
4/4
✓ Branch 0 taken 17817288 times.
✓ Branch 1 taken 1536702 times.
✓ Branch 2 taken 14899668 times.
✓ Branch 3 taken 2917620 times.
19353990 for (int i = 0; i < 4 && op->pack.pattern[i]; i++)
646 14899668 need_in[i] = need_out[0];
647 4454322 break;
648 14581369 case SWS_OP_CLEAR:
649
2/2
✓ Branch 0 taken 58325476 times.
✓ Branch 1 taken 14581369 times.
72906845 for (int i = 0; i < 4; i++) {
650
2/2
✓ Branch 0 taken 41107892 times.
✓ Branch 1 taken 17217584 times.
58325476 if (!SWS_COMP_TEST(op->clear.mask, i))
651 41107892 need_in[i] = need_out[i];
652 }
653 14581369 break;
654 34778702 case SWS_OP_SWIZZLE:
655
2/2
✓ Branch 0 taken 139114808 times.
✓ Branch 1 taken 34778702 times.
173893510 for (int i = 0; i < 4; i++)
656 139114808 need_in[op->swizzle.in[i]] |= need_out[i];
657 34778702 break;
658 40729607 case SWS_OP_LINEAR:
659
2/2
✓ Branch 0 taken 162918428 times.
✓ Branch 1 taken 40729607 times.
203648035 for (int i = 0; i < 4; i++) {
660
2/2
✓ Branch 0 taken 651673712 times.
✓ Branch 1 taken 162918428 times.
814592140 for (int j = 0; j < 4; j++) {
661
2/2
✓ Branch 0 taken 234936116 times.
✓ Branch 1 taken 416737596 times.
651673712 if (op->lin.m[i][j].num)
662 234936116 need_in[j] |= need_out[i];
663 }
664 }
665 40729607 break;
666 5881972 case SWS_OP_LUT_3D:
667
2/2
✓ Branch 0 taken 17645916 times.
✓ Branch 1 taken 5881972 times.
23527888 for (int i = 0; i < 3; i++)
668 17645916 need_in[i] = need_out[0] | need_out[1] | need_out[2];
669 5881972 need_in[3] = need_out[3];
670 5881972 break;
671 }
672
673 303627245 memcpy(need_out, need_in, sizeof(need_in));
674 303627245 }
675
676 /* Infer + propagate output pad metadata */
677 27289222 void ff_sws_op_list_update(SwsOpList *ops)
678 {
679 /* Forward pass, solves for output pad metadata */
680
2/2
✓ Branch 0 taken 303627245 times.
✓ Branch 1 taken 27289222 times.
330916467 for (int n = 0; n < ops->num_ops; n++)
681 303627245 update_output_pads(ops, &ops->ops[n]);
682
683 /* Backwards pass, solves for output component dependencies */
684 27289222 SwsCompMask need_out[4] = {0};
685
2/2
✓ Branch 0 taken 303627245 times.
✓ Branch 1 taken 27289222 times.
330916467 for (int n = ops->num_ops - 1; n >= 0; n--)
686 303627245 update_input_pads(ops, &ops->ops[n], need_out);
687 27289222 }
688
689 39289666 static void op_ref(SwsOp *op)
690 {
691
5/5
✓ Branch 0 taken 4908602 times.
✓ Branch 1 taken 2576552 times.
✓ Branch 2 taken 3132336 times.
✓ Branch 3 taken 1023684 times.
✓ Branch 4 taken 27648492 times.
39289666 switch (op->op) {
692 4908602 case SWS_OP_READ:
693
2/2
✓ Branch 0 taken 1835137 times.
✓ Branch 1 taken 3073465 times.
4908602 if (op->rw.filter.kernel)
694 1835137 av_refstruct_ref(op->rw.filter.kernel);
695 4908602 break;
696 2576552 case SWS_OP_DITHER:
697 2576552 av_refstruct_ref(op->dither.matrix);
698 2576552 break;
699 3132336 case SWS_OP_FILTER_H:
700 case SWS_OP_FILTER_V:
701 3132336 av_refstruct_ref(op->filter.kernel);
702 3132336 break;
703 1023684 case SWS_OP_LUT_3D:
704 1023684 av_refstruct_ref_c(op->lut3d.lut);
705 1023684 break;
706 }
707 39289666 }
708
709 64677763 static void op_unref(SwsOp *op)
710 {
711
5/5
✓ Branch 0 taken 7269942 times.
✓ Branch 1 taken 3481005 times.
✓ Branch 2 taken 4330901 times.
✓ Branch 3 taken 1377996 times.
✓ Branch 4 taken 48217919 times.
64677763 switch (op->op) {
712 7269942 case SWS_OP_READ:
713 7269942 av_refstruct_unref(&op->rw.filter.kernel);
714 7269942 break;
715 3481005 case SWS_OP_DITHER:
716 3481005 av_refstruct_unref(&op->dither.matrix);
717 3481005 break;
718 4330901 case SWS_OP_FILTER_H:
719 case SWS_OP_FILTER_V:
720 4330901 av_refstruct_unref(&op->filter.kernel);
721 4330901 break;
722 1377996 case SWS_OP_LUT_3D:
723 1377996 av_refstruct_unref(&op->lut3d.lut);
724 1377996 break;
725 }
726
727 64677763 *op = (SwsOp) {0};
728 64677763 }
729
730 1974664 SwsOpList *ff_sws_op_list_alloc(void)
731 {
732 1974664 SwsOpList *ops = av_mallocz(sizeof(SwsOpList));
733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1974664 times.
1974664 if (!ops)
734 ✗ return NULL;
735
736
2/2
✓ Branch 0 taken 7898656 times.
✓ Branch 1 taken 1974664 times.
9873320 for (int i = 0; i < 4; i++)
737 7898656 ops->plane_src[i] = ops->plane_dst[i] = i;
738 1974664 ff_fmt_clear(&ops->src);
739 1974664 ff_fmt_clear(&ops->dst);
740 1974664 return ops;
741 }
742
743 10571682 void ff_sws_op_list_free(SwsOpList **p_ops)
744 {
745 10571682 SwsOpList *ops = *p_ops;
746
2/2
✓ Branch 0 taken 3573400 times.
✓ Branch 1 taken 6998282 times.
10571682 if (!ops)
747 3573400 return;
748
749
2/2
✓ Branch 0 taken 44776261 times.
✓ Branch 1 taken 6998282 times.
51774543 for (int i = 0; i < ops->num_ops; i++)
750 44776261 op_unref(&ops->ops[i]);
751
752 6998282 av_freep(&ops->ops);
753 6998282 av_free(ops);
754 6998282 *p_ops = NULL;
755 }
756
757 5023618 SwsOpList *ff_sws_op_list_duplicate(const SwsOpList *ops)
758 {
759 5023618 SwsOpList *copy = av_malloc(sizeof(*copy));
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5023618 times.
5023618 if (!copy)
761 ✗ return NULL;
762
763 5023618 int num = ops->num_ops;
764
1/2
✓ Branch 0 taken 5023618 times.
✗ Branch 1 not taken.
5023618 if (num)
765 5023618 num = 1 << av_ceil_log2(num);
766
767 5023618 *copy = *ops;
768 5023618 copy->ops = av_memdup(ops->ops, num * sizeof(ops->ops[0]));
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5023618 times.
5023618 if (!copy->ops) {
770 ✗ av_free(copy);
771 ✗ return NULL;
772 }
773
774
2/2
✓ Branch 0 taken 39289666 times.
✓ Branch 1 taken 5023618 times.
44313284 for (int i = 0; i < copy->num_ops; i++) {
775 39289666 op_ref(&copy->ops[i]);
776 39289666 copy->ops[i].ops = copy;
777 }
778
779 5023618 return copy;
780 }
781
782 3591234 const SwsOp *ff_sws_op_list_input(const SwsOpList *ops)
783 {
784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3591234 times.
3591234 if (!ops->num_ops)
785 ✗ return NULL;
786
787 3591234 const SwsOp *read = &ops->ops[0];
788
2/2
✓ Branch 0 taken 3541040 times.
✓ Branch 1 taken 50194 times.
3591234 return read->op == SWS_OP_READ ? read : NULL;
789 }
790
791 10111286 const SwsOp *ff_sws_op_list_output(const SwsOpList *ops)
792 {
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10111286 times.
10111286 if (!ops->num_ops)
794 ✗ return NULL;
795
796 10111286 const SwsOp *write = &ops->ops[ops->num_ops - 1];
797
1/2
✓ Branch 0 taken 10111286 times.
✗ Branch 1 not taken.
10111286 return write->op == SWS_OP_WRITE ? write : NULL;
798 }
799
800 12922810 void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
801 {
802 12922810 const int end = ops->num_ops - count;
803 av_assert2(index >= 0 && count >= 0 && index + count <= ops->num_ops);
804
2/2
✓ Branch 0 taken 19901502 times.
✓ Branch 1 taken 12922810 times.
32824312 for (int i = 0; i < count; i++)
805 19901502 op_unref(&ops->ops[index + i]);
806
2/2
✓ Branch 0 taken 91705072 times.
✓ Branch 1 taken 12922810 times.
104627882 for (int i = index; i < end; i++)
807 91705072 ops->ops[i] = ops->ops[i + count];
808 12922810 ops->num_ops = end;
809 12922810 }
810
811 25388097 int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
812 {
813 25388097 void *ret = av_dynarray2_add((void **) &ops->ops, &ops->num_ops, sizeof(*op), NULL);
814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25388097 times.
25388097 if (!ret) {
815 ✗ op_unref(op);
816 ✗ return AVERROR(ENOMEM);
817 }
818
819
2/2
✓ Branch 0 taken 13556809 times.
✓ Branch 1 taken 25388097 times.
38944906 for (int i = ops->num_ops - 1; i > index; i--)
820 13556809 ops->ops[i] = ops->ops[i - 1];
821 25388097 ops->ops[index] = *op;
822 25388097 ops->ops[index].ops = ops;
823 25388097 return 0;
824 }
825
826 23582170 int ff_sws_op_list_append(SwsOpList *ops, SwsOp *op)
827 {
828 23582170 return ff_sws_op_list_insert_at(ops, ops->num_ops, op);
829 }
830
831 2121812 bool ff_sws_op_list_is_noop(const SwsOpList *ops)
832 {
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2121812 times.
2121812 if (!ops->num_ops)
834 ✗ return true;
835
836 2121812 const SwsOp *read = ff_sws_op_list_input(ops);
837 2121812 const SwsOp *write = ff_sws_op_list_output(ops);
838
4/6
✓ Branch 0 taken 2121812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2121812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 431466 times.
✓ Branch 5 taken 1690346 times.
2121812 if (!read || !write || ops->num_ops > 2 ||
839
2/2
✓ Branch 0 taken 178670 times.
✓ Branch 1 taken 252796 times.
431466 read->rw.type != write->rw.type ||
840
2/2
✓ Branch 0 taken 42092 times.
✓ Branch 1 taken 136578 times.
178670 read->rw.mode != write->rw.mode ||
841
2/2
✓ Branch 0 taken 41937 times.
✓ Branch 1 taken 155 times.
42092 read->rw.elems != write->rw.elems ||
842
2/2
✓ Branch 0 taken 29818 times.
✓ Branch 1 taken 12119 times.
41937 read->rw.frac != write->rw.frac ||
843
3/4
✓ Branch 0 taken 1355 times.
✓ Branch 1 taken 28463 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1355 times.
29818 read->rw.filter.op || write->rw.filter.op)
844 2120457 return false;
845
846 /**
847 * Note that this check is unlikely to ever be hit in practice, since it
848 * would imply the existence of planar formats with different plane orders
849 * between them, e.g. rgbap <-> gbrap, which doesn't currently exist.
850 * However, the check is cheap and lets me sleep at night.
851 */
852 1355 const int num_planes = ff_sws_rw_op_planes(read);
853
2/2
✓ Branch 0 taken 2999 times.
✓ Branch 1 taken 1355 times.
4354 for (int i = 0; i < num_planes; i++) {
854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2999 times.
2999 if (ops->plane_src[i] != ops->plane_dst[i])
855 ✗ return false;
856 }
857
858 1355 return true;
859 }
860
861 26032519 uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
862 {
863 26032519 uint32_t mask = 0;
864
2/2
✓ Branch 0 taken 104130076 times.
✓ Branch 1 taken 26032519 times.
130162595 for (int i = 0; i < 4; i++) {
865
2/2
✓ Branch 0 taken 520650380 times.
✓ Branch 1 taken 104130076 times.
624780456 for (int j = 0; j < 5; j++) {
866
2/2
✓ Branch 1 taken 181230850 times.
✓ Branch 2 taken 339419530 times.
520650380 if (ff_cmp_q64(c->m[i][j], Q(i == j)))
867 181230850 mask |= SWS_MASK(i, j);
868 }
869 }
870 26032519 return mask;
871 }
872
873 1355738 static const char *describe_comp_flags(SwsCompFlags flags)
874 {
875
2/2
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 1350950 times.
1355738 if (flags & SWS_COMP_ZERO)
876 4788 return "zero";
877
2/2
✓ Branch 0 taken 142707 times.
✓ Branch 1 taken 1208243 times.
1350950 else if (flags & SWS_COMP_SWAPPED)
878 142707 return "swapped";
879
2/2
✓ Branch 0 taken 24064 times.
✓ Branch 1 taken 1184179 times.
1208243 else if (flags & SWS_COMP_CONST)
880 24064 return "const";
881
2/2
✓ Branch 0 taken 26663 times.
✓ Branch 1 taken 1157516 times.
1184179 else if (flags & SWS_COMP_COPY)
882 26663 return "copy";
883
2/2
✓ Branch 0 taken 525912 times.
✓ Branch 1 taken 631604 times.
1157516 else if (flags & SWS_COMP_EXACT)
884 525912 return "exact";
885 else
886 631604 return "normal";
887 }
888
889 2711476 static void print_deps(AVBPrint *bp, SwsCompMask dep)
890 {
891 10845904 av_bprintf(bp, " {%c%c%c%c}",
892
2/2
✓ Branch 0 taken 1546316 times.
✓ Branch 1 taken 1165160 times.
2711476 SWS_COMP_TEST(dep, 0) ? 'x' : ' ',
893
2/2
✓ Branch 0 taken 907836 times.
✓ Branch 1 taken 1803640 times.
2711476 SWS_COMP_TEST(dep, 1) ? 'y' : ' ',
894
2/2
✓ Branch 0 taken 869844 times.
✓ Branch 1 taken 1841632 times.
2711476 SWS_COMP_TEST(dep, 2) ? 'z' : ' ',
895
2/2
✓ Branch 0 taken 120832 times.
✓ Branch 1 taken 2590644 times.
2711476 SWS_COMP_TEST(dep, 3) ? 'w' : ' ');
896 2711476 }
897
898 3555320 static void print_q(AVBPrint *bp, const AVRational64 q)
899 {
900
2/2
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 3540648 times.
3555320 if (!q.den) {
901
2/4
✓ Branch 0 taken 14672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14672 times.
14672 av_bprintf(bp, "%s", q.num > 0 ? "inf" : q.num < 0 ? "-inf" : "nan");
902
2/2
✓ Branch 0 taken 2914026 times.
✓ Branch 1 taken 626622 times.
3540648 } else if (q.den == 1) {
903 2914026 av_bprintf(bp, "%"PRId64, q.num);
904
7/8
✓ Branch 0 taken 332154 times.
✓ Branch 1 taken 294468 times.
✓ Branch 2 taken 176790 times.
✓ Branch 3 taken 155364 times.
✓ Branch 4 taken 143634 times.
✓ Branch 5 taken 33156 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 143634 times.
626622 } else if (q.num > 1000 || q.num < -1000 || q.den > 1000 || q.den < -1000) {
905 482988 av_bprintf(bp, "%f", ff_q2d_64(q));
906 } else {
907 143634 av_bprintf(bp, "%"PRId64"/%"PRId64, q.num, q.den);
908 }
909 3555320 }
910
911 80996 static void print_q4(AVBPrint *bp, const AVRational64 q4[4], SwsCompMask mask)
912 {
913 80996 av_bprintf(bp, "{");
914
2/2
✓ Branch 0 taken 323984 times.
✓ Branch 1 taken 80996 times.
404980 for (int i = 0; i < 4; i++) {
915
2/2
✓ Branch 0 taken 242988 times.
✓ Branch 1 taken 80996 times.
323984 if (i)
916 242988 av_bprintf(bp, " ");
917
2/2
✓ Branch 0 taken 149542 times.
✓ Branch 1 taken 174442 times.
323984 if (!SWS_COMP_TEST(mask, i)) {
918 149542 av_bprintf(bp, "_");
919 } else {
920 174442 print_q(bp, q4[i]);
921 }
922 }
923 80996 av_bprintf(bp, "}");
924 80996 }
925
926 static const char *const rw_mode_names[] = {
927 [SWS_RW_PLANAR] = "planar",
928 [SWS_RW_PACKED] = "packed",
929 [SWS_RW_PALETTE] = "palette"
930 };
931
932 661663 void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
933 {
934 661663 const char *name = ff_sws_op_type_name(op->op);
935 661663 const SwsCompMask mask = ff_sws_comp_mask_needed(op);
936
937
13/17
✓ Branch 0 taken 53796 times.
✓ Branch 1 taken 263734 times.
✓ Branch 2 taken 5726 times.
✓ Branch 3 taken 5280 times.
✓ Branch 4 taken 27492 times.
✓ Branch 5 taken 24172 times.
✓ Branch 6 taken 37881 times.
✓ Branch 7 taken 84098 times.
✓ Branch 8 taken 37316 times.
✓ Branch 9 taken 38172 times.
✓ Branch 10 taken 18652 times.
✓ Branch 11 taken 43320 times.
✓ Branch 12 taken 22024 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
661663 switch (op->op) {
938 53796 case SWS_OP_INVALID:
939 case SWS_OP_SWAP_BYTES:
940 53796 av_bprintf(bp, "%s", name);
941 53796 break;
942 263734 case SWS_OP_READ:
943 case SWS_OP_WRITE:
944 527468 av_bprintf(bp, "%-20s: %dx %s %s >> %d", name,
945 263734 op->rw.elems, ff_sws_pixel_type_name(op->rw.type),
946 263734 rw_mode_names[op->rw.mode], op->rw.frac);
947
2/2
✓ Branch 0 taken 193510 times.
✓ Branch 1 taken 70224 times.
263734 if (!op->rw.filter.op)
948 193510 break;
949 70224 const SwsFilterWeights *kernel = op->rw.filter.kernel;
950 70224 av_bprintf(bp, " + %d tap %s filter (%c)",
951 70224 kernel->filter_size, kernel->name,
952
2/2
✓ Branch 0 taken 35112 times.
✓ Branch 1 taken 35112 times.
70224 op->rw.filter.op == SWS_OP_FILTER_H ? 'H' : 'V');
953 70224 break;
954 5726 case SWS_OP_LSHIFT:
955 5726 av_bprintf(bp, "%-20s: << %u", name, op->shift.amount);
956 5726 break;
957 5280 case SWS_OP_RSHIFT:
958 5280 av_bprintf(bp, "%-20s: >> %u", name, op->shift.amount);
959 5280 break;
960 27492 case SWS_OP_PACK:
961 case SWS_OP_UNPACK:
962 27492 av_bprintf(bp, "%-20s: {%d %d %d %d}", name,
963 27492 op->pack.pattern[0], op->pack.pattern[1],
964 27492 op->pack.pattern[2], op->pack.pattern[3]);
965 27492 break;
966 24172 case SWS_OP_CLEAR:
967 24172 av_bprintf(bp, "%-20s: ", name);
968 24172 print_q4(bp, op->clear.value, mask & op->clear.mask);
969 24172 break;
970 37881 case SWS_OP_SWIZZLE:
971 37881 av_bprintf(bp, "%-20s: %d%d%d%d", name,
972 37881 op->swizzle.x, op->swizzle.y, op->swizzle.z, op->swizzle.w);
973 37881 break;
974 84098 case SWS_OP_CONVERT:
975 84098 av_bprintf(bp, "%-20s: %s -> %s", name,
976 ff_sws_pixel_type_name(ff_sws_op_input_type(op)),
977 84098 ff_sws_pixel_type_name(op->convert.to));
978 84098 break;
979 37316 case SWS_OP_DITHER:
980 37316 av_bprintf(bp, "%-20s: %dx%d matrix + {%d %d %d %d}", name,
981 37316 1 << op->dither.size_log2, 1 << op->dither.size_log2,
982 37316 op->dither.y_offset[0], op->dither.y_offset[1],
983 37316 op->dither.y_offset[2], op->dither.y_offset[3]);
984 37316 break;
985 38172 case SWS_OP_MIN:
986 38172 av_bprintf(bp, "%-20s: x <= ", name);
987 38172 print_q4(bp, op->clamp.limit, mask & ff_sws_comp_mask_q4(op->clamp.limit));
988 38172 break;
989 18652 case SWS_OP_MAX:
990 18652 av_bprintf(bp, "%-20s: ", name);
991 18652 print_q4(bp, op->clamp.limit, mask & ff_sws_comp_mask_q4(op->clamp.limit));
992 18652 av_bprintf(bp, " <= x");
993 18652 break;
994 43320 case SWS_OP_LINEAR:
995 43320 av_bprintf(bp, "%-20s: [", name);
996
2/2
✓ Branch 0 taken 173280 times.
✓ Branch 1 taken 43320 times.
216600 for (int i = 0; i < 4; i++) {
997
2/2
✓ Branch 0 taken 129960 times.
✓ Branch 1 taken 43320 times.
173280 av_bprintf(bp, "%s[", i ? " " : "");
998
2/2
✓ Branch 0 taken 866400 times.
✓ Branch 1 taken 173280 times.
1039680 for (int j = 0; j < 5; j++) {
999
2/2
✓ Branch 0 taken 693120 times.
✓ Branch 1 taken 173280 times.
866400 av_bprintf(bp, j ? " " : "");
1000 866400 print_q(bp, op->lin.m[i][j]);
1001 }
1002 173280 av_bprintf(bp, "]");
1003 }
1004 43320 av_bprintf(bp, "]");
1005 43320 break;
1006 22024 case SWS_OP_SCALE:
1007 22024 av_bprintf(bp, "%-20s: * %"PRId64, name, op->scale.factor.num);
1008
2/2
✓ Branch 0 taken 16068 times.
✓ Branch 1 taken 5956 times.
22024 if (op->scale.factor.den != 1)
1009 16068 av_bprintf(bp, "/%"PRId64, op->scale.factor.den);
1010 22024 break;
1011 ✗ case SWS_OP_FILTER_H:
1012 case SWS_OP_FILTER_V: {
1013 ✗ const SwsFilterWeights *kernel = op->filter.kernel;
1014 ✗ av_bprintf(bp, "%-20s: %d -> %d %s (%d taps)", name,
1015 ✗ kernel->src_size, kernel->dst_size,
1016 ✗ kernel->name, kernel->filter_size);
1017 ✗ break;
1018 }
1019 ✗ case SWS_OP_LUT_3D:
1020 ✗ av_bprintf(bp, "%-20s: %s", name, op->lut3d.dynamic ? "dynamic" : "static");
1021 ✗ break;
1022 ✗ case SWS_OP_TYPE_NB:
1023 ✗ break;
1024 }
1025 661663 }
1026
1027 263734 static void desc_plane_order(AVBPrint *bp, int nb_planes, const uint8_t *order)
1028 {
1029 263734 bool inorder = true;
1030
2/2
✓ Branch 0 taken 580076 times.
✓ Branch 1 taken 263734 times.
843810 for (int i = 0; i < nb_planes; i++)
1031 580076 inorder &= order[i] == i;
1032
2/2
✓ Branch 0 taken 218256 times.
✓ Branch 1 taken 45478 times.
263734 if (inorder)
1033 218256 return;
1034
1035 45478 av_bprintf(bp, ", via {");
1036
2/2
✓ Branch 0 taken 125795 times.
✓ Branch 1 taken 45478 times.
171273 for (int i = 0; i < nb_planes; i++)
1037
2/2
✓ Branch 0 taken 80317 times.
✓ Branch 1 taken 45478 times.
125795 av_bprintf(bp, "%s%d", i ? ", " : "", order[i]);
1038 45478 av_bprintf(bp, "}");
1039 }
1040
1041 2688598 void ff_sws_op_list_print(void *log, int lev, int lev_extra,
1042 const SwsOpList *ops)
1043 {
1044 2688598 AVBPrint bpc, *bp = &bpc;
1045
2/2
✓ Branch 1 taken 2552520 times.
✓ Branch 2 taken 136078 times.
2688598 if (av_log_get_level() < lev)
1046 2552520 return;
1047
1048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136078 times.
136078 if (!ops->num_ops) {
1049 ✗ av_log(log, lev, " (empty)\n");
1050 ✗ return;
1051 }
1052
1053 136078 av_bprint_init(bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
1054 136078 lev_extra = FFMAX(lev_extra, lev);
1055
1056
2/2
✓ Branch 0 taken 661663 times.
✓ Branch 1 taken 136078 times.
797741 for (int n = 0; n < ops->num_ops; n++) {
1057 661663 const SwsOp *op = &ops->ops[n];
1058 661663 const SwsCompMask mask = ff_sws_comp_mask_needed(op);
1059 661663 av_bprint_clear(bp);
1060 661663 av_bprintf(bp, " ");
1061 661663 ff_sws_op_desc(bp, op);
1062
4/4
✓ Branch 0 taken 534007 times.
✓ Branch 1 taken 127656 times.
✓ Branch 2 taken 136078 times.
✓ Branch 3 taken 397929 times.
661663 if (op->op == SWS_OP_READ || op->op == SWS_OP_WRITE) {
1063 263734 const int planes = ff_sws_rw_op_planes(op);
1064 263734 desc_plane_order(bp, planes,
1065
2/2
✓ Branch 0 taken 127656 times.
✓ Branch 1 taken 136078 times.
263734 op->op == SWS_OP_READ ? ops->plane_src : ops->plane_dst);
1066 }
1067
1068
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 661663 times.
661663 av_assert0(av_bprint_is_complete(bp));
1069 661663 av_log(log, lev, "%s\n", bp->str);
1070
1071
2/2
✓ Branch 0 taken 2646652 times.
✓ Branch 1 taken 661663 times.
3308315 for (int i = 0; i < 4; i++) {
1072 2646652 const SwsOpPad *pad = &op->outputs[i];
1073
2/2
✓ Branch 0 taken 1290914 times.
✓ Branch 1 taken 1355738 times.
2646652 if (!SWS_COMP_TEST(mask, i))
1074 1290914 continue;
1075 1355738 av_bprint_clear(bp);
1076 1355738 av_bprintf(bp, " %c: %3s,", "XYZW"[i], ff_sws_pixel_type_name(pad->type));
1077 1355738 print_deps(bp, pad->dep_in);
1078 1355738 av_bprintf(bp, " ->");
1079 1355738 print_deps(bp, pad->dep_out);
1080 1355738 av_bprintf(bp, " %7s", describe_comp_flags(pad->flags));
1081
1082
3/4
✓ Branch 0 taken 81679 times.
✓ Branch 1 taken 1274059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81679 times.
1355738 if (pad->min.den || pad->max.den) {
1083
2/2
✓ Branch 0 taken 1269271 times.
✓ Branch 1 taken 4788 times.
1274059 if (pad->flags & SWS_COMP_ZERO) {
1084 /* don't print any value */
1085
2/2
✓ Branch 0 taken 24064 times.
✓ Branch 1 taken 1245207 times.
1269271 } else if (pad->flags & SWS_COMP_CONST) {
1086 24064 av_bprintf(bp, " = ");
1087 av_assert1(ff_cmp_q64(pad->min, pad->max) == 0);
1088 24064 print_q(bp, pad->min);
1089 } else {
1090 1245207 av_bprintf(bp, " in [");
1091 1245207 print_q(bp, pad->min);
1092 1245207 av_bprintf(bp, ", ");
1093 1245207 print_q(bp, pad->max);
1094 1245207 av_bprintf(bp, "]");
1095 }
1096 }
1097
1098
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1355738 times.
1355738 av_assert0(av_bprint_is_complete(bp));
1099 1355738 av_log(log, lev_extra, "%s\n", bp->str);
1100 }
1101 }
1102 }
1103