Go to the documentation of this file.
47 #define FMT(fmt, ...) tprintf((char[256]) {0}, 256, fmt, __VA_ARGS__)
48 static const char *
tprintf(
char buf[],
size_t size,
const char *fmt, ...)
63 switch (
op->rw.mode) {
69 const int bits = 8 >>
op->rw.frac;
76 union { uint32_t
u;
float f; } x;
79 }
while (!isnormal(x.f));
86 for (
int i = 0;
i < num;
i++)
92 for (
int i = 0;
i < num;
i++)
101 for (
int i = 0;
i < num;
i++)
111 for (
int i = 0;
i < num;
i++)
135 uintptr_t
id = (uintptr_t) comp_new->
func;
136 id ^= (
id << 6) + (
id >> 2) + 0x9e3779b97f4a7c15 + comp_new->
cpu_flags;
149 void *plane =
src0[
p];
150 switch (read_op->
type) {
152 fill8(plane,
sizeof(
src0[
p]) /
sizeof(uint8_t), ranges[
p]);
155 fill16(plane,
sizeof(
src0[
p]) /
sizeof(uint16_t), ranges[
p]);
158 fill32(plane,
sizeof(
src0[
p]) /
sizeof(uint32_t), ranges[
p]);
161 fill32f(plane,
sizeof(
src0[
p]) /
sizeof(uint32_t), ranges[
p]);
167 memset(dst0, 0,
sizeof(dst0));
168 memset(dst1, 0,
sizeof(dst1));
184 static_assert(
sizeof(
src0[1]) >=
sizeof(uint32_t[256]),
"palette plane too small");
191 for (
int y = 0; y <
LINES - 1; y++)
193 in_bump_y[
LINES - 1] = 0;
201 for (
int x = 0; x <
PIXELS; x++)
202 in_offset_x[x] =
offsets[x] * rw_bits >> 3;
208 exec.
out[
i] = (
void *) dst0[
i];
216 exec.
out[
i] = (
void *) dst1[
i];
224 const int stride =
sizeof(dst0[
i][0]);
226 switch (write_op->
type) {
228 checkasm_check(uint8_t, (
void *) dst0[
i],
stride,
233 checkasm_check(uint16_t, (
void *) dst0[
i],
stride,
238 checkasm_check(uint32_t, (
void *) dst0[
i],
stride,
243 checkasm_check(float_ulp, (
void *) dst0[
i],
stride,
264 static const unsigned def_ranges[4] = {0};
268 const SwsOp *read_op, *write_op;
271 .plane_src = {0, 1, 2, 3},
272 .plane_dst = {0, 1, 2, 3},
277 write_op = &ops[oplist.
num_ops];
280 switch (read_op->
type) {
294 if (ranges[
p] && ranges[
p] <= INT_MAX) {
335 }
else if (
ret < 0) {
351 #define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT, ...) \
353 check_ops(NAME, RANGES, (SwsOp[]) { \
361 .op = SWS_OP_WRITE, \
368 #define MK_RANGES(R) ((const unsigned[]) { R, R, R, R })
369 #define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT, ...) \
370 CHECK_RANGES(NAME, MK_RANGES(RANGE), N_IN, N_OUT, IN, OUT, __VA_ARGS__)
372 #define CHECK(NAME, N_IN, N_OUT, IN, OUT, ...) \
373 CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)
386 #define CHECK_MASK(NAME, MASK, RANGES, IN, OUT, ...) \
388 const SwsCompMask mask = (MASK); \
389 const int num = mask_num(mask); \
392 CHECK_RANGES(NAME, RANGES, 4, num, IN, OUT, __VA_ARGS__); \
397 const unsigned num =
rnd();
400 const unsigned mask = UINT_MAX >> (32 -
bits);
403 const unsigned den =
rnd();
451 const int bits = 8 >> frac;
531 unsigned range = UINT32_MAX >> (32 - osize * 8);
536 .op = SWS_OP_CONVERT,
555 .scale.factor = factor,
569 .op = SWS_OP_CONVERT,
582 .op = SWS_OP_SWIZZLE,
584 .swizzle.in = { swiz->in[0], swiz->in[1], swiz->in[2], swiz->in[3] },
596 const unsigned max = UINT32_MAX >> (32 -
bits);
606 .scale.factor = scale,
614 .op = uop->uop == SWS_UOP_MIN ? SWS_OP_MIN : SWS_OP_MAX,
616 .clamp.limit = { rndq(t), rndq(t), rndq(t), rndq(t) },
623 .op = SWS_OP_SWAP_BYTES,
631 const int num = pat[3] ? 4 : 3;
632 const int total = pat[0] + pat[1] + pat[2] + pat[3];
633 const unsigned range = UINT32_MAX >> (32 - total);
638 .pack.pattern = { pat[0], pat[1], pat[2], pat[3] },
645 const unsigned ranges[4] = {
646 (1 << pat[0]) - 1, (1 << pat[1]) - 1,
647 (1 << pat[2]) - 1, (1 << pat[3]) - 1,
653 .pack.pattern = { pat[0], pat[1], pat[2], pat[3] },
660 .op = uop->uop == SWS_UOP_LSHIFT ? SWS_OP_LSHIFT : SWS_OP_RSHIFT,
662 .shift.amount = uop->par.shift.amount,
670 const unsigned range = UINT32_MAX >> (32 -
bits);
676 for (
int i = 0;
i < 4;
i++) {
698 for (
int i = 0;
i < 4;
i++) {
699 for (
int j = 0; j < 5; j++) {
725 for (
int i = 0;
i < 4;
i++)
754 .par.dither.size_log2 = 0,
758 #define CHECK_FUNCTION(CHECK, NAME, ...) \
759 CHECK(#NAME, &(SwsUOp) { __VA_ARGS__ });
761 #define CHECK_FOR(UOP, CHECK) \
762 SWS_FOR_STRUCT(U8, UOP, CHECK_FUNCTION, CHECK) \
763 SWS_FOR_STRUCT(U16, UOP, CHECK_FUNCTION, CHECK) \
764 SWS_FOR_STRUCT(U32, UOP, CHECK_FUNCTION, CHECK) \
765 SWS_FOR_STRUCT(F32, UOP, CHECK_FUNCTION, CHECK) \
static const int factor[16]
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
static int mask_num(const SwsCompMask mask)
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...
static void check_linear(const char *name, const SwsUOp *uop)
int src_size
The relative sizes of the input and output images.
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
static const char * checkasm_get_cpu_suffix(void)
Get the suffix for the current CPU flag, or "c" if none.
ptrdiff_t in_bump[4]
Pointer bump, difference between stride and processed line size.
AVRational m[4][5]
Generalized 5x5 affine transformation: [ Out.x ] = [ A B C D E ] [ Out.y ] = [ F G H I J ] * [ x y z ...
static void check_pack(const char *name, const SwsUOp *uop)
static void check_shift(const char *name, const SwsUOp *uop)
#define u(width, name, range_min, range_max)
Represents a computed filter kernel.
void checkasm_check_sw_ops(void)
int32_t block_size_out[4]
static void check_unpack(const char *name, const SwsUOp *uop)
int * offsets
The computed source pixel positions for each row of the filter.
void(* filter)(uint8_t *src, int stride, int qscale)
int ff_sws_pixel_type_size(SwsPixelType type)
int ff_sws_filter_generate(void *log, const SwsFilterParams *params, SwsFilterWeights **out)
Generate a filter kernel for the given parameters.
#define DECLARE_ALIGNED_64(t, v)
#define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT,...)
#define SWS_COMP_TEST(mask, X)
const SwsOpBackend *const ff_sws_op_backends[]
static void check_dither(const char *name, const SwsUOp *uop)
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
enum AVPixelFormat hw_format
If NONE, backend only supports software frames.
#define SWS_COMP_ELEMS(N)
#define checkasm_call(func,...)
Call a function with signal handling.
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
#define CHECK_FOR(UOP, CHECK)
#define CHECK_MASK(NAME, MASK, RANGES, IN, OUT,...)
CHECKASM_API CheckasmKey CHECKASM_API void checkasm_set_func_variant(const char *id,...) CHECKASM_PRINTF(1
Set a custom variant identifier for the next checkasm_check_func() call.
#define FF_ARRAY_ELEMS(a)
static const uint16_t dither[8][8]
static const int offsets[]
#define AV_CEIL_RSHIFT(a, b)
int flags
Flags modifying the (de)muxer behaviour.
int32_t * in_bump_y
Line bump; determines how many additional lines to advance (after incrementing normally to the next l...
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 void fill32(uint32_t *line, int num, unsigned range)
static AVFormatContext * ctx
uint8_t SwsCompMask
Bit-mask of components.
Copyright (C) 2026 Niklas Haas.
SwsFilterWeights * kernel
static void fill16(uint16_t *line, int num, unsigned range)
static int rw_pixel_bits(const SwsOp *op)
static const char * tprintf(char buf[], size_t size, const char *fmt,...)
void ff_sws_compiled_op_unref(SwsCompiledOp *comp)
Rational number (pair of numerator and denominator).
static void check_cast(const char *name, const SwsUOp *uop)
static void check_swizzle(const char *name, const SwsUOp *uop)
static void check_scale(const char *name, const SwsUOp *uop)
static void check_write(const char *name, const SwsUOp *uop)
@ SWS_SCALE_SINC
unwindowed sinc
#define SWS_PARAM_DEFAULT
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
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)
uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void fill32f(float *line, int num, unsigned range)
@ SWS_SCALE_POINT
nearest neighbor (point sampling)
static void check_clamp(const char *name, const SwsUOp *uop)
int32_t * in_offset_x
Pixel offset map; for horizontal scaling, in bytes.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void check_expand(const char *name, const SwsUOp *uop)
static void check_expand_bit(const char *name, const SwsUOp *uop)
double scaler_params[SWS_NUM_SCALER_PARAMS]
struct SwsReadWriteOp::@571 filter
Filter kernel to apply to each plane while sampling.
static void check_compiled(const char *name, const SwsOp *read_op, const SwsOp *write_op, const int ranges[NB_PLANES], const SwsCompiledOp *comp_ref, const SwsCompiledOp *comp_new)
static void check_add(const char *name, const SwsUOp *uop)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static void check_swap_bytes(const char *name, const SwsUOp *uop)
static void check_clear(const char *name, const SwsUOp *uop)
static AVRational rndq(SwsPixelType t)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static void check_read(const char *name, const SwsUOp *uop)
static void fill8(uint8_t *line, int num, unsigned range)
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
static void set_range(AVRational *rangeq, unsigned range, unsigned range_def)
static void check_ops(const char *name, const unsigned ranges[NB_PLANES], const SwsOp *ops)
SwsReadWriteMode mode
Examples: rgba = 4x u8 packed yuv444p = 3x u8 rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack monow = ...
Helper struct for representing a list of operations.
Main external API structure.
#define CHECK(NAME, N_IN, N_OUT, IN, OUT,...)
SwsScaler scaler
The filter kernel and parameters to use.
#define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT,...)
static void check_filter(const char *name, const SwsUOp *uop)
int ff_sws_ops_compile(SwsContext *ctx, const SwsOpBackend *backend, const SwsOpList *ops, SwsCompiledOp *out)
Attempt to compile a list of operations using a specific backend, or the best available backend if ba...