FFmpeg
Data Structures | Functions
ops_dispatch.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "ops.h"
#include "ops_internal.h"
#include "ops_dispatch.h"

Go to the source code of this file.

Data Structures

struct  SwsOpPass
 Copyright (C) 2025 Niklas Haas. More...
 

Functions

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...
 
static void op_pass_free (void *ptr)
 
static void get_row_data (const SwsOpPass *p, const int y, const uint8_t *in[4], uint8_t *out[4])
 
static void op_pass_setup (const SwsFrame *out, const SwsFrame *in, const SwsPass *pass)
 
static av_always_inline void handle_tail (const SwsOpPass *p, SwsOpExec *exec, const bool copy_out, const bool copy_in, int y, const int h)
 
static void op_pass_run (const SwsFrame *out, const SwsFrame *in, const int y, const int h, const SwsPass *pass)
 
static int rw_planes (const SwsOp *op)
 
static int rw_pixel_bits (const SwsOp *op)
 
static int compile (SwsGraph *graph, const SwsOpList *ops, const SwsFormat *dst, SwsPass *input, SwsPass **output)
 
int ff_sws_compile_pass (SwsGraph *graph, SwsOpList *ops, int flags, const SwsFormat *dst, SwsPass *input, SwsPass **output)
 Resolves an operation list to a graph pass. More...
 

Function Documentation

◆ 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 47 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 74 of file ops_dispatch.c.

Referenced by compile().

◆ op_pass_free()

static void op_pass_free ( void *  ptr)
static

Definition at line 96 of file ops_dispatch.c.

Referenced by compile().

◆ get_row_data()

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

Definition at line 108 of file ops_dispatch.c.

Referenced by handle_tail(), and op_pass_run().

◆ op_pass_setup()

static void op_pass_setup ( const SwsFrame out,
const SwsFrame in,
const SwsPass pass 
)
static

Definition at line 118 of file ops_dispatch.c.

Referenced by compile().

◆ handle_tail()

static av_always_inline void handle_tail ( const SwsOpPass p,
SwsOpExec exec,
const bool  copy_out,
const bool  copy_in,
int  y,
const int  h 
)
static

Definition at line 188 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.
  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.
  3. For the last row, we also need to memcpy the remainder of the input, to avoid reading past the end of the buffer. Note that since we know the run() function is called on stripes of the same buffer, we don't need to worry about this for the end of a slice.

Definition at line 252 of file ops_dispatch.c.

Referenced by compile().

◆ rw_planes()

static int rw_planes ( const SwsOp op)
static

Definition at line 304 of file ops_dispatch.c.

Referenced by compile().

◆ rw_pixel_bits()

static int rw_pixel_bits ( const SwsOp op)
static

Definition at line 309 of file ops_dispatch.c.

Referenced by compile().

◆ compile()

static int compile ( SwsGraph graph,
const SwsOpList ops,
const SwsFormat dst,
SwsPass input,
SwsPass **  output 
)
static

Definition at line 318 of file ops_dispatch.c.

Referenced by ff_sws_compile_pass().

◆ ff_sws_compile_pass()

int ff_sws_compile_pass ( SwsGraph graph,
SwsOpList ops,
int  flags,
const SwsFormat dst,
SwsPass input,
SwsPass **  output 
)

Resolves an operation list to a graph pass.

The first and last operations must be a read/write respectively. flags is a list of SwsOpCompileFlags.

Note: ops may be modified by this function.

Definition at line 366 of file ops_dispatch.c.