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++)
113 const SwsOp *read_op, *write_op;
114 static const unsigned def_ranges[4] = {0};
131 write_op = &ops[oplist.
num_ops];
137 void *plane =
src0[p];
138 switch (read_op->
type) {
139 case U8:
fill8(plane,
sizeof(
src0[p]) /
sizeof(uint8_t), ranges[p]);
break;
140 case U16:
fill16(plane,
sizeof(
src0[p]) /
sizeof(uint16_t), ranges[p]);
break;
141 case U32:
fill32(plane,
sizeof(
src0[p]) /
sizeof(uint32_t), ranges[p]);
break;
142 case F32:
fill32f(plane,
sizeof(
src0[p]) /
sizeof(uint32_t), ranges[p]);
break;
147 memset(dst0, 0,
sizeof(dst0));
148 memset(dst1, 0,
sizeof(dst1));
153 const bool is_ref = !strcmp(backend->
name,
"c");
154 if (is_ref || !comp_new.func) {
166 if (!comp_new.func) {
168 backend_new = backend;
190 uintptr_t
id = (uintptr_t) backend_new;
191 id ^= (
id << 6) + (
id >> 2) + 0x9e3779b97f4a7c15 + comp_new.cpu_flags;
202 exec.
out[
i] = (
void *) dst0[
i];
210 exec.
out[
i] = (
void *) dst1[
i];
216 const int stride =
sizeof(dst0[
i][0]);
218 switch (write_op->
type) {
248 if (comp_new.func != comp_ref.
func && comp_new.free)
249 comp_new.free(comp_new.priv);
255 #define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT, ...) \
257 check_ops(NAME, RANGES, (SwsOp[]) { \
265 .op = SWS_OP_WRITE, \
272 #define MK_RANGES(R) ((const unsigned[]) { R, R, R, R })
273 #define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT, ...) \
274 CHECK_RANGES(NAME, MK_RANGES(RANGE), N_IN, N_OUT, IN, OUT, __VA_ARGS__)
276 #define CHECK_COMMON_RANGE(NAME, RANGE, IN, OUT, ...) \
277 CHECK_RANGE(FMT("%s_p1000", NAME), RANGE, 1, 1, IN, OUT, __VA_ARGS__); \
278 CHECK_RANGE(FMT("%s_p1110", NAME), RANGE, 3, 3, IN, OUT, __VA_ARGS__); \
279 CHECK_RANGE(FMT("%s_p1111", NAME), RANGE, 4, 4, IN, OUT, __VA_ARGS__); \
280 CHECK_RANGE(FMT("%s_p1001", NAME), RANGE, 4, 2, IN, OUT, __VA_ARGS__, { \
281 .op = SWS_OP_SWIZZLE, \
283 .swizzle = SWS_SWIZZLE(0, 3, 1, 2), \
286 #define CHECK(NAME, N_IN, N_OUT, IN, OUT, ...) \
287 CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)
289 #define CHECK_COMMON(NAME, IN, OUT, ...) \
290 CHECK_COMMON_RANGE(NAME, 0, IN, OUT, __VA_ARGS__)
296 for (
int i = 1;
i <= 4;
i++) {
298 for (
int o = 1; o <=
i; o++) {
345 for (
int frac = 1; frac <= 3; frac++) {
346 const int bits = 8 >> frac;
398 {
U8, {{ 3, 3, 2 }}},
399 {
U8, {{ 2, 3, 3 }}},
400 {
U8, {{ 1, 2, 1 }}},
401 {
U16, {{ 5, 6, 5 }}},
402 {
U16, {{ 5, 5, 5 }}},
403 {
U16, {{ 4, 4, 4 }}},
404 {
U32, {{ 2, 10, 10, 10 }}},
405 {
U32, {{10, 10, 10, 2 }}},
411 const int num = pack.
pattern[3] ? 4 : 3;
416 const unsigned ranges[4] = {
439 const unsigned num =
rnd();
444 const unsigned den =
rnd();
464 {.
q4 = { none, none, none,
zero }},
465 {.q4 = {
zero, none, none, none }},
467 {.q4 = { none, none, none,
alpha }},
468 {.q4 = {
alpha, none, none, none }},
533 static const int patterns[][4] = {
561 const int x = patterns[
i][0], y = patterns[
i][1],
562 z = patterns[
i][2],
w = patterns[
i][3];
563 CHECK(
FMT(
"swizzle_%d%d%d%d_%s", x, y, z,
w,
type), 4, 4, t, t, {
580 const char *
name =
FMT(
"convert_%s_%s", itype, otype);
591 uint32_t
range = (1 << osize * 8) - 1;
606 .convert.expand =
true,
613 .convert.expand =
true,
625 for (
int size_log2 = 0; size_log2 <= 8; size_log2++) {
626 const int size = 1 << size_log2;
643 .dither.size_log2 = size_log2,
672 static const struct {
705 const uint32_t
mask = patterns[p].mask;
708 for (
int i = 0;
i < 4;
i++) {
709 for (
int j = 0; j < 5; j++) {
734 const unsigned max = (1 <<
bits) - 1;
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
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#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)
void checkasm_check_sw_ops(void)
static void check_convert(void)
static av_unused void * func_ref
static void check_swap_bytes(void)
#define CHECK_COMMON_RANGE(NAME, RANGE, IN, OUT,...)
static void check_read_write(void)
static void check_linear(void)
int ff_sws_pixel_type_size(SwsPixelType type)
#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,...)
static av_unused void * func_new
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
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 void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
#define FF_ARRAY_ELEMS(a)
#define AV_CEIL_RSHIFT(a, b)
#define SWS_SWIZZLE(X, Y, Z, W)
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 void fill32(uint32_t *line, int num, unsigned range)
Global execution context for all compiled functions.
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,...)
Rational number (pair of numerator and denominator).
#define checkasm_save_context()
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
static int shift(int a, int b)
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)
#define i(width, name, range_min, range_max)
void * checkasm_check_func(void *func, const char *name,...)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void check_shift(void)
static void check_swizzle(void)
const char * ff_sws_pixel_type_name(SwsPixelType type)
static AVRational rndq(SwsPixelType t)
#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 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,...)
#define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT,...)
static void check_dither(void)