33 if (
a->type !=
b->type)
34 return (
int)
a->type -
b->type;
36 return (
int)
a->uop -
b->uop;
37 if (
a->mask !=
b->mask)
38 return (
int)
a->mask -
b->mask;
39 return memcmp(&
a->par, &
b->par,
sizeof(
a->par));
45#define UOP_NAME(OP, ABBR) [OP] = { ABBR },
66#define Q2PIXEL(val) pixel_from_q64(op->type, val)
71 case 1:
return val.u8 == UINT8_MAX;
72 case 2:
return val.u16 == UINT16_MAX;
73 case 4:
return val.u32 == UINT32_MAX;
125 for (
int i = 0;
i < 4;
i++) {
138 for (
int i = 0;
i < 4;
i++) {
142 for (
int j = 0; j < 5; j++) {
155 for (
int i = 0;
i < 4;
i++) {
211 sizeof(*uop), (uint8_t *) uop))
223 const int end = uops->
num_ops - count;
225 for (
int i = 0;
i < count;
i++)
228 uops->
ops[
i] = uops->
ops[
i + count];
235 for (
int i = 0;
i < 4;
i++)
237 return (1 <<
dither->size_log2) + max_offset;
255 volatile float prod =
a *
b;
256 volatile float result =
b ? prod /
b : 0.0f;
257 return !
b || result ==
a;
267 else if (!minq.
den || !maxq.
den)
292 const uint64_t max_val = UINT64_MAX >> (64 -
bits);
306 op->rw.elems > 2,
op->rw.elems > 3),
310 if (!
op->rw.filter.op)
314 if (
op->rw.filter.op) {
331 if (
op->rw.frac || !is_read)
334 }
else if (
op->rw.frac == 3) {
336 }
else if (
op->rw.frac == 1) {
356 for (
size_t i = 0;
i <
size;
i++) {
375 for (
int i = 0;
i < 4;
i++) {
376 if (
op->swizzle.in[
i] ==
i)
382 for (
int i = 0;
i < 4;
i++) {
388 int idx[4 + 1] = { 0, 1, 2, 3, -1 };
398 const int cur = idx[
dst];
402 if (idx[
src] ==
op->swizzle.in[
dst]) {
435 for (
int i = 0;
i < 4;
i++) {
449 for (
int i = 0;
i < 4;
i++) {
451 if (!(seen &
bit) && idx[
i] ==
i)
463 .par.dither.size_log2 =
op->dither.size_log2,
466 if (
op->dither.size_log2 == 0) {
470 for (
int i = 0;
i < 4;
i++) {
480 const int size = 1 <<
op->dither.size_log2;
481 for (
int i = 0;
i < 4;
i++) {
484 const uint8_t off =
op->dither.y_offset[
i] & (
size - 1);
519 for (
int i = 0;
i < 4;
i++) {
525 bool nonzero = (
op->lin.m[
i][4].num != 0);
526 for (
int j = 0; j < 5; j++) {
532 else if (j < 4 && k.
num == k.
den)
534 else if (j < 4 && nonzero && (!bitexact ||
exact_prod(uop.
type, px, input, j)))
597 if (
op->convert.expand) {
599 switch (
op->convert.to) {
604 switch (
op->convert.to) {
616 for (
int i = 0;
i < 4 &&
op->pack.pattern[
i];
i++) {
630 uop.
mask &=
op->clear.mask;
631 for (
int i = 0;
i < 4;
i++) {
655 for (
int i = 0;
i < 4;
i++) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
static AVFormatContext * ctx
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.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define bit(string, value)
static const uint8_t bits[8]
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
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.
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.
static const int factor[16]
@ SWS_FILTER_SCALE
14-bit coefficients are picked to fit comfortably within int16_t for efficient SIMD processing (e....
static const struct @257111027162314367033347246032313251342043035002 planes[]
static const uint16_t mask[17]
Memory handling functions.
uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
const char * ff_sws_pixel_type_name(SwsPixelType type)
SwsCompMask ff_sws_comp_mask_q4(const AVRational64 q[4])
int ff_sws_rw_op_planes(const SwsOp *op)
Return the number of planes involved in a read/write operation.
@ SWS_RW_PLANAR
Note: 1-component reads are either SWS_RW_PLANAR or SWS_RW_PACKED, depending on the underlying interp...
#define SWS_OP_NEEDED(op, idx)
int ff_sws_uop_list_optimize(SwsContext *ctx, SwsUOpFlags flags, SwsUOpList *uops)
Called internally by ff_sws_ops_translate().
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
#define FF_ARRAY_ELEMS(a)
64-bit Rational number (pair of numerator and denominator).
Main external API structure.
int8_t src[SWS_UOP_MOVE_MAX]
int8_t dst[SWS_UOP_MOVE_MAX]
Helper struct for representing a list of operations.
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
SwsComps comps
Metadata about the operation's input/output components.
SwsFilterWeights * kernel
union SwsUOp::@242237116251216327057105100216205033300341206345 data
int ff_sws_ops_translate(SwsContext *ctx, const SwsOpList *ops, SwsUOpFlags flags, SwsUOpList *uops)
Translate a list of operations down to micro-ops, which can be further optimized and then directly ex...
int ff_sws_dither_height(const SwsDitherUOp *dither)
Computes (1 << size_log2) + MAX(y_offset).
static bool check_filter_fma(SwsContext *ctx, SwsUOpFlags flags, const SwsOp *op)
static void uop_uninit(SwsUOp *uop)
int ff_sws_uop_list_append(SwsUOpList *uops, SwsUOp *uop)
static SwsPixel pixel_from_q64(SwsPixelType type, AVRational64 val)
#define UOP_NAME(OP, ABBR)
static bool exact_prod(SwsPixelType type, SwsPixel coef, const SwsComps *comps, int idx)
void ff_sws_uop_name(const SwsUOp *op, char buf[SWS_UOP_NAME_MAX])
static int translate_linear_op(SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
int ff_sws_uop_cmp(const SwsUOp *a, const SwsUOp *b)
Copyright (C) 2026 Niklas Haas.
static bool pixel_is_1s(SwsPixelType type, SwsPixel val)
static int translate_dither_op(SwsUOpList *ops, const SwsOp *op)
SwsUOpList * ff_sws_uop_list_alloc(void)
void ff_sws_uop_list_free(SwsUOpList **p_ops)
static int translate_swizzle(SwsUOpList *ops, const SwsOp *op)
static int translate_rw_op(SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op)
void ff_sws_uop_list_remove_at(SwsUOpList *uops, int index, int count)
static int translate_op(SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
static int count_idx(const int *arr, size_t size, int val)
static const struct @145311200363243152256244361015041277337174162300 uop_names[SWS_UOP_TYPE_NB]
static bool is_expand_bit(SwsPixelType type, AVRational64 factor)
static SwsPixelType pixel_type_to_int(const SwsPixelType type)
static bool exact_product_f32(float a, float b)
#define ff_sws_comp_mask_str(mask)
#define SWS_COMP_TEST(mask, X)
#define SWS_COMP_ELEMS(N)
@ SWS_UOP_READ_PLANAR_FV_FMA
#define SWS_COMP_MASK(X, Y, Z, W)
#define SWS_UOP_NAME_MAX
Generate a unique name for a SwsUOp.
static av_const bool ff_sws_pixel_type_is_int(SwsPixelType type)
uint8_t SwsCompMask
Bit-mask of components.
static av_const int ff_sws_pixel_type_size(SwsPixelType type)
#define UOPS_LIST(ENTRY)
This file is part of FFmpeg.
static const uint16_t dither[8][8]