FFmpeg
Macros | Functions
ops_tmpl_int.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/bswap.h"
#include "ops_backend.h"
#include "ops_tmpl_common.c"

Go to the source code of this file.

Macros

#define BIT_DEPTH   8
 Copyright (C) 2025 Niklas Haas. More...
 
#define PIXEL_TYPE   SWS_PIXEL_U8
 
#define PIXEL_MAX   0xFFu
 
#define pixel_t   uint8_t
 
#define inter_t   int32_t
 
#define block_t   u8block_t
 
#define px   u8
 
#define IS_FLOAT   0
 
#define FMT_CHAR   u
 
#define WRAP_READ(FUNC, ELEMS, FRAC, PACKED)
 
#define WRAP_WRITE(FUNC, ELEMS, FRAC, PACKED)
 
#define WRAP_PACK_UNPACK(X, Y, Z, W)
 
#define DECL_SWIZZLE(X, Y, Z, W)
 Swizzle by directly swapping the order of arguments to the continuation. More...
 
#define DECL_EXPAND_LUMA(X, W, T0, T1)
 

Functions

 DECL_READ (read_planar, const int elems)
 
 DECL_READ (read_packed, const int elems)
 
 DECL_WRITE (write_planar, const int elems)
 
 DECL_WRITE (write_packed, const int elems)
 
 DECL_READ (read_nibbles, const int elems)
 
 DECL_READ (read_bits, const int elems)
 
 DECL_WRITE (write_nibbles, const int elems)
 
 DECL_WRITE (write_bits, const int elems)
 
 DECL_PATTERN (expand16)
 
 WRAP_COMMON_PATTERNS (expand16,.op=SWS_OP_CONVERT,.convert.to=SWS_PIXEL_U16,.convert.expand=true,)
 
 DECL_PATTERN (expand32)
 
 WRAP_COMMON_PATTERNS (expand32,.op=SWS_OP_CONVERT,.convert.to=SWS_PIXEL_U32,.convert.expand=true,)
 
 DECL_FUNC (pack, const int bits0, const int bits1, const int bits2, const int bits3)
 
 DECL_FUNC (unpack, const int bits0, const int bits1, const int bits2, const int bits3)
 
 DECL_PATTERN (convert_float)
 
 WRAP_COMMON_PATTERNS (convert_float,.op=SWS_OP_CONVERT,.convert.to=SWS_PIXEL_F32,)
 
static const SwsOpTable fn (op_table_int)
 

Macro Definition Documentation

◆ BIT_DEPTH

#define BIT_DEPTH   8

Copyright (C) 2025 Niklas Haas.

This file is part of FFmpeg.

FFmpeg is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

FFmpeg is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with FFmpeg; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Definition at line 27 of file ops_tmpl_int.c.

◆ PIXEL_TYPE

#define PIXEL_TYPE   SWS_PIXEL_U8

Definition at line 47 of file ops_tmpl_int.c.

◆ PIXEL_MAX

#define PIXEL_MAX   0xFFu

Definition at line 48 of file ops_tmpl_int.c.

◆ pixel_t

#define pixel_t   uint8_t

Definition at line 49 of file ops_tmpl_int.c.

◆ inter_t

#define inter_t   int32_t

Definition at line 50 of file ops_tmpl_int.c.

◆ block_t

#define block_t   u8block_t

Definition at line 51 of file ops_tmpl_int.c.

◆ px

#define px   u8

Definition at line 52 of file ops_tmpl_int.c.

◆ IS_FLOAT

#define IS_FLOAT   0

Definition at line 57 of file ops_tmpl_int.c.

◆ FMT_CHAR

#define FMT_CHAR   u

Definition at line 58 of file ops_tmpl_int.c.

◆ WRAP_READ

#define WRAP_READ (   FUNC,
  ELEMS,
  FRAC,
  PACKED 
)
Value:
static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
const SwsOpImpl *restrict impl, \
void *restrict x, void *restrict y, \
void *restrict z, void *restrict w) \
{ \
CALL_READ(FUNC, ELEMS); \
for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
iter->in[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
} \
.rw = { \
.elems = ELEMS, \
.packed = PACKED, \
.frac = FRAC, \
}, \
);

Definition at line 121 of file ops_tmpl_int.c.

◆ WRAP_WRITE

#define WRAP_WRITE (   FUNC,
  ELEMS,
  FRAC,
  PACKED 
)
Value:
static av_flatten void fn(FUNC##ELEMS)(SwsOpIter *restrict iter, \
const SwsOpImpl *restrict impl, \
void *restrict x, void *restrict y, \
void *restrict z, void *restrict w) \
{ \
CALL_WRITE(FUNC, ELEMS); \
for (int i = 0; i < (PACKED ? 1 : ELEMS); i++) \
iter->out[i] += sizeof(block_t) * (PACKED ? ELEMS : 1) >> FRAC; \
} \
.rw = { \
.elems = ELEMS, \
.packed = PACKED, \
.frac = FRAC, \
}, \
);

Definition at line 149 of file ops_tmpl_int.c.

◆ WRAP_PACK_UNPACK

#define WRAP_PACK_UNPACK (   X,
  Y,
  Z,
  W 
)
Value:
DECL_IMPL(pack, pack_##X##Y##Z##W, X, Y, Z, W) \
DECL_ENTRY(pack_##X##Y##Z##W, SWS_COMP(0), \
.pack.pattern = { X, Y, Z, W }, \
); \
DECL_IMPL(unpack, unpack_##X##Y##Z##W, X, Y, Z, W) \
DECL_ENTRY(unpack_##X##Y##Z##W, SWS_COMP_MASK(X, Y, Z, W), \
.pack.pattern = { X, Y, Z, W }, \
);

Definition at line 339 of file ops_tmpl_int.c.

◆ DECL_SWIZZLE

#define DECL_SWIZZLE (   X,
  Y,
  Z,
  W 
)
Value:
static void \
fn(swizzle_##X##Y##Z##W)(SwsOpIter *restrict iter, \
const SwsOpImpl *restrict impl, \
void *restrict c0, void *restrict c1, \
void *restrict c2, void *restrict c3) \
{ \
CONTINUE(c##X, c##Y, c##Z, c##W); \
} \
DECL_ENTRY(swizzle_##X##Y##Z##W, SWS_COMP_ALL, \
.swizzle.in = { X, Y, Z, W }, \
);

Swizzle by directly swapping the order of arguments to the continuation.

Note that this is only safe to do if no arguments are duplicated.

Definition at line 431 of file ops_tmpl_int.c.

◆ DECL_EXPAND_LUMA

#define DECL_EXPAND_LUMA (   X,
  W,
  T0,
  T1 
)
Value:
DECL_FUNC(expand_luma_##X##W##_impl, \
{ \
for (int i = 0; i < SWS_BLOCK_SIZE; i++) \
T0[i] = T1[i] = c0[i]; \
CONTINUE(c##X, T0, T1, c##W); \
} \
DECL_IMPL(expand_luma_##X##W##_impl, expand_luma_##X##W, x, y, z, w) \
DECL_ENTRY(expand_luma_##X##W, SWS_COMP_ALL, \
.swizzle.in = { X, 0, 0, W }, \
);

Definition at line 466 of file ops_tmpl_int.c.

Function Documentation

◆ DECL_READ() [1/4]

DECL_READ ( read_planar  ,
const int  elems 
)

Definition at line 61 of file ops_tmpl_int.c.

◆ DECL_READ() [2/4]

DECL_READ ( read_packed  ,
const int  elems 
)

Definition at line 77 of file ops_tmpl_int.c.

◆ DECL_WRITE() [1/4]

DECL_WRITE ( write_planar  ,
const int  elems 
)

Definition at line 93 of file ops_tmpl_int.c.

◆ DECL_WRITE() [2/4]

DECL_WRITE ( write_packed  ,
const int  elems 
)

Definition at line 107 of file ops_tmpl_int.c.

◆ DECL_READ() [3/4]

DECL_READ ( read_nibbles  ,
const int  elems 
)

Definition at line 178 of file ops_tmpl_int.c.

◆ DECL_READ() [4/4]

DECL_READ ( read_bits  ,
const int  elems 
)

Definition at line 190 of file ops_tmpl_int.c.

◆ DECL_WRITE() [3/4]

DECL_WRITE ( write_nibbles  ,
const int  elems 
)

Definition at line 211 of file ops_tmpl_int.c.

◆ DECL_WRITE() [4/4]

DECL_WRITE ( write_bits  ,
const int  elems 
)

Definition at line 218 of file ops_tmpl_int.c.

◆ DECL_PATTERN() [1/3]

DECL_PATTERN ( expand16  )

Definition at line 259 of file ops_tmpl_int.c.

◆ WRAP_COMMON_PATTERNS() [1/3]

WRAP_COMMON_PATTERNS ( expand16  ,
op = SWS_OP_CONVERT,
.convert.  to = SWS_PIXEL_U16,
.convert.  expand = true 
)

◆ DECL_PATTERN() [2/3]

DECL_PATTERN ( expand32  )

Definition at line 284 of file ops_tmpl_int.c.

◆ WRAP_COMMON_PATTERNS() [2/3]

WRAP_COMMON_PATTERNS ( expand32  ,
op = SWS_OP_CONVERT,
.convert.  to = SWS_PIXEL_U32,
.convert.  expand = true 
)

◆ DECL_FUNC() [1/2]

DECL_FUNC ( pack  ,
const int  bits0,
const int  bits1,
const int  bits2,
const int  bits3 
)

Definition at line 306 of file ops_tmpl_int.c.

◆ DECL_FUNC() [2/2]

DECL_FUNC ( unpack  ,
const int  bits0,
const int  bits1,
const int  bits2,
const int  bits3 
)

Definition at line 322 of file ops_tmpl_int.c.

◆ DECL_PATTERN() [3/3]

DECL_PATTERN ( convert_float  )

Definition at line 407 of file ops_tmpl_int.c.

◆ WRAP_COMMON_PATTERNS() [3/3]

WRAP_COMMON_PATTERNS ( convert_float  ,
op = SWS_OP_CONVERT,
.convert.  to = SWS_PIXEL_F32 
)

◆ fn()

static const SwsOpTable fn ( op_table_int  )
static
SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:50
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:53
DECL_ENTRY
#define DECL_ENTRY(NAME, MASK,...)
Definition: ops_backend.h:134
SWS_OP_UNPACK
@ SWS_OP_UNPACK
Definition: ops.h:56
ELEMS
#define ELEMS
CONTINUE
#define CONTINUE(X, Y, Z, W)
Definition: ops_backend.h:115
SwsOpIter
Copyright (C) 2025 Niklas Haas.
Definition: ops_backend.h:46
c1
static const uint64_t c1
Definition: murmur3.c:52
SWS_COMP_ELEMS
#define SWS_COMP_ELEMS(N)
Definition: ops.h:91
SWS_COMP_MASK
#define SWS_COMP_MASK(X, Y, Z, W)
Definition: ops.h:92
W
#define W(a, i, v)
Definition: jpegls.h:119
op
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.
Definition: anm.c:76
SwsOpImpl
Definition: ops_chain.h:71
SWS_BLOCK_SIZE
#define SWS_BLOCK_SIZE
Copyright (C) 2025 Niklas Haas.
Definition: ops_backend.c:42
fn
static const SwsOpTable fn(op_table_int)
SWS_OP_PACK
@ SWS_OP_PACK
Definition: ops.h:57
SWS_COMP
#define SWS_COMP(X)
Definition: ops.h:88
SWS_COMP_ALL
@ SWS_COMP_ALL
Definition: ops.h:87
c
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
Definition: undefined.txt:32
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:51
Y
#define Y
Definition: boxblur.h:37
unpack
static int unpack(const uint8_t *src, const uint8_t *src_end, uint8_t *dst, int width, int height)
Unpack buffer.
Definition: eatgv.c:73
block_t
#define block_t
Definition: ops_tmpl_int.c:51
av_flatten
#define av_flatten
Definition: attributes.h:117
DECL_IMPL
#define DECL_IMPL(FUNC, NAME,...)
Definition: ops_backend.h:105
c2
static const uint64_t c2
Definition: murmur3.c:53
FUNC
#define FUNC(a)
Definition: bit_depth_template.c:104
w
uint8_t w
Definition: llvidencdsp.c:39
X
@ X
Definition: vf_addroi.c:27
DECL_FUNC
DECL_FUNC(pack, const int bits0, const int bits1, const int bits2, const int bits3)
Definition: ops_tmpl_int.c:306