Go to the documentation of this file.
45 #define FMT(fmt, ...) tprintf((char[256]) {0}, 256, fmt, __VA_ARGS__)
46 static const char *
tprintf(
char buf[],
size_t size,
const char *fmt, ...)
57 const int elems =
op->rw.packed ?
op->rw.elems : 1;
59 const int bits = 8 >>
op->rw.frac;
66 union { uint32_t
u;
float f; } x;
69 }
while (!isnormal(x.f));
76 for (
int i = 0;
i < num;
i++)
82 for (
int i = 0;
i < num;
i++)
91 for (
int i = 0;
i < num;
i++)
101 for (
int i = 0;
i < num;
i++)
121 const SwsOp *read_op, *write_op;
122 static const unsigned def_ranges[4] = {0};
139 write_op = &ops[oplist.
num_ops];
145 void *plane =
src0[
p];
146 switch (read_op->
type) {
148 fill8(plane,
sizeof(
src0[
p]) /
sizeof(uint8_t), ranges[
p]);
153 fill16(plane,
sizeof(
src0[
p]) /
sizeof(uint16_t), ranges[
p]);
158 fill32(plane,
sizeof(
src0[
p]) /
sizeof(uint32_t), ranges[
p]);
163 fill32f(plane,
sizeof(
src0[
p]) /
sizeof(uint32_t), ranges[
p]);
164 if (ranges[
p] && ranges[
p] <= INT_MAX) {
173 memset(dst0, 0,
sizeof(dst0));
174 memset(dst1, 0,
sizeof(dst1));
179 const bool is_ref = !strcmp(backend->
name,
"c");
180 if (is_ref || !comp_new.func) {
192 if (!comp_new.func) {
194 backend_new = backend;
214 for (
int y = 0; y <
LINES - 1; y++)
216 in_bump_y[
LINES - 1] = 0;
224 for (
int x = 0; x <
PIXELS; x++)
225 in_offset_x[x] =
offsets[x] * rw_bits >> 3;
234 uintptr_t
id = (uintptr_t) backend_new;
235 id ^= (
id << 6) + (
id >> 2) + 0x9e3779b97f4a7c15 + comp_new.cpu_flags;
242 exec.
out[
i] = (
void *) dst0[
i];
250 exec.
out[
i] = (
void *) dst1[
i];
256 const int stride =
sizeof(dst0[
i][0]);
258 switch (write_op->
type) {
285 bench(comp_new.func, &exec, comp_new.priv, 0, 0,
PIXELS / comp_new.block_size,
LINES);
288 if (comp_new.func != comp_ref.
func)
294 #define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT, ...) \
296 check_ops(NAME, RANGES, (SwsOp[]) { \
304 .op = SWS_OP_WRITE, \
311 #define MK_RANGES(R) ((const unsigned[]) { R, R, R, R })
312 #define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT, ...) \
313 CHECK_RANGES(NAME, MK_RANGES(RANGE), N_IN, N_OUT, IN, OUT, __VA_ARGS__)
315 #define CHECK_COMMON_RANGE(NAME, RANGE, IN, OUT, ...) \
316 CHECK_RANGE(FMT("%s_p1000", NAME), RANGE, 1, 1, IN, OUT, __VA_ARGS__); \
317 CHECK_RANGE(FMT("%s_p1110", NAME), RANGE, 3, 3, IN, OUT, __VA_ARGS__); \
318 CHECK_RANGE(FMT("%s_p1111", NAME), RANGE, 4, 4, IN, OUT, __VA_ARGS__); \
319 CHECK_RANGE(FMT("%s_p1001", NAME), RANGE, 4, 2, IN, OUT, __VA_ARGS__, { \
320 .op = SWS_OP_SWIZZLE, \
322 .swizzle = SWS_SWIZZLE(0, 3, 1, 2), \
325 #define CHECK(NAME, N_IN, N_OUT, IN, OUT, ...) \
326 CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)
328 #define CHECK_COMMON(NAME, IN, OUT, ...) \
329 CHECK_COMMON_RANGE(NAME, 0, IN, OUT, __VA_ARGS__)
335 for (
int i = 1;
i <= 4;
i++) {
337 for (
int o = 1; o <=
i; o++) {
384 for (
int frac = 1; frac <= 3; frac++) {
385 const int bits = 8 >> frac;
437 {
U8, {{ 3, 3, 2 }}},
438 {
U8, {{ 2, 3, 3 }}},
439 {
U8, {{ 1, 2, 1 }}},
440 {
U16, {{ 5, 6, 5 }}},
441 {
U16, {{ 5, 5, 5 }}},
442 {
U16, {{ 4, 4, 4 }}},
443 {
U32, {{ 2, 10, 10, 10 }}},
444 {
U32, {{10, 10, 10, 2 }}},
450 const int num = pack.
pattern[3] ? 4 : 3;
455 const unsigned ranges[4] = {
478 const unsigned num =
rnd();
483 const unsigned den =
rnd();
503 {{ none, none, none,
zero }},
504 {{
zero, none, none, none }},
506 {{ none, none, none,
alpha }},
507 {{
alpha, none, none, none }},
531 .clear = patterns[
i],
539 .clear.value[3] = { 0, 1 },
572 static const int patterns[][4] = {
600 const int x = patterns[
i][0], y = patterns[
i][1],
601 z = patterns[
i][2],
w = patterns[
i][3];
602 CHECK(
FMT(
"swizzle_%d%d%d%d_%s", x, y, z,
w,
type), 4, 4, t, t, {
619 const char *
name =
FMT(
"convert_%s_%s", itype, otype);
630 uint32_t
range = UINT32_MAX >> (32 - osize * 8);
645 .convert.expand =
true,
652 .convert.expand =
true,
664 for (
int size_log2 = 0; size_log2 <= 8; size_log2++) {
665 const int size = 1 << size_log2;
683 .dither.size_log2 = size_log2,
713 static const struct {
746 const uint32_t
mask = patterns[
p].mask;
749 for (
int i = 0;
i < 4;
i++) {
750 for (
int j = 0; j < 5; j++) {
775 const unsigned max = (1 <<
bits) - 1;
781 .scale = {{
scale, 1 }},
787 .scale = {
rndq(t) },
815 for (
int n = 1; n <= 4; n++) {
844 for (
int n = 1; n <= 4; n++) {
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
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
int src_size
The relative sizes of the input and output images.
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
ptrdiff_t in_bump[4]
Pointer bump, difference between stride and processed line size.
#define CHECK_COMMON(NAME, IN, OUT,...)
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_min_max(void)
#define u(width, name, range_min, range_max)
Represents a computed filter kernel.
void checkasm_check_sw_ops(void)
static void check_convert(void)
int * offsets
The computed source pixel positions for each row of the filter.
static void check_swap_bytes(void)
void(* filter)(uint8_t *src, int stride, int qscale)
#define CHECK_COMMON_RANGE(NAME, RANGE, IN, OUT,...)
static void check_read_write(void)
static void check_linear(void)
static void check_filter(void)
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)
static void check_clear(void)
SwsPixelType
Copyright (C) 2025 Niklas Haas.
#define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT,...)
const SwsOpBackend *const ff_sws_op_backends[]
static void check_scale(void)
bool ff_sws_pixel_type_is_int(SwsPixelType type)
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 void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
#define FF_ARRAY_ELEMS(a)
static const int offsets[]
#define AV_CEIL_RSHIFT(a, b)
#define SWS_SWIZZLE(X, Y, Z, W)
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
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).
#define SWS_PARAM_DEFAULT
uint8_t pattern[4]
Packed bits are assumed to be LSB-aligned within the underlying integer type; i.e.
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
static int shift(int a, int b)
#define i(width, name, range_min, range_max)
static void check_ops(const char *report, const unsigned ranges[NB_PLANES], const SwsOp *ops)
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)
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.
double scaler_params[SWS_NUM_SCALER_PARAMS]
#define checkasm_call_checked(func,...)
static void check_shift(void)
SwsOpType filter
Filter kernel to apply to each plane while sampling.
static void check_swizzle(void)
const char * ff_sws_pixel_type_name(SwsPixelType type)
@ SWS_SCALE_NB
not part of the ABI
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int ff_sws_ops_compile_backend(SwsContext *ctx, const SwsOpBackend *backend, const SwsOpList *ops, SwsCompiledOp *out)
Attempt to compile a list of operations using a specific backend.
static AVRational rndq(SwsPixelType t)
#define check_key(key,...)
#define declare_func(ret,...)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static const int16_t alpha[]
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)
#define checkasm_call(func,...)
static void check_pack_unpack(void)
#define checkasm_check(prefix,...)
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_dither(void)