Go to the documentation of this file.
64 av_log(
ctx, msg_lev,
"Backend '%s' failed to compile operations: %s\n",
85 "block size = %d, over-read = %d, over-write = %d, cpu flags = 0x%x\n",
86 backend->
name,
out->block_size,
out->over_read,
out->over_write,
103 p->comp.free(
p->comp.priv);
109 const uint8_t *in[4], uint8_t *
out[4])
112 for (
int i = 0;
i <
p->planes_in;
i++)
114 for (
int i = 0;
i <
p->planes_out;
i++)
127 const int block_size =
comp->block_size;
128 p->num_blocks = (pass->
width + block_size - 1) / block_size;
131 const int aligned_w =
p->num_blocks * block_size;
132 const int safe_width = (
p->num_blocks - 1) * block_size;
133 const int tail_size = pass->
width - safe_width;
134 p->tail_off_in = safe_width *
p->pixel_bits_in >> 3;
135 p->tail_off_out = safe_width *
p->pixel_bits_out >> 3;
136 p->tail_size_in = tail_size *
p->pixel_bits_in >> 3;
137 p->tail_size_out = tail_size *
p->pixel_bits_out >> 3;
138 p->memcpy_in =
false;
139 p->memcpy_out =
false;
141 for (
int i = 0;
i <
p->planes_in;
i++) {
142 const int idx =
p->idx_in[
i];
143 const int chroma = idx == 1 || idx == 2;
146 const int plane_w = (aligned_w + sub_x) >> sub_x;
147 const int plane_pad = (
comp->over_read + sub_x) >> sub_x;
148 const int plane_size = plane_w *
p->pixel_bits_in >> 3;
149 if (
comp->slice_align)
150 p->memcpy_in |= plane_size + plane_pad > in->
linesize[idx];
157 for (
int i = 0;
i <
p->planes_out;
i++) {
158 const int idx =
p->idx_out[
i];
159 const int chroma = idx == 1 || idx == 2;
162 const int plane_w = (aligned_w + sub_x) >> sub_x;
163 const int plane_pad = (
comp->over_write + sub_x) >> sub_x;
164 const int plane_size = plane_w *
p->pixel_bits_out >> 3;
165 if (
comp->slice_align)
166 p->memcpy_out |= plane_size + plane_pad >
out->linesize[idx];
176 const int blocks_main =
p->num_blocks -
p->memcpy_out;
177 for (
int i = 0;
i < 4;
i++) {
189 const bool copy_out,
const bool copy_in,
196 const int tail_size_in =
p->tail_size_in;
197 const int tail_size_out =
p->tail_size_out;
198 const int bx =
p->num_blocks - 1;
200 const uint8_t *in_data[4];
201 uint8_t *out_data[4];
204 for (
int i = 0;
i <
p->planes_in;
i++) {
205 in_data[
i] +=
p->tail_off_in;
207 exec->
in[
i] = (
void *)
tmp[0][
i];
210 exec->
in[
i] = in_data[
i];
214 for (
int i = 0;
i <
p->planes_out;
i++) {
215 out_data[
i] +=
p->tail_off_out;
220 exec->
out[
i] = out_data[
i];
224 for (
int y_end = y +
h; y < y_end; y++) {
226 for (
int i = 0;
i <
p->planes_in;
i++) {
228 memcpy(
tmp[0][
i], in_data[
i], tail_size_in);
229 in_data[
i] +=
base->in_stride[
i];
233 comp->func(exec,
comp->priv, bx, y,
p->num_blocks, y + 1);
236 for (
int i = 0;
i <
p->planes_out;
i++) {
238 memcpy(out_data[
i],
tmp[1][
i], tail_size_out);
239 out_data[
i] +=
base->out_stride[
i];
243 for (
int i = 0;
i < 4;
i++) {
244 if (!copy_in && exec->
in[
i])
246 if (!copy_out && exec->
out[
i])
280 const int last_slice = y +
h == pass->
height;
281 const bool memcpy_in = last_slice &&
p->memcpy_in;
282 const bool memcpy_out =
p->memcpy_out;
283 const int num_blocks =
p->num_blocks;
284 const int blocks_main = num_blocks - memcpy_out;
285 const int h_main =
h - memcpy_in;
289 comp->func(&exec,
comp->priv, 0, y, blocks_main, y + h_main);
294 comp->func(&exec,
comp->priv, 0, y + h_main, num_blocks - 1, y +
h);
306 return op->rw.packed ? 1 :
op->rw.elems;
311 const int elems =
op->rw.packed ?
op->rw.elems : 1;
313 const int bits = 8 >>
op->rw.frac;
338 .height =
dst->height,
339 .block_size_in =
p->comp.block_size *
p->pixel_bits_in >> 3,
340 .block_size_out =
p->comp.block_size *
p->pixel_bits_out >> 3,
343 for (
int i = 0;
i < 4;
i++) {
380 if (!
read || !write) {
382 "and write, respectively.\n");
static int rw_planes(const SwsOp *op)
void ff_sws_op_list_free(SwsOpList **p_ops)
#define AV_LOG_WARNING
Something somehow does not look correct.
Represents a single filter pass in the scaling graph.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
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)
SwsOpList * ff_sws_op_list_duplicate(const SwsOpList *ops)
Returns a duplicate of ops, or NULL on OOM.
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int ff_sws_ops_compile(SwsContext *ctx, const SwsOpList *ops, SwsCompiledOp *out)
Compile a list of operations using the best available backend.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
#define AV_LOG_VERBOSE
Detailed information.
void(* free)(void *priv)
Optional private state and associated free() function.
int ff_sws_pixel_type_size(SwsPixelType type)
#define DECLARE_ALIGNED_64(t, v)
void ff_sws_op_list_print(void *log, int lev, int lev_extra, const SwsOpList *ops)
Print out the contents of an operation list.
const SwsOpBackend *const ff_sws_op_backends[]
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.
int(* compile)(SwsContext *ctx, SwsOpList *ops, SwsCompiledOp *out)
Compile an operation list to an implementation chain.
enum AVPixelFormat hw_format
If NONE, backend only supports software frames.
Represents a view into a single field of frame data.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
enum AVPixelFormat format
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
const SwsFrame * out_frame
static AVFormatContext * ctx
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
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.
Copyright (C) 2026 Niklas Haas.
bool ff_sws_op_list_is_noop(const SwsOpList *ops)
Returns whether an op list represents a true no-op operation, i.e.
static void op_pass_free(void *ptr)
static int rw_pixel_bits(const SwsOp *op)
static void copy(const float *p1, float *p2, const int length)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define i(width, name, range_min, range_max)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int ff_sws_graph_add_pass(SwsGraph *graph, enum AVPixelFormat fmt, int width, int height, SwsPass *input, int align, void *priv, sws_filter_run_t run, SwsPass **out_pass)
Allocate and add a new pass to the filter graph.
void ff_sws_op_list_update_comps(SwsOpList *ops)
Infer + propagate known information about components.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
int ff_sws_op_list_optimize(SwsOpList *ops)
Fuse compatible and eliminate redundant operations, as well as replacing some operations with more ef...
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define DECLARE_ALIGNED_32(t, v)
Copyright (C) 2025 Niklas Haas.
const SwsFrame * in_frame
void(* setup)(const SwsFrame *out, const SwsFrame *in, const SwsPass *pass)
Called once from the main thread before running the filter.
static void op_pass_setup(const SwsFrame *out, const SwsFrame *in, const SwsPass *pass)
static int compile(SwsGraph *graph, const SwsOpList *ops, const SwsFormat *dst, SwsPass *input, SwsPass **output)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
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.
Filter graph, which represents a 'baked' pixel format conversion.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static void op_pass_run(const SwsFrame *out, const SwsFrame *in, const int y, const int h, const SwsPass *pass)
Helper struct for representing a list of operations.
Main external API structure.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static void get_row_data(const SwsOpPass *p, const int y, const uint8_t *in[4], uint8_t *out[4])