FFmpeg
Data Structures | Macros | Functions
uops_tmpl.c File Reference
#include <libavutil/bswap.h>
#include "uops_tmpl.h"

Go to the source code of this file.

Data Structures

struct  fn
 

Macros

#define BIT_DEPTH   8
 Copyright (C) 2026 Niklas Haas. More...
 
#define PIXEL_MAX   0xFFu
 
#define pixel_t   uint8_t
 
#define inter_t   int32_t
 
#define PX   U8
 
#define px   u8
 
#define DECL_CAST(DST, dst)
 
#define ONE(N)   SWS_COMP_TEST(one, N)
 
#define ZERO(N)   SWS_COMP_TEST(zero, N)
 
#define LIN_VAL(I, J, val)   ((one & SWS_MASK(I, J)) ? (val) : c.m[I][J] * (val))
 
#define LIN_ROW(I, var)
 

Functions

 DECL_READ (read_planar, const SwsCompMask mask)
 
 DECL_READ (read_packed, const SwsCompMask mask)
 
 DECL_WRITE (write_planar, const SwsCompMask mask)
 
 DECL_WRITE (write_packed, const SwsCompMask mask)
 
 DECL_READ (read_bit, const SwsCompMask mask)
 
 DECL_READ (read_nibble, const SwsCompMask mask)
 
 DECL_READ (read_palette, const SwsCompMask mask)
 
 DECL_WRITE (write_bit, const SwsCompMask mask)
 
 DECL_WRITE (write_nibble, const SwsCompMask mask)
 
 DECL_SETUP (setup_filter_v, params, out)
 
 DECL_READ (read_planar_fv, const SwsCompMask mask, const SwsPixelType type)
 
 DECL_SETUP (setup_filter_h, params, out)
 
 DECL_READ (read_planar_fh, const SwsCompMask mask, const SwsPixelType type)
 
 DECL_FUNC (permute, const SwsCompMask mask, int num_moves, int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t s0, int8_t s1, int8_t s2, int8_t s3, int8_t s4, int8_t s5)
 
 DECL_FUNC (copy, const SwsCompMask mask, int num_moves, int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t s0, int8_t s1, int8_t s2, int8_t s3, int8_t s4, int8_t s5)
 
 DECL_FUNC (lshift, const SwsCompMask mask, const uint8_t amount)
 
 DECL_FUNC (rshift, const SwsCompMask mask, const uint8_t amount)
 
 DECL_FUNC (expand_bit, const SwsCompMask mask)
 
 DECL_FUNC (expand_pair, const SwsCompMask mask)
 
 DECL_FUNC (expand_quad, const SwsCompMask mask)
 
 DECL_FUNC (unpack, const SwsCompMask mask, const uint8_t bx, const uint8_t by, const uint8_t bz, const uint8_t bw)
 
 DECL_FUNC (pack, const SwsCompMask mask, const uint8_t bx, const uint8_t by, const uint8_t bz, const uint8_t bw)
 
 DECL_FUNC (clear, const SwsCompMask mask, const SwsCompMask one, const SwsCompMask zero)
 
 DECL_FUNC (scale, const SwsCompMask mask)
 
 DECL_FUNC (add, const SwsCompMask mask)
 
 DECL_FUNC (min, const SwsCompMask mask)
 
 DECL_FUNC (max, const SwsCompMask mask)
 
 DECL_SETUP (setup_dither, params, out)
 
 DECL_FUNC (dither, const SwsCompMask mask, const uint8_t off0, const uint8_t off1, const uint8_t off2, const uint8_t off3, const uint8_t size_log2)
 
 DECL_SETUP (setup_linear, params, out)
 
 DECL_FUNC (linear, const SwsCompMask mask, const uint32_t one, const uint32_t zero)
 Fully general case for a 5x5 linear affine transformation. More...
 
 DECL_SETUP (setup_lut3d, params, out)
 

Macro Definition Documentation

◆ BIT_DEPTH

#define BIT_DEPTH   8

Copyright (C) 2026 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 26 of file uops_tmpl.c.

◆ PIXEL_MAX

#define PIXEL_MAX   0xFFu

Definition at line 51 of file uops_tmpl.c.

◆ pixel_t

#define pixel_t   uint8_t

Definition at line 52 of file uops_tmpl.c.

◆ inter_t

#define inter_t   int32_t

Definition at line 53 of file uops_tmpl.c.

◆ PX

#define PX   U8

Definition at line 54 of file uops_tmpl.c.

◆ px

#define px   u8

Definition at line 55 of file uops_tmpl.c.

◆ DECL_CAST

#define DECL_CAST (   DST,
  dst 
)
Value:
DECL_FUNC(to_##dst, const SwsCompMask mask) \
{ \
block_t xx, yy, zz, ww; \
for (int i = 0; i < SWS_BLOCK_SIZE; i++) { \
if (X) xx.dst[i] = x[i]; \
if (Y) yy.dst[i] = y[i]; \
if (Z) zz.dst[i] = z[i]; \
if (W) ww.dst[i] = w[i]; \
} \
CONTINUE(&xx, &yy, &zz, &ww); \
} \
SWS_FOR(PX, TO_##DST, DECL_IMPL, to_##dst) \
SWS_FOR_STRUCT(PX, TO_##DST, DECL_ENTRY)

Definition at line 418 of file uops_tmpl.c.

◆ ONE

#define ONE (   N)    SWS_COMP_TEST(one, N)

◆ ZERO

#define ZERO (   N)    SWS_COMP_TEST(zero, N)

◆ LIN_VAL

#define LIN_VAL (   I,
  J,
  val 
)    ((one & SWS_MASK(I, J)) ? (val) : c.m[I][J] * (val))

◆ LIN_ROW

#define LIN_ROW (   I,
  var 
)
Value:
do { \
var[i] = (zero & SWS_MASK(I, 4)) ? 0 : c.k[I]; \
if (!(zero & SWS_MASK(I, 0))) var[i] += LIN_VAL(I, 0, xx); \
if (!(zero & SWS_MASK(I, 1))) var[i] += LIN_VAL(I, 1, yy); \
if (!(zero & SWS_MASK(I, 2))) var[i] += LIN_VAL(I, 2, zz); \
if (!(zero & SWS_MASK(I, 3))) var[i] += LIN_VAL(I, 3, ww); \
} while (0)

Function Documentation

◆ DECL_READ() [1/7]

DECL_READ ( read_planar  ,
const SwsCompMask  mask 
)

Definition at line 64 of file uops_tmpl.c.

◆ DECL_READ() [2/7]

DECL_READ ( read_packed  ,
const SwsCompMask  mask 
)

Definition at line 82 of file uops_tmpl.c.

◆ DECL_WRITE() [1/4]

DECL_WRITE ( write_planar  ,
const SwsCompMask  mask 
)

Definition at line 98 of file uops_tmpl.c.

◆ DECL_WRITE() [2/4]

DECL_WRITE ( write_packed  ,
const SwsCompMask  mask 
)

Definition at line 114 of file uops_tmpl.c.

◆ DECL_READ() [3/7]

DECL_READ ( read_bit  ,
const SwsCompMask  mask 
)

Definition at line 131 of file uops_tmpl.c.

◆ DECL_READ() [4/7]

DECL_READ ( read_nibble  ,
const SwsCompMask  mask 
)

Definition at line 152 of file uops_tmpl.c.

◆ DECL_READ() [5/7]

DECL_READ ( read_palette  ,
const SwsCompMask  mask 
)

Definition at line 167 of file uops_tmpl.c.

◆ DECL_WRITE() [3/4]

DECL_WRITE ( write_bit  ,
const SwsCompMask  mask 
)

Definition at line 185 of file uops_tmpl.c.

◆ DECL_WRITE() [4/4]

DECL_WRITE ( write_nibble  ,
const SwsCompMask  mask 
)

Definition at line 204 of file uops_tmpl.c.

◆ DECL_SETUP() [1/5]

DECL_SETUP ( setup_filter_v  ,
params  ,
out   
)

Definition at line 241 of file uops_tmpl.c.

◆ DECL_READ() [6/7]

DECL_READ ( read_planar_fv  ,
const SwsCompMask  mask,
const SwsPixelType  type 
)

Definition at line 265 of file uops_tmpl.c.

◆ DECL_SETUP() [2/5]

DECL_SETUP ( setup_filter_h  ,
params  ,
out   
)

Definition at line 304 of file uops_tmpl.c.

◆ DECL_READ() [7/7]

DECL_READ ( read_planar_fh  ,
const SwsCompMask  mask,
const SwsPixelType  type 
)

Definition at line 317 of file uops_tmpl.c.

◆ DECL_FUNC() [1/16]

DECL_FUNC ( permute  ,
const SwsCompMask  mask,
int  num_moves,
int8_t  d0,
int8_t  d1,
int8_t  d2,
int8_t  d3,
int8_t  d4,
int8_t  d5,
int8_t  s0,
int8_t  s1,
int8_t  s2,
int8_t  s3,
int8_t  s4,
int8_t  s5 
)

Definition at line 364 of file uops_tmpl.c.

◆ DECL_FUNC() [2/16]

DECL_FUNC ( copy  ,
const SwsCompMask  mask,
int  num_moves,
int8_t  d0,
int8_t  d1,
int8_t  d2,
int8_t  d3,
int8_t  d4,
int8_t  d5,
int8_t  s0,
int8_t  s1,
int8_t  s2,
int8_t  s3,
int8_t  s4,
int8_t  s5 
)

Definition at line 384 of file uops_tmpl.c.

◆ DECL_FUNC() [3/16]

DECL_FUNC ( lshift  ,
const SwsCompMask  mask,
const uint8_t  amount 
)

Definition at line 447 of file uops_tmpl.c.

◆ DECL_FUNC() [4/16]

DECL_FUNC ( rshift  ,
const SwsCompMask  mask,
const uint8_t  amount 
)

Definition at line 460 of file uops_tmpl.c.

◆ DECL_FUNC() [5/16]

DECL_FUNC ( expand_bit  ,
const SwsCompMask  mask 
)

Definition at line 499 of file uops_tmpl.c.

◆ DECL_FUNC() [6/16]

DECL_FUNC ( expand_pair  ,
const SwsCompMask  mask 
)

Definition at line 514 of file uops_tmpl.c.

◆ DECL_FUNC() [7/16]

DECL_FUNC ( expand_quad  ,
const SwsCompMask  mask 
)

Definition at line 529 of file uops_tmpl.c.

◆ DECL_FUNC() [8/16]

DECL_FUNC ( unpack  ,
const SwsCompMask  mask,
const uint8_t  bx,
const uint8_t  by,
const uint8_t  bz,
const uint8_t  bw 
)

Definition at line 557 of file uops_tmpl.c.

◆ DECL_FUNC() [9/16]

DECL_FUNC ( pack  ,
const SwsCompMask  mask,
const uint8_t  bx,
const uint8_t  by,
const uint8_t  bz,
const uint8_t  bw 
)

Definition at line 583 of file uops_tmpl.c.

◆ DECL_FUNC() [10/16]

DECL_FUNC ( clear  ,
const SwsCompMask  mask,
const SwsCompMask  one,
const SwsCompMask  zero 
)

Definition at line 616 of file uops_tmpl.c.

◆ DECL_FUNC() [11/16]

DECL_FUNC ( scale  ,
const SwsCompMask  mask 
)

Definition at line 645 of file uops_tmpl.c.

◆ DECL_FUNC() [12/16]

DECL_FUNC ( add  ,
const SwsCompMask  mask 
)

Definition at line 660 of file uops_tmpl.c.

◆ DECL_FUNC() [13/16]

DECL_FUNC ( min  ,
const SwsCompMask  mask 
)

Definition at line 673 of file uops_tmpl.c.

◆ DECL_FUNC() [14/16]

DECL_FUNC ( max  ,
const SwsCompMask  mask 
)

Definition at line 686 of file uops_tmpl.c.

◆ DECL_SETUP() [3/5]

DECL_SETUP ( setup_dither  ,
params  ,
out   
)

Definition at line 712 of file uops_tmpl.c.

◆ DECL_FUNC() [15/16]

DECL_FUNC ( dither  ,
const SwsCompMask  mask,
const uint8_t  off0,
const uint8_t  off1,
const uint8_t  off2,
const uint8_t  off3,
const uint8_t  size_log2 
)

Definition at line 746 of file uops_tmpl.c.

◆ DECL_SETUP() [4/5]

DECL_SETUP ( setup_linear  ,
params  ,
out   
)

Definition at line 787 of file uops_tmpl.c.

◆ DECL_FUNC() [16/16]

DECL_FUNC ( linear  ,
const SwsCompMask  mask,
const uint32_t  one,
const uint32_t  zero 
)

Fully general case for a 5x5 linear affine transformation.

Should never be called without constant mask. This function will compile down to the appropriately optimized version for the required subset of operations when called with a constant mask.

Definition at line 809 of file uops_tmpl.c.

◆ DECL_SETUP() [5/5]

DECL_SETUP ( setup_lut3d  ,
params  ,
out   
)

Definition at line 847 of file uops_tmpl.c.

Z
#define Z
Definition: uops_tmpl.h:83
DECL_ENTRY
#define DECL_ENTRY(SETUP, NAME,...)
Definition: uops_tmpl.h:139
mask
int mask
Definition: mediacodecdec_common.c:154
PX
#define PX
Definition: uops_tmpl.c:54
SWS_FOR
#define SWS_FOR(TYPE, UOP, MACRO,...)
Definition: uops_macros.h:17
W
#define W(a, i, v)
Definition: jpegls.h:119
SwsCompMask
uint8_t SwsCompMask
Bit-mask of components.
Definition: uops.h:88
if
if(ret)
Definition: filter_design.txt:179
DECL_IMPL
#define DECL_IMPL(FUNC, NAME, TYPE, UOP,...)
Definition: uops_tmpl.h:119
SWS_BLOCK_SIZE
#define SWS_BLOCK_SIZE
Copyright (C) 2026 Niklas Haas.
Definition: uops_tmpl.h:40
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
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
zero
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:121
Y
#define Y
Definition: boxblur.h:37
CONTINUE
#define CONTINUE(...)
Definition: uops_tmpl.h:107
DECL_FUNC
DECL_FUNC(permute, const SwsCompMask mask, int num_moves, int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t d4, int8_t d5, int8_t s0, int8_t s1, int8_t s2, int8_t s3, int8_t s4, int8_t s5)
Definition: uops_tmpl.c:364
X
@ X
Definition: vf_addroi.c:27
DST
#define DST(x, y)
Definition: vp9dsp_template.c:813
w
uint8_t w
Definition: llvidencdsp.c:39
LIN_VAL
#define LIN_VAL(I, J, val)
SWS_MASK
#define SWS_MASK(I, J)
Definition: uops.h:231