FFmpeg
ops.h
Go to the documentation of this file.
1 /**
2  * Copyright (C) 2025 Niklas Haas
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef SWSCALE_OPS_H
22 #define SWSCALE_OPS_H
23 
24 #include <assert.h>
25 #include <stdbool.h>
26 #include <stdalign.h>
27 
28 #include "libavutil/bprint.h"
29 
30 #include "graph.h"
31 #include "filters.h"
32 
33 typedef enum SwsPixelType {
40 } SwsPixelType;
41 
45 
46 typedef enum SwsOpType {
48 
49  /* Defined for all types; but implemented for integers only */
50  SWS_OP_READ, /* gather raw pixels from planes */
51  SWS_OP_WRITE, /* write raw pixels to planes */
52  SWS_OP_SWAP_BYTES, /* swap byte order (for differing endianness) */
53  SWS_OP_SWIZZLE, /* rearrange channel order, or duplicate channels */
54 
55  /* Bit manipulation operations. Defined for integers only. */
56  SWS_OP_UNPACK, /* split tightly packed data into components */
57  SWS_OP_PACK, /* compress components into tightly packed data */
58  SWS_OP_LSHIFT, /* logical left shift of raw pixel values */
59  SWS_OP_RSHIFT, /* right shift of raw pixel values */
60 
61  /* Generic arithmetic. Defined and implemented for all types */
62  SWS_OP_CLEAR, /* clear pixel values */
63  SWS_OP_CONVERT, /* convert (cast) between formats */
64  SWS_OP_MIN, /* numeric minimum */
65  SWS_OP_MAX, /* numeric maximum */
66  SWS_OP_SCALE, /* multiplication by scalar */
67 
68  /* Floating-point only arithmetic operations. */
69  SWS_OP_LINEAR, /* generalized linear affine transform */
70  SWS_OP_DITHER, /* add dithering noise */
71 
72  /* Filtering operations. Always output floating point. */
73  SWS_OP_FILTER_H, /* horizontal filtering */
74  SWS_OP_FILTER_V, /* vertical filtering */
75 
77 } SwsOpType;
78 
79 const char *ff_sws_op_type_name(SwsOpType op);
80 
81 /**
82  * Bit-mask of components. Exact meaning depends on the usage context.
83  */
84 typedef uint8_t SwsCompMask;
85 enum {
87  SWS_COMP_ALL = 0xF,
88 #define SWS_COMP(X) (1 << (X))
89 #define SWS_COMP_TEST(mask, X) (!!((mask) & SWS_COMP(X)))
90 #define SWS_COMP_INV(mask) ((mask) ^ SWS_COMP_ALL)
91 #define SWS_COMP_ELEMS(N) ((1 << (N)) - 1)
92 #define SWS_COMP_MASK(X, Y, Z, W) \
93  (((X) ? SWS_COMP(0) : 0) | \
94  ((Y) ? SWS_COMP(1) : 0) | \
95  ((Z) ? SWS_COMP(2) : 0) | \
96  ((W) ? SWS_COMP(3) : 0))
97 };
98 
99 /* Compute SwsCompMask from values with denominator != 0 */
101 
102 typedef enum SwsCompFlags {
103  SWS_COMP_GARBAGE = 1 << 0, /* contents are undefined / garbage data */
104  SWS_COMP_EXACT = 1 << 1, /* value is an exact integer */
105  SWS_COMP_ZERO = 1 << 2, /* known to be a constant zero */
106  SWS_COMP_SWAPPED = 1 << 3, /* byte order is swapped */
107 } SwsCompFlags;
108 
109 typedef struct SwsComps {
110  SwsCompFlags flags[4]; /* knowledge about (output) component contents */
111 
112  /* Keeps track of the known possible value range, or {0, 0} for undefined
113  * or (unknown range) floating point inputs */
115 } SwsComps;
116 
117 typedef struct SwsReadWriteOp {
118  /**
119  * Examples:
120  * rgba = 4x u8 packed
121  * yuv444p = 3x u8
122  * rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack
123  * monow = 1x u8 (frac 3)
124  * rgb4 = 1x u8 (frac 1)
125  */
126  uint8_t elems; /* number of elements (of type `op.type`) to read/write */
127  uint8_t frac; /* fractional pixel step factor (log2) */
128  bool packed; /* read multiple elements from a single plane */
129 
130  /**
131  * Filter kernel to apply to each plane while sampling. Currently, only
132  * one shared filter kernel is supported for all planes. (Optional)
133  *
134  * Note: As with SWS_OP_FILTER_*, if a filter kernel is in use, the read
135  * operation will always output floating point values.
136  */
137  SwsOpType filter; /* some value of SWS_OP_FILTER_* */
138  SwsFilterWeights *kernel; /* (refstruct) */
140 
141 typedef struct SwsPackOp {
142  /**
143  * Packed bits are assumed to be LSB-aligned within the underlying
144  * integer type; i.e. (msb) 0 ... X Y Z W (lsb).
145  */
146  uint8_t pattern[4]; /* bit depth pattern, from MSB to LSB */
147 } SwsPackOp;
148 
149 typedef struct SwsSwizzleOp {
150  /**
151  * Input component for each output component:
152  * Out[x] := In[swizzle.in[x]]
153  */
154  union {
155  uint32_t mask;
156  uint8_t in[4];
157  struct { uint8_t x, y, z, w; };
158  };
159 } SwsSwizzleOp;
160 
161 #define SWS_SWIZZLE(X,Y,Z,W) ((SwsSwizzleOp) { .in = {X, Y, Z, W} })
163 
164 typedef struct SwsShiftOp {
165  uint8_t amount; /* number of bits to shift */
166 } SwsShiftOp;
167 
168 typedef struct SwsClearOp {
169  SwsCompMask mask; /* mask of components to clear */
170  AVRational value[4]; /* value to set */
171 } SwsClearOp;
172 
173 typedef struct SwsConvertOp {
174  SwsPixelType to; /* type of pixel to convert to */
175  bool expand; /* if true, integers are expanded to the full range */
176 } SwsConvertOp;
177 
178 typedef struct SwsClampOp {
179  AVRational limit[4]; /* per-component min/max value */
180 } SwsClampOp;
181 
182 typedef struct SwsScaleOp {
183  AVRational factor; /* scalar multiplication factor */
184 } SwsScaleOp;
185 
186 typedef struct SwsDitherOp {
187  AVRational *matrix; /* tightly packed dither matrix (refstruct) */
188  AVRational min, max; /* minimum/maximum value in `matrix` */
189  int size_log2; /* size (in bits) of the dither matrix */
190  int8_t y_offset[4]; /* row offset for each component, or -1 for ignored */
191 } SwsDitherOp;
192 
193 typedef struct SwsLinearOp {
194  /**
195  * Generalized 5x5 affine transformation:
196  * [ Out.x ] = [ A B C D E ]
197  * [ Out.y ] = [ F G H I J ] * [ x y z w 1 ]
198  * [ Out.z ] = [ K L M N O ]
199  * [ Out.w ] = [ P Q R S T ]
200  *
201  * The mask keeps track of which components differ from an identity matrix.
202  * There may be more efficient implementations of particular subsets, for
203  * example the common subset of {A, E, G, J, M, O} can be implemented with
204  * just three fused multiply-add operations.
205  */
206  AVRational m[4][5];
207  uint32_t mask; /* m[i][j] <-> 1 << (5 * i + j) */
208 } SwsLinearOp;
209 
210 #define SWS_MASK(I, J) (1 << (5 * (I) + (J)))
211 #define SWS_MASK_OFF(I) SWS_MASK(I, 4)
212 #define SWS_MASK_ROW(I) (0x1F << (5 * (I)))
213 #define SWS_MASK_COL(J) (0x8421 << J)
214 
215 enum {
216  SWS_MASK_ALL = (1 << 20) - 1,
219 
220  SWS_MASK_DIAG3 = SWS_MASK(0, 0) | SWS_MASK(1, 1) | SWS_MASK(2, 2),
222  SWS_MASK_MAT3 = SWS_MASK(0, 0) | SWS_MASK(0, 1) | SWS_MASK(0, 2) |
223  SWS_MASK(1, 0) | SWS_MASK(1, 1) | SWS_MASK(1, 2) |
224  SWS_MASK(2, 0) | SWS_MASK(2, 1) | SWS_MASK(2, 2),
225 
229 };
230 
231 /* Helper function to compute the correct mask */
233 
234 typedef struct SwsFilterOp {
235  SwsFilterWeights *kernel; /* filter kernel (refstruct) */
236 } SwsFilterOp;
237 
238 typedef struct SwsOp {
239  SwsOpType op; /* operation to perform */
240  SwsPixelType type; /* pixel type to operate on */
241  union {
253  };
254 
255  /**
256  * Metadata about the operation's input/output components. Discarded
257  * and regenerated automatically by `ff_sws_op_list_update_comps()`.
258  *
259  * Note that backends may rely on the presence and accuracy of this
260  * metadata for all operations, during ff_sws_ops_compile().
261  */
263 } SwsOp;
264 
265 #define SWS_OP_NEEDED(op, idx) (!((op)->comps.flags[idx] & SWS_COMP_GARBAGE))
266 
267 /* Compute SwsCompMask from a mask of needed components */
269 
270 /**
271  * Describe an operation in human-readable form.
272  */
273 void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op);
274 
275 /**
276  * Frees any allocations associated with an SwsOp and sets it to {0}.
277  */
278 void ff_sws_op_uninit(SwsOp *op);
279 
280 /**
281  * Apply an operation to an AVRational. No-op for read/write operations.
282  */
283 void ff_sws_apply_op_q(const SwsOp *op, AVRational x[4]);
284 
285 /**
286  * Helper struct for representing a list of operations.
287  */
288 typedef struct SwsOpList {
290  int num_ops;
291 
292  /* Metadata associated with this operation list */
294 
295  /* Input/output plane indices */
296  uint8_t plane_src[4], plane_dst[4];
297 
298  /**
299  * Source component metadata associated with pixel values from each
300  * corresponding component (in plane/memory order, i.e. not affected by
301  * `plane_src`). Lets the optimizer know additional information about
302  * the value range and/or pixel data to expect.
303  *
304  * The default value of {0} is safe to pass in the case that no additional
305  * information is known.
306  */
308 } SwsOpList;
309 
311 void ff_sws_op_list_free(SwsOpList **ops);
312 
313 /**
314  * Returns a duplicate of `ops`, or NULL on OOM.
315  */
317 
318 /**
319  * Returns the input operation for a given op list, or NULL if there is none
320  * (e.g. for a pure CLEAR-only operation list).
321  *
322  * This will always be an op of type SWS_OP_READ.
323  */
324 const SwsOp *ff_sws_op_list_input(const SwsOpList *ops);
325 
326 /**
327  * Returns the output operation for a given op list, or NULL if there is none.
328  *
329  * This will always be an op of type SWS_OP_WRITE.
330  */
331 const SwsOp *ff_sws_op_list_output(const SwsOpList *ops);
332 
333 /**
334  * Returns whether an op list represents a true no-op operation, i.e. may be
335  * eliminated entirely from an execution graph.
336  */
337 bool ff_sws_op_list_is_noop(const SwsOpList *ops);
338 
339 /**
340  * Returns the size of the largest pixel type used in `ops`.
341  */
342 int ff_sws_op_list_max_size(const SwsOpList *ops);
343 
344 /**
345  * These will take over ownership of `op` and set it to {0}, even on failure.
346  */
349 
350 void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count);
351 
352 /**
353  * Print out the contents of an operation list.
354  */
355 void ff_sws_op_list_print(void *log_ctx, int log_level, int log_level_extra,
356  const SwsOpList *ops);
357 
358 /**
359  * Infer + propagate known information about components. Called automatically
360  * when needed by the optimizer and compiler.
361  */
363 
364 /**
365  * Fuse compatible and eliminate redundant operations, as well as replacing
366  * some operations with more efficient alternatives.
367  */
369 
371  /* Automatically optimize the operations when compiling */
373 };
374 
375 /**
376  * Resolves an operation list to a graph pass. The first and last operations
377  * must be a read/write respectively. `flags` is a list of SwsOpCompileFlags.
378  *
379  * Takes over ownership of `ops` and sets it to NULL, even on failure.
380  *
381  * Note: `ops` may be modified by this function.
382  */
383 int ff_sws_compile_pass(SwsGraph *graph, SwsOpList **ops, int flags,
385 
386 /**
387  * Helper function to enumerate over all possible (optimized) operation lists,
388  * under the current set of options in `ctx`, and run the given callback on
389  * each list.
390  *
391  * @param src_fmt If set (not AV_PIX_FMT_NONE), constrain the source format
392  * @param dst_fmt If set (not AV_PIX_FMT_NONE), constrain the destination format
393  * @return 0 on success, the return value if cb() < 0, or a negative error code
394  *
395  * @note `ops` belongs to ff_sws_enum_op_lists(), but may be mutated by `cb`.
396  * @see ff_sws_enum_ops()
397  */
398 int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque,
399  enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
400  int (*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops));
401 
402 /**
403  * Helper function to enumerate over all possible operations, under the current
404  * set of options in `ctx`, and run the given callback on each operation.
405  *
406  * @param src_fmt If set (not AV_PIX_FMT_NONE), constrain the source format
407  * @param dst_fmt If set (not AV_PIX_FMT_NONE), constrain the destination format
408  * @return 0 on success, the return value if cb() < 0, or a negative error code
409  *
410  * @note May contain duplicates. `op` belongs to ff_sws_enum_ops(), but may be
411  * mutated by `cb`.
412  * @see ff_sws_num_op_lists()
413  */
414 int ff_sws_enum_ops(SwsContext *ctx, void *opaque,
415  enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
416  int (*cb)(SwsContext *ctx, void *opaque, SwsOp *op));
417 
418 #endif
SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:50
flags
const SwsFlags flags[]
Definition: swscale.c:72
SWS_PIXEL_U16
@ SWS_PIXEL_U16
Definition: ops.h:36
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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.
Definition: ops.c:671
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:53
SwsPass
Represents a single filter pass in the scaling graph.
Definition: graph.h:75
SwsClearOp::value
AVRational value[4]
Definition: ops.h:170
SWS_OP_LSHIFT
@ SWS_OP_LSHIFT
Definition: ops.h:58
SWS_OP_UNPACK
@ SWS_OP_UNPACK
Definition: ops.h:56
SwsClearOp
Definition: ops.h:168
ff_sws_enum_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,...
Definition: ops.c:1095
SwsSwizzleOp::mask
uint32_t mask
Definition: ops.h:155
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:247
SwsOpList::comps_src
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
Definition: ops.h:307
SWS_COMP_ZERO
@ SWS_COMP_ZERO
Definition: ops.h:105
SWS_OP_CLEAR
@ SWS_OP_CLEAR
Definition: ops.h:62
SwsOp::swizzle
SwsSwizzleOp swizzle
Definition: ops.h:245
SwsLinearOp::m
AVRational m[4][5]
Generalized 5x5 affine transformation: [ Out.x ] = [ A B C D E ] [ Out.y ] = [ F G H I J ] * [ x y z ...
Definition: ops.h:206
SWS_MASK_MAT4
@ SWS_MASK_MAT4
Definition: ops.h:228
SwsSwizzleOp::z
uint8_t z
Definition: ops.h:157
SwsOp::convert
SwsConvertOp convert
Definition: ops.h:248
output
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
Definition: filter_design.txt:226
mask
int mask
Definition: mediacodecdec_common.c:154
SwsOp::rw
SwsReadWriteOp rw
Definition: ops.h:243
SWS_OP_DITHER
@ SWS_OP_DITHER
Definition: ops.h:70
SwsFilterWeights
Represents a computed filter kernel.
Definition: filters.h:64
SwsFilterOp
Definition: ops.h:234
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: ops.c:748
av_const
#define av_const
Definition: attributes.h:113
SwsCompMask
uint8_t SwsCompMask
Bit-mask of components.
Definition: ops.h:84
ff_sws_pixel_type_size
int ff_sws_pixel_type_size(SwsPixelType type) av_const
Definition: ops.c:77
SwsClampOp::limit
AVRational limit[4]
Definition: ops.h:179
SWS_PIXEL_U32
@ SWS_PIXEL_U32
Definition: ops.h:37
SWS_OP_TYPE_NB
@ SWS_OP_TYPE_NB
Definition: ops.h:76
SWS_MASK_ALL
@ SWS_MASK_ALL
Definition: ops.h:216
SwsPixelType
SwsPixelType
Copyright (C) 2025 Niklas Haas.
Definition: ops.h:33
SwsComps::max
AVRational max[4]
Definition: ops.h:114
SwsOpList::plane_dst
uint8_t plane_dst[4]
Definition: ops.h:296
SwsSwizzleOp::w
uint8_t w
Definition: ops.h:157
SWS_PIXEL_F32
@ SWS_PIXEL_F32
Definition: ops.h:38
SwsClearOp::mask
SwsCompMask mask
Definition: ops.h:169
SwsOpList::num_ops
int num_ops
Definition: ops.h:290
SwsCompFlags
SwsCompFlags
Definition: ops.h:102
SwsDitherOp
Definition: ops.h:186
ff_sws_op_uninit
void ff_sws_op_uninit(SwsOp *op)
Frees any allocations associated with an SwsOp and sets it to {0}.
SWS_MASK_LUMA
@ SWS_MASK_LUMA
Definition: ops.h:217
ff_sws_op_list_alloc
SwsOpList * ff_sws_op_list_alloc(void)
Definition: ops.c:607
SWS_PIXEL_U8
@ SWS_PIXEL_U8
Definition: ops.h:35
SwsReadWriteOp
Definition: ops.h:117
SwsSwizzleOp
Definition: ops.h:149
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
SWS_MASK_ALPHA
@ SWS_MASK_ALPHA
Definition: ops.h:218
SwsLinearOp::mask
uint32_t mask
Definition: ops.h:207
SwsOp::op
SwsOpType op
Definition: ops.h:239
SwsOpCompileFlags
SwsOpCompileFlags
Definition: ops.h:370
SWS_OP_SCALE
@ SWS_OP_SCALE
Definition: ops.h:66
SwsOp::clear
SwsClearOp clear
Definition: ops.h:247
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: ops.c:714
SwsScaleOp::factor
AVRational factor
Definition: ops.h:183
SwsFilterOp::kernel
SwsFilterWeights * kernel
Definition: ops.h:235
ff_sws_op_list_insert_at
int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
Definition: ops.c:700
SwsComps::min
AVRational min[4]
Definition: ops.h:114
op
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.
Definition: anm.c:76
SWS_MASK_OFF3
@ SWS_MASK_OFF3
Definition: ops.h:221
SwsDitherOp::max
AVRational max
Definition: ops.h:188
SWS_OP_MIN
@ SWS_OP_MIN
Definition: ops.h:64
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
SWS_OP_LINEAR
@ SWS_OP_LINEAR
Definition: ops.h:69
SWS_OP_FILTER_H
@ SWS_OP_FILTER_H
Definition: ops.h:73
ff_sws_op_desc
void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
Describe an operation in human-readable form.
Definition: ops.c:854
SWS_OP_PACK
@ SWS_OP_PACK
Definition: ops.h:57
SwsOp::dither
SwsDitherOp dither
Definition: ops.h:251
SwsReadWriteOp::kernel
SwsFilterWeights * kernel
Definition: ops.h:138
ff_sws_comp_mask_q4
SwsCompMask ff_sws_comp_mask_q4(const AVRational q[4])
Definition: ops.c:137
filters.h
ff_sws_op_list_duplicate
SwsOpList * ff_sws_op_list_duplicate(const SwsOpList *ops)
Returns a duplicate of ops, or NULL on OOM.
Definition: ops.c:634
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
SwsReadWriteOp::frac
uint8_t frac
Definition: ops.h:127
ff_sws_pixel_type_is_int
bool ff_sws_pixel_type_is_int(SwsPixelType type) av_const
Definition: ops.c:92
SWS_MASK_DIAG4
@ SWS_MASK_DIAG4
Definition: ops.h:226
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.
Definition: ops.c:719
SWS_COMP_GARBAGE
@ SWS_COMP_GARBAGE
Definition: ops.h:103
SwsConvertOp::to
SwsPixelType to
Definition: ops.h:174
SWS_OP_FILTER_V
@ SWS_OP_FILTER_V
Definition: ops.h:74
ff_sws_op_list_print
void ff_sws_op_list_print(void *log_ctx, int log_level, int log_level_extra, const SwsOpList *ops)
Print out the contents of an operation list.
Definition: ops.c:961
SwsOp::clamp
SwsClampOp clamp
Definition: ops.h:249
SwsOpType
SwsOpType
Definition: ops.h:46
SWS_COMP_ALL
@ SWS_COMP_ALL
Definition: ops.h:87
SWS_MASK
#define SWS_MASK(I, J)
Definition: ops.h:210
SWS_PIXEL_NONE
@ SWS_PIXEL_NONE
Definition: ops.h:34
index
int index
Definition: gxfenc.c:90
SwsConvertOp::expand
bool expand
Definition: ops.h:175
SwsPackOp::pattern
uint8_t pattern[4]
Packed bits are assumed to be LSB-aligned within the underlying integer type; i.e.
Definition: ops.h:146
ff_sws_op_list_free
void ff_sws_op_list_free(SwsOpList **ops)
Definition: ops.c:620
SwsDitherOp::size_log2
int size_log2
Definition: ops.h:189
SwsClampOp
Definition: ops.h:178
SwsOp::type
SwsPixelType type
Definition: ops.h:240
SwsDitherOp::matrix
AVRational * matrix
Definition: ops.h:187
SWS_MASK_OFF4
@ SWS_MASK_OFF4
Definition: ops.h:227
SwsShiftOp
Definition: ops.h:164
SWS_OP_RSHIFT
@ SWS_OP_RSHIFT
Definition: ops.h:59
SwsOp::lin
SwsLinearOp lin
Definition: ops.h:242
SwsOpList::src
SwsFormat src
Definition: ops.h:293
SWS_OP_INVALID
@ SWS_OP_INVALID
Definition: ops.h:47
SwsFormat
Definition: format.h:77
SwsShiftOp::amount
uint8_t amount
Definition: ops.h:165
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:51
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.
Definition: ops.c:680
SwsOp::comps
SwsComps comps
Metadata about the operation's input/output components.
Definition: ops.h:262
SwsScaleOp
Definition: ops.h:182
SWS_OP_FLAG_OPTIMIZE
@ SWS_OP_FLAG_OPTIMIZE
Definition: ops.h:372
SwsLinearOp
Definition: ops.h:193
input
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
Definition: filter_design.txt:172
ff_sws_op_list_update_comps
void ff_sws_op_list_update_comps(SwsOpList *ops)
Infer + propagate known information about components.
Definition: ops.c:341
ff_sws_op_list_optimize
int ff_sws_op_list_optimize(SwsOpList *ops)
Fuse compatible and eliminate redundant operations, as well as replacing some operations with more ef...
Definition: ops_optimizer.c:340
bprint.h
SwsOp::filter
SwsFilterOp filter
Definition: ops.h:252
SwsOpList::ops
SwsOp * ops
Definition: ops.h:289
SwsPackOp
Definition: ops.h:141
SWS_MASK_MAT3
@ SWS_MASK_MAT3
Definition: ops.h:222
graph.h
SwsOp
Definition: ops.h:238
ff_sws_apply_op_q
void ff_sws_apply_op_q(const SwsOp *op, AVRational x[4])
Apply an operation to an AVRational.
Definition: ops.c:180
SwsComps::flags
SwsCompFlags flags[4]
Definition: ops.h:110
SWS_COMP_NONE
@ SWS_COMP_NONE
Definition: ops.h:86
SwsOpList::dst
SwsFormat dst
Definition: ops.h:293
SWS_OP_MAX
@ SWS_OP_MAX
Definition: ops.h:65
ff_sws_comp_mask_swizzle
SwsCompMask ff_sws_comp_mask_swizzle(SwsCompMask mask, SwsSwizzleOp swiz)
Definition: ops.c:147
SwsReadWriteOp::filter
SwsOpType filter
Filter kernel to apply to each plane while sampling.
Definition: ops.h:137
SWS_PIXEL_TYPE_NB
@ SWS_PIXEL_TYPE_NB
Definition: ops.h:39
SwsComps
Definition: ops.h:109
ff_sws_op_type_name
const char * ff_sws_op_type_name(SwsOpType op)
Definition: ops.c:109
SWS_MASK_OFF
#define SWS_MASK_OFF(I)
Definition: ops.h:211
SWS_COMP_SWAPPED
@ SWS_COMP_SWAPPED
Definition: ops.h:106
SwsReadWriteOp::packed
bool packed
Definition: ops.h:128
SwsSwizzleOp::y
uint8_t y
Definition: ops.h:157
SWS_OP_SWAP_BYTES
@ SWS_OP_SWAP_BYTES
Definition: ops.h:52
SwsDitherOp::min
AVRational min
Definition: ops.h:188
SwsOp::shift
SwsShiftOp shift
Definition: ops.h:246
SwsSwizzleOp::x
uint8_t x
Definition: ops.h:157
SWS_COMP_EXACT
@ SWS_COMP_EXACT
Definition: ops.h:104
ff_sws_enum_op_lists
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 ...
Definition: ops.c:1050
SwsReadWriteOp::elems
uint8_t elems
Examples: rgba = 4x u8 packed yuv444p = 3x u8 rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack monow = ...
Definition: ops.h:126
ff_sws_pixel_type_name
const char * ff_sws_pixel_type_name(SwsPixelType type)
Definition: ops.c:62
SwsGraph
Filter graph, which represents a 'baked' pixel format conversion.
Definition: graph.h:121
SwsDitherOp::y_offset
int8_t y_offset[4]
Definition: ops.h:190
SwsSwizzleOp::in
uint8_t in[4]
Definition: ops.h:156
SWS_OP_CONVERT
@ SWS_OP_CONVERT
Definition: ops.h:63
ff_sws_op_list_remove_at
void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
Definition: ops.c:689
SWS_MASK_DIAG3
@ SWS_MASK_DIAG3
Definition: ops.h:220
SwsOp::scale
SwsScaleOp scale
Definition: ops.h:250
SwsConvertOp
Definition: ops.h:173
SwsOpList::plane_src
uint8_t plane_src[4]
Definition: ops.h:296
SwsOpList
Helper struct for representing a list of operations.
Definition: ops.h:288
SwsOp::pack
SwsPackOp pack
Definition: ops.h:244
SwsContext
Main external API structure.
Definition: swscale.h:206
ff_sws_linear_mask
uint32_t ff_sws_linear_mask(SwsLinearOp)
Definition: ops.c:759
ff_sws_compile_pass
int ff_sws_compile_pass(SwsGraph *graph, SwsOpList **ops, int flags, SwsPass *input, SwsPass **output)
Resolves an operation list to a graph pass.
Definition: ops_dispatch.c:576
ff_sws_comp_mask_needed
SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
Definition: ops.c:159