FFmpeg
Macros | Enumerations | Functions
sw_ops.c File Reference
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/mem_internal.h"
#include "libavutil/refstruct.h"
#include "libswscale/ops.h"
#include "libswscale/ops_dispatch.h"
#include "libswscale/uops.h"
#include "libswscale/uops_macros.h"
#include "checkasm.h"

Go to the source code of this file.

Macros

#define FMT(fmt, ...)   tprintf((char[256]) {0}, 256, fmt, __VA_ARGS__)
 
#define CHECK_RANGES(NAME, RANGES, N_IN, N_OUT, IN, OUT, ...)
 
#define MK_RANGES(R)   ((const unsigned[]) { R, R, R, R })
 
#define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT, ...)   CHECK_RANGES(NAME, MK_RANGES(RANGE), N_IN, N_OUT, IN, OUT, __VA_ARGS__)
 
#define CHECK(NAME, N_IN, N_OUT, IN, OUT, ...)   CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)
 
#define CHECK_MASK(NAME, MASK, RANGES, IN, OUT, ...)
 
#define CHECK_FUNCTION(CHECK, NAME, ...)   CHECK(#NAME, &(SwsUOp) { __VA_ARGS__ });
 
#define CHECK_FOR(UOP, CHECK)
 

Enumerations

enum  { NB_PLANES = 4, PIXELS = 64, LINES = 16 }
 Copyright (C) 2025 Niklas Haas. More...
 
enum  { U8 = SWS_PIXEL_U8, U16 = SWS_PIXEL_U16, U32 = SWS_PIXEL_U32, F32 = SWS_PIXEL_F32 }
 

Functions

static const char * tprintf (char buf[], size_t size, const char *fmt,...)
 
static int rw_pixel_bits (const SwsOp *op)
 
static float rndf (void)
 
static void fill32f (float *line, int num, unsigned range)
 
static void fill32 (uint32_t *line, int num, unsigned range)
 
static void fill16 (uint16_t *line, int num, unsigned range)
 
static void fill8 (uint8_t *line, int num, unsigned range)
 
static void set_range (AVRational *rangeq, unsigned range, unsigned range_def)
 
static void check_compiled (const char *name, const SwsOp *read_op, const SwsOp *write_op, const int ranges[NB_PLANES], const SwsCompiledOp *comp_ref, const SwsCompiledOp *comp_new)
 
static void check_ops (const char *name, const unsigned ranges[NB_PLANES], const SwsOp *ops)
 
static int mask_num (const SwsCompMask mask)
 
static AVRational rndq (SwsPixelType t)
 
static void check_read (const char *name, const SwsUOp *uop)
 
static void check_write (const char *name, const SwsUOp *uop)
 
static void check_filter (const char *name, const SwsUOp *uop)
 
static void check_cast (const char *name, const SwsUOp *uop)
 
static void check_expand_bit (const char *name, const SwsUOp *uop)
 
static void check_expand (const char *name, const SwsUOp *uop)
 
static void check_swizzle (const char *name, const SwsUOp *uop)
 
static void check_scale (const char *name, const SwsUOp *uop)
 
static void check_clamp (const char *name, const SwsUOp *uop)
 
static void check_swap_bytes (const char *name, const SwsUOp *uop)
 
static void check_unpack (const char *name, const SwsUOp *uop)
 
static void check_pack (const char *name, const SwsUOp *uop)
 
static void check_shift (const char *name, const SwsUOp *uop)
 
static void check_clear (const char *name, const SwsUOp *uop)
 
static void check_linear (const char *name, const SwsUOp *uop)
 
static void check_dither (const char *name, const SwsUOp *uop)
 
static void check_add (const char *name, const SwsUOp *uop)
 
void checkasm_check_sw_ops (void)
 

Macro Definition Documentation

◆ FMT

#define FMT (   fmt,
  ... 
)    tprintf((char[256]) {0}, 256, fmt, __VA_ARGS__)

Definition at line 47 of file sw_ops.c.

◆ CHECK_RANGES

#define CHECK_RANGES (   NAME,
  RANGES,
  N_IN,
  N_OUT,
  IN,
  OUT,
  ... 
)
Value:
do { \
check_ops(NAME, RANGES, (SwsOp[]) { \
{ \
.op = SWS_OP_READ, \
.type = IN, \
.rw.elems = N_IN, \
}, \
__VA_ARGS__, \
{ \
.op = SWS_OP_WRITE, \
.type = OUT, \
.rw.elems = N_OUT, \
}, {0} \
}); \
} while (0)

Definition at line 343 of file sw_ops.c.

◆ MK_RANGES

#define MK_RANGES (   R)    ((const unsigned[]) { R, R, R, R })

Definition at line 360 of file sw_ops.c.

◆ CHECK_RANGE

#define CHECK_RANGE (   NAME,
  RANGE,
  N_IN,
  N_OUT,
  IN,
  OUT,
  ... 
)    CHECK_RANGES(NAME, MK_RANGES(RANGE), N_IN, N_OUT, IN, OUT, __VA_ARGS__)

Definition at line 361 of file sw_ops.c.

◆ CHECK

#define CHECK (   NAME,
  N_IN,
  N_OUT,
  IN,
  OUT,
  ... 
)    CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)

Definition at line 364 of file sw_ops.c.

◆ CHECK_MASK

#define CHECK_MASK (   NAME,
  MASK,
  RANGES,
  IN,
  OUT,
  ... 
)
Value:
do { \
const SwsCompMask mask = (MASK); \
const int num = mask_num(mask); \
if (!num) \
break; /* can't test these with current infrastructure */ \
CHECK_RANGES(NAME, RANGES, 4, num, IN, OUT, __VA_ARGS__); \
} while (0)

Definition at line 378 of file sw_ops.c.

◆ CHECK_FUNCTION

#define CHECK_FUNCTION (   CHECK,
  NAME,
  ... 
)    CHECK(#NAME, &(SwsUOp) { __VA_ARGS__ });

Definition at line 749 of file sw_ops.c.

◆ CHECK_FOR

#define CHECK_FOR (   UOP,
  CHECK 
)
Value:
SWS_FOR_STRUCT(U16, UOP, CHECK_FUNCTION, CHECK) \
SWS_FOR_STRUCT(U32, UOP, CHECK_FUNCTION, CHECK) \
SWS_FOR_STRUCT(F32, UOP, CHECK_FUNCTION, CHECK) \
report(#UOP)

Definition at line 752 of file sw_ops.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

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 General Public License as published by the Free Software Foundation; either version 2 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 General Public License for more details.

You should have received a copy of the GNU 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.

Enumerator
NB_PLANES 
PIXELS 
LINES 

Definition at line 34 of file sw_ops.c.

◆ anonymous enum

anonymous enum
Enumerator
U8 
U16 
U32 
F32 

Definition at line 40 of file sw_ops.c.

Function Documentation

◆ tprintf()

static const char* tprintf ( char  buf[],
size_t  size,
const char *  fmt,
  ... 
)
static

Definition at line 48 of file sw_ops.c.

◆ rw_pixel_bits()

static int rw_pixel_bits ( const SwsOp op)
static

Definition at line 57 of file sw_ops.c.

Referenced by check_compiled().

◆ rndf()

static float rndf ( void  )
static

Definition at line 71 of file sw_ops.c.

Referenced by fill32f().

◆ fill32f()

static void fill32f ( float line,
int  num,
unsigned  range 
)
static

Definition at line 80 of file sw_ops.c.

Referenced by check_compiled().

◆ fill32()

static void fill32 ( uint32_t *  line,
int  num,
unsigned  range 
)
static

Definition at line 87 of file sw_ops.c.

Referenced by check_compiled(), fill16(), and fill8().

◆ fill16()

static void fill16 ( uint16_t *  line,
int  num,
unsigned  range 
)
static

Definition at line 93 of file sw_ops.c.

Referenced by check_compiled().

◆ fill8()

static void fill8 ( uint8_t *  line,
int  num,
unsigned  range 
)
static

Definition at line 103 of file sw_ops.c.

Referenced by check_compiled().

◆ set_range()

static void set_range ( AVRational rangeq,
unsigned  range,
unsigned  range_def 
)
static

Definition at line 113 of file sw_ops.c.

Referenced by check_ops().

◆ check_compiled()

static void check_compiled ( const char *  name,
const SwsOp read_op,
const SwsOp write_op,
const int  ranges[NB_PLANES],
const SwsCompiledOp comp_ref,
const SwsCompiledOp comp_new 
)
static

We can't use check_func() alone because the actual function pointer may be a wrapper or entry point shared by multiple implementations. Solve it by hashing in the active CPU flags as well.

Definition at line 121 of file sw_ops.c.

Referenced by check_ops().

◆ check_ops()

static void check_ops ( const char *  name,
const unsigned  ranges[NB_PLANES],
const SwsOp ops 
)
static

Definition at line 248 of file sw_ops.c.

Referenced by check_filter(), check_read(), and check_write().

◆ mask_num()

static int mask_num ( const SwsCompMask  mask)
inlinestatic

Definition at line 367 of file sw_ops.c.

Referenced by check_filter(), check_read(), and check_write().

◆ rndq()

static AVRational rndq ( SwsPixelType  t)
static

Definition at line 387 of file sw_ops.c.

Referenced by check_dither(), check_linear(), and check_scale().

◆ check_read()

static void check_read ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 400 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_write()

static void check_write ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 428 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_filter()

static void check_filter ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 460 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_cast()

static void check_cast ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 509 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_expand_bit()

static void check_expand_bit ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 533 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_expand()

static void check_expand ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 550 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_swizzle()

static void check_swizzle ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 569 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_scale()

static void check_scale ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 579 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_clamp()

static void check_clamp ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 601 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_swap_bytes()

static void check_swap_bytes ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 611 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_unpack()

static void check_unpack ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 619 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_pack()

static void check_pack ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 633 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_shift()

static void check_shift ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 648 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_clear()

static void check_clear ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 657 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_linear()

static void check_linear ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 683 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_dither()

static void check_dither ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 708 of file sw_ops.c.

Referenced by check_add(), and checkasm_check_sw_ops().

◆ check_add()

static void check_add ( const char *  name,
const SwsUOp uop 
)
static

Definition at line 737 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ checkasm_check_sw_ops()

void checkasm_check_sw_ops ( void  )

Definition at line 759 of file sw_ops.c.

SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:38
U8
@ U8
Definition: sw_ops.c:41
mask_num
static int mask_num(const SwsCompMask mask)
Definition: sw_ops.c:367
mask
int mask
Definition: mediacodecdec_common.c:154
U32
@ U32
Definition: sw_ops.c:43
SWS_FOR_STRUCT
#define SWS_FOR_STRUCT(TYPE, UOP, MACRO,...)
Definition: uops_macros.h:19
SwsCompMask
uint8_t SwsCompMask
Bit-mask of components.
Definition: uops.h:61
U16
@ U16
Definition: sw_ops.c:42
MASK
#define MASK
Definition: median_template.c:42
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:39
IN
#define IN(x)
Definition: vp9dsp_template.c:1200
OUT
@ OUT
Definition: af_loudnorm.c:41
F32
@ F32
Definition: sw_ops.c:44
CHECK_FUNCTION
#define CHECK_FUNCTION(CHECK, NAME,...)
Definition: sw_ops.c:749
SwsOp
Definition: ops.h:226
CHECK
#define CHECK(NAME, N_IN, N_OUT, IN, OUT,...)
Definition: sw_ops.c:364