FFmpeg
Macros | Functions | Variables
ops.c File Reference
#include <float.h>
#include <libavutil/avassert.h>
#include <libavutil/mem.h>
#include "../ops_chain.h"

Go to the source code of this file.

Macros

#define DECL_ENTRY(TYPE, NAME, ...)
 Copyright (C) 2025 Niklas Haas. More...
 
#define DECL_ASM(TYPE, NAME, ...)
 
#define DECL_PATTERN(TYPE, NAME, X, Y, Z, W, ...)
 
#define REF_PATTERN(NAME, X, Y, Z, W)   &op_p##X##Y##Z##W##_##NAME
 
#define DECL_COMMON_PATTERNS(TYPE, NAME, ...)
 
#define REF_COMMON_PATTERNS(NAME)
 
#define DECL_RW(EXT, TYPE, NAME, OP, ELEMS, PACKED, FRAC)
 
#define DECL_PACKED_RW(EXT, DEPTH)
 
#define DECL_PACK_UNPACK(EXT, TYPE, X, Y, Z, W)
 
#define DECL_SWAP_BYTES(EXT, TYPE, X, Y, Z, W)
 
#define DECL_CLEAR_ALPHA(EXT, IDX)
 
#define DECL_CLEAR_ZERO(EXT, IDX)
 
#define DECL_CLEAR(EXT, X, Y, Z, W)
 
#define DECL_SWIZZLE(EXT, X, Y, Z, W)
 
#define DECL_CONVERT(EXT, FROM, TO)
 
#define DECL_EXPAND(EXT, FROM, TO)
 
#define DECL_SHIFT16(EXT)
 
#define DECL_MIN_MAX(EXT)
 
#define DECL_SCALE(EXT)
 
#define DECL_DITHER(EXT, SIZE)
 
#define DECL_LINEAR(EXT, NAME, MASK)
 
#define DECL_FUNCS_8(SIZE, EXT, FLAG)
 
#define DECL_FUNCS_16(SIZE, EXT, FLAG)
 
#define DECL_FUNCS_32(SIZE, EXT, FLAG)
 
#define ASSIGN_SHUFFLE_FUNC(IN, OUT, EXT)
 
#define ASSIGN_PROCESS_FUNC(NAME)
 

Functions

static int setup_swap_bytes (const SwsOp *op, SwsOpPriv *out)
 
static int setup_clear (const SwsOp *op, SwsOpPriv *out)
 
static int setup_shift (const SwsOp *op, SwsOpPriv *out)
 
static int setup_dither (const SwsOp *op, SwsOpPriv *out)
 
static int setup_linear (const SwsOp *op, SwsOpPriv *out)
 
static av_const int get_mmsize (const int cpu_flags)
 
static bool op_is_type_invariant (const SwsOp *op)
 Returns true if the operation's implementation only depends on the block size, and not the underlying pixel type. More...
 
static int solve_shuffle (const SwsOpList *ops, int mmsize, SwsCompiledOp *out)
 
static void normalize_clear (SwsOp *op)
 
static int compile (SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
 

Variables

const SwsOpBackend backend_x86
 

Macro Definition Documentation

◆ DECL_ENTRY

#define DECL_ENTRY (   TYPE,
  NAME,
  ... 
)
Value:
static const SwsOpEntry op_##NAME = { \
.type = SWS_PIXEL_##TYPE, \
__VA_ARGS__ \
}

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 28 of file ops.c.

◆ DECL_ASM

#define DECL_ASM (   TYPE,
  NAME,
  ... 
)
Value:
void ff_##NAME(void); \
DECL_ENTRY(TYPE, NAME, \
.func = ff_##NAME, \
__VA_ARGS__)

Definition at line 34 of file ops.c.

◆ DECL_PATTERN

#define DECL_PATTERN (   TYPE,
  NAME,
  X,
  Y,
  Z,
  W,
  ... 
)
Value:
DECL_ASM(TYPE, p##X##Y##Z##W##_##NAME, \
.unused = { !X, !Y, !Z, !W }, \
__VA_ARGS__ \
)

Definition at line 40 of file ops.c.

◆ REF_PATTERN

#define REF_PATTERN (   NAME,
  X,
  Y,
  Z,
  W 
)    &op_p##X##Y##Z##W##_##NAME

Definition at line 46 of file ops.c.

◆ DECL_COMMON_PATTERNS

#define DECL_COMMON_PATTERNS (   TYPE,
  NAME,
  ... 
)
Value:
DECL_PATTERN(TYPE, NAME, 1, 0, 0, 0, __VA_ARGS__); \
DECL_PATTERN(TYPE, NAME, 1, 0, 0, 1, __VA_ARGS__); \
DECL_PATTERN(TYPE, NAME, 1, 1, 1, 0, __VA_ARGS__); \
DECL_PATTERN(TYPE, NAME, 1, 1, 1, 1, __VA_ARGS__) \

Definition at line 49 of file ops.c.

◆ REF_COMMON_PATTERNS

#define REF_COMMON_PATTERNS (   NAME)
Value:
REF_PATTERN(NAME, 1, 0, 0, 0), \
REF_PATTERN(NAME, 1, 0, 0, 1), \
REF_PATTERN(NAME, 1, 1, 1, 0), \
REF_PATTERN(NAME, 1, 1, 1, 1)

Definition at line 55 of file ops.c.

◆ DECL_RW

#define DECL_RW (   EXT,
  TYPE,
  NAME,
  OP,
  ELEMS,
  PACKED,
  FRAC 
)
Value:
DECL_ASM(TYPE, NAME##ELEMS##EXT, \
.op = SWS_OP_##OP, \
.rw = { .elems = ELEMS, .packed = PACKED, .frac = FRAC }, \
);

Definition at line 61 of file ops.c.

◆ DECL_PACKED_RW

#define DECL_PACKED_RW (   EXT,
  DEPTH 
)
Value:
DECL_RW(EXT, U##DEPTH, read##DEPTH##_packed, READ, 2, true, 0) \
DECL_RW(EXT, U##DEPTH, read##DEPTH##_packed, READ, 3, true, 0) \
DECL_RW(EXT, U##DEPTH, read##DEPTH##_packed, READ, 4, true, 0) \
DECL_RW(EXT, U##DEPTH, write##DEPTH##_packed, WRITE, 2, true, 0) \
DECL_RW(EXT, U##DEPTH, write##DEPTH##_packed, WRITE, 3, true, 0) \
DECL_RW(EXT, U##DEPTH, write##DEPTH##_packed, WRITE, 4, true, 0) \

Definition at line 67 of file ops.c.

◆ DECL_PACK_UNPACK

#define DECL_PACK_UNPACK (   EXT,
  TYPE,
  X,
  Y,
  Z,
  W 
)
Value:
DECL_ASM(TYPE, pack_##X##Y##Z##W##EXT, \
.pack.pattern = {X, Y, Z, W}, \
); \
DECL_ASM(TYPE, unpack_##X##Y##Z##W##EXT, \
.pack.pattern = {X, Y, Z, W}, \
); \

Definition at line 75 of file ops.c.

◆ DECL_SWAP_BYTES

#define DECL_SWAP_BYTES (   EXT,
  TYPE,
  X,
  Y,
  Z,
  W 
)
Value:
DECL_ENTRY(TYPE, p##X##Y##Z##W##_swap_bytes_##TYPE##EXT, \
.unused = { !X, !Y, !Z, !W }, \
.func = ff_p##X##Y##Z##W##_shuffle##EXT, \
.setup = setup_swap_bytes, \
);

Definition at line 94 of file ops.c.

◆ DECL_CLEAR_ALPHA

#define DECL_CLEAR_ALPHA (   EXT,
  IDX 
)
Value:
DECL_ASM(U8, clear_alpha##IDX##EXT, \
.clear_value = -1, \
.unused[IDX] = true, \
); \

Definition at line 102 of file ops.c.

◆ DECL_CLEAR_ZERO

#define DECL_CLEAR_ZERO (   EXT,
  IDX 
)
Value:
DECL_ASM(U8, clear_zero##IDX##EXT, \
.clear_value = 0, \
.unused[IDX] = true, \
);

Definition at line 109 of file ops.c.

◆ DECL_CLEAR

#define DECL_CLEAR (   EXT,
  X,
  Y,
  Z,
  W 
)
Value:
DECL_PATTERN(U8, clear##EXT, X, Y, Z, W, \
.setup = setup_clear, \
.flexible = true, \
);

Definition at line 123 of file ops.c.

◆ DECL_SWIZZLE

#define DECL_SWIZZLE (   EXT,
  X,
  Y,
  Z,
  W 
)
Value:
DECL_ASM(U8, swizzle_##X##Y##Z##W##EXT, \
.swizzle.in = {X, Y, Z, W}, \
);

Definition at line 130 of file ops.c.

◆ DECL_CONVERT

#define DECL_CONVERT (   EXT,
  FROM,
  TO 
)
Value:
DECL_COMMON_PATTERNS(FROM, convert_##FROM##_##TO##EXT, \
.convert.to = SWS_PIXEL_##TO, \
);

Definition at line 136 of file ops.c.

◆ DECL_EXPAND

#define DECL_EXPAND (   EXT,
  FROM,
  TO 
)
Value:
DECL_COMMON_PATTERNS(FROM, expand_##FROM##_##TO##EXT, \
.convert.to = SWS_PIXEL_##TO, \
.convert.expand = true, \
);

Definition at line 142 of file ops.c.

◆ DECL_SHIFT16

#define DECL_SHIFT16 (   EXT)
Value:
DECL_COMMON_PATTERNS(U16, lshift16##EXT, \
.setup = setup_shift, \
.flexible = true, \
); \
DECL_COMMON_PATTERNS(U16, rshift16##EXT, \
.setup = setup_shift, \
.flexible = true, \
);

Definition at line 155 of file ops.c.

◆ DECL_MIN_MAX

#define DECL_MIN_MAX (   EXT)
Value:
.op = SWS_OP_MIN, \
.setup = ff_sws_setup_q4, \
.flexible = true, \
); \
.op = SWS_OP_MAX, \
.setup = ff_sws_setup_q4, \
.flexible = true, \
);

Definition at line 168 of file ops.c.

◆ DECL_SCALE

#define DECL_SCALE (   EXT)
Value:

Definition at line 181 of file ops.c.

◆ DECL_DITHER

#define DECL_DITHER (   EXT,
  SIZE 
)
Value:
.setup = setup_dither, \
.free = SIZE > 2 ? av_free : NULL, \
.dither_size = SIZE, \
);

Definition at line 205 of file ops.c.

◆ DECL_LINEAR

#define DECL_LINEAR (   EXT,
  NAME,
  MASK 
)
Value:
DECL_ASM(F32, NAME##EXT, \
.setup = setup_linear, \
.free = av_free, \
.linear_mask = (MASK), \
);

Definition at line 227 of file ops.c.

◆ DECL_FUNCS_8

#define DECL_FUNCS_8 (   SIZE,
  EXT,
  FLAG 
)

Definition at line 235 of file ops.c.

◆ DECL_FUNCS_16

#define DECL_FUNCS_16 (   SIZE,
  EXT,
  FLAG 
)

Definition at line 363 of file ops.c.

◆ DECL_FUNCS_32

#define DECL_FUNCS_32 (   SIZE,
  EXT,
  FLAG 
)

Definition at line 403 of file ops.c.

◆ ASSIGN_SHUFFLE_FUNC

#define ASSIGN_SHUFFLE_FUNC (   IN,
  OUT,
  EXT 
)
Value:
do { \
SWS_DECL_FUNC(ff_packed_shuffle##IN##_##OUT##_##EXT); \
if (in_total == IN && out_total == OUT) \
out->func = ff_packed_shuffle##IN##_##OUT##_##EXT; \
} while (0)

◆ ASSIGN_PROCESS_FUNC

#define ASSIGN_PROCESS_FUNC (   NAME)
Value:
do { \
SWS_DECL_FUNC(NAME); \
void NAME##_return(void); \
ret = ff_sws_op_chain_append(chain, NAME##_return, \
NULL, (SwsOpPriv) {0}); \
out->func = NAME; \
} while (0)

Function Documentation

◆ setup_swap_bytes()

static int setup_swap_bytes ( const SwsOp op,
SwsOpPriv out 
)
static

Definition at line 86 of file ops.c.

◆ setup_clear()

static int setup_clear ( const SwsOp op,
SwsOpPriv out 
)
static

Definition at line 116 of file ops.c.

◆ setup_shift()

static int setup_shift ( const SwsOp op,
SwsOpPriv out 
)
static

Definition at line 149 of file ops.c.

◆ setup_dither()

static int setup_dither ( const SwsOp op,
SwsOpPriv out 
)
static

Definition at line 189 of file ops.c.

◆ setup_linear()

static int setup_linear ( const SwsOp op,
SwsOpPriv out 
)
static

Definition at line 213 of file ops.c.

◆ get_mmsize()

static av_const int get_mmsize ( const int  cpu_flags)
static

Definition at line 510 of file ops.c.

Referenced by compile().

◆ op_is_type_invariant()

static bool op_is_type_invariant ( const SwsOp op)
static

Returns true if the operation's implementation only depends on the block size, and not the underlying pixel type.

Definition at line 526 of file ops.c.

Referenced by compile().

◆ solve_shuffle()

static int solve_shuffle ( const SwsOpList ops,
int  mmsize,
SwsCompiledOp out 
)
static

Definition at line 540 of file ops.c.

Referenced by compile().

◆ normalize_clear()

static void normalize_clear ( SwsOp op)
static

Definition at line 605 of file ops.c.

Referenced by compile().

◆ compile()

static int compile ( SwsContext ctx,
SwsOpList ops,
SwsCompiledOp out 
)
static

Definition at line 629 of file ops.c.

Variable Documentation

◆ backend_x86

const SwsOpBackend backend_x86
Initial value:
= {
.name = "x86",
.compile = compile,
}

Definition at line 720 of file ops.c.

func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
W
@ W
Definition: vf_addroi.c:27
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:58
SWS_OP_LSHIFT
@ SWS_OP_LSHIFT
Definition: ops.h:56
SWS_OP_UNPACK
@ SWS_OP_UNPACK
Definition: ops.h:51
setup_linear
static int setup_linear(const SwsOp *op, SwsOpPriv *out)
Definition: ops.c:213
SWS_OP_CLEAR
@ SWS_OP_CLEAR
Definition: ops.h:55
SWS_OP_DITHER
@ SWS_OP_DITHER
Definition: ops.h:60
ELEMS
#define ELEMS
SwsOpEntry::type
SwsPixelType type
Definition: ops_chain.h:98
max
#define max(a, b)
Definition: cuda_runtime.h:33
convert
static void convert(float y, float u, float v, float *b, float *g, float *r)
Definition: exr.c:968
READ
#define READ
Definition: cbs_apv.c:84
U16
@ U16
Definition: sw_ops.c:40
X
@ X
Definition: vf_addroi.c:27
DECL_RW
#define DECL_RW(EXT, TYPE, NAME, OP, ELEMS, PACKED, FRAC)
Definition: ops.c:61
SWS_OP_SCALE
@ SWS_OP_SCALE
Definition: ops.h:64
setup_dither
static int setup_dither(const SwsOp *op, SwsOpPriv *out)
Definition: ops.c:189
ff_sws_setup_q
int ff_sws_setup_q(const SwsOp *op, SwsOpPriv *out)
Definition: ops_chain.c:265
DECL_ENTRY
#define DECL_ENTRY(TYPE, NAME,...)
Copyright (C) 2025 Niklas Haas.
Definition: ops.c:28
F32
@ F32
Definition: sw_ops.c:42
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
U8
@ U8
Definition: sw_ops.c:39
SWS_OP_MIN
@ SWS_OP_MIN
Definition: ops.h:65
SWS_OP_LINEAR
@ SWS_OP_LINEAR
Definition: ops.h:63
WRITE
#define WRITE
Definition: cbs_apv.c:115
SWS_OP_PACK
@ SWS_OP_PACK
Definition: ops.h:52
DECL_ASM
#define DECL_ASM(TYPE, NAME,...)
Definition: ops.c:34
TYPE
#define TYPE
Definition: ffv1dec.c:96
NULL
#define NULL
Definition: coverity.c:32
MASK
#define MASK
Definition: median_template.c:42
SWS_OP_RSHIFT
@ SWS_OP_RSHIFT
Definition: ops.h:57
SIZE
#define SIZE
Definition: bitstream_template.c:36
SwsOpEntry
Definition: ops_chain.h:95
IN
#define IN(x)
Definition: vp9dsp_template.c:1200
OUT
@ OUT
Definition: af_loudnorm.c:40
Y
#define Y
Definition: boxblur.h:37
compile
static int compile(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
Definition: ops.c:629
setup_swap_bytes
static int setup_swap_bytes(const SwsOp *op, SwsOpPriv *out)
Definition: ops.c:86
ff_sws_setup_q4
int ff_sws_setup_q4(const SwsOp *op, SwsOpPriv *out)
Definition: ops_chain.c:278
DEPTH
#define DEPTH
Definition: v210enc.c:43
SWS_OP_MAX
@ SWS_OP_MAX
Definition: ops.h:66
U
#define U(x)
Definition: vpx_arith.h:37
OP
#define OP(gb, pixel, count)
SWS_OP_SWAP_BYTES
@ SWS_OP_SWAP_BYTES
Definition: ops.h:50
setup_shift
static int setup_shift(const SwsOp *op, SwsOpPriv *out)
Definition: ops.c:149
REF_PATTERN
#define REF_PATTERN(NAME, X, Y, Z, W)
Definition: ops.c:46
DECL_COMMON_PATTERNS
#define DECL_COMMON_PATTERNS(TYPE, NAME,...)
Definition: ops.c:49
DECL_PATTERN
#define DECL_PATTERN(TYPE, NAME, X, Y, Z, W,...)
Definition: ops.c:40
ff_sws_op_chain_append
int ff_sws_op_chain_append(SwsOpChain *chain, SwsFuncPtr func, void(*free)(void *), SwsOpPriv priv)
Definition: ops_chain.c:47
setup_clear
static int setup_clear(const SwsOp *op, SwsOpPriv *out)
Definition: ops.c:116
_
#define _
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:273
SWS_OP_CONVERT
@ SWS_OP_CONVERT
Definition: ops.h:59
SwsOpPriv
Copyright (C) 2025 Niklas Haas.
Definition: ops_chain.h:42
read
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
Definition: bitstream_template.h:239
min
float min
Definition: vorbis_enc_data.h:429
dither
static const uint8_t dither[8][8]
Definition: vf_fspp.c:62