Go to the documentation of this file.
31 # define PIXEL_TYPE SWS_PIXEL_U32
32 # define PIXEL_MAX 0xFFFFFFFFu
33 # define SWAP_BYTES av_bswap32
34 # define pixel_t uint32_t
35 # define inter_t int64_t
36 # define block_t u32block_t
39 # define PIXEL_TYPE SWS_PIXEL_U16
40 # define PIXEL_MAX 0xFFFFu
41 # define SWAP_BYTES av_bswap16
42 # define pixel_t uint16_t
43 # define inter_t int64_t
44 # define block_t u16block_t
47 # define PIXEL_TYPE SWS_PIXEL_U8
48 # define PIXEL_MAX 0xFFu
49 # define pixel_t uint8_t
50 # define inter_t int32_t
51 # define block_t u8block_t
54 # error Invalid BIT_DEPTH
81 x[
i] = in0[elems *
i + 0];
83 y[
i] = in0[elems *
i + 1];
85 z[
i] = in0[elems *
i + 2];
87 w[
i] = in0[elems *
i + 3];
111 out0[elems *
i + 0] = x[
i];
113 out0[elems *
i + 1] = y[
i];
115 out0[elems *
i + 2] = z[
i];
117 out0[elems *
i + 3] =
w[
i];
121 #define WRAP_READ(FUNC, ELEMS, FRAC, PACKED) \
122 static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
123 const SwsOpImpl *restrict impl, \
124 void *restrict x, void *restrict y, \
125 void *restrict z, void *restrict w) \
127 CALL_READ(FUNC, ELEMS); \
128 for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
129 iter->in[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
132 DECL_ENTRY(FUNC##ELEMS, \
149 #define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED) \
150 static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
151 const SwsOpImpl *restrict impl, \
152 void *restrict x, void *restrict y, \
153 void *restrict z, void *restrict w) \
155 CALL_WRITE(FUNC, ELEMS); \
156 for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
157 iter->out[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
160 DECL_ENTRY(FUNC##ELEMS, \
161 .op = SWS_OP_WRITE, \
184 x[
i + 1] =
val & 0xF;
195 x[
i + 0] = (
val >> 7) & 1;
196 x[
i + 1] = (
val >> 6) & 1;
197 x[
i + 2] = (
val >> 5) & 1;
198 x[
i + 3] = (
val >> 4) & 1;
199 x[
i + 4] = (
val >> 3) & 1;
200 x[
i + 5] = (
val >> 2) & 1;
201 x[
i + 6] = (
val >> 1) & 1;
202 x[
i + 7] = (
val >> 0) & 1;
215 out0[
i >> 1] = x[
i] << 4 | x[
i + 1];
222 out0[
i >> 3] = x[
i + 0] << 7 |
243 x[
i] = SWAP_BYTES(x[
i]);
245 y[
i] = SWAP_BYTES(y[
i]);
247 z[
i] = SWAP_BYTES(z[
i]);
249 w[
i] = SWAP_BYTES(
w[
i]);
266 x16[
i] = x[
i] << 8 | x[
i];
268 y16[
i] = y[
i] << 8 | y[
i];
270 z16[
i] = z[
i] << 8 | z[
i];
272 w16[
i] =
w[
i] << 8 |
w[
i];
281 .convert.expand =
true,
290 x32[
i] = (uint32_t)x[
i] << 24 | x[
i] << 16 | x[
i] << 8 | x[
i];
291 y32[
i] = (uint32_t)y[
i] << 24 | y[
i] << 16 | y[
i] << 8 | y[
i];
292 z32[
i] = (uint32_t)z[
i] << 24 | z[
i] << 16 | z[
i] << 8 | z[
i];
293 w32[
i] = (uint32_t)
w[
i] << 24 |
w[
i] << 16 |
w[
i] << 8 |
w[
i];
302 .convert.expand =
true,
339 #define WRAP_PACK_UNPACK(X, Y, Z, W) \
340 DECL_IMPL(pack, pack_##X##Y##Z##W, X, Y, Z, W) \
342 DECL_ENTRY(pack_##X##Y##Z##W, \
344 .pack.pattern = { X, Y, Z, W }, \
347 DECL_IMPL(unpack, unpack_##X##Y##Z##W, X, Y, Z, W) \
349 DECL_ENTRY(unpack_##X##Y##Z##W, \
350 .op = SWS_OP_UNPACK, \
351 .pack.pattern = { X, Y, Z, W }, \
366 const uint8_t amount = impl->priv.u8[0];
381 const uint8_t amount = impl->priv.u8[0];
431 #define DECL_SWIZZLE(X, Y, Z, W) \
433 fn(swizzle_##X##Y##Z##W)(SwsOpIter *restrict iter, \
434 const SwsOpImpl *restrict impl, \
435 void *restrict c0, void *restrict c1, \
436 void *restrict c2, void *restrict c3) \
438 CONTINUE(c##X, c##Y, c##Z, c##W); \
441 DECL_ENTRY(swizzle_##X##Y##Z##W, \
442 .op = SWS_OP_SWIZZLE, \
443 .swizzle.in = { X, Y, Z, W }, \
466 #define DECL_EXPAND_LUMA(X, W, T0, T1) \
467 DECL_FUNC(expand_luma_##X##W##_impl, \
468 block_t c0, block_t c1, block_t c2, block_t c3) \
471 for (int i = 0; i < SWS_BLOCK_SIZE; i++) \
472 T0[i] = T1[i] = c0[i]; \
474 CONTINUE(c##X, T0, T1, c##W); \
477 DECL_IMPL(expand_luma_##X##W##_impl, expand_luma_##X##W, x, y, z, w) \
479 DECL_ENTRY(expand_luma_##X##W, \
480 .op = SWS_OP_SWIZZLE, \
481 .swizzle.in = { X, 0, 0, W }, \
492 &
fn(op_read_planar1),
493 &
fn(op_read_planar2),
494 &
fn(op_read_planar3),
495 &
fn(op_read_planar4),
496 &
fn(op_read_packed2),
497 &
fn(op_read_packed3),
498 &
fn(op_read_packed4),
500 &
fn(op_write_planar1),
501 &
fn(op_write_planar2),
502 &
fn(op_write_planar3),
503 &
fn(op_write_planar4),
504 &
fn(op_write_packed2),
505 &
fn(op_write_packed3),
506 &
fn(op_write_packed4),
520 &
fn(op_read_nibbles1),
522 &
fn(op_write_nibbles1),
534 #elif BIT_DEPTH == 16
541 #elif BIT_DEPTH == 32
542 &
fn(op_pack_2101010),
543 &
fn(op_pack_1010102),
544 &
fn(op_unpack_2101010),
545 &
fn(op_unpack_1010102),
569 &
fn(op_swizzle_3012),
570 &
fn(op_swizzle_3021),
571 &
fn(op_swizzle_2103),
572 &
fn(op_swizzle_3210),
573 &
fn(op_swizzle_3102),
574 &
fn(op_swizzle_3201),
575 &
fn(op_swizzle_1203),
576 &
fn(op_swizzle_1023),
577 &
fn(op_swizzle_2013),
578 &
fn(op_swizzle_2310),
579 &
fn(op_swizzle_2130),
580 &
fn(op_swizzle_1230),
581 &
fn(op_swizzle_1320),
582 &
fn(op_swizzle_0213),
583 &
fn(op_swizzle_0231),
584 &
fn(op_swizzle_0312),
585 &
fn(op_swizzle_3120),
586 &
fn(op_swizzle_0321),
588 &
fn(op_expand_luma_03),
589 &
fn(op_expand_luma_30),
590 &
fn(op_expand_luma_10),
591 &
fn(op_expand_luma_01),
Copyright (C) 2025 Niklas Haas.
float f32block_t[SWS_BLOCK_SIZE]
int ff_sws_setup_shift(const SwsImplParams *params, SwsImplResult *out)
static const uint8_t bits3[81]
#define CONTINUE(X, Y, Z, W)
static void convert(float y, float u, float v, float *b, float *g, float *r)
static double val(void *priv, double ch)
#define DECL_SWIZZLE(X, Y, Z, W)
Swizzle by directly swapping the order of arguments to the continuation.
static const uint8_t bits1[81]
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.
uint16_t u16block_t[SWS_BLOCK_SIZE]
uint32_t u32block_t[SWS_BLOCK_SIZE]
#define SWS_BLOCK_SIZE
Copyright (C) 2025 Niklas Haas.
static const SwsOpTable fn(op_table_int)
#define DECL_EXPAND_LUMA(X, W, T0, T1)
#define i(width, name, range_min, range_max)
static int read_bits(int bits, int *ppos, unsigned *src)
#define xf(width, name, var, range_min, range_max, subs,...)
#define WRAP_READ(FUNC, ELEMS, FRAC, PACKED)
static int unpack(const uint8_t *src, const uint8_t *src_end, uint8_t *dst, int width, int height)
Unpack buffer.
#define WRAP_PACK_UNPACK(X, Y, Z, W)
#define REF_COMMON_PATTERNS(NAME)
#define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED)
static const uint8_t bits0[]
static void scale(int *out, const int *in, const int w, const int h, const int shift)
DECL_WRITE(write_planar, const int elems)
WRAP_COMMON_PATTERNS(expand16,.op=SWS_OP_CONVERT,.convert.to=SWS_PIXEL_U16,.convert.expand=true,)
static const uint8_t bits2[81]
DECL_FUNC(pack, const int bits0, const int bits1, const int bits2, const int bits3)
DECL_READ(read_planar, const int elems)