FFmpeg
Data Structures | Enumerations | Functions | Variables
ops.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/bswap.h"
#include "libavutil/mem.h"
#include "libavutil/rational.h"
#include "libavutil/refstruct.h"
#include "format.h"
#include "ops.h"
#include "ops_internal.h"

Go to the source code of this file.

Data Structures

struct  EnumOpaque
 

Enumerations

enum  { SWS_COMP_IDENTITY = SWS_COMP_ZERO | SWS_COMP_EXACT }
 

Functions

const char * ff_sws_pixel_type_name (SwsPixelType type)
 
int ff_sws_pixel_type_size (SwsPixelType type)
 
bool ff_sws_pixel_type_is_int (SwsPixelType type)
 
const char * ff_sws_op_type_name (SwsOpType op)
 
static AVRational av_min_q (AVRational a, AVRational b)
 
static AVRational av_max_q (AVRational a, AVRational b)
 
void ff_sws_apply_op_q (const SwsOp *op, AVRational x[4])
 Apply an operation to an AVRational. More...
 
static SwsCompFlags merge_comp_flags (SwsCompFlags a, SwsCompFlags b)
 
static void propagate_flags (SwsOp *op, const SwsComps *prev)
 
static void clear_undefined_values (AVRational dst[4], const AVRational src[4])
 
static void apply_filter_weights (SwsComps *comps, const SwsComps *prev, const SwsFilterWeights *weights)
 
void ff_sws_op_list_update_comps (SwsOpList *ops)
 Infer + propagate known information about components. More...
 
static void op_uninit (SwsOp *op)
 
SwsOpListff_sws_op_list_alloc (void)
 
void ff_sws_op_list_free (SwsOpList **p_ops)
 
SwsOpListff_sws_op_list_duplicate (const SwsOpList *ops)
 Returns a duplicate of ops, or NULL on OOM. More...
 
const SwsOpff_sws_op_list_input (const SwsOpList *ops)
 Returns the input operation for a given op list, or NULL if there is none (e.g. More...
 
const SwsOpff_sws_op_list_output (const SwsOpList *ops)
 Returns the output operation for a given op list, or NULL if there is none. More...
 
void ff_sws_op_list_remove_at (SwsOpList *ops, int index, int count)
 
int ff_sws_op_list_insert_at (SwsOpList *ops, int index, SwsOp *op)
 
int ff_sws_op_list_append (SwsOpList *ops, SwsOp *op)
 These will take over ownership of op and set it to {0}, even on failure. More...
 
bool ff_sws_op_list_is_noop (const SwsOpList *ops)
 Returns whether an op list represents a true no-op operation, i.e. More...
 
int ff_sws_op_list_max_size (const SwsOpList *ops)
 Returns the size of the largest pixel type used in ops. More...
 
uint32_t ff_sws_linear_mask (const SwsLinearOp c)
 
static const char * describe_lin_mask (uint32_t mask)
 
static char describe_comp_flags (SwsCompFlags flags)
 
static void print_q (AVBPrint *bp, const AVRational q, bool ignore_den0)
 
static void print_q4 (AVBPrint *bp, const AVRational q4[4], bool ignore_den0, const SwsCompFlags flags[4])
 
void ff_sws_op_desc (AVBPrint *bp, const SwsOp *op)
 Describe an operation in human-readable form. More...
 
static void desc_plane_order (AVBPrint *bp, int nb_planes, const uint8_t *order)
 
void ff_sws_op_list_print (void *log, int lev, int lev_extra, const SwsOpList *ops)
 Print out the contents of an operation list. More...
 
static int enum_ops_fmt (SwsContext *ctx, void *opaque, enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, int(*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops))
 
int ff_sws_enum_op_lists (SwsContext *ctx, void *opaque, enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, int(*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops))
 Helper function to enumerate over all possible (optimized) operation lists, under the current set of options in ctx, and run the given callback on each list. More...
 
static int enum_ops (SwsContext *ctx, void *opaque, SwsOpList *ops)
 
int ff_sws_enum_ops (SwsContext *ctx, void *opaque, enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, int(*cb)(SwsContext *ctx, void *opaque, SwsOp *op))
 Helper function to enumerate over all possible operations, under the current set of options in ctx, and run the given callback on each operation. More...
 

Variables

const SwsOpBackend backend_c
 Copyright (C) 2025 Niklas Haas. More...
 
const SwsOpBackend backend_murder
 
const SwsOpBackend backend_aarch64
 
const SwsOpBackend backend_x86
 
const SwsOpBackend backend_vulkan
 
const SwsOpBackend *const ff_sws_op_backends []
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SWS_COMP_IDENTITY 

Definition at line 254 of file ops.c.

Function Documentation

◆ ff_sws_pixel_type_name()

const char* ff_sws_pixel_type_name ( SwsPixelType  type)

◆ ff_sws_pixel_type_size()

int ff_sws_pixel_type_size ( SwsPixelType  type)

◆ ff_sws_pixel_type_is_int()

bool ff_sws_pixel_type_is_int ( SwsPixelType  type)

◆ ff_sws_op_type_name()

const char* ff_sws_op_type_name ( SwsOpType  op)

Definition at line 100 of file ops.c.

Referenced by ff_sws_op_desc().

◆ av_min_q()

static AVRational av_min_q ( AVRational  a,
AVRational  b 
)
static

Definition at line 129 of file ops.c.

Referenced by ff_sws_apply_op_q().

◆ av_max_q()

static AVRational av_max_q ( AVRational  a,
AVRational  b 
)
static

Definition at line 134 of file ops.c.

Referenced by ff_sws_apply_op_q().

◆ ff_sws_apply_op_q()

void ff_sws_apply_op_q ( const SwsOp op,
AVRational  x[4] 
)

Apply an operation to an AVRational.

No-op for read/write operations.

Definition at line 139 of file ops.c.

Referenced by ff_sws_op_list_update_comps(), and op_commute_clear().

◆ merge_comp_flags()

static SwsCompFlags merge_comp_flags ( SwsCompFlags  a,
SwsCompFlags  b 
)
static

Definition at line 258 of file ops.c.

Referenced by ff_sws_op_list_update_comps().

◆ propagate_flags()

static void propagate_flags ( SwsOp op,
const SwsComps prev 
)
static

Definition at line 266 of file ops.c.

Referenced by ff_sws_op_list_update_comps().

◆ clear_undefined_values()

static void clear_undefined_values ( AVRational  dst[4],
const AVRational  src[4] 
)
static

Definition at line 273 of file ops.c.

Referenced by ff_sws_op_list_update_comps().

◆ apply_filter_weights()

static void apply_filter_weights ( SwsComps comps,
const SwsComps prev,
const SwsFilterWeights weights 
)
static

Definition at line 281 of file ops.c.

Referenced by ff_sws_op_list_update_comps().

◆ ff_sws_op_list_update_comps()

void ff_sws_op_list_update_comps ( SwsOpList ops)

Infer + propagate known information about components.

Called automatically when needed by the optimizer and compiler.

Definition at line 300 of file ops.c.

Referenced by ff_sws_op_list_optimize(), and ff_sws_ops_compile_backend().

◆ op_uninit()

static void op_uninit ( SwsOp op)
static

Definition at line 552 of file ops.c.

Referenced by ff_sws_op_list_free(), ff_sws_op_list_insert_at(), and ff_sws_op_list_remove_at().

◆ ff_sws_op_list_alloc()

SwsOpList* ff_sws_op_list_alloc ( void  )

Definition at line 570 of file ops.c.

Referenced by enum_ops_fmt().

◆ ff_sws_op_list_free()

void ff_sws_op_list_free ( SwsOpList **  p_ops)

◆ ff_sws_op_list_duplicate()

SwsOpList* ff_sws_op_list_duplicate ( const SwsOpList ops)

Returns a duplicate of ops, or NULL on OOM.

Definition at line 597 of file ops.c.

Referenced by ff_sws_op_list_subpass(), and ff_sws_ops_compile_backend().

◆ ff_sws_op_list_input()

const SwsOp* ff_sws_op_list_input ( const SwsOpList ops)

Returns the input operation for a given op list, or NULL if there is none (e.g.

for a pure CLEAR-only operation list).

This will always be an op of type SWS_OP_READ.

Definition at line 634 of file ops.c.

Referenced by aarch64_collect_process(), aarch64_compile(), compile(), ff_sws_compile_pass(), ff_sws_op_list_is_noop(), ff_sws_solve_shuffle(), and get_input_size().

◆ ff_sws_op_list_output()

const SwsOp* ff_sws_op_list_output ( const SwsOpList ops)

Returns the output operation for a given op list, or NULL if there is none.

This will always be an op of type SWS_OP_WRITE.

Definition at line 643 of file ops.c.

Referenced by aarch64_collect_process(), aarch64_compile(), compile(), ff_sws_compile_pass(), and ff_sws_op_list_is_noop().

◆ ff_sws_op_list_remove_at()

void ff_sws_op_list_remove_at ( SwsOpList ops,
int  index,
int  count 
)

Definition at line 652 of file ops.c.

Referenced by ff_sws_op_list_optimize(), and ff_sws_op_list_subpass().

◆ ff_sws_op_list_insert_at()

int ff_sws_op_list_insert_at ( SwsOpList ops,
int  index,
SwsOp op 
)

Definition at line 663 of file ops.c.

Referenced by ff_sws_op_list_append(), ff_sws_op_list_optimize(), and ff_sws_op_list_subpass().

◆ ff_sws_op_list_append()

int ff_sws_op_list_append ( SwsOpList ops,
SwsOp op 
)

These will take over ownership of op and set it to {0}, even on failure.

Definition at line 677 of file ops.c.

Referenced by ff_sws_op_list_subpass().

◆ ff_sws_op_list_is_noop()

bool ff_sws_op_list_is_noop ( const SwsOpList ops)

Returns whether an op list represents a true no-op operation, i.e.

may be eliminated entirely from an execution graph.

Note that this check is unlikely to ever be hit in practice, since it would imply the existence of planar formats with different plane orders between them, e.g. rgbap <-> gbrap, which doesn't currently exist. However, the check is cheap and lets me sleep at night.

Definition at line 682 of file ops.c.

Referenced by ff_sws_compile_pass(), and print_ops().

◆ ff_sws_op_list_max_size()

int ff_sws_op_list_max_size ( const SwsOpList ops)

Returns the size of the largest pixel type used in ops.

Definition at line 711 of file ops.c.

Referenced by aarch64_optimize(), compile(), and register_op().

◆ ff_sws_linear_mask()

uint32_t ff_sws_linear_mask ( const SwsLinearOp  c)

Definition at line 722 of file ops.c.

Referenced by extract_swizzle(), and ff_sws_op_list_optimize().

◆ describe_lin_mask()

static const char* describe_lin_mask ( uint32_t  mask)
static

Definition at line 734 of file ops.c.

Referenced by ff_sws_op_desc().

◆ describe_comp_flags()

static char describe_comp_flags ( SwsCompFlags  flags)
static

Definition at line 775 of file ops.c.

Referenced by ff_sws_op_list_print().

◆ print_q()

static void print_q ( AVBPrint *  bp,
const AVRational  q,
bool  ignore_den0 
)
static

Definition at line 789 of file ops.c.

Referenced by ff_sws_op_desc(), and print_q4().

◆ print_q4()

static void print_q4 ( AVBPrint *  bp,
const AVRational  q4[4],
bool  ignore_den0,
const SwsCompFlags  flags[4] 
)
static

Definition at line 804 of file ops.c.

Referenced by ff_sws_op_desc(), and ff_sws_op_list_print().

◆ ff_sws_op_desc()

void ff_sws_op_desc ( AVBPrint *  bp,
const SwsOp op 
)

Describe an operation in human-readable form.

Definition at line 820 of file ops.c.

Referenced by ff_sws_op_list_print(), and register_op().

◆ desc_plane_order()

static void desc_plane_order ( AVBPrint *  bp,
int  nb_planes,
const uint8_t *  order 
)
static

Definition at line 912 of file ops.c.

Referenced by ff_sws_op_list_print().

◆ ff_sws_op_list_print()

void ff_sws_op_list_print ( void *  log,
int  lev,
int  lev_extra,
const SwsOpList ops 
)

Print out the contents of an operation list.

Definition at line 926 of file ops.c.

Referenced by ff_sws_compile_pass(), ff_sws_ops_compile(), and print_ops().

◆ enum_ops_fmt()

static int enum_ops_fmt ( SwsContext ctx,
void *  opaque,
enum AVPixelFormat  src_fmt,
enum AVPixelFormat  dst_fmt,
int(*)(SwsContext *ctx, void *opaque, SwsOpList *ops)  cb 
)
static

Definition at line 977 of file ops.c.

Referenced by ff_sws_enum_op_lists().

◆ ff_sws_enum_op_lists()

int ff_sws_enum_op_lists ( SwsContext ctx,
void *  opaque,
enum AVPixelFormat  src_fmt,
enum AVPixelFormat  dst_fmt,
int(*)(SwsContext *ctx, void *opaque, SwsOpList *ops)  cb 
)

Helper function to enumerate over all possible (optimized) operation lists, under the current set of options in ctx, and run the given callback on each list.

Parameters
src_fmtIf set (not AV_PIX_FMT_NONE), constrain the source format
dst_fmtIf set (not AV_PIX_FMT_NONE), constrain the destination format
Returns
0 on success, the return value if cb() < 0, or a negative error code
Note
ops belongs to ff_sws_enum_op_lists(), but may be mutated by cb.
See also
ff_sws_enum_ops()

Definition at line 1015 of file ops.c.

Referenced by ff_sws_enum_ops(), and main().

◆ enum_ops()

static int enum_ops ( SwsContext ctx,
void *  opaque,
SwsOpList ops 
)
static

Definition at line 1049 of file ops.c.

Referenced by ff_sws_enum_ops().

◆ ff_sws_enum_ops()

int ff_sws_enum_ops ( SwsContext ctx,
void *  opaque,
enum AVPixelFormat  src_fmt,
enum AVPixelFormat  dst_fmt,
int(*)(SwsContext *ctx, void *opaque, SwsOp *op cb 
)

Helper function to enumerate over all possible operations, under the current set of options in ctx, and run the given callback on each operation.

Parameters
src_fmtIf set (not AV_PIX_FMT_NONE), constrain the source format
dst_fmtIf set (not AV_PIX_FMT_NONE), constrain the destination format
Returns
0 on success, the return value if cb() < 0, or a negative error code
Note
May contain duplicates. op belongs to ff_sws_enum_ops(), but may be mutated by cb.
See also
ff_sws_num_op_lists()

Definition at line 1060 of file ops.c.

Referenced by main().

Variable Documentation

◆ backend_c

const SwsOpBackend backend_c

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 100 of file ops_backend.c.

◆ backend_murder

const SwsOpBackend backend_murder

Definition at line 130 of file ops_memcpy.c.

◆ backend_aarch64

const SwsOpBackend backend_aarch64

Definition at line 255 of file ops.c.

◆ backend_x86

const SwsOpBackend backend_x86

Definition at line 1037 of file ops.c.

◆ backend_vulkan

const SwsOpBackend backend_vulkan

Definition at line 412 of file ops.c.

◆ ff_sws_op_backends

const SwsOpBackend* const ff_sws_op_backends[]
Initial value:

Definition at line 39 of file ops.c.

Referenced by check_ops(), and ff_sws_ops_compile().

backend_c
const SwsOpBackend backend_c
Copyright (C) 2025 Niklas Haas.
Definition: ops_backend.c:100
NULL
#define NULL
Definition: coverity.c:32
backend_murder
const SwsOpBackend backend_murder
Definition: ops_memcpy.c:130