FFmpeg
Data Structures | Macros | Functions | Variables
ops_internal.h File Reference
#include "libavutil/mem_internal.h"
#include "ops.h"
#include "ops_dispatch.h"

Go to the source code of this file.

Data Structures

struct  SwsOpBackend
 

Macros

#define Q(N)   ((AVRational) { N, 1 })
 Copyright (C) 2025 Niklas Haas. More...
 

Functions

static AVRational ff_sws_pixel_expand (SwsPixelType from, SwsPixelType to)
 
static void ff_sws_pack_op_decode (const SwsOp *op, uint64_t mask[4], int shift[4])
 
int ff_sws_ops_compile_backend (SwsContext *ctx, const SwsOpBackend *backend, const SwsOpList *ops, SwsCompiledOp *out)
 Attempt to compile a list of operations using a specific backend. More...
 
int ff_sws_ops_compile (SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
 Compile a list of operations using the best available backend. More...
 
int ff_sws_solve_shuffle (const SwsOpList *ops, uint8_t shuffle[], int size, uint8_t clear_val, int *read_bytes, int *write_bytes)
 "Solve" an op list into a fixed shuffle mask, with an optional ability to also directly clear the output value (for e.g. More...
 
int ff_sws_op_list_subpass (SwsOpList *ops, SwsOpList **out_rest)
 Eliminate SWS_OP_FILTER_* operations by merging them with prior SWS_OP_READ operations. More...
 

Variables

const SwsOpBackend *const ff_sws_op_backends []
 

Macro Definition Documentation

◆ Q

#define Q (   N)    ((AVRational) { N, 1 })

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 29 of file ops_internal.h.

Function Documentation

◆ ff_sws_pixel_expand()

static AVRational ff_sws_pixel_expand ( SwsPixelType  from,
SwsPixelType  to 
)
inlinestatic

Definition at line 31 of file ops_internal.h.

Referenced by ff_sws_apply_op_q(), and ff_sws_op_list_optimize().

◆ ff_sws_pack_op_decode()

static void ff_sws_pack_op_decode ( const SwsOp op,
uint64_t  mask[4],
int  shift[4] 
)
inlinestatic

Definition at line 43 of file ops_internal.h.

Referenced by ff_sws_apply_op_q().

◆ ff_sws_ops_compile_backend()

int ff_sws_ops_compile_backend ( SwsContext ctx,
const SwsOpBackend backend,
const SwsOpList ops,
SwsCompiledOp out 
)

Attempt to compile a list of operations using a specific backend.

Returns 0 on success, or a negative error code on failure.

Definition at line 55 of file ops_dispatch.c.

Referenced by check_ops(), and ff_sws_ops_compile().

◆ ff_sws_ops_compile()

int ff_sws_ops_compile ( SwsContext ctx,
const SwsOpList ops,
SwsCompiledOp out 
)

Compile a list of operations using the best available backend.

Returns 0 on success, or a negative error code on failure.

Definition at line 82 of file ops_dispatch.c.

Referenced by compile().

◆ ff_sws_solve_shuffle()

int ff_sws_solve_shuffle ( const SwsOpList ops,
uint8_t  shuffle[],
int  size,
uint8_t  clear_val,
int *  read_bytes,
int *  write_bytes 
)

"Solve" an op list into a fixed shuffle mask, with an optional ability to also directly clear the output value (for e.g.

rgb24 -> rgb0). This can accept any operation chain that only consists of the following operations:

  • SWS_OP_READ (non-planar, non-fractional)
  • SWS_OP_SWIZZLE
  • SWS_OP_SWAP_BYTES
  • SWS_OP_CLEAR to zero (when clear_val is specified)
  • SWS_OP_CONVERT (integer expand)
  • SWS_OP_WRITE (non-planar, non-fractional)

Basically, any operation that purely consists of moving around and reordering bytes within a single plane, can be turned into a shuffle mask.

Parameters
opsThe operation list to decompose.
shuffleThe output shuffle mask.
sizeThe size (in bytes) of the output shuffle mask.
clear_valIf nonzero, this index will be used to clear the output.
read_bytesReturns the number of bytes read per shuffle iteration.
write_bytesReturns the number of bytes written per shuffle iteration.
Returns
The number of pixels processed per iteration, or a negative error code; in particular AVERROR(ENOTSUP) for unsupported operations.

Definition at line 779 of file ops_optimizer.c.

Referenced by solve_shuffle().

◆ ff_sws_op_list_subpass()

int ff_sws_op_list_subpass ( SwsOpList ops,
SwsOpList **  out_rest 
)

Eliminate SWS_OP_FILTER_* operations by merging them with prior SWS_OP_READ operations.

This may require splitting the op list into multiple subpasses, along filter boundaries. After this function, ops will no longer contain bare filtering operations. The remainder, if any, is output to out_rest.

Returns 0 or a negative error code.

Not all components may be needed; but we need the ones that are used to be contiguous for the write/read operations. So, first compress them into a linearly ascending list of components

Definition at line 929 of file ops_optimizer.c.

Referenced by ff_sws_compile_pass().

Variable Documentation

◆ ff_sws_op_backends

const SwsOpBackend* const ff_sws_op_backends[]

Definition at line 44 of file ops.c.

Referenced by check_ops(), and ff_sws_ops_compile().