21#ifndef SWSCALE_UOPS_TMPL_H
22#define SWSCALE_UOPS_TMPL_H
41# define SWS_BLOCK_SIZE 32
51#define SIZEOF_BLOCK (sizeof(pixel_t) * SWS_BLOCK_SIZE)
75#define SWS_OP_PRIV(impl) ((const void *) (impl)->priv)
84 "SwsFilterPriv alignment exceeds SwsOpPriv");
90#elif defined(__clang__)
91# define SWS_LOOP AV_PRAGMA(clang loop vectorize(assume_safety))
92#elif defined(__GNUC__)
93# define SWS_LOOP AV_PRAGMA(GCC ivdep)
99#define bitfn2(name, ext) name ## _ ## ext
100#define bitfn(name, ext) bitfn2(name, ext)
101#define fn(name) bitfn(name, PX)
103#define bump_ptr(ptr, bump) ((pixel_t *) ((uintptr_t) (ptr) + (bump)))
106#define X SWS_COMP_TEST(mask, 0)
107#define Y SWS_COMP_TEST(mask, 1)
108#define Z SWS_COMP_TEST(mask, 2)
109#define W SWS_COMP_TEST(mask, 3)
112#define DECL_FUNC(NAME, ...) \
113 av_always_inline static void \
114 fn(NAME)(SwsOpIter *restrict iter, const SwsOpImpl *restrict impl, \
115 pixel_t *restrict x, pixel_t *restrict y, \
116 pixel_t *restrict z, pixel_t *restrict w, \
119#define DECL_READ(NAME, ...) \
120 DECL_FUNC(NAME, __VA_ARGS__, \
121 const pixel_t *restrict in0, const pixel_t *restrict in1, \
122 const pixel_t *restrict in2, const pixel_t *restrict in3) \
124#define DECL_WRITE(NAME, ...) \
125 DECL_FUNC(NAME, __VA_ARGS__, \
126 pixel_t *restrict out0, pixel_t *restrict out1, \
127 pixel_t *restrict out2, pixel_t *restrict out3) \
129#define CALL(NAME, ...) fn(NAME)(iter, impl, x, y, z, w, __VA_ARGS__)
131#define NEXT_IMPL(N) \
132 ((const SwsOpImpl *) &impl->priv[FFALIGN(N, alignof(SwsOpImpl))])
136#define CONTINUE(N, ...) \
137 ((void (*)(SwsOpIter *, const SwsOpImpl *, \
138 void *restrict x, void *restrict y, \
139 void *restrict z, void *restrict w)) NEXT_IMPL(N)->func) \
140 (iter, NEXT_IMPL(N), __VA_ARGS__)
143#define DECL_SETUP(NAME, PARAMS, OUT) \
144 av_unused static int fn(NAME)(const SwsImplParams *PARAMS, \
148#define DECL_IMPL(FUNC, NAME, TYPE, UOP, ...) \
149 av_flatten static void NAME##_c(SwsOpIter *restrict iter, \
150 const SwsOpImpl *restrict impl, \
151 void *restrict x, void *restrict y, \
152 void *restrict z, void *restrict w) \
154 CALL(FUNC, __VA_ARGS__); \
157#define DECL_IMPL_READ(...) \
158 DECL_IMPL(__VA_ARGS__, \
159 (const pixel_t *) iter->in[0], (const pixel_t *) iter->in[1], \
160 (const pixel_t *) iter->in[2], (const pixel_t *) iter->in[3])
162#define DECL_IMPL_WRITE(...) \
163 DECL_IMPL(__VA_ARGS__, \
164 (pixel_t *) iter->out[0], (pixel_t *) iter->out[1], \
165 (pixel_t *) iter->out[2], (pixel_t *) iter->out[3])
167#define REF_ENTRY(DUMMY, NAME, ...) &uop_##NAME,
168#define DECL_ENTRY(SETUP, NAME, ...) \
169 static const SwsUOpEntry uop_##NAME = { \
170 .func = (SwsFuncPtr) NAME##_c, \
Macro definitions for various function/variable attributes.
Copyright (C) 2026 Niklas Haas.
Internal context holding per-iter execution data.
uint32_t u32[SWS_BLOCK_SIZE]
float f32[SWS_BLOCK_SIZE]
uint16_t u16[SWS_BLOCK_SIZE]
uint8_t u8[SWS_BLOCK_SIZE]
#define SWS_BLOCK_SIZE
Copyright (C) 2026 Niklas Haas.