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)
70#elif defined(__clang__)
71# define SWS_LOOP AV_PRAGMA(clang loop vectorize(assume_safety))
72#elif defined(__GNUC__)
73# define SWS_LOOP AV_PRAGMA(GCC ivdep)
79#define bitfn2(name, ext) name ## _ ## ext
80#define bitfn(name, ext) bitfn2(name, ext)
81#define fn(name) bitfn(name, PX)
83#define bump_ptr(ptr, bump) ((pixel_t *) ((uintptr_t) (ptr) + (bump)))
86#define X SWS_COMP_TEST(mask, 0)
87#define Y SWS_COMP_TEST(mask, 1)
88#define Z SWS_COMP_TEST(mask, 2)
89#define W SWS_COMP_TEST(mask, 3)
92#define DECL_FUNC(NAME, ...) \
93 av_always_inline static void \
94 fn(NAME)(SwsOpIter *restrict iter, const SwsOpImpl *restrict impl, \
95 pixel_t *restrict x, pixel_t *restrict y, \
96 pixel_t *restrict z, pixel_t *restrict w, \
99#define DECL_READ(NAME, ...) \
100 DECL_FUNC(NAME, __VA_ARGS__, \
101 const pixel_t *restrict in0, const pixel_t *restrict in1, \
102 const pixel_t *restrict in2, const pixel_t *restrict in3) \
104#define DECL_WRITE(NAME, ...) \
105 DECL_FUNC(NAME, __VA_ARGS__, \
106 pixel_t *restrict out0, pixel_t *restrict out1, \
107 pixel_t *restrict out2, pixel_t *restrict out3) \
109#define CALL(NAME, ...) fn(NAME)(iter, impl, x, y, z, w, __VA_ARGS__)
112#define CONTINUE(...) \
113 ((void (*)(SwsOpIter *, const SwsOpImpl *, \
114 void *restrict x, void *restrict y, \
115 void *restrict z, void *restrict w)) impl->cont) \
116 (iter, &impl[1], __VA_ARGS__)
119#define DECL_SETUP(NAME, PARAMS, OUT) \
120 av_unused static int fn(NAME)(const SwsImplParams *PARAMS, \
124#define DECL_IMPL(FUNC, NAME, TYPE, UOP, ...) \
125 av_flatten static void NAME##_c(SwsOpIter *restrict iter, \
126 const SwsOpImpl *restrict impl, \
127 void *restrict x, void *restrict y, \
128 void *restrict z, void *restrict w) \
130 CALL(FUNC, __VA_ARGS__); \
133#define DECL_IMPL_READ(...) \
134 DECL_IMPL(__VA_ARGS__, \
135 (const pixel_t *) iter->in[0], (const pixel_t *) iter->in[1], \
136 (const pixel_t *) iter->in[2], (const pixel_t *) iter->in[3])
138#define DECL_IMPL_WRITE(...) \
139 DECL_IMPL(__VA_ARGS__, \
140 (pixel_t *) iter->out[0], (pixel_t *) iter->out[1], \
141 (pixel_t *) iter->out[2], (pixel_t *) iter->out[3])
143#define REF_ENTRY(DUMMY, NAME, ...) &uop_##NAME,
144#define DECL_ENTRY(SETUP, NAME, ...) \
145 static const SwsUOpEntry uop_##NAME = { \
146 .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.