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...
 

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 50 of file uops_tmpl.c.

◆ pixel_t

#define pixel_t   uint8_t

Definition at line 51 of file uops_tmpl.c.

◆ inter_t

#define inter_t   int32_t

Definition at line 52 of file uops_tmpl.c.

◆ PX

#define PX   U8

Definition at line 53 of file uops_tmpl.c.

◆ px

#define px   u8

Definition at line 54 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 417 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 63 of file uops_tmpl.c.

◆ DECL_READ() [2/7]

DECL_READ ( read_packed  ,
const SwsCompMask  mask 
)

Definition at line 81 of file uops_tmpl.c.

◆ DECL_WRITE() [1/4]

DECL_WRITE ( write_planar  ,
const SwsCompMask  mask 
)

Definition at line 97 of file uops_tmpl.c.

◆ DECL_WRITE() [2/4]

DECL_WRITE ( write_packed  ,
const SwsCompMask  mask 
)

Definition at line 113 of file uops_tmpl.c.

◆ DECL_READ() [3/7]

DECL_READ ( read_bit  ,
const SwsCompMask  mask 
)

Definition at line 130 of file uops_tmpl.c.

◆ DECL_READ() [4/7]

DECL_READ ( read_nibble  ,
const SwsCompMask  mask 
)

Definition at line 151 of file uops_tmpl.c.

◆ DECL_READ() [5/7]

DECL_READ ( read_palette  ,
const SwsCompMask  mask 
)

Definition at line 166 of file uops_tmpl.c.

◆ DECL_WRITE() [3/4]

DECL_WRITE ( write_bit  ,
const SwsCompMask  mask 
)

Definition at line 184 of file uops_tmpl.c.

◆ DECL_WRITE() [4/4]

DECL_WRITE ( write_nibble  ,
const SwsCompMask  mask 
)

Definition at line 203 of file uops_tmpl.c.

◆ DECL_SETUP() [1/4]

DECL_SETUP ( setup_filter_v  ,
params  ,
out   
)

Definition at line 240 of file uops_tmpl.c.

◆ DECL_READ() [6/7]

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

Definition at line 264 of file uops_tmpl.c.

◆ DECL_SETUP() [2/4]

DECL_SETUP ( setup_filter_h  ,
params  ,
out   
)

Definition at line 303 of file uops_tmpl.c.

◆ DECL_READ() [7/7]

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

Definition at line 316 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 363 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 383 of file uops_tmpl.c.

◆ DECL_FUNC() [3/16]

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

Definition at line 446 of file uops_tmpl.c.

◆ DECL_FUNC() [4/16]

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

Definition at line 459 of file uops_tmpl.c.

◆ DECL_FUNC() [5/16]

DECL_FUNC ( expand_bit  ,
const SwsCompMask  mask 
)

Definition at line 498 of file uops_tmpl.c.

◆ DECL_FUNC() [6/16]

DECL_FUNC ( expand_pair  ,
const SwsCompMask  mask 
)

Definition at line 513 of file uops_tmpl.c.

◆ DECL_FUNC() [7/16]

DECL_FUNC ( expand_quad  ,
const SwsCompMask  mask 
)

Definition at line 528 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 556 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 582 of file uops_tmpl.c.

◆ DECL_FUNC() [10/16]

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

Definition at line 615 of file uops_tmpl.c.

◆ DECL_FUNC() [11/16]

DECL_FUNC ( scale  ,
const SwsCompMask  mask 
)

Definition at line 644 of file uops_tmpl.c.

◆ DECL_FUNC() [12/16]

DECL_FUNC ( add  ,
const SwsCompMask  mask 
)

Definition at line 659 of file uops_tmpl.c.

◆ DECL_FUNC() [13/16]

DECL_FUNC ( min  ,
const SwsCompMask  mask 
)

Definition at line 672 of file uops_tmpl.c.

◆ DECL_FUNC() [14/16]

DECL_FUNC ( max  ,
const SwsCompMask  mask 
)

Definition at line 685 of file uops_tmpl.c.

◆ DECL_SETUP() [3/4]

DECL_SETUP ( setup_dither  ,
params  ,
out   
)

Definition at line 711 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 745 of file uops_tmpl.c.

◆ DECL_SETUP() [4/4]

DECL_SETUP ( setup_linear  ,
params  ,
out   
)

Definition at line 786 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 808 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:53
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:87
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:363
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:229
X
@ X
Definition: vf_addroi.c:27