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 #include "uops.h"
33 
34 typedef enum SwsOpType {
36 
37  /* Defined for all types; but implemented for integers only */
38  SWS_OP_READ, /* gather raw pixels from planes */
39  SWS_OP_WRITE, /* write raw pixels to planes */
40  SWS_OP_SWAP_BYTES, /* swap byte order (for differing endianness) */
41  SWS_OP_SWIZZLE, /* rearrange channel order, or duplicate channels */
42 
43  /* Bit manipulation operations. Defined for integers only. */
44  SWS_OP_UNPACK, /* split tightly packed data into components */
45  SWS_OP_PACK, /* compress components into tightly packed data */
46  SWS_OP_LSHIFT, /* logical left shift of raw pixel values */
47  SWS_OP_RSHIFT, /* right shift of raw pixel values */
48 
49  /* Generic arithmetic. Defined and implemented for all types */
50  SWS_OP_CLEAR, /* clear pixel values */
51  SWS_OP_CONVERT, /* convert (cast) between formats */
52  SWS_OP_MIN, /* numeric minimum */
53  SWS_OP_MAX, /* numeric maximum */
54  SWS_OP_SCALE, /* multiplication by scalar */
55 
56  /* Floating-point only arithmetic operations. */
57  SWS_OP_LINEAR, /* generalized linear affine transform */
58  SWS_OP_DITHER, /* add dithering noise */
59 
60  /* Filtering operations. Always output floating point. */
61  SWS_OP_FILTER_H, /* horizontal filtering */
62  SWS_OP_FILTER_V, /* vertical filtering */
63 
65 } SwsOpType;
66 
67 const char *ff_sws_op_type_name(SwsOpType op);
68 
69 /* Compute SwsCompMask from values with denominator != 0 */
71 
72 typedef enum SwsCompFlags {
73  SWS_COMP_GARBAGE = 1 << 0, /* contents are undefined / garbage data */
74  SWS_COMP_EXACT = 1 << 1, /* value is an exact integer */
75  SWS_COMP_ZERO = 1 << 2, /* known to be a constant zero */
76  SWS_COMP_SWAPPED = 1 << 3, /* byte order is swapped */
77 } SwsCompFlags;
78 
79 typedef struct SwsComps {
80  SwsCompFlags flags[4]; /* knowledge about (output) component contents */
81 
82  /* Keeps track of the known possible value range, or {0, 0} for undefined
83  * or (unknown range) floating point inputs */
84  AVRational min[4], max[4];
85 } SwsComps;
86 
87 typedef enum SwsReadWriteMode {
88  /**
89  * Note: 1-component reads are either SWS_RW_PLANAR or SWS_RW_PACKED,
90  * depending on the underlying interpretation. If multiple components are
91  * packed into one element (e.g. rgb10a2 -> u16), they are marked as
92  * SWS_RW_PACKED. Otherwise (e.g. gray16le), they are SWS_RW_PLANAR.
93  *
94  * This is a purely semantic/informative difference; the underlying code
95  * treats 1-components reads/writes the same regardless of mode.
96  */
97  SWS_RW_PLANAR, /* one plane per component */
98  SWS_RW_PACKED, /* all components on a single plane */
99  SWS_RW_PALETTE, /* plane 0 is 8-bit index, plane 1 is packed palette */
101 
102 typedef struct SwsReadWriteOp {
103  /**
104  * Examples:
105  * rgba = 4x u8 packed
106  * yuv444p = 3x u8
107  * rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack
108  * monow = 1x u8 (frac 3)
109  * rgb4 = 1x u8 (frac 1)
110  * pal8 = 4x u8 (palette)
111  */
112  SwsReadWriteMode mode; /* how data is laid out in memory */
113  uint8_t elems; /* number of elements (of type `op.type`) to read/write */
114  uint8_t frac; /* fractional pixel step factor (log2) */
115 
116  /**
117  * Filter kernel to apply to each plane while sampling. Currently, only
118  * one shared filter kernel is supported for all planes. (Optional)
119  *
120  * Note: As with SWS_OP_FILTER_*, if a filter kernel is in use, the read
121  * operation will always output floating point values.
122  */
123  struct {
124  SwsOpType op; /* some value of SWS_OP_FILTER_* */
125  SwsFilterWeights *kernel; /* (refstruct) */
126  SwsPixelType type; /* pixel type to store result as */
127  } filter;
129 
130 typedef struct SwsPackOp {
131  /**
132  * Packed bits are assumed to be LSB-aligned within the underlying
133  * integer type; i.e. (msb) 0 ... X Y Z W (lsb).
134  */
135  uint8_t pattern[4]; /* bit depth pattern, from MSB to LSB */
136 } SwsPackOp;
137 
138 typedef struct SwsSwizzleOp {
139  /**
140  * Input component for each output component:
141  * Out[x] := In[swizzle.in[x]]
142  */
143  union {
144  uint32_t mask;
145  uint8_t in[4];
146  struct { uint8_t x, y, z, w; };
147  };
148 } SwsSwizzleOp;
149 
150 #define SWS_SWIZZLE(X,Y,Z,W) ((SwsSwizzleOp) { .in = {X, Y, Z, W} })
152 
153 typedef struct SwsShiftOp {
154  uint8_t amount; /* number of bits to shift */
155 } SwsShiftOp;
156 
157 typedef struct SwsClearOp {
158  SwsCompMask mask; /* mask of components to clear */
159  AVRational value[4]; /* value to set */
160 } SwsClearOp;
161 
162 typedef struct SwsConvertOp {
163  SwsPixelType to; /* type of pixel to convert to */
164  bool expand; /* if true, integers are expanded to the full range */
165 } SwsConvertOp;
166 
167 typedef struct SwsClampOp {
168  AVRational limit[4]; /* per-component min/max value */
169 } SwsClampOp;
170 
171 typedef struct SwsScaleOp {
172  AVRational factor; /* scalar multiplication factor */
173 } SwsScaleOp;
174 
175 typedef struct SwsDitherOp {
176  AVRational *matrix; /* tightly packed dither matrix (refstruct) */
177  AVRational min, max; /* minimum/maximum value in `matrix` */
178  int size_log2; /* size (in bits) of the dither matrix */
179  int8_t y_offset[4]; /* row offset for each component, or -1 for ignored */
180 } SwsDitherOp;
181 
182 typedef struct SwsLinearOp {
183  /**
184  * Generalized 5x5 affine transformation:
185  * [ Out.x ] = [ A B C D E ]
186  * [ Out.y ] = [ F G H I J ] * [ x y z w 1 ]
187  * [ Out.z ] = [ K L M N O ]
188  * [ Out.w ] = [ P Q R S T ]
189  *
190  * The mask keeps track of which components differ from an identity matrix.
191  * There may be more efficient implementations of particular subsets, for
192  * example the common subset of {A, E, G, J, M, O} can be implemented with
193  * just three fused multiply-add operations.
194  */
195  AVRational m[4][5];
196  uint32_t mask; /* m[i][j] <-> 1 << (5 * i + j) */
197 } SwsLinearOp;
198 
199 #define SWS_MASK(I, J) (1 << (5 * (I) + (J)))
200 #define SWS_MASK_OFF(I) SWS_MASK(I, 4)
201 #define SWS_MASK_ROW(I) (0x1F << (5 * (I)))
202 #define SWS_MASK_COL(J) (0x8421 << J)
203 
204 enum {
205  SWS_MASK_ALL = (1 << 20) - 1,
208 
209  SWS_MASK_DIAG3 = SWS_MASK(0, 0) | SWS_MASK(1, 1) | SWS_MASK(2, 2),
211  SWS_MASK_MAT3 = SWS_MASK(0, 0) | SWS_MASK(0, 1) | SWS_MASK(0, 2) |
212  SWS_MASK(1, 0) | SWS_MASK(1, 1) | SWS_MASK(1, 2) |
213  SWS_MASK(2, 0) | SWS_MASK(2, 1) | SWS_MASK(2, 2),
214 
218 };
219 
220 /* Helper function to compute the correct mask */
221 uint32_t ff_sws_linear_mask(const SwsLinearOp *c);
222 
223 typedef struct SwsFilterOp {
224  SwsFilterWeights *kernel; /* filter kernel (refstruct) */
225  SwsPixelType type; /* pixel type to store result as */
226 } SwsFilterOp;
227 
228 typedef struct SwsOp {
229  SwsOpType op; /* operation to perform */
230  SwsPixelType type; /* pixel type to operate on */
231  union {
243  };
244 
245  /**
246  * Metadata about the operation's input/output components. Discarded
247  * and regenerated automatically by `ff_sws_op_list_update_comps()`.
248  *
249  * Note that backends may rely on the presence and accuracy of this
250  * metadata for all operations, during ff_sws_ops_compile().
251  */
253 } SwsOp;
254 
255 #define SWS_OP_NEEDED(op, idx) (!((op)->comps.flags[idx] & SWS_COMP_GARBAGE))
256 
257 /* Compute SwsCompMask from a mask of needed components */
259 
260 /**
261  * Return the number of planes involved in a read/write operation.
262  */
263 int ff_sws_rw_op_planes(const SwsOp *op);
264 
265 /**
266  * Describe an operation in human-readable form.
267  */
268 void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op);
269 
270 /**
271  * Frees any allocations associated with an SwsOp and sets it to {0}.
272  */
273 void ff_sws_op_uninit(SwsOp *op);
274 
275 /**
276  * Apply an operation to an AVRational. No-op for read/write operations.
277  */
278 void ff_sws_apply_op_q(const SwsOp *op, AVRational x[4]);
279 
280 /**
281  * Helper struct for representing a list of operations.
282  */
283 typedef struct SwsOpList {
285  int num_ops;
286 
287  /* Metadata associated with this operation list */
289 
290  /* Input/output plane indices */
291  uint8_t plane_src[4], plane_dst[4];
292 
293  /**
294  * Source component metadata associated with pixel values from each
295  * corresponding component (in plane/memory order, i.e. not affected by
296  * `plane_src`). Lets the optimizer know additional information about
297  * the value range and/or pixel data to expect.
298  *
299  * The default value of {0} is safe to pass in the case that no additional
300  * information is known.
301  */
303 } SwsOpList;
304 
306 void ff_sws_op_list_free(SwsOpList **ops);
307 
308 /**
309  * Returns a duplicate of `ops`, or NULL on OOM.
310  */
312 
313 /**
314  * Returns the input operation for a given op list, or NULL if there is none
315  * (e.g. for a pure CLEAR-only operation list).
316  *
317  * This will always be an op of type SWS_OP_READ.
318  */
319 const SwsOp *ff_sws_op_list_input(const SwsOpList *ops);
320 
321 /**
322  * Returns the output operation for a given op list, or NULL if there is none.
323  *
324  * This will always be an op of type SWS_OP_WRITE.
325  */
326 const SwsOp *ff_sws_op_list_output(const SwsOpList *ops);
327 
328 /**
329  * Returns whether an op list represents a true no-op operation, i.e. may be
330  * eliminated entirely from an execution graph.
331  */
332 bool ff_sws_op_list_is_noop(const SwsOpList *ops);
333 
334 /**
335  * Returns the size of the largest pixel type used in `ops`.
336  */
337 int ff_sws_op_list_max_size(const SwsOpList *ops);
338 
339 /**
340  * These will take over ownership of `op` and set it to {0}, even on failure.
341  */
344 
345 void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count);
346 
347 /**
348  * Print out the contents of an operation list.
349  */
350 void ff_sws_op_list_print(void *log_ctx, int log_level, int log_level_extra,
351  const SwsOpList *ops);
352 
353 /**
354  * Infer + propagate known information about components. Called automatically
355  * when needed by the optimizer and compiler.
356  */
358 
359 /**
360  * Fuse compatible and eliminate redundant operations, as well as replacing
361  * some operations with more efficient alternatives.
362  */
364 
366  /* Automatically optimize the operations when compiling */
368 };
369 
370 /**
371  * Helper function to enumerate over all possible (optimized) operation lists,
372  * under the current set of options in `ctx`, and run the given callback on
373  * each list.
374  *
375  * @param src_fmt If set (not AV_PIX_FMT_NONE), constrain the source format
376  * @param dst_fmt If set (not AV_PIX_FMT_NONE), constrain the destination format
377  * @return 0 on success, the return value if cb() < 0, or a negative error code
378  *
379  * @note `ops` belongs to ff_sws_enum_op_lists(), but may be mutated by `cb`.
380  */
381 int ff_sws_enum_op_lists(SwsContext *ctx, void *opaque,
382  enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
383  int (*cb)(SwsContext *ctx, void *opaque, SwsOpList *ops));
384 
385 #endif
SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:38
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:685
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:41
SwsClearOp::value
AVRational value[4]
Definition: ops.h:159
SWS_OP_LSHIFT
@ SWS_OP_LSHIFT
Definition: ops.h:46
SWS_OP_UNPACK
@ SWS_OP_UNPACK
Definition: ops.h:44
SwsClearOp
Definition: ops.h:157
SWS_RW_PLANAR
@ SWS_RW_PLANAR
Note: 1-component reads are either SWS_RW_PLANAR or SWS_RW_PACKED, depending on the underlying interp...
Definition: ops.h:97
SWS_MASK_OFF4
@ SWS_MASK_OFF4
Definition: ops.h:216
SwsSwizzleOp::mask
uint32_t mask
Definition: ops.h:144
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:302
SWS_COMP_ZERO
@ SWS_COMP_ZERO
Definition: ops.h:75
SWS_OP_CLEAR
@ SWS_OP_CLEAR
Definition: ops.h:50
SwsOp::swizzle
SwsSwizzleOp swizzle
Definition: ops.h:235
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:195
SwsSwizzleOp::z
uint8_t z
Definition: ops.h:146
SwsOp::convert
SwsConvertOp convert
Definition: ops.h:238
mask
int mask
Definition: mediacodecdec_common.c:154
SwsOp::rw
SwsReadWriteOp rw
Definition: ops.h:233
SWS_OP_DITHER
@ SWS_OP_DITHER
Definition: ops.h:58
SwsFilterWeights
Represents a computed filter kernel.
Definition: filters.h:85
SwsFilterOp
Definition: ops.h:223
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:762
SwsClampOp::limit
AVRational limit[4]
Definition: ops.h:168
SWS_OP_TYPE_NB
@ SWS_OP_TYPE_NB
Definition: ops.h:64
ff_sws_linear_mask
uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
Definition: ops.c:773
SWS_MASK_ALL
@ SWS_MASK_ALL
Definition: ops.h:205
SwsComps::max
AVRational max[4]
Definition: ops.h:84
SwsOpList::plane_dst
uint8_t plane_dst[4]
Definition: ops.h:291
SwsSwizzleOp::w
uint8_t w
Definition: ops.h:146
SwsClearOp::mask
SwsCompMask mask
Definition: ops.h:158
SwsOpList::num_ops
int num_ops
Definition: ops.h:285
SwsCompFlags
SwsCompFlags
Definition: ops.h:72
SwsDitherOp
Definition: ops.h:175
ff_sws_op_uninit
void ff_sws_op_uninit(SwsOp *op)
Frees any allocations associated with an SwsOp and sets it to {0}.
ff_sws_op_list_alloc
SwsOpList * ff_sws_op_list_alloc(void)
Definition: ops.c:621
SwsReadWriteOp
Definition: ops.h:102
SwsSwizzleOp
Definition: ops.h:138
SWS_MASK_DIAG4
@ SWS_MASK_DIAG4
Definition: ops.h:215
SwsLinearOp::mask
uint32_t mask
Definition: ops.h:196
SwsOp::op
SwsOpType op
Definition: ops.h:229
SWS_RW_PACKED
@ SWS_RW_PACKED
Definition: ops.h:98
SwsOpCompileFlags
SwsOpCompileFlags
Definition: ops.h:365
SWS_OP_SCALE
@ SWS_OP_SCALE
Definition: ops.h:54
SwsOp::clear
SwsClearOp clear
Definition: ops.h:237
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:728
SwsScaleOp::factor
AVRational factor
Definition: ops.h:172
SWS_MASK_MAT3
@ SWS_MASK_MAT3
Definition: ops.h:211
SwsFilterOp::kernel
SwsFilterWeights * kernel
Definition: ops.h:224
ff_sws_op_list_insert_at
int ff_sws_op_list_insert_at(SwsOpList *ops, int index, SwsOp *op)
Definition: ops.c:714
SwsComps::min
AVRational min[4]
Definition: ops.h:84
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
SwsDitherOp::max
AVRational max
Definition: ops.h:177
SWS_OP_MIN
@ SWS_OP_MIN
Definition: ops.h:52
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
SwsCompMask
uint8_t SwsCompMask
Bit-mask of components.
Definition: uops.h:61
SWS_OP_LINEAR
@ SWS_OP_LINEAR
Definition: ops.h:57
SWS_OP_FILTER_H
@ SWS_OP_FILTER_H
Definition: ops.h:61
ff_sws_op_desc
void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
Describe an operation in human-readable form.
Definition: ops.c:874
SWS_OP_PACK
@ SWS_OP_PACK
Definition: ops.h:45
ff_sws_rw_op_planes
int ff_sws_rw_op_planes(const SwsOp *op)
Return the number of planes involved in a read/write operation.
Definition: ops.c:170
SwsOp::dither
SwsDitherOp dither
Definition: ops.h:241
SwsReadWriteOp::kernel
SwsFilterWeights * kernel
Definition: ops.h:125
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:648
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
SwsReadWriteOp::frac
uint8_t frac
Definition: ops.h:114
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:733
SWS_COMP_GARBAGE
@ SWS_COMP_GARBAGE
Definition: ops.h:73
SwsConvertOp::to
SwsPixelType to
Definition: ops.h:163
SWS_OP_FILTER_V
@ SWS_OP_FILTER_V
Definition: ops.h:62
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:981
SwsOp::clamp
SwsClampOp clamp
Definition: ops.h:239
SwsOpType
SwsOpType
Copyright (C) 2025 Niklas Haas.
Definition: ops.h:34
SWS_MASK_OFF3
@ SWS_MASK_OFF3
Definition: ops.h:210
SWS_MASK
#define SWS_MASK(I, J)
Definition: ops.h:199
SwsPixelType
SwsPixelType
Definition: uops.h:38
index
int index
Definition: gxfenc.c:90
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
SwsConvertOp::expand
bool expand
Definition: ops.h:164
SWS_MASK_LUMA
@ SWS_MASK_LUMA
Definition: ops.h:206
SwsPackOp::pattern
uint8_t pattern[4]
Packed bits are assumed to be LSB-aligned within the underlying integer type; i.e.
Definition: ops.h:135
ff_sws_op_list_free
void ff_sws_op_list_free(SwsOpList **ops)
Definition: ops.c:634
SwsDitherOp::size_log2
int size_log2
Definition: ops.h:178
SwsClampOp
Definition: ops.h:167
SwsOp::type
SwsPixelType type
Definition: ops.h:230
SwsDitherOp::matrix
AVRational * matrix
Definition: ops.h:176
SWS_MASK_ALPHA
@ SWS_MASK_ALPHA
Definition: ops.h:207
SwsShiftOp
Definition: ops.h:153
SWS_OP_RSHIFT
@ SWS_OP_RSHIFT
Definition: ops.h:47
SwsOp::lin
SwsLinearOp lin
Definition: ops.h:232
SwsOpList::src
SwsFormat src
Definition: ops.h:288
SWS_OP_INVALID
@ SWS_OP_INVALID
Definition: ops.h:35
SwsFormat
Definition: format.h:77
SwsShiftOp::amount
uint8_t amount
Definition: ops.h:154
SWS_MASK_DIAG3
@ SWS_MASK_DIAG3
Definition: ops.h:209
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:39
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:694
SwsOp::comps
SwsComps comps
Metadata about the operation's input/output components.
Definition: ops.h:252
SwsScaleOp
Definition: ops.h:171
SWS_OP_FLAG_OPTIMIZE
@ SWS_OP_FLAG_OPTIMIZE
Definition: ops.h:367
SwsLinearOp
Definition: ops.h:182
ff_sws_op_list_update_comps
void ff_sws_op_list_update_comps(SwsOpList *ops)
Infer + propagate known information about components.
Definition: ops.c:355
SwsReadWriteOp::op
SwsOpType op
Definition: ops.h:124
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:352
bprint.h
SwsOp::filter
SwsFilterOp filter
Definition: ops.h:242
SwsOpList::ops
SwsOp * ops
Definition: ops.h:284
SwsPackOp
Definition: ops.h:130
SwsFilterOp::type
SwsPixelType type
Definition: ops.h:225
SwsReadWriteOp::type
SwsPixelType type
Definition: ops.h:126
graph.h
SwsReadWriteMode
SwsReadWriteMode
Definition: ops.h:87
SwsOp
Definition: ops.h:228
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:194
SwsComps::flags
SwsCompFlags flags[4]
Definition: ops.h:80
SwsOpList::dst
SwsFormat dst
Definition: ops.h:288
SWS_OP_MAX
@ SWS_OP_MAX
Definition: ops.h:53
SwsReadWriteOp::filter
struct SwsReadWriteOp::@571 filter
Filter kernel to apply to each plane while sampling.
SWS_RW_PALETTE
@ SWS_RW_PALETTE
Definition: ops.h:99
SwsComps
Definition: ops.h:79
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:200
SWS_COMP_SWAPPED
@ SWS_COMP_SWAPPED
Definition: ops.h:76
SwsSwizzleOp::y
uint8_t y
Definition: ops.h:146
SWS_OP_SWAP_BYTES
@ SWS_OP_SWAP_BYTES
Definition: ops.h:40
SwsDitherOp::min
AVRational min
Definition: ops.h:177
SwsOp::shift
SwsShiftOp shift
Definition: ops.h:236
SwsSwizzleOp::x
uint8_t x
Definition: ops.h:146
SWS_COMP_EXACT
@ SWS_COMP_EXACT
Definition: ops.h:74
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:1079
SwsReadWriteOp::elems
uint8_t elems
Definition: ops.h:113
SWS_MASK_MAT4
@ SWS_MASK_MAT4
Definition: ops.h:217
SwsDitherOp::y_offset
int8_t y_offset[4]
Definition: ops.h:179
uops.h
SwsSwizzleOp::in
uint8_t in[4]
Definition: ops.h:145
SWS_OP_CONVERT
@ SWS_OP_CONVERT
Definition: ops.h:51
ff_sws_op_list_remove_at
void ff_sws_op_list_remove_at(SwsOpList *ops, int index, int count)
Definition: ops.c:703
SwsOp::scale
SwsScaleOp scale
Definition: ops.h:240
SwsConvertOp
Definition: ops.h:162
SwsReadWriteOp::mode
SwsReadWriteMode mode
Examples: rgba = 4x u8 packed yuv444p = 3x u8 rgb565 = 1x u16 <- use SWS_OP_UNPACK to unpack monow = ...
Definition: ops.h:112
SwsOpList::plane_src
uint8_t plane_src[4]
Definition: ops.h:291
SwsOpList
Helper struct for representing a list of operations.
Definition: ops.h:283
SwsOp::pack
SwsPackOp pack
Definition: ops.h:234
SwsContext
Main external API structure.
Definition: swscale.h:229
ff_sws_comp_mask_swizzle
void ff_sws_comp_mask_swizzle(SwsCompMask *mask, const SwsSwizzleOp *swiz)
Definition: ops.c:147
ff_sws_comp_mask_needed
SwsCompMask ff_sws_comp_mask_needed(const SwsOp *op)
Definition: ops.c:160