Go to the documentation of this file.
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++) {
205 sizeof(*uop), (uint8_t *) uop))
217 const int end = uops->
num_ops - count;
219 for (
int i = 0;
i < count;
i++)
222 uops->
ops[
i] = uops->
ops[
i + count];
229 for (
int i = 0;
i < 4;
i++)
231 return (1 <<
dither->size_log2) + max_offset;
249 volatile float prod =
a *
b;
250 volatile float result =
b ? prod /
b : 0.0f;
261 else if (!minq.
den || !maxq.
den)
286 const uint64_t max_val = UINT64_MAX >> (64 -
bits);
300 op->rw.elems > 2,
op->rw.elems > 3),
304 if (!
op->rw.filter.op)
308 if (
op->rw.filter.op) {
325 if (
op->rw.frac || !is_read)
328 }
else if (
op->rw.frac == 3) {
330 }
else if (
op->rw.frac == 1) {
350 for (
size_t i = 0;
i <
size;
i++) {
369 for (
int i = 0;
i < 4;
i++) {
370 if (
op->swizzle.in[
i] ==
i)
376 for (
int i = 0;
i < 4;
i++) {
382 int idx[4 + 1] = { 0, 1, 2, 3, -1 };
392 const int cur = idx[
dst];
396 if (idx[
src] ==
op->swizzle.in[
dst]) {
429 for (
int i = 0;
i < 4;
i++) {
443 for (
int i = 0;
i < 4;
i++) {
445 if (!(seen &
bit) && idx[
i] ==
i)
457 .par.dither.size_log2 =
op->dither.size_log2,
460 if (
op->dither.size_log2 == 0) {
464 for (
int i = 0;
i < 4;
i++) {
474 const int size = 1 <<
op->dither.size_log2;
475 for (
int i = 0;
i < 4;
i++) {
478 const uint8_t off =
op->dither.y_offset[
i] & (
size - 1);
512 for (
int i = 0;
i < 4;
i++) {
518 bool nonzero = (
op->lin.m[
i][4].num != 0);
519 for (
int j = 0; j < 5; j++) {
525 else if (j < 4 && k.
num == k.
den)
590 if (
op->convert.expand) {
592 switch (
op->convert.to) {
597 switch (
op->convert.to) {
609 for (
int i = 0;
i < 4 &&
op->pack.pattern[
i];
i++) {
623 uop.
mask &=
op->clear.mask;
624 for (
int i = 0;
i < 4;
i++) {
648 for (
int i = 0;
i < 4;
i++) {
static const int factor[16]
int ff_sws_rw_op_planes(const SwsOp *op)
Return the number of planes involved in a read/write operation.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ SWS_RW_PLANAR
Note: 1-component reads are either SWS_RW_PLANAR or SWS_RW_PACKED, depending on the underlying interp...
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
SwsCompMask ff_sws_comp_mask_q4(const AVRational64 q[4])
static av_const bool ff_sws_pixel_type_is_int(SwsPixelType type)
#define u(width, name, range_min, range_max)
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.
@ SWS_FILTER_SCALE
14-bit coefficients are picked to fit comfortably within int16_t for efficient SIMD processing (e....
static int translate_rw_op(SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op)
int ff_sws_uop_cmp(const SwsUOp *a, const SwsUOp *b)
Copyright (C) 2026 Niklas Haas.
#define SWS_COMP_MASK(X, Y, Z, W)
#define SWS_UOP_NAME_MAX
Generate a unique name for a SwsUOp.
static bool check_filter_fma(SwsContext *ctx, SwsUOpFlags flags, const SwsOp *op)
SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
#define bit(string, value)
#define SWS_COMP_TEST(mask, X)
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
#define UOP_NAME(OP, ABBR)
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define SWS_COMP_ELEMS(N)
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
static const struct @603 planes[]
#define FF_ARRAY_ELEMS(a)
#define SWS_OP_NEEDED(op, idx)
SwsFilterWeights * kernel
#define flags(name, subs,...)
static const uint16_t dither[8][8]
#define UOPS_LIST(ENTRY)
This file is part of FFmpeg.
int flags
Flags modifying the (de)muxer behaviour.
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static AVFormatContext * ctx
uint8_t SwsCompMask
Bit-mask of components.
static int count_idx(const int *arr, size_t size, int val)
static av_const int ff_sws_pixel_type_size(SwsPixelType type)
and forward the result(frame or status change) to the corresponding input. If nothing is possible
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
int8_t dst[SWS_UOP_MOVE_MAX]
static int translate_dither_op(SwsUOpList *ops, const SwsOp *op)
static bool pixel_is_1s(SwsPixelType type, SwsPixel val)
void ff_sws_uop_list_remove_at(SwsUOpList *uops, int index, int count)
static bool exact_prod(SwsPixelType type, SwsPixel coef, const SwsComps *comps, int idx)
static void uop_uninit(SwsUOp *uop)
@ SWS_UOP_READ_PLANAR_FV_FMA
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
64-bit Rational number (pair of numerator and denominator).
void * av_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
SwsComps comps
Metadata about the operation's input/output components.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
SwsUOpList * ff_sws_uop_list_alloc(void)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
int ff_sws_uop_list_optimize(SwsContext *ctx, SwsUOpFlags flags, SwsUOpList *uops)
Called internally by ff_sws_ops_translate().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static bool exact_product_f32(float a, float b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is needed
static SwsPixelType pixel_type_to_int(const SwsPixelType type)
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...
static bool is_expand_bit(SwsPixelType type, AVRational64 factor)
void ff_sws_uop_list_free(SwsUOpList **p_ops)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
static const struct @592 uop_names[SWS_UOP_TYPE_NB]
const char * ff_sws_pixel_type_name(SwsPixelType type)
void ff_sws_uop_name(const SwsUOp *op, char buf[SWS_UOP_NAME_MAX])
int ff_sws_uop_list_append(SwsUOpList *uops, SwsUOp *uop)
int8_t src[SWS_UOP_MOVE_MAX]
static int translate_linear_op(SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
int ff_sws_dither_height(const SwsDitherUOp *dither)
Computes (1 << size_log2) + MAX(y_offset).
static int translate_op(SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Helper struct for representing a list of operations.
Main external API structure.
static int translate_swizzle(SwsUOpList *ops, const SwsOp *op)
static SwsPixel pixel_from_q64(SwsPixelType type, AVRational64 val)
#define ff_sws_comp_mask_str(mask)