Go to the documentation of this file.
21 #ifndef SWSCALE_OPS_BACKEND_H
22 #define SWSCALE_OPS_BACKEND_H
54 # define SWS_LOOP AV_PRAGMA(clang loop vectorize(assume_safety))
55 #elif defined(__GNUC__)
56 # define SWS_FUNC __attribute__((optimize("tree-vectorize")))
57 # define SWS_LOOP AV_PRAGMA(GCC ivdep)
64 #define bitfn2(name, ext) name ## _ ## ext
65 #define bitfn(name, ext) bitfn2(name, ext)
67 #define FN_SUFFIX AV_JOIN(FMT_CHAR, BIT_DEPTH)
68 #define fn(name) bitfn(name, FN_SUFFIX)
70 #define av_q2pixel(q) ((q).den ? (pixel_t) (q).num / (q).den : 0)
73 #define DECL_FUNC(NAME, ...) \
74 static av_always_inline void fn(NAME)(SwsOpIter *restrict iter, \
75 const SwsOpImpl *restrict impl, \
76 block_t x, block_t y, \
77 block_t z, block_t w, \
80 #define DECL_READ(NAME, ...) \
81 DECL_FUNC(NAME, const pixel_t *restrict in0, const pixel_t *restrict in1, \
82 const pixel_t *restrict in2, const pixel_t *restrict in3, \
85 #define DECL_WRITE(NAME, ...) \
86 DECL_FUNC(NAME, pixel_t *restrict out0, pixel_t *restrict out1, \
87 pixel_t *restrict out2, pixel_t *restrict out3, \
91 #define CALL(FUNC, ...) \
92 fn(FUNC)(iter, impl, x, y, z, w, __VA_ARGS__)
94 #define CALL_READ(FUNC, ...) \
95 CALL(FUNC, (const pixel_t *) iter->in[0], (const pixel_t *) iter->in[1], \
96 (const pixel_t *) iter->in[2], (const pixel_t *) iter->in[3], \
99 #define CALL_WRITE(FUNC, ...) \
100 CALL(FUNC, (pixel_t *) iter->out[0], (pixel_t *) iter->out[1], \
101 (pixel_t *) iter->out[2], (pixel_t *) iter->out[3], __VA_ARGS__)
104 #define DECL_IMPL(NAME) \
105 static SWS_FUNC void fn(NAME)(SwsOpIter *restrict iter, \
106 const SwsOpImpl *restrict impl, \
107 block_t x, block_t y, \
108 block_t z, block_t w)
111 #define CONTINUE(TYPE, ...) \
112 ((void (*)(SwsOpIter *, const SwsOpImpl *, \
113 TYPE x, TYPE y, TYPE z, TYPE w)) impl->cont) \
114 (iter, &impl[1], __VA_ARGS__)
117 #define DECL_SETUP(NAME) \
118 static int fn(NAME)(const SwsOp *op, SwsOpPriv *out)
120 #define SETUP_MEMDUP(c) ff_setup_memdup(&(c), sizeof(c), out)
128 #define DECL_ENTRY(NAME, ...) \
129 static const SwsOpEntry fn(op_##NAME) = { \
130 .func = (SwsFuncPtr) fn(NAME), \
131 .type = PIXEL_TYPE, \
136 #define DECL_PATTERN(NAME) \
137 DECL_FUNC(NAME, const bool X, const bool Y, const bool Z, const bool W)
139 #define WRAP_PATTERN(FUNC, X, Y, Z, W, ...) \
140 DECL_IMPL(FUNC##_##X##Y##Z##W) \
142 CALL(FUNC, X, Y, Z, W); \
145 DECL_ENTRY(FUNC##_##X##Y##Z##W, \
146 .unused = { !X, !Y, !Z, !W }, \
150 #define WRAP_COMMON_PATTERNS(FUNC, ...) \
151 WRAP_PATTERN(FUNC, 1, 0, 0, 0, __VA_ARGS__); \
152 WRAP_PATTERN(FUNC, 1, 0, 0, 1, __VA_ARGS__); \
153 WRAP_PATTERN(FUNC, 1, 1, 1, 0, __VA_ARGS__); \
154 WRAP_PATTERN(FUNC, 1, 1, 1, 1, __VA_ARGS__)
156 #define REF_COMMON_PATTERNS(NAME) \
157 &fn(op_##NAME##_1000), \
158 &fn(op_##NAME##_1001), \
159 &fn(op_##NAME##_1110), \
160 &fn(op_##NAME##_1111)
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
Copyright (C) 2025 Niklas Haas.
static int ff_setup_memdup(const void *c, size_t size, SwsOpPriv *out)
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
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
Copyright (C) 2025 Niklas Haas.