FFmpeg
Macros | Functions | Variables
uops.c File Reference
#include <stdbool.h>
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "libavutil/tree.h"
#include "ops.h"
#include "ops_internal.h"
#include "uops.h"

Go to the source code of this file.

Macros

#define UOP_NAME(OP, ABBR)   [SWS_UOP_##OP] = { "SWS_UOP_" #OP, ABBR, #OP }
 
#define Q2PIXEL(val)   pixel_from_q(op->type, val)
 
#define BPRINT_STR(str)   av_bprint_append_data(bp, str, strlen(str))
 

Functions

int ff_sws_uop_cmp (const SwsUOp *a, const SwsUOp *b)
 Copyright (C) 2026 Niklas Haas. More...
 
static SwsPixel pixel_from_q (SwsPixelType type, AVRational val)
 
static bool pixel_is_1s (SwsPixelType type, SwsPixel val)
 
void ff_sws_uop_name (const SwsUOp *op, char buf[SWS_UOP_NAME_MAX])
 
static int generate_entry_struct (void *opaque, void *key)
 
static int generate_entry_args (void *opaque, void *key)
 
static void uop_uninit (SwsUOp *uop)
 
void ff_sws_uop_list_free (SwsUOpList **p_ops)
 
SwsUOpListff_sws_uop_list_alloc (void)
 
int ff_sws_uop_list_append (SwsUOpList *uops, SwsUOp *uop)
 
int ff_sws_dither_height (const SwsDitherUOp *dither)
 Computes (1 << size_log2) + MAX(y_offset). More...
 
static SwsPixelType pixel_type_to_int (const SwsPixelType type)
 
static bool exact_product_f32 (float a, float b)
 
static bool exact_prod (SwsPixelType type, SwsPixel coef, const SwsComps *comps, int idx)
 
static bool check_filter_fma (SwsContext *ctx, SwsUOpFlags flags, const SwsOp *op)
 
static int translate_rw_op (SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op)
 
static int count_idx (const int *arr, size_t size, int val)
 
static int translate_move (SwsUOpList *ops, const SwsOp *op)
 
static int translate_swizzle (SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op)
 
static int translate_dither_op (SwsUOpList *ops, const SwsOp *op)
 
static int translate_linear_op (SwsContext *ctx, SwsUOpList *ops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
 
static bool is_expand_bit (SwsPixelType type, AVRational factor)
 
static int translate_op (SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags, const SwsOp *op, const SwsComps *input)
 
int ff_sws_ops_translate (SwsContext *ctx, const SwsOpList *ops, SwsUOpFlags flags, SwsUOpList *uops)
 Translate a list of operations down to micro-ops, which can be further optimized and then directly executed by backends. More...
 
static int register_uop (struct AVTreeNode **root, const SwsUOp *uop)
 
static int register_flags (SwsContext *ctx, const SwsOpList *ops, SwsUOpFlags flags)
 
static int register_uops (SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
 
static int register_all_uops (SwsContext *ctx, void *graph, SwsOpList *ops)
 
static int enum_type (void *opaque, void *elem)
 
static int free_uop_key (void *opaque, void *key)
 
int ff_sws_uops_macros_gen (char **out_str)
 Generate a set of boilerplate C preprocessor macros for describing and programmatically iterating over all possible SwsUOps. More...
 

Variables

struct {
   char   full [32]
 
   char   abbr [32]
 
   char   macro [32]
 
uop_names [SWS_UOP_TYPE_NB]
 
struct {
   char   full [16]
 
   char   prefix [8]
 
pixel_types [SWS_PIXEL_TYPE_NB]
 
static const SwsUOpFlags uop_flags []
 
static const SwsOpBackend backend_uops
 
static const SwsFlags flags []
 

Macro Definition Documentation

◆ UOP_NAME

#define UOP_NAME (   OP,
  ABBR 
)    [SWS_UOP_##OP] = { "SWS_UOP_" #OP, ABBR, #OP }

◆ Q2PIXEL

#define Q2PIXEL (   val)    pixel_from_q(op->type, val)

Definition at line 114 of file uops.c.

◆ BPRINT_STR

#define BPRINT_STR (   str)    av_bprint_append_data(bp, str, strlen(str))

Function Documentation

◆ ff_sws_uop_cmp()

int ff_sws_uop_cmp ( const SwsUOp a,
const SwsUOp b 
)

Copyright (C) 2026 Niklas Haas.

Compare two SwsUOps for equality (excluding constant data).

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 32 of file uops.c.

Referenced by ff_sws_uop_cmp_v(), and ff_sws_uop_lookup().

◆ pixel_from_q()

static SwsPixel pixel_from_q ( SwsPixelType  type,
AVRational  val 
)
static

Definition at line 98 of file uops.c.

Referenced by exact_prod().

◆ pixel_is_1s()

static bool pixel_is_1s ( SwsPixelType  type,
SwsPixel  val 
)
static

Definition at line 116 of file uops.c.

Referenced by translate_op().

◆ ff_sws_uop_name()

void ff_sws_uop_name ( const SwsUOp op,
char  buf[SWS_UOP_NAME_MAX] 
)

◆ generate_entry_struct()

static int generate_entry_struct ( void *  opaque,
void *  key 
)
static

Definition at line 223 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ generate_entry_args()

static int generate_entry_args ( void *  opaque,
void *  key 
)
static

Definition at line 289 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ uop_uninit()

static void uop_uninit ( SwsUOp uop)
static

Definition at line 352 of file uops.c.

Referenced by ff_sws_uop_list_append(), and ff_sws_uop_list_free().

◆ ff_sws_uop_list_free()

void ff_sws_uop_list_free ( SwsUOpList **  p_ops)

Definition at line 368 of file uops.c.

Referenced by compile(), print_ops(), and register_flags().

◆ ff_sws_uop_list_alloc()

SwsUOpList* ff_sws_uop_list_alloc ( void  )

Definition at line 382 of file uops.c.

Referenced by compile(), print_ops(), and register_flags().

◆ ff_sws_uop_list_append()

int ff_sws_uop_list_append ( SwsUOpList uops,
SwsUOp uop 
)

◆ ff_sws_dither_height()

int ff_sws_dither_height ( const SwsDitherUOp dither)

Computes (1 << size_log2) + MAX(y_offset).

The dither matrix attached to the SwsUOp is always pre-padded to this number of lines.

Definition at line 400 of file uops.c.

Referenced by DECL_SETUP(), and translate_dither_op().

◆ pixel_type_to_int()

static SwsPixelType pixel_type_to_int ( const SwsPixelType  type)
static

Definition at line 408 of file uops.c.

Referenced by translate_move(), translate_op(), translate_rw_op(), and translate_swizzle().

◆ exact_product_f32()

static bool exact_product_f32 ( float  a,
float  b 
)
static

Definition at line 421 of file uops.c.

Referenced by exact_prod().

◆ exact_prod()

static bool exact_prod ( SwsPixelType  type,
SwsPixel  coef,
const SwsComps comps,
int  idx 
)
static

Definition at line 428 of file uops.c.

Referenced by translate_linear_op().

◆ check_filter_fma()

static bool check_filter_fma ( SwsContext ctx,
SwsUOpFlags  flags,
const SwsOp op 
)
static

Definition at line 450 of file uops.c.

Referenced by translate_rw_op().

◆ translate_rw_op()

static int translate_rw_op ( SwsContext ctx,
SwsUOpList ops,
SwsUOpFlags  flags,
const SwsOp op 
)
static

Definition at line 468 of file uops.c.

Referenced by translate_op().

◆ count_idx()

static int count_idx ( const int *  arr,
size_t  size,
int  val 
)
static

Definition at line 510 of file uops.c.

Referenced by translate_move().

◆ translate_move()

static int translate_move ( SwsUOpList ops,
const SwsOp op 
)
static

Definition at line 521 of file uops.c.

Referenced by translate_swizzle().

◆ translate_swizzle()

static int translate_swizzle ( SwsUOpList ops,
SwsUOpFlags  flags,
const SwsOp op 
)
static

Definition at line 592 of file uops.c.

Referenced by translate_op().

◆ translate_dither_op()

static int translate_dither_op ( SwsUOpList ops,
const SwsOp op 
)
static

Definition at line 646 of file uops.c.

Referenced by translate_op().

◆ translate_linear_op()

static int translate_linear_op ( SwsContext ctx,
SwsUOpList ops,
SwsUOpFlags  flags,
const SwsOp op,
const SwsComps input 
)
static

Definition at line 694 of file uops.c.

Referenced by translate_op().

◆ is_expand_bit()

static bool is_expand_bit ( SwsPixelType  type,
AVRational  factor 
)
static

Definition at line 731 of file uops.c.

Referenced by translate_op().

◆ translate_op()

static int translate_op ( SwsContext ctx,
SwsUOpList uops,
SwsUOpFlags  flags,
const SwsOp op,
const SwsComps input 
)
static

Definition at line 749 of file uops.c.

Referenced by ff_sws_ops_translate().

◆ ff_sws_ops_translate()

int ff_sws_ops_translate ( SwsContext ctx,
const SwsOpList ops,
SwsUOpFlags  flags,
SwsUOpList uops 
)

Translate a list of operations down to micro-ops, which can be further optimized and then directly executed by backends.

Return 0 or a negative error code.

Definition at line 850 of file uops.c.

Referenced by compile(), print_ops(), and register_flags().

◆ register_uop()

static int register_uop ( struct AVTreeNode **  root,
const SwsUOp uop 
)
static

Definition at line 863 of file uops.c.

Referenced by ff_sws_uops_macros_gen(), and register_flags().

◆ register_flags()

static int register_flags ( SwsContext ctx,
const SwsOpList ops,
SwsUOpFlags  flags 
)
static

Definition at line 884 of file uops.c.

Referenced by register_uops().

◆ register_uops()

static int register_uops ( SwsContext ctx,
const SwsOpList ops,
SwsCompiledOp out 
)
static

Definition at line 911 of file uops.c.

◆ register_all_uops()

static int register_all_uops ( SwsContext ctx,
void *  graph,
SwsOpList ops 
)
static

Definition at line 930 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ enum_type()

static int enum_type ( void *  opaque,
void *  elem 
)
static

Definition at line 948 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ free_uop_key()

static int free_uop_key ( void *  opaque,
void *  key 
)
static

Definition at line 958 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ ff_sws_uops_macros_gen()

int ff_sws_uops_macros_gen ( char **  out_str)

Generate a set of boilerplate C preprocessor macros for describing and programmatically iterating over all possible SwsUOps.

This function can be quite slow as it iterates over every possible combination of pixel formats and flags.

Returns 0 or a negative error code. On success, an allocated string is returned via out_str, and must be av_free()'d by the caller.

Additionally make sure planar reads/writes are always available for all formats, because checkasm depends on them to be able to verify the input/output of any other operations.

Definition at line 964 of file uops.c.

Referenced by main().

Variable Documentation

◆ full

char full[16]

Definition at line 44 of file uops.c.

Referenced by ff_avg_h264_qpel16_mc01_mmi(), ff_avg_h264_qpel16_mc02_mmi(), ff_avg_h264_qpel16_mc03_mmi(), ff_avg_h264_qpel16_mc11_mmi(), ff_avg_h264_qpel16_mc13_mmi(), ff_avg_h264_qpel16_mc31_mmi(), ff_avg_h264_qpel16_mc33_mmi(), ff_avg_h264_qpel4_mc01_mmi(), ff_avg_h264_qpel4_mc02_mmi(), ff_avg_h264_qpel4_mc03_mmi(), ff_avg_h264_qpel4_mc11_mmi(), ff_avg_h264_qpel4_mc12_mmi(), ff_avg_h264_qpel4_mc13_mmi(), ff_avg_h264_qpel4_mc31_mmi(), ff_avg_h264_qpel4_mc32_mmi(), ff_avg_h264_qpel4_mc33_mmi(), ff_avg_h264_qpel8_mc01_mmi(), ff_avg_h264_qpel8_mc02_mmi(), ff_avg_h264_qpel8_mc03_mmi(), ff_avg_h264_qpel8_mc11_mmi(), ff_avg_h264_qpel8_mc13_mmi(), ff_avg_h264_qpel8_mc31_mmi(), ff_avg_h264_qpel8_mc33_mmi(), ff_put_h264_qpel16_mc01_mmi(), ff_put_h264_qpel16_mc02_mmi(), ff_put_h264_qpel16_mc03_mmi(), ff_put_h264_qpel16_mc11_mmi(), ff_put_h264_qpel16_mc13_mmi(), ff_put_h264_qpel16_mc31_mmi(), ff_put_h264_qpel16_mc33_mmi(), ff_put_h264_qpel4_mc01_mmi(), ff_put_h264_qpel4_mc02_mmi(), ff_put_h264_qpel4_mc03_mmi(), ff_put_h264_qpel4_mc11_mmi(), ff_put_h264_qpel4_mc12_mmi(), ff_put_h264_qpel4_mc13_mmi(), ff_put_h264_qpel4_mc31_mmi(), ff_put_h264_qpel4_mc32_mmi(), ff_put_h264_qpel4_mc33_mmi(), ff_put_h264_qpel8_mc01_mmi(), ff_put_h264_qpel8_mc02_mmi(), ff_put_h264_qpel8_mc03_mmi(), ff_put_h264_qpel8_mc11_mmi(), ff_put_h264_qpel8_mc13_mmi(), ff_put_h264_qpel8_mc31_mmi(), ff_put_h264_qpel8_mc33_mmi(), filter_frame(), init(), map_idx_10_to_20(), map_idx_10_to_34(), map_idx_20_to_34(), map_idx_34_to_20(), parse_string(), remap20(), and remap34().

◆ abbr

char abbr[32]

Definition at line 45 of file uops.c.

Referenced by av_parse_video_rate(), and av_parse_video_size().

◆ macro

char macro[32]

Definition at line 46 of file uops.c.

Referenced by ff_sws_uops_macros_gen().

◆ uop_names

const { ... } uop_names[SWS_UOP_TYPE_NB]

◆ prefix

char prefix[8]

◆ pixel_types

const { ... } pixel_types[SWS_PIXEL_TYPE_NB]
Initial value:
= {
[SWS_PIXEL_NONE] = { "SWS_PIXEL_NONE", "" },
[SWS_PIXEL_U8] = { "SWS_PIXEL_U8", "U8_" },
[SWS_PIXEL_U16] = { "SWS_PIXEL_U16", "U16_" },
[SWS_PIXEL_U32] = { "SWS_PIXEL_U32", "U32_" },
[SWS_PIXEL_F32] = { "SWS_PIXEL_F32", "F32_" },
}

Referenced by ff_sws_uops_macros_gen(), generate_entry_args(), and generate_entry_struct().

◆ uop_flags

const SwsUOpFlags uop_flags[]
static
Initial value:

Definition at line 906 of file uops.c.

Referenced by register_uops().

◆ backend_uops

const SwsOpBackend backend_uops
static
Initial value:
= {
.name = "uops_gen",
.compile = register_uops,
}

Definition at line 925 of file uops.c.

Referenced by register_all_uops().

◆ flags

const SwsFlags flags[]
static
SWS_PIXEL_NONE
@ SWS_PIXEL_NONE
Definition: uops.h:39
SWS_BITEXACT
@ SWS_BITEXACT
Definition: swscale.h:180
SWS_UOP_FLAG_MOVE
@ SWS_UOP_FLAG_MOVE
Definition: uops.h:85
SWS_PIXEL_U32
@ SWS_PIXEL_U32
Definition: uops.h:42
SWS_PIXEL_U8
@ SWS_PIXEL_U8
Definition: uops.h:40
SWS_PIXEL_F32
@ SWS_PIXEL_F32
Definition: uops.h:43
SWS_UOP_FLAG_FMA
@ SWS_UOP_FLAG_FMA
Definition: uops.h:84
SWS_ACCURATE_RND
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition: swscale.h:179
SWS_PIXEL_U16
@ SWS_PIXEL_U16
Definition: uops.h:41
register_uops
static int register_uops(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
Definition: uops.c:911