Go to the documentation of this file.
38 #if ARCH_X86_64 && HAVE_X86ASM
119 for (
int i = 0;
i < 4;
i++)
127 for (
int i = 0;
i < 4;
i++)
136 for (
int i = 0;
i < 4;
i++)
140 for (
int i = 0;
i < 4;
i++)
146 for (
int i = 0;
i < 4;
i++) {
154 for (
int i = 0;
i < 4;
i++)
160 for (
int i = 0;
i < 4;
i++)
161 x[
i] = x[
i].den ?
Q((x[
i].num / x[
i].den) >>
op->c.u) : x[
i];
165 const AVRational orig[4] = { x[0], x[1], x[2], x[3] };
166 for (
int i = 0;
i < 4;
i++)
167 x[
i] = orig[
op->swizzle.in[
i]];
173 for (
int i = 0;
i < 4;
i++) {
174 x[
i] = x[
i].
den ?
Q(x[
i].num / x[
i].den) : x[
i];
175 if (
op->convert.expand)
182 for (
int i = 0;
i < 4;
i++) {
183 if (
op->dither.y_offset[
i] >= 0 && x[
i].
den)
188 for (
int i = 0;
i < 4;
i++)
192 for (
int i = 0;
i < 4;
i++)
197 const AVRational orig[4] = { x[0], x[1], x[2], x[3] };
198 for (
int i = 0;
i < 4;
i++) {
200 for (
int j = 0; j < 4; j++)
207 for (
int i = 0;
i < 4;
i++)
221 return ((
a &
b) & flags_and) | ((
a |
b) & flags_or);
227 for (
int i = 0;
i < 4;
i++)
234 for (
int i = 0;
i < 4;
i++) {
249 for (
int n = 0; n < ops->
num_ops; n++) {
259 memcpy(
op->comps.min, prev.
min,
sizeof(prev.
min));
260 memcpy(
op->comps.max, prev.
max,
sizeof(prev.
max));
270 for (
int i = 0;
i <
op->rw.elems;
i++) {
276 for (
int i =
op->rw.elems;
i < 4;
i++) {
278 op->comps.min[
i] = prev.
min[
i];
279 op->comps.max[
i] = prev.
max[
i];
283 for (
int i = 0;
i < 4;
i++) {
285 op->comps.min[
i] = prev.
min[
i];
286 op->comps.max[
i] = prev.
max[
i];
290 for (
int i = 0;
i <
op->rw.elems;
i++)
307 for (
int i = 0;
i < 4;
i++)
311 for (
int i = 0;
i < 4;
i++) {
312 const int pattern =
op->pack.pattern[
i];
316 op->comps.min[
i] =
Q(0);
317 op->comps.max[
i] =
Q((1ULL << pattern) - 1);
324 for (
int i = 0;
i < 4;
i++) {
325 if (
op->pack.pattern[
i])
334 for (
int i = 0;
i < 4;
i++) {
335 if (
op->c.q4[
i].den) {
336 op->comps.flags[
i] = 0;
337 if (
op->c.q4[
i].num == 0)
339 if (
op->c.q4[
i].den == 1)
347 for (
int i = 0;
i < 4;
i++)
348 op->comps.flags[
i] = prev.
flags[
op->swizzle.in[
i]];
351 for (
int i = 0;
i < 4;
i++) {
358 for (
int i = 0;
i < 4;
i++) {
361 for (
int j = 0; j < 4; j++) {
375 if (
op->lin.m[
i][4].num) {
377 if (
op->lin.m[
i][4].den != 1)
388 for (
int i = 0;
i < 4;
i++) {
390 if (
op->c.q.den != 1)
406 for (
int n = ops->
num_ops - 1; n >= 0; n--) {
412 for (
int i = 0;
i <
op->rw.elems;
i++)
414 for (
int i =
op->rw.elems;
i < 4;
i++)
425 for (
int i = 0;
i < 4;
i++)
430 for (
int i = 0;
i < 4;
i++) {
431 if (
op->pack.pattern[
i])
433 op->comps.unused[
i] =
i > 0;
435 op->comps.unused[0] = unused;
439 for (
int i = 0;
i < 4;
i++) {
440 if (
op->pack.pattern[
i])
443 op->comps.unused[
i] =
true;
447 for (
int i = 0;
i < 4;
i++) {
449 op->comps.unused[
i] =
true;
455 bool unused[4] = {
true,
true,
true,
true };
456 for (
int i = 0;
i < 4;
i++)
458 for (
int i = 0;
i < 4;
i++)
459 op->comps.unused[
i] = unused[
i];
463 for (
int j = 0; j < 4; j++) {
465 for (
int i = 0;
i < 4;
i++) {
466 if (
op->lin.m[
i][j].num)
469 op->comps.unused[j] = unused;
564 const int end = ops->
num_ops - count;
611 const int num_planes =
read->rw.packed ? 1 :
read->rw.elems;
612 for (
int i = 0;
i < num_planes;
i++) {
634 for (
int i = 0;
i < 4;
i++) {
635 for (
int j = 0; j < 5; j++) {
646 static const struct {
677 return patterns[
i].
name;
713 return q.
num > 0 ?
"inf" : q.
num < 0 ?
"-inf" :
"nan";
714 }
else if (q.
den == 1) {
726 #define PRINTQ(q) print_q(q, (char[32]){0}, sizeof(char[32]))
743 op->comps.unused[0] ?
'X' :
'.',
744 op->comps.unused[1] ?
'X' :
'.',
745 op->comps.unused[2] ?
'X' :
'.',
746 op->comps.unused[3] ?
'X' :
'.',
761 op->rw.elems,
op->rw.packed ?
"packed" :
"planar",
765 op->rw.packed ? 1 :
op->rw.elems, buf));
781 op->pack.pattern[0],
op->pack.pattern[1],
782 op->pack.pattern[2],
op->pack.pattern[3]);
785 av_log(
log,
lev,
"%-20s: {%s %s %s %s}\n",
"SWS_OP_CLEAR",
793 op->swizzle.x,
op->swizzle.y,
op->swizzle.z,
op->swizzle.w);
796 av_log(
log,
lev,
"%-20s: %s -> %s%s\n",
"SWS_OP_CONVERT",
799 op->convert.expand ?
" (expand)" :
"");
802 av_log(
log,
lev,
"%-20s: %dx%d matrix + {%d %d %d %d}\n",
"SWS_OP_DITHER",
803 1 <<
op->dither.size_log2, 1 <<
op->dither.size_log2,
804 op->dither.y_offset[0],
op->dither.y_offset[1],
805 op->dither.y_offset[2],
op->dither.y_offset[3]);
808 av_log(
log,
lev,
"%-20s: x <= {%s %s %s %s}\n",
"SWS_OP_MIN",
815 av_log(
log,
lev,
"%-20s: {%s %s %s %s} <= x\n",
"SWS_OP_MAX",
825 "[%s %s %s %s %s]]\n",
840 if (
op->comps.min[0].den ||
op->comps.min[1].den ||
841 op->comps.min[2].den ||
op->comps.min[3].den ||
842 op->comps.max[0].den ||
op->comps.max[1].den ||
843 op->comps.max[2].den ||
op->comps.max[3].den)
845 av_log(
log, lev_extra,
" min: {%s, %s, %s, %s}, max: {%s, %s, %s, %s}\n",
858 av_log(
log,
lev,
" (X = unused, z = byteswapped, + = exact, 0 = zero)\n");
void ff_sws_op_list_free(SwsOpList **p_ops)
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 default minimum maximum flags name is the option name
SwsOpList * ff_sws_op_list_alloc(void)
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
SwsOpList * ff_sws_op_list_duplicate(const SwsOpList *ops)
Returns a duplicate of ops, or NULL on OOM.
static AVRational av_min_q(AVRational a, AVRational b)
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
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.
uint32_t ff_sws_linear_mask(const SwsLinearOp c)
int ff_sws_op_list_max_size(const SwsOpList *ops)
Returns the size of the largest pixel type used in ops.
const SwsOpBackend backend_x86
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.
const SwsOpBackend backend_vulkan
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.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int ff_sws_pixel_type_size(SwsPixelType type)
static char describe_comp_flags(unsigned flags)
static void clear_undefined_values(AVRational dst[4], const AVRational src[4])
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
SwsPixelType
Copyright (C) 2025 Niklas Haas.
void ff_sws_op_list_print(void *log, int lev, int lev_extra, const SwsOpList *ops)
Print out the contents of an operation list.
const SwsOpBackend *const ff_sws_op_backends[]
static const unsigned flags_identity
bool ff_sws_pixel_type_is_int(SwsPixelType type)
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
static int16_t mult(Float11 *f1, Float11 *f2)
#define FF_ARRAY_ELEMS(a)
#define SWS_SWIZZLE(X, Y, Z, W)
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 double av_q2d(AVRational a)
Convert an AVRational to a double.
const SwsOpBackend backend_c
Copyright (C) 2025 Niklas Haas.
static AVRational ff_sws_pixel_expand(SwsPixelType from, SwsPixelType to)
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.
static const char * describe_order(SwsSwizzleOp order, int planes, char buf[32])
static unsigned merge_comp_flags(unsigned a, unsigned b)
bool ff_sws_op_list_is_noop(const SwsOpList *ops)
Returns whether an op list represents a true no-op operation, i.e.
Rational number (pair of numerator and denominator).
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
static const struct @562 planes[]
void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
static const char * print_q(const AVRational q, char buf[], int buf_len)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
void ff_sws_apply_op_q(const SwsOp *op, AVRational x[4])
Apply an operation to an AVRational.
static void copy(const float *p1, float *p2, const int length)
static int shift(int a, int b)
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)
int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
static AVRational av_make_q(int num, int den)
Create an AVRational.
void ff_sws_op_list_update_comps(SwsOpList *ops)
Infer + propagate known information about components.
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
static void op_uninit(SwsOp *op)
SwsComps comps
Metadata about the operation's input/output components.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static AVRational av_max_q(AVRational a, AVRational b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static LevelCodes lev[4+3+3]
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
const SwsOpBackend backend_murder
#define FFSWAP(type, a, b)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * ff_sws_pixel_type_name(SwsPixelType type)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static const char * describe_lin_mask(uint32_t mask)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
static void ff_sws_pack_op_decode(const SwsOp *op, uint64_t mask[4], int shift[4])
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
static void propagate_flags(SwsOp *op, const SwsComps *prev)
Helper struct for representing a list of operations.
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.