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_internal.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_COMMON_RANGE(NAME, RANGE, IN, OUT, ...)
 
#define CHECK(NAME, N_IN, N_OUT, IN, OUT, ...)   CHECK_RANGE(NAME, 0, N_IN, N_OUT, IN, OUT, __VA_ARGS__)
 
#define CHECK_COMMON(NAME, IN, OUT, ...)   CHECK_COMMON_RANGE(NAME, 0, IN, OUT, __VA_ARGS__)
 

Enumerations

enum  { LINES = 2, NB_PLANES = 4, PIXELS = 64 }
 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 check_ops (const char *report, const unsigned ranges[NB_PLANES], const SwsOp *ops)
 
static void check_read_write (void)
 
static void check_swap_bytes (void)
 
static void check_pack_unpack (void)
 
static AVRational rndq (SwsPixelType t)
 
static void check_clear (void)
 
static void check_shift (void)
 
static void check_swizzle (void)
 
static void check_convert (void)
 
static void check_dither (void)
 
static void check_min_max (void)
 
static void check_linear (void)
 
static void check_scale (void)
 
void checkasm_check_sw_ops (void)
 

Macro Definition Documentation

◆ FMT

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

Definition at line 45 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 255 of file sw_ops.c.

◆ MK_RANGES

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

Definition at line 272 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 273 of file sw_ops.c.

◆ CHECK_COMMON_RANGE

#define CHECK_COMMON_RANGE (   NAME,
  RANGE,
  IN,
  OUT,
  ... 
)
Value:
CHECK_RANGE(FMT("%s_p1000", NAME), RANGE, 1, 1, IN, OUT, __VA_ARGS__); \
CHECK_RANGE(FMT("%s_p1110", NAME), RANGE, 3, 3, IN, OUT, __VA_ARGS__); \
CHECK_RANGE(FMT("%s_p1111", NAME), RANGE, 4, 4, IN, OUT, __VA_ARGS__); \
CHECK_RANGE(FMT("%s_p1001", NAME), RANGE, 4, 2, IN, OUT, __VA_ARGS__, { \
.op = SWS_OP_SWIZZLE, \
.type = OUT, \
.swizzle = SWS_SWIZZLE(0, 3, 1, 2), \
})

Definition at line 276 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 286 of file sw_ops.c.

◆ CHECK_COMMON

#define CHECK_COMMON (   NAME,
  IN,
  OUT,
  ... 
)    CHECK_COMMON_RANGE(NAME, 0, IN, OUT, __VA_ARGS__)

Definition at line 289 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
LINES 
NB_PLANES 
PIXELS 

Definition at line 32 of file sw_ops.c.

◆ anonymous enum

anonymous enum
Enumerator
U8 
U16 
U32 
F32 

Definition at line 38 of file sw_ops.c.

Function Documentation

◆ tprintf()

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

Definition at line 46 of file sw_ops.c.

◆ rw_pixel_bits()

static int rw_pixel_bits ( const SwsOp op)
static

Definition at line 55 of file sw_ops.c.

Referenced by check_ops().

◆ rndf()

static float rndf ( void  )
static

Definition at line 64 of file sw_ops.c.

Referenced by fill32f().

◆ fill32f()

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

Definition at line 73 of file sw_ops.c.

Referenced by check_ops().

◆ fill32()

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

Definition at line 80 of file sw_ops.c.

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

◆ fill16()

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

Definition at line 86 of file sw_ops.c.

Referenced by check_ops().

◆ fill8()

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

Definition at line 96 of file sw_ops.c.

Referenced by check_ops().

◆ check_ops()

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

Don't use check_func() because the actual function pointer may be a wrapper shared by multiple implementations. Instead, take a hash of both the backend pointer and the active CPU flags.

Definition at line 106 of file sw_ops.c.

Referenced by check_read_write().

◆ check_read_write()

static void check_read_write ( void  )
static

Definition at line 292 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_swap_bytes()

static void check_swap_bytes ( void  )
static

Definition at line 379 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_pack_unpack()

static void check_pack_unpack ( void  )
static

Definition at line 392 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ rndq()

static AVRational rndq ( SwsPixelType  t)
static

Definition at line 437 of file sw_ops.c.

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

◆ check_clear()

static void check_clear ( void  )
static

Definition at line 449 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_shift()

static void check_shift ( void  )
static

Definition at line 506 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_swizzle()

static void check_swizzle ( void  )
static

Definition at line 529 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_convert()

static void check_convert ( void  )
static

Definition at line 572 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_dither()

static void check_dither ( void  )
static

Definition at line 617 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_min_max()

static void check_min_max ( void  )
static

Definition at line 652 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_linear()

static void check_linear ( void  )
static

Definition at line 670 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ check_scale()

static void check_scale ( void  )
static

Definition at line 727 of file sw_ops.c.

Referenced by checkasm_check_sw_ops().

◆ checkasm_check_sw_ops()

void checkasm_check_sw_ops ( void  )

Definition at line 752 of file sw_ops.c.

SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:48
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:58
CHECK_RANGE
#define CHECK_RANGE(NAME, RANGE, N_IN, N_OUT, IN, OUT,...)
Definition: sw_ops.c:273
SWS_SWIZZLE
#define SWS_SWIZZLE(X, Y, Z, W)
Definition: ops.h:126
FMT
#define FMT(fmt,...)
Definition: sw_ops.c:45
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:49
IN
#define IN(x)
Definition: vp9dsp_template.c:1200
OUT
@ OUT
Definition: af_loudnorm.c:40
SwsOp
Definition: ops.h:179