FFmpeg
Loading...
Searching...
No Matches
ops_dispatch.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/cpu.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/refstruct.h"
#include "ops.h"
#include "ops_internal.h"
#include "ops_dispatch.h"
#include "swscale_internal.h"

Go to the source code of this file.

Data Structures

struct  SwsOpPass
 
struct  CompileArgs
 

Macros

#define RET(x)
 Copyright (C) 2025 Niklas Haas.
 

Functions

static int compile_backend (SwsContext *ctx, const SwsOpBackend *backend, const SwsOpList *ops, SwsCompiledOp *out)
 
int ff_sws_ops_compile (SwsContext *ctx, const SwsOpBackend *backend, const SwsOpList *ops, SwsCompiledOp *out)
 Attempt to compile a list of operations using a specific backend, or the best available backend if backend is NULL.
 
void ff_sws_compiled_op_unref (SwsCompiledOp *comp)
 
static void op_pass_free (void *ptr)
 
static void get_row_data (const SwsOpPass *p, const int y_dst, const uint8_t *in[4], uint8_t *out[4])
 
static int get_lines_in (const SwsOpPass *p, const int y, const int h, const int plane)
 
static size_t pixel_bytes (size_t pixels, int pixel_bits, enum AVRounding rounding)
 
static size_t safe_bytes_pad (int linesize, int plane_pad)
 
static size_t safe_blocks_offset (size_t num_blocks, unsigned block_size, ptrdiff_t safe_offset, const int32_t *offset_bytes)
 
static int op_pass_setup (const SwsFrame *out, const SwsFrame *in, const SwsPass *pass)
 
static void copy_lines (uint8_t *dst, const size_t dst_stride, const uint8_t *src, const size_t src_stride, const int h, const size_t bytes)
 
static void op_pass_run (const SwsFrame *out, const SwsFrame *in, const int y, const int h, const SwsPass *pass)
 
static void op_list_get_plane_copy (const SwsOpList *ops, SwsPass *pass)
 
static int rw_data_planes (const SwsOp *op)
 
static int rw_pixel_bits (const SwsOp *op)
 
static void align_pass (SwsPass *pass, int block_size, const int *over_rw, int pixel_bits)
 
static int compile_single (const CompileArgs *args, const SwsOpList *ops, SwsPass *link, SwsPass *input, SwsPass **output)
 
static SwsCompMask plane_mask_flags (const SwsOp *op, SwsCompFlags flags)
 
static int compile_subpass (const CompileArgs *args, SwsOpList **pops, SwsPass *link, SwsPass *input, SwsPass **output)
 
int ff_sws_compile_pass (SwsGraph *graph, const SwsOpBackend *backend, SwsOpList **pops, int flags, SwsPass *input, SwsPass **output)
 Resolves an operation list to a graph pass.
 

Macro Definition Documentation

◆ RET

#define RET ( x)
Value:
do { \
if ((ret = (x)) < 0) \
goto fail; \
} while (0)
#define fail
Definition test.h:479

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 33 of file ops_dispatch.c.

Referenced by compile_subpass().

Function Documentation

◆ compile_backend()

static int compile_backend ( SwsContext * ctx,
const SwsOpBackend * backend,
const SwsOpList * ops,
SwsCompiledOp * out )
static

Definition at line 65 of file ops_dispatch.c.

Referenced by ff_sws_ops_compile().

◆ ff_sws_ops_compile()

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

Attempt to compile a list of operations using a specific backend, or the best available backend if backend is NULL.

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

Definition at line 106 of file ops_dispatch.c.

Referenced by compile_single().

◆ ff_sws_compiled_op_unref()

void ff_sws_compiled_op_unref ( SwsCompiledOp * comp)

Definition at line 128 of file ops_dispatch.c.

Referenced by op_pass_free(), and run_test().

◆ op_pass_free()

static void op_pass_free ( void * ptr)
static

Definition at line 136 of file ops_dispatch.c.

Referenced by compile_single().

◆ get_row_data()

static void get_row_data ( const SwsOpPass * p,
const int y_dst,
const uint8_t * in[4],
uint8_t * out[4] )
inlinestatic

Definition at line 150 of file ops_dispatch.c.

Referenced by op_pass_run().

◆ get_lines_in()

static int get_lines_in ( const SwsOpPass * p,
const int y,
const int h,
const int plane )
inlinestatic

Definition at line 161 of file ops_dispatch.c.

Referenced by op_pass_run().

◆ pixel_bytes()

static size_t pixel_bytes ( size_t pixels,
int pixel_bits,
enum AVRounding rounding )
inlinestatic

Definition at line 173 of file ops_dispatch.c.

Referenced by op_pass_setup().

◆ safe_bytes_pad()

static size_t safe_bytes_pad ( int linesize,
int plane_pad )
static

Definition at line 190 of file ops_dispatch.c.

Referenced by op_pass_setup().

◆ safe_blocks_offset()

static size_t safe_blocks_offset ( size_t num_blocks,
unsigned block_size,
ptrdiff_t safe_offset,
const int32_t * offset_bytes )
static

Definition at line 197 of file ops_dispatch.c.

Referenced by op_pass_setup().

◆ op_pass_setup()

static int op_pass_setup ( const SwsFrame * out,
const SwsFrame * in,
const SwsPass * pass )
static

Definition at line 207 of file ops_dispatch.c.

Referenced by compile_single().

◆ copy_lines()

static void copy_lines ( uint8_t * dst,
const size_t dst_stride,
const uint8_t * src,
const size_t src_stride,
const int h,
const size_t bytes )
static

Definition at line 367 of file ops_dispatch.c.

Referenced by op_pass_run().

◆ op_pass_run()

static void op_pass_run ( const SwsFrame * out,
const SwsFrame * in,
const int y,
const int h,
const SwsPass * pass )
static

To ensure safety, we need to consider the following:

  1. We can overread the input, unless this is the last line of an unpadded buffer. All defined operations can handle arbitrary pixel input, so overread of arbitrary data is fine. For flipped images, this condition is actually inverted to where the first line is the one at the end of the buffer.
  2. We can overwrite the output, as long as we don't write more than the amount of pixels that fit into one linesize. So we always need to memcpy the last column on the output side if unpadded.

Definition at line 378 of file ops_dispatch.c.

Referenced by compile_single().

◆ op_list_get_plane_copy()

static void op_list_get_plane_copy ( const SwsOpList * ops,
SwsPass * pass )
static

Definition at line 479 of file ops_dispatch.c.

Referenced by compile_single().

◆ rw_data_planes()

static int rw_data_planes ( const SwsOp * op)
static

Definition at line 506 of file ops_dispatch.c.

Referenced by compile_single().

◆ rw_pixel_bits()

static int rw_pixel_bits ( const SwsOp * op)
static

Definition at line 513 of file ops_dispatch.c.

Referenced by compile_single().

◆ align_pass()

static void align_pass ( SwsPass * pass,
int block_size,
const int * over_rw,
int pixel_bits )
static

Definition at line 530 of file ops_dispatch.c.

Referenced by compile_single().

◆ compile_single()

static int compile_single ( const CompileArgs * args,
const SwsOpList * ops,
SwsPass * link,
SwsPass * input,
SwsPass ** output )
static

Definition at line 555 of file ops_dispatch.c.

Referenced by compile_subpass().

◆ plane_mask_flags()

static SwsCompMask plane_mask_flags ( const SwsOp * op,
SwsCompFlags flags )
static

Definition at line 707 of file ops_dispatch.c.

Referenced by compile_subpass().

◆ compile_subpass()

static int compile_subpass ( const CompileArgs * args,
SwsOpList ** pops,
SwsPass * link,
SwsPass * input,
SwsPass ** output )
static

Definition at line 719 of file ops_dispatch.c.

Referenced by compile_subpass(), and ff_sws_compile_pass().

◆ ff_sws_compile_pass()

int ff_sws_compile_pass ( SwsGraph * graph,
const SwsOpBackend * backend,
SwsOpList ** ops,
int flags,
SwsPass * input,
SwsPass ** output )

Resolves an operation list to a graph pass.

The last op must be a write.

Parameters
backendForce the use of a specific backend (Optional)
opsOperations to compile. Ownership passes to this function, and will be set to NULL, even on failure.
flagsSet of SwsOpCompileFlags
inputThe input for the compiled passes. (Optional)
outputThe resulting final output pass will be stored here. Optional if using SWS_OP_FLAG_DRY_RUN.

Definition at line 781 of file ops_dispatch.c.

Referenced by add_ops_convert_pass(), print_passes(), register_all_uops(), and register_op().