FFmpeg
Loading...
Searching...
No Matches
ops.c
Go to the documentation of this file.
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
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
34extern const SwsOpBackend backend_c;
35extern const SwsOpBackend backend_murder;
36extern const SwsOpBackend backend_aarch64;
37extern const SwsOpBackend backend_x86;
38#if CONFIG_SWSCALE_VULKAN
39extern const SwsOpBackend backend_spirv;
40#endif
41
44#if ARCH_AARCH64 && HAVE_NEON
46#elif ARCH_X86_64 && HAVE_X86ASM
48#endif
49 &backend_c,
50#if CONFIG_SWSCALE_VULKAN
52#endif
53 NULL
54};
55
57{
58 switch (type) {
59 case SWS_PIXEL_U8: return "u8";
60 case SWS_PIXEL_U16: return "u16";
61 case SWS_PIXEL_U32: return "u32";
62 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
72{
73 switch (op) {
74 case SWS_OP_READ: return "SWS_OP_READ";
75 case SWS_OP_WRITE: return "SWS_OP_WRITE";
76 case SWS_OP_SWAP_BYTES: return "SWS_OP_SWAP_BYTES";
77 case SWS_OP_SWIZZLE: return "SWS_OP_SWIZZLE";
78 case SWS_OP_UNPACK: return "SWS_OP_UNPACK";
79 case SWS_OP_PACK: return "SWS_OP_PACK";
80 case SWS_OP_LSHIFT: return "SWS_OP_LSHIFT";
81 case SWS_OP_RSHIFT: return "SWS_OP_RSHIFT";
82 case SWS_OP_CLEAR: return "SWS_OP_CLEAR";
83 case SWS_OP_CONVERT: return "SWS_OP_CONVERT";
84 case SWS_OP_MIN: return "SWS_OP_MIN";
85 case SWS_OP_MAX: return "SWS_OP_MAX";
86 case SWS_OP_SCALE: return "SWS_OP_SCALE";
87 case SWS_OP_LINEAR: return "SWS_OP_LINEAR";
88 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
101{
102 SwsCompMask mask = 0;
103 for (int i = 0; i < 4; i++) {
104 if (q[i].den)
105 mask |= SWS_COMP(i);
106 }
107 return mask;
108}
109
111{
112 const SwsCompMask orig = *mask;
113 SwsCompMask res = 0;
114 for (int i = 0; i < 4; i++) {
115 const int src = swiz->in[i];
116 if (SWS_COMP_TEST(orig, src))
117 res |= SWS_COMP(i);
118 }
119
120 *mask = res;
121}
122
124{
125 SwsCompMask mask = 0;
126 for (int i = 0; i < 4; i++) {
127 if (SWS_OP_NEEDED(op, i))
128 mask |= SWS_COMP(i);
129 }
130 return mask;
131}
132
134{
135 av_assert2(op->op == SWS_OP_READ || op->op == SWS_OP_WRITE);
136 switch (op->rw.mode) {
137 case SWS_RW_PLANAR: return op->rw.elems;
138 case SWS_RW_PACKED: return 1;
139 case SWS_RW_PALETTE: return 2;
140 }
141
142 av_unreachable("Invalid read/write mode!");
143 return 0;
144}
145
146static inline int op_index(const SwsOp *op)
147{
148 SwsOpList *ops = op->ops;
149 av_assert1(op >= ops->ops && op < ops->ops + ops->num_ops);
150 return op - ops->ops;
151}
152
154{
155 if (!op)
156 return NULL;
157 SwsOpList *ops = op->ops;
158 const int idx = op_index(op);
159 return idx > 0 ? &ops->ops[idx - 1] : NULL;
160}
161
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
172{
174 for (int i = 0; op && i < 4; i++) {
175 if (!SWS_OP_NEEDED(op, i) || !op->outputs[i].type)
176 continue;
177 else if (!type)
178 type = op->outputs[i].type;
179 else if (op->outputs[i].type != type)
180 return SWS_PIXEL_NONE;
181 }
182
183 return type;
184}
185
190
191/* biased towards `a` */
193{
194 return ff_cmp_q64(a, b) == 1 ? b : a;
195}
196
198{
199 return ff_cmp_q64(a, b) == -1 ? b : a;
200}
201
203{
204 uint64_t mask[4];
205 int shift[4];
206
207 switch (op->op) {
208 case SWS_OP_READ:
209 case SWS_OP_WRITE:
210 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 case SWS_OP_PACK: {
219 ff_sws_pack_decode(op->pack.pattern, mask, shift);
220 unsigned val = 0;
221 for (int i = 0; i < 4; i++)
222 val |= (x[i].num & mask[i]) << shift[i];
223 x[0] = Q(val);
224 return;
225 }
227 switch (ff_sws_op_input_type(op)) {
228 case SWS_PIXEL_U16:
229 for (int i = 0; i < 4; i++) {
230 av_assert2(x[i].num >= 0 && x[i].num <= UINT16_MAX);
231 x[i].num = av_bswap16(x[i].num);
232 }
233 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 case SWS_OP_CLEAR:
244 for (int i = 0; i < 4; i++) {
245 if (SWS_COMP_TEST(op->clear.mask, i))
246 x[i] = op->clear.value[i];
247 }
248 return;
249 case SWS_OP_LSHIFT: {
250 AVRational64 mult = Q(1 << op->shift.amount);
251 for (int i = 0; i < 4; i++)
252 x[i] = x[i].den ? ff_mul_q64(x[i], mult) : x[i];
253 return;
254 }
255 case SWS_OP_RSHIFT: {
256 for (int i = 0; i < 4; i++)
257 x[i] = x[i].den ? Q((x[i].num / x[i].den) >> op->shift.amount) : x[i];
258 return;
259 }
260 case SWS_OP_SWIZZLE: {
261 const AVRational64 orig[4] = { x[0], x[1], x[2], x[3] };
262 for (int i = 0; i < 4; i++)
263 x[i] = orig[op->swizzle.in[i]];
264 return;
265 }
266 case SWS_OP_CONVERT:
267 if (ff_sws_pixel_type_is_int(op->convert.to)) {
268 for (int i = 0; i < 4; i++)
269 x[i] = x[i].den ? Q(x[i].num / x[i].den) : x[i];
270 }
271 return;
272 case SWS_OP_DITHER:
273 for (int i = 0; i < 4; i++) {
274 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 return;
278 case SWS_OP_MIN:
279 for (int i = 0; i < 4; i++)
280 x[i] = av_min_q64(x[i], op->clamp.limit[i]);
281 return;
282 case SWS_OP_MAX:
283 for (int i = 0; i < 4; i++)
284 x[i] = av_max_q64(x[i], op->clamp.limit[i]);
285 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 case SWS_OP_SCALE:
297 for (int i = 0; i < 4; i++)
298 x[i] = x[i].den ? ff_mul_q64(x[i], op->scale.factor) : x[i];
299 return;
300 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 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
315enum {
318
320};
321
322/* merge_comp_flags() forms a monoid with SWS_COMP_IDENTITY as the null element */
324{
325 const SwsCompFlags flags_or = SWS_COMP_SWAPPED;
326 const SwsCompFlags flags_and = SWS_COMP_IDENTITY;
327 return ((a & b) & flags_and) | ((a | b) & flags_or);
328}
329
331{
332 const AVRational64 posw = { weights->sum_positive, SWS_FILTER_SCALE };
333 const AVRational64 negw = { weights->sum_negative, SWS_FILTER_SCALE };
334
335 /* Only point sampling preserves exactness */
336 if (weights->filter_size != 1)
337 pad->flags &= ~SWS_COMP_EXACT;
338
339 /* Update min/max assuming extremes */
340 const AVRational64 min = pad->min, max = pad->max;
341 pad->min = ff_add_q64(ff_mul_q64(min, posw), ff_mul_q64(max, negw));
342 pad->max = ff_add_q64(ff_mul_q64(min, negw), ff_mul_q64(max, posw));
343}
344
346{
347 static const SwsOpPad dummy[4] = {0};
348 const SwsOp *prev = ff_sws_op_prev(op);
349 const SwsOpPad *in = prev ? prev->outputs : dummy;
350 SwsOpPad *out = op->outputs;
351 SwsCompMask invalid = 0;
352 for (int i = 0; i < 4; i++) {
353 out[i].type = SWS_PIXEL_NONE;
354 out[i].flags = SWS_COMP_IDENTITY;
355 out[i].dep_in = SWS_COMP_NONE;
356 }
357
358 switch (op->op) {
359 case SWS_OP_LINEAR:
360 case SWS_OP_DITHER:
362 case SWS_OP_UNPACK:
363 case SWS_OP_LUT_3D:
364 break; /* special cases, handled below */
365 default: {
366 AVRational64 min[4], max[4];
367 for (int i = 0; i < 4; i++) {
368 min[i] = in[i].min;
369 max[i] = in[i].max;
370 }
371
374 for (int i = 0; i < 4; i++) {
375 out[i].min = min[i];
376 out[i].max = max[i];
377 }
378 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 switch (op->op) {
402 case SWS_OP_READ:
403 /* Active components are taken from the user-provided values,
404 * other components are explicitly stripped */
405 for (int i = 0; i < op->rw.elems; i++) {
406 int idx = 0;
407 switch (op->rw.mode) {
408 case SWS_RW_PALETTE: idx = i; break;
409 case SWS_RW_PACKED: idx = i; break;
410 case SWS_RW_PLANAR: idx = ops->plane_src[i]; break;
411 }
412
413 SwsOpPad *src = &ops->inputs[idx];
414 SwsOpPad *dst = &out[i];
415 dst->type = op->rw.type;
416 dst->flags = src->flags & SWS_COMP_DIRTY;
417 dst->min = src->min;
418 dst->max = src->max;
419 dst->dep_in = SWS_COMP(i);
420
421 if (op->rw.filter.op) {
422 apply_filter_weights(dst, op->rw.filter.kernel);
423 dst->type = op->rw.filter.type;
424 } 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 dst->flags |= SWS_COMP_COPY;
431 }
432 }
433
434 /* Forward unused/untouched components */
435 for (int i = op->rw.elems; i < 4; i++)
436 FORWARD(i, i, flags);
437 break;
439 for (int i = 0; i < 4; i++) {
441 out[i].min = in[i].min;
442 out[i].max = in[i].max;
443 }
444 break;
445 case SWS_OP_WRITE:
446 av_assert0(op->rw.elems <= 4);
447 for (int i = 0; i < op->rw.elems; i++)
448 av_assert1(in[i].type == op->rw.type);
449 for (int i = 0; i < 4; i++)
450 FORWARD(i, i, flags);
451 break;
452 case SWS_OP_LSHIFT:
453 case SWS_OP_RSHIFT:
454 for (int i = 0; i < 4; i++)
456 break;
457 case SWS_OP_MIN:
458 case SWS_OP_MAX: {
459 for (int i = 0; i < 4; i++) {
460 SwsOpPad *dst = &out[i];
461 FORWARD(i, i, flags);
462 if (op->clamp.limit[i].den)
463 dst->flags &= SWS_COMP_DIRTY;
464
465 /* Reset undefined bounds to known range */
466 AVRational64 *bound = op->op == SWS_OP_MIN ? &dst->max : &dst->min;
467 if (!bound->den)
468 *bound = op->clamp.limit[i];
469 }
470 break;
471 }
472 case SWS_OP_DITHER:
473 for (int i = 0; i < 4; i++) {
474 FORWARD(i, i, flags);
475 out[i].min = in[i].min;
476 out[i].max = in[i].max;
477 if (op->dither.y_offset[i] < 0)
478 continue;
479 /* Strip zero flag because of the nonzero dithering offset */
481 out[i].min = ff_add_q64(out[i].min, op->dither.min);
482 out[i].max = ff_add_q64(out[i].max, op->dither.max);
483 }
484 break;
485 case SWS_OP_UNPACK:
486 for (int i = 0; i < 4; i++) {
487 const int pattern = op->pack.pattern[i];
488 if (pattern) {
489 av_assert1(pattern < 32);
491 out[i].min = Q(0);
492 out[i].max = Q((1ULL << pattern) - 1);
493 } else
494 RESET(i);
495 }
496 break;
497 case SWS_OP_PACK:
498 for (int i = 0; i < 4; i++) {
499 if (op->pack.pattern[i])
501 if (i > 0) /* clear remaining pads for sanity */
502 RESET(i);
503 }
504 break;
505 case SWS_OP_CLEAR:
506 for (int i = 0; i < 4; i++) {
507 if (SWS_COMP_TEST(op->clear.mask, i)) {
508 out[i].type = op->clear.type[i];
509 out[i].flags = SWS_COMP_CONST;
510 if (op->clear.value[i].num == 0)
511 out[i].flags |= SWS_COMP_ZERO;
512 if (op->clear.value[i].den == 1)
513 out[i].flags |= SWS_COMP_EXACT;
514 } else {
515 FORWARD(i, i, flags);
516 }
517 }
518 break;
519 case SWS_OP_SWIZZLE:
520 for (int i = 0; i < 4; i++)
521 FORWARD(i, op->swizzle.in[i], flags);
522 break;
523 case SWS_OP_CONVERT:
524 for (int i = 0; i < 4; i++) {
525 FORWARD(i, i, flags);
526 out[i].type = op->convert.to;
527 if (!(in[i].flags & SWS_COMP_EXACT))
528 out[i].flags &= SWS_COMP_DIRTY;
529 if (ff_sws_pixel_type_is_int(op->convert.to))
530 out[i].flags |= SWS_COMP_EXACT;
531 }
532 break;
533 case SWS_OP_LINEAR:
534 for (int i = 0; i < 4; i++) {
535 SwsOpPad *dst = &out[i];
536 bool first = true;
537 dst->type = op->lin.type[i];
538 dst->min = dst->max = Q(0);
539 for (int j = 0; j < 4; j++) {
540 const SwsOpPad *src = &in[j];
541 const AVRational64 k = op->lin.m[i][j];
542 AVRational64 mink = ff_mul_q64(src->min, k);
543 AVRational64 maxk = ff_mul_q64(src->max, k);
544 if (!k.num)
545 continue;
546 FORWARD(i, j, flags);
547 if (k.den != 1) /* fractional coefficient */
548 dst->flags &= ~SWS_COMP_EXACT;
549 if (k.num < 0)
550 FFSWAP(AVRational64, mink, maxk);
551 dst->min = ff_add_q64(dst->min, mink);
552 dst->max = ff_add_q64(dst->max, maxk);
553 if (!first || ff_cmp_q64(k, Q(1)))
554 dst->flags &= SWS_COMP_DIRTY;
555 first = false;
556 }
557 if (op->lin.m[i][4].num) { /* nonzero offset */
559 if (op->lin.m[i][4].den != 1) /* fractional offset */
560 dst->flags &= ~SWS_COMP_EXACT;
561 dst->min = ff_add_q64(dst->min, op->lin.m[i][4]);
562 dst->max = ff_add_q64(dst->max, op->lin.m[i][4]);
563 }
564 }
565 break;
566 case SWS_OP_SCALE:
567 for (int i = 0; i < 4; i++) {
569 if (op->scale.factor.den != 1) /* fractional scale */
570 out[i].flags &= ~SWS_COMP_EXACT;
571 if (op->scale.factor.num < 0)
573 }
574 break;
575 case SWS_OP_FILTER_H:
576 case SWS_OP_FILTER_V: {
577 for (int i = 0; i < 4; i++) {
579 apply_filter_weights(&out[i], op->filter.kernel);
580 out[i].type = op->filter.type;
581 }
582 break;
583 }
584 case SWS_OP_LUT_3D:
585 for (int i = 0; i < 3; i++) {
586 /* 3x3 dependency matrix; strip all information */
587 for (int j = 0; j < 3; j++)
588 FORWARD(i, j, flags & 0);
589 /* LUT output domain is always scaled to full 16-bit range */
590 out[i].min = Q(0);
591 out[i].max = Q(UINT16_MAX);
592 }
593 /* Pass through alpha channel untouched */
594 FORWARD(3, 3, flags);
595 out[3].min = in[3].min;
596 out[3].max = in[3].max;
597 break;
598 case SWS_OP_INVALID:
599 case SWS_OP_TYPE_NB:
600 av_unreachable("Invalid operation type!");
601 }
602
603 for (int i = 0; i < 4; i++) {
604 if (!out[i].type || SWS_COMP_TEST(invalid, i))
605 RESET(i);
606 }
607
608#undef FORWARD
609#undef RESET
610}
611
612static void update_input_pads(SwsOpList *ops, SwsOp *op, SwsCompMask need_out[4])
613{
614 SwsCompMask need_in[4] = {0};
615
616 for (int i = 0; i < 4; i++)
617 op->outputs[i].dep_out = need_out[i];
618
619 switch (op->op) {
620 case SWS_OP_READ:
621 case SWS_OP_WRITE:
622 for (int i = 0; i < op->rw.elems; i++)
623 need_in[i] = (op->op == SWS_OP_WRITE) ? SWS_COMP(i) : 0;
624 for (int i = op->rw.elems; i < 4; i++)
625 need_in[i] = need_out[i];
626 break;
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 for (int i = 0; i < 4; i++)
638 need_in[i] = need_out[i];
639 break;
640 case SWS_OP_UNPACK:
641 for (int i = 0; i < 4 && op->pack.pattern[i]; i++)
642 need_in[0] |= need_out[i];
643 break;
644 case SWS_OP_PACK:
645 for (int i = 0; i < 4 && op->pack.pattern[i]; i++)
646 need_in[i] = need_out[0];
647 break;
648 case SWS_OP_CLEAR:
649 for (int i = 0; i < 4; i++) {
650 if (!SWS_COMP_TEST(op->clear.mask, i))
651 need_in[i] = need_out[i];
652 }
653 break;
654 case SWS_OP_SWIZZLE:
655 for (int i = 0; i < 4; i++)
656 need_in[op->swizzle.in[i]] |= need_out[i];
657 break;
658 case SWS_OP_LINEAR:
659 for (int i = 0; i < 4; i++) {
660 for (int j = 0; j < 4; j++) {
661 if (op->lin.m[i][j].num)
662 need_in[j] |= need_out[i];
663 }
664 }
665 break;
666 case SWS_OP_LUT_3D:
667 for (int i = 0; i < 3; i++)
668 need_in[i] = need_out[0] | need_out[1] | need_out[2];
669 need_in[3] = need_out[3];
670 break;
671 }
672
673 memcpy(need_out, need_in, sizeof(need_in));
674}
675
676/* Infer + propagate output pad metadata */
678{
679 /* Forward pass, solves for output pad metadata */
680 for (int n = 0; n < ops->num_ops; n++)
681 update_output_pads(ops, &ops->ops[n]);
682
683 /* Backwards pass, solves for output component dependencies */
684 SwsCompMask need_out[4] = {0};
685 for (int n = ops->num_ops - 1; n >= 0; n--)
686 update_input_pads(ops, &ops->ops[n], need_out);
687}
688
689static void op_ref(SwsOp *op)
690{
691 switch (op->op) {
692 case SWS_OP_READ:
693 if (op->rw.filter.kernel)
694 av_refstruct_ref(op->rw.filter.kernel);
695 break;
696 case SWS_OP_DITHER:
697 av_refstruct_ref(op->dither.matrix);
698 break;
699 case SWS_OP_FILTER_H:
700 case SWS_OP_FILTER_V:
701 av_refstruct_ref(op->filter.kernel);
702 break;
703 case SWS_OP_LUT_3D:
704 av_refstruct_ref_c(op->lut3d.lut);
705 break;
706 }
707}
708
709static void op_unref(SwsOp *op)
710{
711 switch (op->op) {
712 case SWS_OP_READ:
713 av_refstruct_unref(&op->rw.filter.kernel);
714 break;
715 case SWS_OP_DITHER:
716 av_refstruct_unref(&op->dither.matrix);
717 break;
718 case SWS_OP_FILTER_H:
719 case SWS_OP_FILTER_V:
720 av_refstruct_unref(&op->filter.kernel);
721 break;
722 case SWS_OP_LUT_3D:
723 av_refstruct_unref(&op->lut3d.lut);
724 break;
725 }
726
727 *op = (SwsOp) {0};
728}
729
731{
732 SwsOpList *ops = av_mallocz(sizeof(SwsOpList));
733 if (!ops)
734 return NULL;
735
736 for (int i = 0; i < 4; i++)
737 ops->plane_src[i] = ops->plane_dst[i] = i;
738 ff_fmt_clear(&ops->src);
739 ff_fmt_clear(&ops->dst);
740 return ops;
741}
742
744{
745 SwsOpList *ops = *p_ops;
746 if (!ops)
747 return;
748
749 for (int i = 0; i < ops->num_ops; i++)
750 op_unref(&ops->ops[i]);
751
752 av_freep(&ops->ops);
753 av_free(ops);
754 *p_ops = NULL;
755}
756
758{
759 SwsOpList *copy = av_malloc(sizeof(*copy));
760 if (!copy)
761 return NULL;
762
763 int num = ops->num_ops;
764 if (num)
765 num = 1 << av_ceil_log2(num);
766
767 *copy = *ops;
768 copy->ops = av_memdup(ops->ops, num * sizeof(ops->ops[0]));
769 if (!copy->ops) {
770 av_free(copy);
771 return NULL;
772 }
773
774 for (int i = 0; i < copy->num_ops; i++) {
775 op_ref(&copy->ops[i]);
776 copy->ops[i].ops = copy;
777 }
778
779 return copy;
780}
781
783{
784 if (!ops->num_ops)
785 return NULL;
786
787 const SwsOp *read = &ops->ops[0];
788 return read->op == SWS_OP_READ ? read : NULL;
789}
790
792{
793 if (!ops->num_ops)
794 return NULL;
795
796 const SwsOp *write = &ops->ops[ops->num_ops - 1];
797 return write->op == SWS_OP_WRITE ? write : NULL;
798}
799
800void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
801{
802 const int end = ops->num_ops - count;
803 av_assert2(index >= 0 && count >= 0 && index + count <= ops->num_ops);
804 for (int i = 0; i < count; i++)
805 op_unref(&ops->ops[index + i]);
806 for (int i = index; i < end; i++)
807 ops->ops[i] = ops->ops[i + count];
808 ops->num_ops = end;
809}
810
812{
813 void *ret = av_dynarray2_add((void **) &ops->ops, &ops->num_ops, sizeof(*op), NULL);
814 if (!ret) {
815 op_unref(op);
816 return AVERROR(ENOMEM);
817 }
818
819 for (int i = ops->num_ops - 1; i > index; i--)
820 ops->ops[i] = ops->ops[i - 1];
821 ops->ops[index] = *op;
822 ops->ops[index].ops = ops;
823 return 0;
824}
825
827{
828 return ff_sws_op_list_insert_at(ops, ops->num_ops, op);
829}
830
832{
833 if (!ops->num_ops)
834 return true;
835
836 const SwsOp *read = ff_sws_op_list_input(ops);
837 const SwsOp *write = ff_sws_op_list_output(ops);
838 if (!read || !write || ops->num_ops > 2 ||
839 read->rw.type != write->rw.type ||
840 read->rw.mode != write->rw.mode ||
841 read->rw.elems != write->rw.elems ||
842 read->rw.frac != write->rw.frac ||
843 read->rw.filter.op || write->rw.filter.op)
844 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 const int num_planes = ff_sws_rw_op_planes(read);
853 for (int i = 0; i < num_planes; i++) {
854 if (ops->plane_src[i] != ops->plane_dst[i])
855 return false;
856 }
857
858 return true;
859}
860
862{
863 uint32_t mask = 0;
864 for (int i = 0; i < 4; i++) {
865 for (int j = 0; j < 5; j++) {
866 if (ff_cmp_q64(c->m[i][j], Q(i == j)))
867 mask |= SWS_MASK(i, j);
868 }
869 }
870 return mask;
871}
872
874{
875 if (flags & SWS_COMP_ZERO)
876 return "zero";
877 else if (flags & SWS_COMP_SWAPPED)
878 return "swapped";
879 else if (flags & SWS_COMP_CONST)
880 return "const";
881 else if (flags & SWS_COMP_COPY)
882 return "copy";
883 else if (flags & SWS_COMP_EXACT)
884 return "exact";
885 else
886 return "normal";
887}
888
889static void print_deps(AVBPrint *bp, SwsCompMask dep)
890{
891 av_bprintf(bp, " {%c%c%c%c}",
892 SWS_COMP_TEST(dep, 0) ? 'x' : ' ',
893 SWS_COMP_TEST(dep, 1) ? 'y' : ' ',
894 SWS_COMP_TEST(dep, 2) ? 'z' : ' ',
895 SWS_COMP_TEST(dep, 3) ? 'w' : ' ');
896}
897
898static void print_q(AVBPrint *bp, const AVRational64 q)
899{
900 if (!q.den) {
901 av_bprintf(bp, "%s", q.num > 0 ? "inf" : q.num < 0 ? "-inf" : "nan");
902 } else if (q.den == 1) {
903 av_bprintf(bp, "%"PRId64, q.num);
904 } else if (q.num > 1000 || q.num < -1000 || q.den > 1000 || q.den < -1000) {
905 av_bprintf(bp, "%f", ff_q2d_64(q));
906 } else {
907 av_bprintf(bp, "%"PRId64"/%"PRId64, q.num, q.den);
908 }
909}
910
911static void print_q4(AVBPrint *bp, const AVRational64 q4[4], SwsCompMask mask)
912{
913 av_bprintf(bp, "{");
914 for (int i = 0; i < 4; i++) {
915 if (i)
916 av_bprintf(bp, " ");
917 if (!SWS_COMP_TEST(mask, i)) {
918 av_bprintf(bp, "_");
919 } else {
920 print_q(bp, q4[i]);
921 }
922 }
923 av_bprintf(bp, "}");
924}
925
926static const char *const rw_mode_names[] = {
927 [SWS_RW_PLANAR] = "planar",
928 [SWS_RW_PACKED] = "packed",
929 [SWS_RW_PALETTE] = "palette"
930};
931
932void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
933{
934 const char *name = ff_sws_op_type_name(op->op);
936
937 switch (op->op) {
938 case SWS_OP_INVALID:
940 av_bprintf(bp, "%s", name);
941 break;
942 case SWS_OP_READ:
943 case SWS_OP_WRITE:
944 av_bprintf(bp, "%-20s: %dx %s %s >> %d", name,
945 op->rw.elems, ff_sws_pixel_type_name(op->rw.type),
946 rw_mode_names[op->rw.mode], op->rw.frac);
947 if (!op->rw.filter.op)
948 break;
949 const SwsFilterWeights *kernel = op->rw.filter.kernel;
950 av_bprintf(bp, " + %d tap %s filter (%c)",
951 kernel->filter_size, ff_sws_scaler_name(kernel->scaler),
952 op->rw.filter.op == SWS_OP_FILTER_H ? 'H' : 'V');
953 break;
954 case SWS_OP_LSHIFT:
955 av_bprintf(bp, "%-20s: << %u", name, op->shift.amount);
956 break;
957 case SWS_OP_RSHIFT:
958 av_bprintf(bp, "%-20s: >> %u", name, op->shift.amount);
959 break;
960 case SWS_OP_PACK:
961 case SWS_OP_UNPACK:
962 av_bprintf(bp, "%-20s: {%d %d %d %d}", name,
963 op->pack.pattern[0], op->pack.pattern[1],
964 op->pack.pattern[2], op->pack.pattern[3]);
965 break;
966 case SWS_OP_CLEAR:
967 av_bprintf(bp, "%-20s: ", name);
968 print_q4(bp, op->clear.value, mask & op->clear.mask);
969 break;
970 case SWS_OP_SWIZZLE:
971 av_bprintf(bp, "%-20s: %d%d%d%d", name,
972 op->swizzle.x, op->swizzle.y, op->swizzle.z, op->swizzle.w);
973 break;
974 case SWS_OP_CONVERT:
975 av_bprintf(bp, "%-20s: %s -> %s", name,
977 ff_sws_pixel_type_name(op->convert.to));
978 break;
979 case SWS_OP_DITHER:
980 av_bprintf(bp, "%-20s: %dx%d matrix + {%d %d %d %d}", name,
981 1 << op->dither.size_log2, 1 << op->dither.size_log2,
982 op->dither.y_offset[0], op->dither.y_offset[1],
983 op->dither.y_offset[2], op->dither.y_offset[3]);
984 break;
985 case SWS_OP_MIN:
986 av_bprintf(bp, "%-20s: x <= ", name);
987 print_q4(bp, op->clamp.limit, mask & ff_sws_comp_mask_q4(op->clamp.limit));
988 break;
989 case SWS_OP_MAX:
990 av_bprintf(bp, "%-20s: ", name);
991 print_q4(bp, op->clamp.limit, mask & ff_sws_comp_mask_q4(op->clamp.limit));
992 av_bprintf(bp, " <= x");
993 break;
994 case SWS_OP_LINEAR:
995 av_bprintf(bp, "%-20s: [", name);
996 for (int i = 0; i < 4; i++) {
997 av_bprintf(bp, "%s[", i ? " " : "");
998 for (int j = 0; j < 5; j++) {
999 av_bprintf(bp, j ? " " : "");
1000 print_q(bp, op->lin.m[i][j]);
1001 }
1002 av_bprintf(bp, "]");
1003 }
1004 av_bprintf(bp, "]");
1005 break;
1006 case SWS_OP_SCALE:
1007 av_bprintf(bp, "%-20s: * %"PRId64, name, op->scale.factor.num);
1008 if (op->scale.factor.den != 1)
1009 av_bprintf(bp, "/%"PRId64, op->scale.factor.den);
1010 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 ff_sws_scaler_name(kernel->scaler), 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}
1026
1027static void desc_plane_order(AVBPrint *bp, int nb_planes, const uint8_t *order)
1028{
1029 bool inorder = true;
1030 for (int i = 0; i < nb_planes; i++)
1031 inorder &= order[i] == i;
1032 if (inorder)
1033 return;
1034
1035 av_bprintf(bp, ", via {");
1036 for (int i = 0; i < nb_planes; i++)
1037 av_bprintf(bp, "%s%d", i ? ", " : "", order[i]);
1038 av_bprintf(bp, "}");
1039}
1040
1041void ff_sws_op_list_print(void *log, int lev, int lev_extra,
1042 const SwsOpList *ops)
1043{
1044 AVBPrint bpc, *bp = &bpc;
1045 if (av_log_get_level() < lev)
1046 return;
1047
1048 if (!ops->num_ops) {
1049 av_log(log, lev, " (empty)\n");
1050 return;
1051 }
1052
1054 lev_extra = FFMAX(lev_extra, lev);
1055
1056 for (int n = 0; n < ops->num_ops; n++) {
1057 const SwsOp *op = &ops->ops[n];
1059 av_bprint_clear(bp);
1060 av_bprintf(bp, " ");
1061 ff_sws_op_desc(bp, op);
1062 if (op->op == SWS_OP_READ || op->op == SWS_OP_WRITE) {
1063 const int planes = ff_sws_rw_op_planes(op);
1065 op->op == SWS_OP_READ ? ops->plane_src : ops->plane_dst);
1066 }
1067
1069 av_log(log, lev, "%s\n", bp->str);
1070
1071 for (int i = 0; i < 4; i++) {
1072 const SwsOpPad *pad = &op->outputs[i];
1073 if (!SWS_COMP_TEST(mask, i))
1074 continue;
1075 av_bprint_clear(bp);
1076 av_bprintf(bp, " %c: %3s,", "XYZW"[i], ff_sws_pixel_type_name(pad->type));
1077 print_deps(bp, pad->dep_in);
1078 av_bprintf(bp, " ->");
1079 print_deps(bp, pad->dep_out);
1080 av_bprintf(bp, " %7s", describe_comp_flags(pad->flags));
1081
1082 if (pad->min.den || pad->max.den) {
1083 if (pad->flags & SWS_COMP_ZERO) {
1084 /* don't print any value */
1085 } else if (pad->flags & SWS_COMP_CONST) {
1086 av_bprintf(bp, " = ");
1087 av_assert1(ff_cmp_q64(pad->min, pad->max) == 0);
1088 print_q(bp, pad->min);
1089 } else {
1090 av_bprintf(bp, " in [");
1091 print_q(bp, pad->min);
1092 av_bprintf(bp, ", ");
1093 print_q(bp, pad->max);
1094 av_bprintf(bp, "]");
1095 }
1096 }
1097
1099 av_log(log, lev_extra, "%s\n", bp->str);
1100 }
1101 }
1102}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
const SwsOpBackend backend_aarch64
Definition ops.c:252
static double val(void *priv, double ch)
Definition aeval.c:77
static double bound(const double threshold, const double val)
static FILE * out
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition avassert.h:68
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition bprint.c:121
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition bprint.c:68
AVBPrint public header.
#define AV_BPRINT_SIZE_AUTOMATIC
byte swapping routines
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static LevelCodes lev[4+3+3]
Definition clearvideo.c:80
#define av_ceil_log2
Definition common.h:97
#define NULL
Definition coverity.c:32
#define min(a, b)
#define max(a, b)
int ret
Definition ffplay.c:391
static int dummy
Definition ffplay.c:4429
#define print_q(k, v, s)
Definition ffprobe.c:489
const char * ff_sws_scaler_name(SwsScaler scaler)
Return the friendly name of a given scaler enum, or NULL if invalid.
Definition filters.c:510
static void ff_fmt_clear(SwsFormat *fmt)
Definition format.h:94
AVRational64 ff_mul_q64(AVRational64 b, AVRational64 c)
Multiply two 64-bit rationals.
Definition rational64.c:208
static AVRational64 ff_make_q64(int64_t num, int64_t den)
Create an AVRational64.
Definition rational64.h:64
static double ff_q2d_64(AVRational64 a)
Convert an AVRational64 to a double.
Definition rational64.h:90
AVRational64 ff_add_q64(AVRational64 b, AVRational64 c)
Add two 64-bit rationals.
Definition rational64.c:222
int ff_cmp_q64(AVRational64 a, AVRational64 b)
Compare two 64-bit rationals.
Definition rational64.c:185
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition bprint.h:218
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition bprint.c:226
#define AVERROR(e)
Definition error.h:45
int av_log_get_level(void)
Get the current log level.
Definition log.c:477
void * av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
Add an element of size elem_size to a dynamic array.
Definition mem.c:447
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition mem.c:408
int index
Definition gxfenc.c:90
int a
static const int weights[]
Definition hevc_pel.c:32
#define Q(q)
#define b
Definition input.c:43
enum MPFType type
Definition jpegmpfenc.c:55
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition anm.c:76
static int shift(int a, int b)
Definition bonk.c:261
static int16_t mult(Float11 *f1, Float11 *f2)
Definition g726.c:60
Macro definitions for various function/variable attributes.
@ SWS_FILTER_SCALE
14-bit coefficients are picked to fit comfortably within int16_t for efficient SIMD processing (e....
Definition filters.h:40
static const struct @257111027162314367033347246032313251342043035002 planes[]
static const uint16_t mask[17]
Definition lzw.c:38
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
Describe an operation in human-readable form.
Definition ops.c:932
const SwsOpBackend backend_c
Copyright (C) 2025 Niklas Haas.
SwsPixelType ff_sws_op_output_type(const SwsOp *op)
Definition ops.c:171
const SwsOp * ff_sws_op_next(const SwsOp *op)
Definition ops.c:162
uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
Definition ops.c:861
static void update_output_pads(SwsOpList *ops, SwsOp *op)
Definition ops.c:345
static void print_q4(AVBPrint *bp, const AVRational64 q4[4], SwsCompMask mask)
Definition ops.c:911
static void desc_plane_order(AVBPrint *bp, int nb_planes, const uint8_t *order)
Definition ops.c:1027
int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
Definition ops.c:811
static void op_ref(SwsOp *op)
Definition ops.c:689
static void update_input_pads(SwsOpList *ops, SwsOp *op, SwsCompMask need_out[4])
Definition ops.c:612
const SwsOpBackend backend_x86
Definition ops.c:736
const SwsOp * ff_sws_op_list_input(const SwsOpList *ops)
Returns the input operation for a given op list, or NULL if there is none (e.g.
Definition ops.c:782
void ff_sws_op_list_free(SwsOpList **p_ops)
Definition ops.c:743
const SwsOpBackend *const ff_sws_op_backends[]
Definition ops.c:42
static const char * describe_comp_flags(SwsCompFlags flags)
Definition ops.c:873
static AVRational64 av_min_q64(AVRational64 a, AVRational64 b)
Definition ops.c:192
const SwsOpBackend backend_murder
Definition ops_memcpy.c:162
void ff_sws_op_list_update(SwsOpList *ops)
Infer + propagate known information about components.
Definition ops.c:677
int ff_sws_op_list_append(SwsOpList *ops, SwsOp *op)
These will take over ownership of op and set it to {0}, even on failure.
Definition ops.c:826
void ff_sws_comp_mask_swizzle(SwsCompMask *mask, const SwsSwizzleOp *swiz)
Definition ops.c:110
SwsOpList * ff_sws_op_list_alloc(void)
Definition ops.c:730
#define FORWARD(I, J, EXPR)
static void print_deps(AVBPrint *bp, SwsCompMask dep)
Definition ops.c:889
const char * ff_sws_op_type_name(SwsOpType op)
Definition ops.c:71
@ SWS_COMP_IDENTITY
Definition ops.c:316
@ SWS_COMP_DIRTY
Definition ops.c:319
static AVRational64 av_max_q64(AVRational64 a, AVRational64 b)
Definition ops.c:197
SwsPixelType ff_sws_op_input_type(const SwsOp *op)
Return the input/output type of an operation, if all inputs/outputs are the same type,...
Definition ops.c:186
SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
Definition ops.c:123
const char * ff_sws_pixel_type_name(SwsPixelType type)
Definition ops.c:56
static SwsCompFlags merge_comp_flags(SwsCompFlags a, SwsCompFlags b)
Definition ops.c:323
SwsCompMask ff_sws_comp_mask_q4(const AVRational64 q[4])
Definition ops.c:100
#define RESET(I)
int ff_sws_rw_op_planes(const SwsOp *op)
Return the number of planes involved in a read/write operation.
Definition ops.c:133
const SwsOp * ff_sws_op_list_output(const SwsOpList *ops)
Returns the output operation for a given op list, or NULL if there is none.
Definition ops.c:791
bool ff_sws_op_list_is_noop(const SwsOpList *ops)
Returns whether an op list represents a true no-op operation, i.e.
Definition ops.c:831
const SwsOp * ff_sws_op_prev(const SwsOp *op)
Return the previous/next operation in the list, or NULL if there is none.
Definition ops.c:153
void ff_sws_op_list_print(void *log, int lev, int lev_extra, const SwsOpList *ops)
Print out the contents of an operation list.
Definition ops.c:1041
static const char *const rw_mode_names[]
Definition ops.c:926
void ff_sws_apply_op_q(const SwsOp *op, AVRational64 x[4])
Apply an operation to an AVRational64.
Definition ops.c:202
static int op_index(const SwsOp *op)
Definition ops.c:146
void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
Definition ops.c:800
static void apply_filter_weights(SwsOpPad *pad, const SwsFilterWeights *weights)
Definition ops.c:330
SwsOpList * ff_sws_op_list_duplicate(const SwsOpList *ops)
Returns a duplicate of ops, or NULL on OOM.
Definition ops.c:757
static void op_unref(SwsOp *op)
Definition ops.c:709
SwsOpType
Copyright (C) 2025 Niklas Haas.
Definition ops.h:36
@ SWS_OP_TYPE_NB
Definition ops.h:69
@ SWS_OP_INVALID
Definition ops.h:37
@ SWS_OP_RSHIFT
Definition ops.h:49
@ SWS_OP_SWIZZLE
Definition ops.h:43
@ SWS_OP_LSHIFT
Definition ops.h:48
@ SWS_OP_FILTER_V
Definition ops.h:64
@ SWS_OP_SCALE
Definition ops.h:56
@ SWS_OP_FILTER_H
Definition ops.h:63
@ SWS_OP_WRITE
Definition ops.h:41
@ SWS_OP_READ
Definition ops.h:40
@ SWS_OP_CLEAR
Definition ops.h:52
@ SWS_OP_SWAP_BYTES
Definition ops.h:42
@ SWS_OP_MIN
Definition ops.h:54
@ SWS_OP_UNPACK
Definition ops.h:46
@ SWS_OP_LINEAR
Definition ops.h:57
@ SWS_OP_PACK
Definition ops.h:47
@ SWS_OP_DITHER
Definition ops.h:60
@ SWS_OP_MAX
Definition ops.h:55
@ SWS_OP_LUT_3D
Definition ops.h:67
@ SWS_OP_CONVERT
Definition ops.h:53
@ SWS_RW_PALETTE
Definition ops.h:89
@ SWS_RW_PLANAR
Note: 1-component reads are either SWS_RW_PLANAR or SWS_RW_PACKED, depending on the underlying interp...
Definition ops.h:87
@ SWS_RW_PACKED
Definition ops.h:88
SwsCompFlags
Definition ops.h:229
@ SWS_COMP_CONST
Definition ops.h:234
@ SWS_COMP_ZERO
Definition ops.h:231
@ SWS_COMP_EXACT
Definition ops.h:230
@ SWS_COMP_SWAPPED
Definition ops.h:232
@ SWS_COMP_COPY
Definition ops.h:233
#define SWS_OP_NEEDED(op, idx)
Definition ops.h:282
static void ff_sws_pack_decode(const uint8_t pattern[4], uint64_t mask[4], int shift[4])
#define av_malloc(s)
Definition ops_static.c:52
const char * name
Definition qsvenc.c:142
Utilities for rational number calculation.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition refstruct.c:121
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
Definition refstruct.c:150
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
Definition refstruct.c:141
#define av_bswap32
Definition bswap.h:47
#define av_bswap16
Definition bswap.h:28
64-bit Rational number (pair of numerator and denominator).
Definition rational64.h:52
int64_t num
Numerator.
Definition rational64.h:53
int64_t den
Denominator.
Definition rational64.h:54
Represents a computed filter kernel.
Definition filters.h:91
SwsScaler scaler
Copy of the parameters used to generate this filter, for reference.
Definition filters.h:116
int filter_size
The number of source texels to convolve over for each row.
Definition filters.h:95
Helper struct for representing a list of operations.
Definition ops.h:318
SwsFormat dst
Definition ops.h:323
uint8_t plane_src[4]
Definition ops.h:326
uint8_t plane_dst[4]
Definition ops.h:326
SwsOp * ops
Definition ops.h:319
SwsOpPad inputs[4]
Source component metadata associated with pixel values from each corresponding component (in plane/me...
Definition ops.h:337
int num_ops
Definition ops.h:320
SwsFormat src
Definition ops.h:323
SwsCompMask dep_in
Definition ops.h:246
SwsCompFlags flags
Definition ops.h:239
AVRational64 min
Definition ops.h:243
AVRational64 max
Definition ops.h:243
SwsCompMask dep_out
Definition ops.h:246
SwsPixelType type
Definition ops.h:238
Definition ops.h:252
SwsOpType op
Definition ops.h:253
SwsReadWriteOp rw
Definition ops.h:256
SwsOpPad outputs[4]
Metadata about the operation's input/output components.
Definition ops.h:276
SwsOpList * ops
Definition ops.h:279
SwsReadWriteMode mode
Definition ops.h:103
SwsPixelType type
Examples: rgba = 4x u8 packed yuv444p = 3x u8 rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack monow = ...
Definition ops.h:102
SwsOpType op
Definition ops.h:115
uint8_t frac
Definition ops.h:105
uint8_t elems
Definition ops.h:104
struct SwsReadWriteOp::@312356277033155231251141106170064356360153154105 filter
Filter kernel to apply to each plane while sampling.
uint8_t in[4]
Definition ops.h:136
#define av_free(p)
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
int num
Definition error.c:23
@ SWS_COMP_NONE
Definition uops.h:131
SwsPixelType
Definition uops.h:40
@ SWS_PIXEL_F32
Definition uops.h:45
@ SWS_PIXEL_U32
Definition uops.h:44
@ SWS_PIXEL_U16
Definition uops.h:43
@ SWS_PIXEL_TYPE_NB
Definition uops.h:46
@ SWS_PIXEL_NONE
Definition uops.h:41
@ SWS_PIXEL_U8
Definition uops.h:42
#define SWS_COMP(X)
Definition uops.h:133
#define SWS_COMP_TEST(mask, X)
Definition uops.h:134
#define SWS_MASK(I, J)
Definition uops.h:275
static av_const bool ff_sws_pixel_type_is_int(SwsPixelType type)
Definition uops.h:64
uint8_t SwsCompMask
Bit-mask of components.
Definition uops.h:129
static void copy(const float *p1, float *p2, const int length)
static double c[64]
const SwsOpBackend backend_spirv
Definition ops.c:1331