FFmpeg
format.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 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 #include "libavutil/attributes.h"
22 #include "libavutil/avassert.h"
25 #include "libavutil/refstruct.h"
26 
27 #include "format.h"
28 #include "csputils.h"
29 #include "ops_internal.h"
30 #include "config_components.h"
31 
32 #if CONFIG_UNSTABLE
33 #include "libavutil/hwcontext.h"
34 #endif
35 
36 #define RET(x) \
37  do { \
38  int _ret = (x); \
39  if (_ret < 0) \
40  return _ret; \
41  } while (0)
42 
43 typedef struct LegacyFormatEntry {
44  uint8_t is_supported_in :1;
45  uint8_t is_supported_out :1;
48 
49 /* Format support table for legacy swscale */
51  [AV_PIX_FMT_YUV420P] = { 1, 1 },
52  [AV_PIX_FMT_YUYV422] = { 1, 1 },
53  [AV_PIX_FMT_RGB24] = { 1, 1 },
54  [AV_PIX_FMT_BGR24] = { 1, 1 },
55  [AV_PIX_FMT_YUV422P] = { 1, 1 },
56  [AV_PIX_FMT_YUV444P] = { 1, 1 },
57  [AV_PIX_FMT_YUV410P] = { 1, 1 },
58  [AV_PIX_FMT_YUV411P] = { 1, 1 },
59  [AV_PIX_FMT_GRAY8] = { 1, 1 },
60  [AV_PIX_FMT_MONOWHITE] = { 1, 1 },
61  [AV_PIX_FMT_MONOBLACK] = { 1, 1 },
62  [AV_PIX_FMT_PAL8] = { 1, 0 },
63  [AV_PIX_FMT_YUVJ420P] = { 1, 1 },
64  [AV_PIX_FMT_YUVJ411P] = { 1, 1 },
65  [AV_PIX_FMT_YUVJ422P] = { 1, 1 },
66  [AV_PIX_FMT_YUVJ444P] = { 1, 1 },
67  [AV_PIX_FMT_YVYU422] = { 1, 1 },
68  [AV_PIX_FMT_UYVY422] = { 1, 1 },
69  [AV_PIX_FMT_UYYVYY411] = { 1, 0 },
70  [AV_PIX_FMT_BGR8] = { 1, 1 },
71  [AV_PIX_FMT_BGR4] = { 0, 1 },
72  [AV_PIX_FMT_BGR4_BYTE] = { 1, 1 },
73  [AV_PIX_FMT_RGB8] = { 1, 1 },
74  [AV_PIX_FMT_RGB4] = { 0, 1 },
75  [AV_PIX_FMT_RGB4_BYTE] = { 1, 1 },
76  [AV_PIX_FMT_NV12] = { 1, 1 },
77  [AV_PIX_FMT_NV21] = { 1, 1 },
78  [AV_PIX_FMT_ARGB] = { 1, 1 },
79  [AV_PIX_FMT_RGBA] = { 1, 1 },
80  [AV_PIX_FMT_ABGR] = { 1, 1 },
81  [AV_PIX_FMT_BGRA] = { 1, 1 },
82  [AV_PIX_FMT_0RGB] = { 1, 1 },
83  [AV_PIX_FMT_RGB0] = { 1, 1 },
84  [AV_PIX_FMT_0BGR] = { 1, 1 },
85  [AV_PIX_FMT_BGR0] = { 1, 1 },
86  [AV_PIX_FMT_GRAY9BE] = { 1, 1 },
87  [AV_PIX_FMT_GRAY9LE] = { 1, 1 },
88  [AV_PIX_FMT_GRAY10BE] = { 1, 1 },
89  [AV_PIX_FMT_GRAY10LE] = { 1, 1 },
90  [AV_PIX_FMT_GRAY12BE] = { 1, 1 },
91  [AV_PIX_FMT_GRAY12LE] = { 1, 1 },
92  [AV_PIX_FMT_GRAY14BE] = { 1, 1 },
93  [AV_PIX_FMT_GRAY14LE] = { 1, 1 },
94  [AV_PIX_FMT_GRAY16BE] = { 1, 1 },
95  [AV_PIX_FMT_GRAY16LE] = { 1, 1 },
96  [AV_PIX_FMT_YUV440P] = { 1, 1 },
97  [AV_PIX_FMT_YUVJ440P] = { 1, 1 },
98  [AV_PIX_FMT_YUV440P10LE] = { 1, 1 },
99  [AV_PIX_FMT_YUV440P10BE] = { 1, 1 },
100  [AV_PIX_FMT_YUV440P12LE] = { 1, 1 },
101  [AV_PIX_FMT_YUV440P12BE] = { 1, 1 },
102  [AV_PIX_FMT_YUVA420P] = { 1, 1 },
103  [AV_PIX_FMT_YUVA422P] = { 1, 1 },
104  [AV_PIX_FMT_YUVA444P] = { 1, 1 },
105  [AV_PIX_FMT_YUVA420P9BE] = { 1, 1 },
106  [AV_PIX_FMT_YUVA420P9LE] = { 1, 1 },
107  [AV_PIX_FMT_YUVA422P9BE] = { 1, 1 },
108  [AV_PIX_FMT_YUVA422P9LE] = { 1, 1 },
109  [AV_PIX_FMT_YUVA444P9BE] = { 1, 1 },
110  [AV_PIX_FMT_YUVA444P9LE] = { 1, 1 },
111  [AV_PIX_FMT_YUVA420P10BE] = { 1, 1 },
112  [AV_PIX_FMT_YUVA420P10LE] = { 1, 1 },
113  [AV_PIX_FMT_YUVA422P10BE] = { 1, 1 },
114  [AV_PIX_FMT_YUVA422P10LE] = { 1, 1 },
115  [AV_PIX_FMT_YUVA444P10BE] = { 1, 1 },
116  [AV_PIX_FMT_YUVA444P10LE] = { 1, 1 },
117  [AV_PIX_FMT_YUVA420P16BE] = { 1, 1 },
118  [AV_PIX_FMT_YUVA420P16LE] = { 1, 1 },
119  [AV_PIX_FMT_YUVA422P16BE] = { 1, 1 },
120  [AV_PIX_FMT_YUVA422P16LE] = { 1, 1 },
121  [AV_PIX_FMT_YUVA444P16BE] = { 1, 1 },
122  [AV_PIX_FMT_YUVA444P16LE] = { 1, 1 },
123  [AV_PIX_FMT_RGB48BE] = { 1, 1 },
124  [AV_PIX_FMT_RGB48LE] = { 1, 1 },
125  [AV_PIX_FMT_RGBA64BE] = { 1, 1, 1 },
126  [AV_PIX_FMT_RGBA64LE] = { 1, 1, 1 },
127  [AV_PIX_FMT_RGB565BE] = { 1, 1 },
128  [AV_PIX_FMT_RGB565LE] = { 1, 1 },
129  [AV_PIX_FMT_RGB555BE] = { 1, 1 },
130  [AV_PIX_FMT_RGB555LE] = { 1, 1 },
131  [AV_PIX_FMT_BGR565BE] = { 1, 1 },
132  [AV_PIX_FMT_BGR565LE] = { 1, 1 },
133  [AV_PIX_FMT_BGR555BE] = { 1, 1 },
134  [AV_PIX_FMT_BGR555LE] = { 1, 1 },
135  [AV_PIX_FMT_YUV420P16LE] = { 1, 1 },
136  [AV_PIX_FMT_YUV420P16BE] = { 1, 1 },
137  [AV_PIX_FMT_YUV422P16LE] = { 1, 1 },
138  [AV_PIX_FMT_YUV422P16BE] = { 1, 1 },
139  [AV_PIX_FMT_YUV444P16LE] = { 1, 1 },
140  [AV_PIX_FMT_YUV444P16BE] = { 1, 1 },
141  [AV_PIX_FMT_RGB444LE] = { 1, 1 },
142  [AV_PIX_FMT_RGB444BE] = { 1, 1 },
143  [AV_PIX_FMT_BGR444LE] = { 1, 1 },
144  [AV_PIX_FMT_BGR444BE] = { 1, 1 },
145  [AV_PIX_FMT_YA8] = { 1, 1 },
146  [AV_PIX_FMT_YA16BE] = { 1, 1 },
147  [AV_PIX_FMT_YA16LE] = { 1, 1 },
148  [AV_PIX_FMT_BGR48BE] = { 1, 1 },
149  [AV_PIX_FMT_BGR48LE] = { 1, 1 },
150  [AV_PIX_FMT_BGRA64BE] = { 1, 1, 1 },
151  [AV_PIX_FMT_BGRA64LE] = { 1, 1, 1 },
152  [AV_PIX_FMT_YUV420P9BE] = { 1, 1 },
153  [AV_PIX_FMT_YUV420P9LE] = { 1, 1 },
154  [AV_PIX_FMT_YUV420P10BE] = { 1, 1 },
155  [AV_PIX_FMT_YUV420P10LE] = { 1, 1 },
156  [AV_PIX_FMT_YUV420P12BE] = { 1, 1 },
157  [AV_PIX_FMT_YUV420P12LE] = { 1, 1 },
158  [AV_PIX_FMT_YUV420P14BE] = { 1, 1 },
159  [AV_PIX_FMT_YUV420P14LE] = { 1, 1 },
160  [AV_PIX_FMT_YUV422P9BE] = { 1, 1 },
161  [AV_PIX_FMT_YUV422P9LE] = { 1, 1 },
162  [AV_PIX_FMT_YUV422P10BE] = { 1, 1 },
163  [AV_PIX_FMT_YUV422P10LE] = { 1, 1 },
164  [AV_PIX_FMT_YUV422P12BE] = { 1, 1 },
165  [AV_PIX_FMT_YUV422P12LE] = { 1, 1 },
166  [AV_PIX_FMT_YUV422P14BE] = { 1, 1 },
167  [AV_PIX_FMT_YUV422P14LE] = { 1, 1 },
168  [AV_PIX_FMT_YUV444P9BE] = { 1, 1 },
169  [AV_PIX_FMT_YUV444P9LE] = { 1, 1 },
170  [AV_PIX_FMT_YUV444P10BE] = { 1, 1 },
171  [AV_PIX_FMT_YUV444P10LE] = { 1, 1 },
172  [AV_PIX_FMT_YUV444P12BE] = { 1, 1 },
173  [AV_PIX_FMT_YUV444P12LE] = { 1, 1 },
174  [AV_PIX_FMT_YUV444P14BE] = { 1, 1 },
175  [AV_PIX_FMT_YUV444P14LE] = { 1, 1 },
176  [AV_PIX_FMT_YUV444P10MSBBE] = { 1, 1 },
177  [AV_PIX_FMT_YUV444P10MSBLE] = { 1, 1 },
178  [AV_PIX_FMT_YUV444P12MSBBE] = { 1, 1 },
179  [AV_PIX_FMT_YUV444P12MSBLE] = { 1, 1 },
180  [AV_PIX_FMT_GBRP] = { 1, 1 },
181  [AV_PIX_FMT_GBRP9LE] = { 1, 1 },
182  [AV_PIX_FMT_GBRP9BE] = { 1, 1 },
183  [AV_PIX_FMT_GBRP10LE] = { 1, 1 },
184  [AV_PIX_FMT_GBRP10BE] = { 1, 1 },
185  [AV_PIX_FMT_GBRAP10LE] = { 1, 1 },
186  [AV_PIX_FMT_GBRAP10BE] = { 1, 1 },
187  [AV_PIX_FMT_GBRP10MSBLE] = { 1, 1 },
188  [AV_PIX_FMT_GBRP10MSBBE] = { 1, 1 },
189  [AV_PIX_FMT_GBRP12LE] = { 1, 1 },
190  [AV_PIX_FMT_GBRP12BE] = { 1, 1 },
191  [AV_PIX_FMT_GBRP12MSBLE] = { 1, 1 },
192  [AV_PIX_FMT_GBRP12MSBBE] = { 1, 1 },
193  [AV_PIX_FMT_GBRAP12LE] = { 1, 1 },
194  [AV_PIX_FMT_GBRAP12BE] = { 1, 1 },
195  [AV_PIX_FMT_GBRP14LE] = { 1, 1 },
196  [AV_PIX_FMT_GBRP14BE] = { 1, 1 },
197  [AV_PIX_FMT_GBRAP14LE] = { 1, 1 },
198  [AV_PIX_FMT_GBRAP14BE] = { 1, 1 },
199  [AV_PIX_FMT_GBRP16LE] = { 1, 1 },
200  [AV_PIX_FMT_GBRP16BE] = { 1, 1 },
201  [AV_PIX_FMT_GBRPF32LE] = { 1, 1 },
202  [AV_PIX_FMT_GBRPF32BE] = { 1, 1 },
203  [AV_PIX_FMT_GBRAPF32LE] = { 1, 1 },
204  [AV_PIX_FMT_GBRAPF32BE] = { 1, 1 },
205  [AV_PIX_FMT_GBRPF16LE] = { 1, 0 },
206  [AV_PIX_FMT_GBRPF16BE] = { 1, 0 },
207  [AV_PIX_FMT_GBRAPF16LE] = { 1, 0 },
208  [AV_PIX_FMT_GBRAPF16BE] = { 1, 0 },
209  [AV_PIX_FMT_GBRAP] = { 1, 1 },
210  [AV_PIX_FMT_GBRAP16LE] = { 1, 1 },
211  [AV_PIX_FMT_GBRAP16BE] = { 1, 1 },
212  [AV_PIX_FMT_BAYER_BGGR8] = { 1, 0 },
213  [AV_PIX_FMT_BAYER_RGGB8] = { 1, 0 },
214  [AV_PIX_FMT_BAYER_GBRG8] = { 1, 0 },
215  [AV_PIX_FMT_BAYER_GRBG8] = { 1, 0 },
216  [AV_PIX_FMT_BAYER_BGGR16LE] = { 1, 0 },
217  [AV_PIX_FMT_BAYER_BGGR16BE] = { 1, 0 },
218  [AV_PIX_FMT_BAYER_RGGB16LE] = { 1, 0 },
219  [AV_PIX_FMT_BAYER_RGGB16BE] = { 1, 0 },
220  [AV_PIX_FMT_BAYER_GBRG16LE] = { 1, 0 },
221  [AV_PIX_FMT_BAYER_GBRG16BE] = { 1, 0 },
222  [AV_PIX_FMT_BAYER_GRBG16LE] = { 1, 0 },
223  [AV_PIX_FMT_BAYER_GRBG16BE] = { 1, 0 },
224  [AV_PIX_FMT_XYZ12BE] = { 1, 1, 1 },
225  [AV_PIX_FMT_XYZ12LE] = { 1, 1, 1 },
226  [AV_PIX_FMT_AYUV64LE] = { 1, 1},
227  [AV_PIX_FMT_AYUV64BE] = { 1, 1 },
228  [AV_PIX_FMT_P010LE] = { 1, 1 },
229  [AV_PIX_FMT_P010BE] = { 1, 1 },
230  [AV_PIX_FMT_P012LE] = { 1, 1 },
231  [AV_PIX_FMT_P012BE] = { 1, 1 },
232  [AV_PIX_FMT_P016LE] = { 1, 1 },
233  [AV_PIX_FMT_P016BE] = { 1, 1 },
234  [AV_PIX_FMT_GRAYF32LE] = { 1, 1 },
235  [AV_PIX_FMT_GRAYF32BE] = { 1, 1 },
236  [AV_PIX_FMT_GRAYF16LE] = { 1, 0 },
237  [AV_PIX_FMT_GRAYF16BE] = { 1, 0 },
238  [AV_PIX_FMT_YAF32LE] = { 1, 0 },
239  [AV_PIX_FMT_YAF32BE] = { 1, 0 },
240  [AV_PIX_FMT_YAF16LE] = { 1, 0 },
241  [AV_PIX_FMT_YAF16BE] = { 1, 0 },
242  [AV_PIX_FMT_YUVA422P12BE] = { 1, 1 },
243  [AV_PIX_FMT_YUVA422P12LE] = { 1, 1 },
244  [AV_PIX_FMT_YUVA444P12BE] = { 1, 1 },
245  [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 },
246  [AV_PIX_FMT_NV24] = { 1, 1 },
247  [AV_PIX_FMT_NV42] = { 1, 1 },
248  [AV_PIX_FMT_Y210LE] = { 1, 1 },
249  [AV_PIX_FMT_Y212LE] = { 1, 1 },
250  [AV_PIX_FMT_Y216LE] = { 1, 1 },
251  [AV_PIX_FMT_X2RGB10LE] = { 1, 1 },
252  [AV_PIX_FMT_X2BGR10LE] = { 1, 1 },
253  [AV_PIX_FMT_NV20BE] = { 1, 1 },
254  [AV_PIX_FMT_NV20LE] = { 1, 1 },
255  [AV_PIX_FMT_P210BE] = { 1, 1 },
256  [AV_PIX_FMT_P210LE] = { 1, 1 },
257  [AV_PIX_FMT_P212BE] = { 1, 1 },
258  [AV_PIX_FMT_P212LE] = { 1, 1 },
259  [AV_PIX_FMT_P410BE] = { 1, 1 },
260  [AV_PIX_FMT_P410LE] = { 1, 1 },
261  [AV_PIX_FMT_P412BE] = { 1, 1 },
262  [AV_PIX_FMT_P412LE] = { 1, 1 },
263  [AV_PIX_FMT_P216BE] = { 1, 1 },
264  [AV_PIX_FMT_P216LE] = { 1, 1 },
265  [AV_PIX_FMT_P416BE] = { 1, 1 },
266  [AV_PIX_FMT_P416LE] = { 1, 1 },
267  [AV_PIX_FMT_NV16] = { 1, 1 },
268  [AV_PIX_FMT_VUYA] = { 1, 1 },
269  [AV_PIX_FMT_VUYX] = { 1, 1 },
270  [AV_PIX_FMT_RGBAF16BE] = { 1, 0 },
271  [AV_PIX_FMT_RGBAF16LE] = { 1, 0 },
272  [AV_PIX_FMT_RGBF16BE] = { 1, 0 },
273  [AV_PIX_FMT_RGBF16LE] = { 1, 0 },
274  [AV_PIX_FMT_RGBF32BE] = { 1, 0 },
275  [AV_PIX_FMT_RGBF32LE] = { 1, 0 },
276  [AV_PIX_FMT_XV30LE] = { 1, 1 },
277  [AV_PIX_FMT_XV36LE] = { 1, 1 },
278  [AV_PIX_FMT_XV36BE] = { 1, 1 },
279  [AV_PIX_FMT_XV48LE] = { 1, 1 },
280  [AV_PIX_FMT_XV48BE] = { 1, 1 },
281  [AV_PIX_FMT_AYUV] = { 1, 1 },
282  [AV_PIX_FMT_UYVA] = { 1, 1 },
283  [AV_PIX_FMT_VYU444] = { 1, 1 },
284  [AV_PIX_FMT_V30XLE] = { 1, 1 },
285 };
286 
288 {
289  return (unsigned)pix_fmt < FF_ARRAY_ELEMS(legacy_format_entries) ?
291 }
292 
294 {
295  return (unsigned)pix_fmt < FF_ARRAY_ELEMS(legacy_format_entries) ?
297 }
298 
300 {
301  return (unsigned)pix_fmt < FF_ARRAY_ELEMS(legacy_format_entries) ?
303 }
304 
306 {
308  /* RGB-like family */
309  fmt->csp = AVCOL_SPC_RGB;
310  fmt->range = AVCOL_RANGE_JPEG;
311  } else if (desc->flags & AV_PIX_FMT_FLAG_XYZ) {
312  fmt->csp = AVCOL_SPC_UNSPECIFIED;
313  fmt->color = (SwsColor) {
314  .prim = AVCOL_PRI_BT709, /* swscale currently hard-codes this XYZ matrix */
315  .trc = AVCOL_TRC_SMPTE428,
316  };
317  } else if (desc->nb_components < 3) {
318  /* Grayscale formats */
320  fmt->csp = AVCOL_SPC_UNSPECIFIED;
321  if (desc->flags & AV_PIX_FMT_FLAG_FLOAT)
323  else
324  fmt->range = AVCOL_RANGE_JPEG; // FIXME: this restriction should be lifted
325  }
326 
327  switch (av_pix_fmt_desc_get_id(desc)) {
328  case AV_PIX_FMT_YUVJ420P:
329  case AV_PIX_FMT_YUVJ411P:
330  case AV_PIX_FMT_YUVJ422P:
331  case AV_PIX_FMT_YUVJ444P:
332  case AV_PIX_FMT_YUVJ440P:
333  fmt->range = AVCOL_RANGE_JPEG;
334  break;
335  }
336 
337  if (!desc->log2_chroma_w && !desc->log2_chroma_h)
339 }
340 
341 /**
342  * This function also sanitizes and strips the input data, removing irrelevant
343  * fields for certain formats.
344  */
346 {
348  AVFrameSideData *sd;
349 
350  enum AVPixelFormat format = frame->format;
351  enum AVPixelFormat hw_format = AV_PIX_FMT_NONE;
352 
353 #if CONFIG_UNSTABLE
354  if (frame->hw_frames_ctx) {
355  AVHWFramesContext *hwfc = (AVHWFramesContext *)frame->hw_frames_ctx->data;
356  hw_format = frame->format;
357  format = hwfc->sw_format;
358  }
359 #endif
360 
362 
363  SwsFormat fmt = {
364  .width = frame->width,
365  .height = frame->height,
366  .format = format,
367  .hw_format = hw_format,
368  .range = frame->color_range,
369  .csp = frame->colorspace,
370  .loc = frame->chroma_location,
371  .desc = desc,
372  .color = {
373  .prim = frame->color_primaries,
374  .trc = frame->color_trc,
375  },
376  };
377 
378  av_assert1(fmt.width > 0);
379  av_assert1(fmt.height > 0);
381  av_assert0(desc);
382  sanitize_fmt(&fmt, desc);
383 
384  if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
385  fmt.height = (fmt.height + (field == FIELD_TOP)) >> 1;
386  fmt.interlaced = 1;
387  fmt.field = field;
388  }
389 
390  /* Set luminance and gamut information */
391  fmt.color.min_luma = av_make_q(0, 1);
392  switch (fmt.color.trc) {
393  case AVCOL_TRC_SMPTE2084:
394  fmt.color.max_luma = av_make_q(10000, 1); break;
396  fmt.color.max_luma = av_make_q( 1000, 1); break; /* HLG reference display */
397  default:
398  fmt.color.max_luma = av_make_q( 203, 1); break; /* SDR reference brightness */
399  }
400 
402  if (primaries)
403  fmt.color.gamut = primaries->prim;
404 
407  if (mdm->has_luminance) {
408  fmt.color.min_luma = mdm->min_luminance;
409  fmt.color.max_luma = mdm->max_luminance;
410  }
411 
412  if (mdm->has_primaries) {
413  /* Ignore mastering display white point as it has no bearance on
414  * the underlying content */
415  fmt.color.gamut.r.x = mdm->display_primaries[0][0];
416  fmt.color.gamut.r.y = mdm->display_primaries[0][1];
417  fmt.color.gamut.g.x = mdm->display_primaries[1][0];
418  fmt.color.gamut.g.y = mdm->display_primaries[1][1];
419  fmt.color.gamut.b.x = mdm->display_primaries[2][0];
420  fmt.color.gamut.b.y = mdm->display_primaries[2][1];
421  }
422  }
423 
425  const AVDynamicHDRPlus *dhp = (const AVDynamicHDRPlus *) sd->data;
426  const AVHDRPlusColorTransformParams *pars = &dhp->params[0];
427  const AVRational nits = av_make_q(10000, 1);
428  AVRational maxrgb = pars->maxscl[0];
429 
430  if (!dhp->num_windows || dhp->application_version > 1)
431  goto skip_hdr10;
432 
433  /* Maximum of MaxSCL components */
434  if (av_cmp_q(pars->maxscl[1], maxrgb) > 0)
435  maxrgb = pars->maxscl[1];
436  if (av_cmp_q(pars->maxscl[2], maxrgb) > 0)
437  maxrgb = pars->maxscl[2];
438 
439  if (maxrgb.num > 0) {
440  /* Estimate true luminance from MaxSCL */
442  if (!luma)
443  goto skip_hdr10;
444  fmt.color.frame_peak = av_add_q(av_mul_q(luma->cr, pars->maxscl[0]),
445  av_add_q(av_mul_q(luma->cg, pars->maxscl[1]),
446  av_mul_q(luma->cb, pars->maxscl[2])));
447  /* Scale the scene average brightness by the ratio between the
448  * maximum luminance and the MaxRGB values */
449  fmt.color.frame_avg = av_mul_q(pars->average_maxrgb,
450  av_div_q(fmt.color.frame_peak, maxrgb));
451  } else {
452  /**
453  * Calculate largest value from histogram to use as fallback for
454  * clips with missing MaxSCL information. Note that this may end
455  * up picking the "reserved" value at the 5% percentile, which in
456  * practice appears to track the brightest pixel in the scene.
457  */
458  for (int i = 0; i < pars->num_distribution_maxrgb_percentiles; i++) {
459  const AVRational pct = pars->distribution_maxrgb[i].percentile;
460  if (av_cmp_q(pct, maxrgb) > 0)
461  maxrgb = pct;
462  fmt.color.frame_peak = maxrgb;
463  fmt.color.frame_avg = pars->average_maxrgb;
464  }
465  }
466 
467  /* Rescale to nits */
468  fmt.color.frame_peak = av_mul_q(nits, fmt.color.frame_peak);
469  fmt.color.frame_avg = av_mul_q(nits, fmt.color.frame_avg);
470  }
471 skip_hdr10:
472 
473  /* PQ is always scaled down to absolute zero, so ignore mastering metadata */
474  if (fmt.color.trc == AVCOL_TRC_SMPTE2084)
475  fmt.color.min_luma = av_make_q(0, 1);
476 
477  return fmt;
478 }
479 
481 {
482  ff_fmt_clear(fmt);
483  fmt->format = pixfmt;
485  sanitize_fmt(fmt, fmt->desc);
486 }
487 
488 static int infer_prim_ref(SwsColor *csp, const SwsColor *ref)
489 {
490  if (csp->prim != AVCOL_PRI_UNSPECIFIED)
491  return 0;
492 
493  /* Reuse the reference gamut only for "safe", similar primaries */
494  switch (ref->prim) {
495  case AVCOL_PRI_BT709:
496  case AVCOL_PRI_BT470M:
497  case AVCOL_PRI_BT470BG:
498  case AVCOL_PRI_SMPTE170M:
499  case AVCOL_PRI_SMPTE240M:
500  csp->prim = ref->prim;
501  csp->gamut = ref->gamut;
502  break;
503  default:
504  csp->prim = AVCOL_PRI_BT709;
506  break;
507  }
508 
509  return 1;
510 }
511 
512 static int infer_trc_ref(SwsColor *csp, const SwsColor *ref)
513 {
514  if (csp->trc != AVCOL_TRC_UNSPECIFIED)
515  return 0;
516 
517  /* Pick a suitable SDR transfer function, to try and minimize conversions */
518  switch (ref->trc) {
520  /* HDR curves, never default to these */
521  case AVCOL_TRC_SMPTE2084:
523  csp->trc = AVCOL_TRC_BT709;
524  csp->min_luma = av_make_q(0, 1);
525  csp->max_luma = av_make_q(203, 1);
526  break;
527  default:
528  csp->trc = ref->trc;
529  csp->min_luma = ref->min_luma;
530  csp->max_luma = ref->max_luma;
531  break;
532  }
533 
534  return 1;
535 }
536 
538 {
539  int incomplete = 0;
540 
541  incomplete |= infer_prim_ref(dst, src);
542  incomplete |= infer_prim_ref(src, dst);
545 
546  incomplete |= infer_trc_ref(dst, src);
547  incomplete |= infer_trc_ref(src, dst);
550 
551  return incomplete;
552 }
553 
554 /* Variant of sws_test_format() for the ops-based code */
555 static int test_format_ops(enum AVPixelFormat format, int output);
557 {
559 }
560 
562  enum AVPixelFormat format, int output)
563 {
564  /* The only non-ops backend is the legacy backend */
565  const SwsBackend backends_ops = SWS_BACKEND_ALL ^ SWS_BACKEND_LEGACY;
566  return ((backends & SWS_BACKEND_LEGACY) && test_format_legacy(format, output)) ||
567  ((backends & backends_ops) && test_format_ops(format, output));
568 }
569 
571 {
573 }
574 
576 {
577  switch (format) {
578  case AV_PIX_FMT_NONE: return 1;
579 #if CONFIG_VULKAN
580  case AV_PIX_FMT_VULKAN: return 1;
581 #endif
582  default: return 0;
583  }
584 }
585 
587 {
588  switch (csp) {
590  case AVCOL_SPC_RGB:
591  case AVCOL_SPC_BT709:
592  case AVCOL_SPC_BT470BG:
593  case AVCOL_SPC_SMPTE170M:
594  case AVCOL_SPC_FCC:
595  case AVCOL_SPC_SMPTE240M:
597  return 1;
598  default:
599  return 0;
600  }
601 }
602 
604 {
605  return ((prim > AVCOL_PRI_RESERVED0 && prim < AVCOL_PRI_NB) ||
606  (prim >= AVCOL_PRI_EXT_BASE && prim < AVCOL_PRI_EXT_NB)) &&
607  prim != AVCOL_PRI_RESERVED;
608 }
609 
611 {
613  : av_csp_itu_eotf(trc);
614  return trc == AVCOL_TRC_UNSPECIFIED || eotf != NULL;
615 }
616 
617 static int test_range(enum AVColorRange range)
618 {
619  return (unsigned)range < AVCOL_RANGE_NB;
620 }
621 
622 static int test_loc(enum AVChromaLocation loc)
623 {
624  return (unsigned)loc < AVCHROMA_LOC_NB;
625 }
626 
627 int ff_test_fmt(const SwsBackend backends, const SwsFormat *fmt, int output)
628 {
629  return fmt->width > 0 && fmt->height > 0 &&
630  ff_sws_test_pixfmt_backend(backends, fmt->format, output) &&
631  sws_test_colorspace(fmt->csp, output) &&
633  sws_test_transfer (fmt->color.trc, output) &&
634  sws_test_hw_format (fmt->hw_format) &&
635  test_range (fmt->range) &&
636  test_loc (fmt->loc);
637 }
638 
640 {
641  for (int field = 0; field < 2; field++) {
642  const SwsFormat fmt = ff_fmt_from_frame(frame, field);
644  return 0;
645  if (!fmt.interlaced)
646  break;
647  }
648 
649  return 1;
650 }
651 
652 int sws_is_noop(const AVFrame *dst, const AVFrame *src)
653 {
654  for (int field = 0; field < 2; field++) {
655  SwsFormat dst_fmt = ff_fmt_from_frame(dst, field);
656  SwsFormat src_fmt = ff_fmt_from_frame(src, field);
657  if (!ff_fmt_equal(&dst_fmt, &src_fmt))
658  return 0;
659  if (!dst_fmt.interlaced)
660  break;
661  }
662 
663  return 1;
664 }
665 
667 {
668  dst->format = src->format;
669  dst->width = src->width;
670  dst->height = src->height;
671  dst->avframe = src;
672  for (int i = 0; i < FF_ARRAY_ELEMS(dst->data); i++) {
673  dst->data[i] = src->data[i];
674  dst->linesize[i] = src->linesize[i];
675  }
676 }
677 
678 #if CONFIG_UNSTABLE
679 
680 /**
681  * Returns the underlying descriptor for fake formats like PAL8 whose
682  * descriptors alone do not fully describe the pixel data.
683  */
684 static inline const AVPixFmtDescriptor *fmt_desc_decoded(enum AVPixelFormat fmt)
685 {
686  if (fmt == AV_PIX_FMT_PAL8)
688 
690  av_assert0(!(desc->flags & AV_PIX_FMT_FLAG_PAL));
691  return desc;
692 }
693 
694 /* Returns the type suitable for a pixel after fully decoding/unpacking it */
695 static SwsPixelType fmt_pixel_type(enum AVPixelFormat fmt)
696 {
697  const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt);
698  const int bits = FFALIGN(desc->comp[0].depth, 8);
699  if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) {
700  switch (bits) {
701  case 32: return SWS_PIXEL_F32;
702  /* TODO: no support for 16-bit float yet */
703  }
704  } else {
705  switch (bits) {
706  case 8: return SWS_PIXEL_U8;
707  case 16: return SWS_PIXEL_U16;
708  /* TODO: AVRational cannot represent UINT32_MAX */
709  }
710  }
711 
712  return SWS_PIXEL_NONE;
713 }
714 
715 /* A regular format is defined as any format that contains only a single
716  * component per elementary data type (i.e. no sub-byte pack/unpack needed),
717  * and whose components map 1:1 onto elementary data units */
718 static int is_regular_fmt(enum AVPixelFormat fmt)
719 {
722  return 0; /* no 1:1 correspondence between components and data units */
723  if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM))
724  return 0; /* bitstream formats are packed by definition */
725  if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) || desc->nb_components == 1)
726  return 1; /* planar formats are regular by definition */
727 
728  const int step = desc->comp[0].step;
729  int total_bits = 0;
730 
731  for (int i = 0; i < desc->nb_components; i++) {
732  if (desc->comp[i].shift || desc->comp[i].step != step)
733  return 0; /* irregular/packed format */
734  total_bits += desc->comp[i].depth;
735  }
736 
737  /* Exclude formats with missing components like RGB0, 0RGB, etc. */
738  return total_bits == step * 8;
739 }
740 
741 typedef struct FmtInfo {
742  SwsReadWriteOp rw;
743  SwsSwizzleOp swizzle;
744  SwsPackOp pack;
745  int shift;
746 } FmtInfo;
747 
748 #define BITSTREAM_FMT(SWIZ, FRAC, MODE, ...) (FmtInfo) { \
749  .rw = { .elems = 1, .frac = FRAC, .mode = MODE }, \
750  .swizzle = SWIZ, \
751  __VA_ARGS__ \
752 }
753 
754 #define SUBPACKED_FMT(SWIZ, ...) (FmtInfo) { \
755  .rw = { .elems = 1, .mode = SWS_RW_PACKED }, \
756  .swizzle = SWIZ, \
757  .pack.pattern = {__VA_ARGS__}, \
758 }
759 
760 #define PACKED_FMT(SWIZ, N, ...) (FmtInfo) { \
761  .rw = { .elems = N, .mode = SWS_RW_PACKED }, \
762  .swizzle = SWIZ, \
763  __VA_ARGS__ \
764 }
765 
766 #define RGBA SWS_SWIZZLE(0, 1, 2, 3)
767 #define BGRA SWS_SWIZZLE(2, 1, 0, 3)
768 #define ARGB SWS_SWIZZLE(3, 0, 1, 2)
769 #define ABGR SWS_SWIZZLE(3, 2, 1, 0)
770 #define AVYU SWS_SWIZZLE(3, 2, 0, 1)
771 #define VYUA SWS_SWIZZLE(2, 0, 1, 3)
772 #define UYVA SWS_SWIZZLE(1, 0, 2, 3)
773 #define VUYA BGRA
774 
775 static FmtInfo fmt_info_irregular(enum AVPixelFormat fmt)
776 {
777  switch (fmt) {
778  /* Bitstream formats */
781  return BITSTREAM_FMT(RGBA, 3, SWS_RW_PLANAR);
782  case AV_PIX_FMT_RGB4: return BITSTREAM_FMT(RGBA, 1, SWS_RW_PACKED, .pack = {{ 1, 2, 1 }});
783  case AV_PIX_FMT_BGR4: return BITSTREAM_FMT(BGRA, 1, SWS_RW_PACKED, .pack = {{ 1, 2, 1 }});
784 
785  /* Sub-packed 8-bit aligned formats */
786  case AV_PIX_FMT_RGB4_BYTE: return SUBPACKED_FMT(RGBA, 1, 2, 1);
787  case AV_PIX_FMT_BGR4_BYTE: return SUBPACKED_FMT(BGRA, 1, 2, 1);
788  case AV_PIX_FMT_RGB8: return SUBPACKED_FMT(RGBA, 3, 3, 2);
789  case AV_PIX_FMT_BGR8: return SUBPACKED_FMT(BGRA, 2, 3, 3);
790 
791  /* Sub-packed 16-bit aligned formats */
792  case AV_PIX_FMT_RGB565LE:
793  case AV_PIX_FMT_RGB565BE:
794  return SUBPACKED_FMT(RGBA, 5, 6, 5);
795  case AV_PIX_FMT_BGR565LE:
796  case AV_PIX_FMT_BGR565BE:
797  return SUBPACKED_FMT(BGRA, 5, 6, 5);
798  case AV_PIX_FMT_RGB555LE:
799  case AV_PIX_FMT_RGB555BE:
800  return SUBPACKED_FMT(RGBA, 5, 5, 5);
801  case AV_PIX_FMT_BGR555LE:
802  case AV_PIX_FMT_BGR555BE:
803  return SUBPACKED_FMT(BGRA, 5, 5, 5);
804  case AV_PIX_FMT_RGB444LE:
805  case AV_PIX_FMT_RGB444BE:
806  return SUBPACKED_FMT(RGBA, 4, 4, 4);
807  case AV_PIX_FMT_BGR444LE:
808  case AV_PIX_FMT_BGR444BE:
809  return SUBPACKED_FMT(BGRA, 4, 4, 4);
810 
811  /* Sub-packed 32-bit aligned formats */
814  return SUBPACKED_FMT(ARGB, 2, 10, 10, 10);
817  return SUBPACKED_FMT(ABGR, 2, 10, 10, 10);
818  case AV_PIX_FMT_XV30LE:
819  case AV_PIX_FMT_XV30BE:
820  return SUBPACKED_FMT(AVYU, 2, 10, 10, 10);
821  case AV_PIX_FMT_V30XLE:
822  case AV_PIX_FMT_V30XBE:
823  return SUBPACKED_FMT(VYUA, 10, 10, 10, 2);
824 
825  /* 3-component formats with extra padding */
826  case AV_PIX_FMT_RGB0: return PACKED_FMT(RGBA, 4);
827  case AV_PIX_FMT_BGR0: return PACKED_FMT(BGRA, 4);
828  case AV_PIX_FMT_0RGB: return PACKED_FMT(ARGB, 4);
829  case AV_PIX_FMT_0BGR: return PACKED_FMT(ABGR, 4);
830  case AV_PIX_FMT_VUYX: return PACKED_FMT(VUYA, 4);
831  case AV_PIX_FMT_XV36LE:
832  case AV_PIX_FMT_XV36BE:
833  return PACKED_FMT(UYVA, 4, .shift = 4);
834  case AV_PIX_FMT_XV48LE:
835  case AV_PIX_FMT_XV48BE:
836  return PACKED_FMT(UYVA, 4);
837 
838  /* Miscellaneous irregular formats */
839  case AV_PIX_FMT_PAL8:
840  return (FmtInfo) {
841  .rw = { .elems = 4, .mode = SWS_RW_PALETTE },
842  /* PAL8 is explicitly defined as endian-dependent */
843  #if AV_HAVE_BIGENDIAN
844  .swizzle = ARGB,
845  #else
846  .swizzle = BGRA,
847  #endif
848  };
849  }
850 
851  return (FmtInfo) {0};
852 }
853 
854 struct comp {
855  int index;
856  int plane;
857  int offset;
858 };
859 
860 /* Compare by (plane, offset) */
861 static int cmp_comp(const void *a, const void *b) {
862  const struct comp *ca = a;
863  const struct comp *cb = b;
864  if (ca->plane != cb->plane)
865  return ca->plane - cb->plane;
866  return ca->offset - cb->offset;
867 }
868 
869 static int fmt_analyze_regular(const AVPixFmtDescriptor *desc, SwsReadWriteOp *rw_op,
870  SwsSwizzleOp *swizzle, SwsShiftOp *shift)
871 {
872  if (desc->nb_components == 2) {
873  /* YA formats */
874  *swizzle = SWS_SWIZZLE(0, 3, 1, 2);
875  } else {
876  /* Sort by increasing component order */
877  struct comp sorted[4] = { {0}, {1}, {2}, {3} };
878  for (int i = 0; i < desc->nb_components; i++) {
879  sorted[i].plane = desc->comp[i].plane;
880  sorted[i].offset = desc->comp[i].offset;
881  }
882 
883  qsort(sorted, desc->nb_components, sizeof(struct comp), cmp_comp);
884 
885  SwsSwizzleOp swiz = SWS_SWIZZLE(0, 1, 2, 3);
886  for (int i = 0; i < desc->nb_components; i++)
887  swiz.in[i] = sorted[i].index;
888  *swizzle = swiz;
889  }
890 
892  if (desc->nb_components > 1 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR))
894 
895  *shift = (SwsShiftOp) { desc->comp[0].shift };
896  *rw_op = (SwsReadWriteOp) {
897  .elems = desc->nb_components,
898  .mode = mode,
899  };
900  return 0;
901 }
902 
903 static int fmt_analyze(enum AVPixelFormat fmt, SwsReadWriteOp *rw_op,
904  SwsPackOp *pack_op, SwsSwizzleOp *swizzle,
905  SwsShiftOp *shift, SwsPixelType *pixel_type,
906  SwsPixelType *raw_type)
907 {
909  if (!desc)
910  return AVERROR(EINVAL);
911 
912  /* No support for subsampled formats at the moment */
913  if (desc->log2_chroma_w || desc->log2_chroma_h)
914  return AVERROR(ENOTSUP);
915 
916  /* No support for semi-planar formats at the moment */
917  if (desc->flags & AV_PIX_FMT_FLAG_PLANAR &&
918  av_pix_fmt_count_planes(fmt) < desc->nb_components)
919  return AVERROR(ENOTSUP);
920 
921  *pixel_type = *raw_type = fmt_pixel_type(fmt);
922  if (!*pixel_type)
923  return AVERROR(ENOTSUP);
924 
925  if (is_regular_fmt(fmt)) {
926  *pack_op = (SwsPackOp) {0};
927  return fmt_analyze_regular(desc, rw_op, swizzle, shift);
928  }
929 
930  FmtInfo info = fmt_info_irregular(fmt);
931  if (!info.rw.elems)
932  return AVERROR(ENOTSUP);
933 
934  *rw_op = info.rw;
935  *pack_op = info.pack;
936  *swizzle = info.swizzle;
937  *shift = (SwsShiftOp) { info.shift };
938 
939  if (info.pack.pattern[0]) {
940  const int sum = info.pack.pattern[0] + info.pack.pattern[1] +
941  info.pack.pattern[2] + info.pack.pattern[3];
942  if (sum > 16)
943  *raw_type = SWS_PIXEL_U32;
944  else if (sum > 8)
945  *raw_type = SWS_PIXEL_U16;
946  else
947  *raw_type = SWS_PIXEL_U8;
948  }
949 
950  return 0;
951 }
952 
953 static int test_format_ops(enum AVPixelFormat format, int output)
954 {
955  SwsReadWriteOp rw;
956  SwsSwizzleOp swizzle;
957  SwsPackOp pack;
959  SwsPixelType pixel_type, raw_type;
960  int ret = fmt_analyze(format, &rw, &pack, &swizzle, &shift,
961  &pixel_type, &raw_type);
962  if (ret < 0)
963  return 0;
964  if (rw.mode == SWS_RW_PALETTE && output)
965  return 0; /* palettes are currently only supported as input */
966  return 1;
967 }
968 
969 static void swizzle_inv(SwsSwizzleOp *swiz)
970 {
971  /* Input[x] =: Output[swizzle.x] */
972  unsigned tmp[4];
973  tmp[swiz->x] = 0;
974  tmp[swiz->y] = 1;
975  tmp[swiz->z] = 2;
976  tmp[swiz->w] = 3;
977  *swiz = (SwsSwizzleOp) {{ .x = tmp[0], tmp[1], tmp[2], tmp[3] }};
978 }
979 
980 /**
981  * This initializes all absent components explicitly to zero. There is no
982  * need to worry about the correct neutral value as fmt_decode() will
983  * implicitly ignore and overwrite absent components in any case. This function
984  * is just to ensure that we don't operate on undefined memory. In most cases,
985  * it will end up getting pushed towards the output or optimized away entirely
986  * by the optimization pass.
987  */
988 static SwsClearOp fmt_clear(const SwsFormat *fmt)
989 {
990  const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
991  const bool has_chroma = desc->nb_components >= 3;
992  const bool has_alpha = desc->flags & AV_PIX_FMT_FLAG_ALPHA;
993 
994  SwsClearOp c = {0};
995  if (!has_chroma) {
996  c.mask |= SWS_COMP(1) | SWS_COMP(2);
997  c.value[1] = c.value[2] = Q(0);
998  }
999 
1000  if (!has_alpha) {
1001  c.mask |= SWS_COMP(3);
1002  c.value[3] = Q(0);
1003  }
1004 
1005  return c;
1006 }
1007 
1008 #if HAVE_BIGENDIAN
1009 # define NATIVE_ENDIAN_FLAG AV_PIX_FMT_FLAG_BE
1010 #else
1011 # define NATIVE_ENDIAN_FLAG 0
1012 #endif
1013 
1014 static inline AVRational64 intmax_q64(int bits)
1015 {
1016  av_assert1(bits >= 0 && bits < 64);
1017  return Q(UINT64_MAX >> (64 - bits));
1018 }
1019 
1020 int ff_sws_decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
1021 {
1022  const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
1023  SwsPixelType pixel_type, raw_type;
1024  SwsReadWriteOp rw_op;
1025  SwsSwizzleOp swizzle;
1026  SwsPackOp unpack;
1027  SwsComps *comps = &ops->comps_src;
1028  SwsShiftOp shift;
1029 
1030  RET(fmt_analyze(fmt->format, &rw_op, &unpack, &swizzle, &shift,
1031  &pixel_type, &raw_type));
1032 
1033  swizzle_inv(&swizzle);
1034 
1035  /* Set baseline pixel content flags */
1036  const int integer = ff_sws_pixel_type_is_int(raw_type);
1037  const int swapped = ff_sws_pixel_type_size(raw_type) > 1 &&
1038  (desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG;
1039  for (int i = 0; i < rw_op.elems; i++) {
1040  comps->flags[i] = (integer ? SWS_COMP_EXACT : 0) |
1041  (swapped ? SWS_COMP_SWAPPED : 0);
1042  }
1043 
1044  /* Generate value range information for simple unpacked formats */
1045  if (integer && !unpack.pattern[0]) {
1046  /* YA formats have desc->comp[] in the order {Y, A} instead of the
1047  * canonical order {Y, U, V, A} */
1048  const int is_ya = desc->nb_components == 2;
1049  for (int c = 0; c < desc->nb_components; c++) {
1050  const int bits = desc->comp[c].depth + shift.amount;
1051  const int idx = swizzle.in[is_ya ? 3 * c : c];
1052  comps->min[idx] = Q(0);
1053  comps->max[idx] = intmax_q64(bits);
1054  }
1055  }
1056 
1057  /* TODO: handle subsampled or semipacked input formats */
1058  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1059  .op = SWS_OP_READ,
1060  .type = raw_type,
1061  .rw = rw_op,
1062  }));
1063 
1064  if (swapped) {
1065  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1066  .op = SWS_OP_SWAP_BYTES,
1067  .type = raw_type,
1068  }));
1069  }
1070 
1071  if (unpack.pattern[0]) {
1072  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1073  .op = SWS_OP_UNPACK,
1074  .type = raw_type,
1075  .pack = unpack,
1076  }));
1077 
1078  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1079  .op = SWS_OP_CONVERT,
1080  .type = raw_type,
1081  .convert.to = pixel_type,
1082  }));
1083  }
1084 
1085  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1086  .op = SWS_OP_SWIZZLE,
1087  .type = pixel_type,
1088  .swizzle = swizzle,
1089  }));
1090 
1091  if (shift.amount) {
1092  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1093  .op = SWS_OP_RSHIFT,
1094  .type = pixel_type,
1095  .shift = shift,
1096  }));
1097  }
1098 
1099  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1100  .op = SWS_OP_CLEAR,
1101  .type = pixel_type,
1102  .clear = fmt_clear(fmt),
1103  }));
1104 
1105  return 0;
1106 }
1107 
1108 int ff_sws_encode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
1109 {
1110  const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
1111  SwsPixelType pixel_type, raw_type;
1112  SwsReadWriteOp rw_op;
1113  SwsSwizzleOp swizzle;
1114  SwsPackOp pack;
1115  SwsShiftOp shift;
1116 
1117  RET(fmt_analyze(fmt->format, &rw_op, &pack, &swizzle, &shift,
1118  &pixel_type, &raw_type));
1119 
1120  if (rw_op.mode == SWS_RW_PALETTE)
1121  return AVERROR(ENOTSUP);
1122 
1123  if (shift.amount) {
1124  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1125  .op = SWS_OP_LSHIFT,
1126  .type = pixel_type,
1127  .shift = shift,
1128  }));
1129  }
1130 
1131  if (rw_op.elems > desc->nb_components) {
1132  /* Format writes unused alpha channel, clear it explicitly for sanity */
1133  av_assert1(!(desc->flags & AV_PIX_FMT_FLAG_ALPHA));
1134  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1135  .op = SWS_OP_CLEAR,
1136  .type = pixel_type,
1137  .clear.mask = SWS_COMP(3),
1138  .clear.value[3] = Q(0),
1139  }));
1140  }
1141 
1142  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1143  .op = SWS_OP_SWIZZLE,
1144  .type = pixel_type,
1145  .swizzle = swizzle,
1146  }));
1147 
1148  if (pack.pattern[0]) {
1149  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1150  .op = SWS_OP_CONVERT,
1151  .type = pixel_type,
1152  .convert.to = raw_type,
1153  }));
1154 
1155  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1156  .op = SWS_OP_PACK,
1157  .type = raw_type,
1158  .pack = pack,
1159  }));
1160  }
1161 
1162  if (ff_sws_pixel_type_size(raw_type) > 1 &&
1163  (desc->flags & AV_PIX_FMT_FLAG_BE) != NATIVE_ENDIAN_FLAG) {
1164  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1165  .op = SWS_OP_SWAP_BYTES,
1166  .type = raw_type,
1167  }));
1168  }
1169 
1170  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1171  .op = SWS_OP_WRITE,
1172  .type = raw_type,
1173  .rw = rw_op,
1174  }));
1175 
1176  return 0;
1177 }
1178 
1179 static inline AVRational64 av_neg_q64(AVRational64 x)
1180 {
1181  return (AVRational64) { -x.num, x.den };
1182 }
1183 
1184 static SwsLinearOp fmt_encode_range(const SwsFormat *fmt, bool *incomplete)
1185 {
1186  const AVRational64 q0 = Q(0);
1187  const AVRational64 q1 = Q(1);
1188 
1189  SwsLinearOp c = { .m = {
1190  { q1, q0, q0, q0, q0 },
1191  { q0, q1, q0, q0, q0 },
1192  { q0, q0, q1, q0, q0 },
1193  { q0, q0, q0, q1, q0 },
1194  }};
1195 
1196  const AVPixFmtDescriptor *desc = fmt_desc_decoded(fmt->format);
1197  const int depth0 = desc->comp[0].depth;
1198  const int depth1 = desc->comp[1].depth;
1199  const int depth2 = desc->comp[2].depth;
1200  const int depth3 = desc->comp[3].depth;
1201 
1202  if (desc->flags & AV_PIX_FMT_FLAG_FLOAT)
1203  return c; /* floats are directly output as-is */
1204 
1205  if (fmt->csp == AVCOL_SPC_RGB || (desc->flags & AV_PIX_FMT_FLAG_XYZ)) {
1206  c.m[0][0] = intmax_q64(depth0);
1207  c.m[1][1] = intmax_q64(depth1);
1208  c.m[2][2] = intmax_q64(depth2);
1209  } else if (fmt->range == AVCOL_RANGE_JPEG) {
1210  /* Full range YUV */
1211  c.m[0][0] = intmax_q64(depth0);
1212  if (desc->nb_components >= 3) {
1213  /* This follows the ITU-R convention, which is slightly different
1214  * from the JFIF convention. */
1215  c.m[1][1] = intmax_q64(depth1);
1216  c.m[2][2] = intmax_q64(depth2);
1217  c.m[1][4] = Q(1 << (depth1 - 1));
1218  c.m[2][4] = Q(1 << (depth2 - 1));
1219  }
1220  } else {
1221  /* Limited range YUV */
1222  if (fmt->range == AVCOL_RANGE_UNSPECIFIED)
1223  *incomplete = true;
1224  c.m[0][0] = Q(219 << (depth0 - 8));
1225  c.m[0][4] = Q( 16 << (depth0 - 8));
1226  if (desc->nb_components >= 3) {
1227  c.m[1][1] = Q(224 << (depth1 - 8));
1228  c.m[2][2] = Q(224 << (depth2 - 8));
1229  c.m[1][4] = Q(128 << (depth1 - 8));
1230  c.m[2][4] = Q(128 << (depth2 - 8));
1231  }
1232  }
1233 
1234  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA) {
1235  const bool is_ya = desc->nb_components == 2;
1236  c.m[3][3] = intmax_q64(is_ya ? depth1 : depth3);
1237  }
1238 
1239  if (fmt->format == AV_PIX_FMT_MONOWHITE) {
1240  /* This format is inverted, 0 = white, 1 = black */
1241  c.m[0][4] = av_add_q64(c.m[0][4], c.m[0][0]);
1242  c.m[0][0] = av_neg_q64(c.m[0][0]);
1243  }
1244 
1245  c.mask = ff_sws_linear_mask(&c);
1246  return c;
1247 }
1248 
1249 static SwsLinearOp fmt_decode_range(const SwsFormat *fmt, bool *incomplete)
1250 {
1251  SwsLinearOp c = fmt_encode_range(fmt, incomplete);
1252 
1253  /* Invert main diagonal + offset: x = s * y + k ==> y = (x - k) / s */
1254  for (int i = 0; i < 4; i++) {
1255  av_assert1(c.m[i][i].num);
1256  c.m[i][i] = av_inv_q64(c.m[i][i]);
1257  c.m[i][4] = av_mul_q64(c.m[i][4], av_neg_q64(c.m[i][i]));
1258  }
1259 
1260  /* Explicitly initialize alpha for sanity */
1261  if (!(fmt->desc->flags & AV_PIX_FMT_FLAG_ALPHA))
1262  c.m[3][4] = Q(1);
1263 
1264  c.mask = ff_sws_linear_mask(&c);
1265  return c;
1266 }
1267 
1268 static AVRational64 *generate_bayer_matrix(const int size_log2)
1269 {
1270  const int size = 1 << size_log2;
1271  const int num_entries = size * size;
1272  AVRational64 *m = av_refstruct_allocz(sizeof(*m) * num_entries);
1273  av_assert1(size_log2 < 16);
1274  if (!m)
1275  return NULL;
1276 
1277  /* Start with a 1x1 matrix */
1278  m[0] = Q(0);
1279 
1280  /* Generate three copies of the current, appropriately scaled and offset */
1281  for (int sz = 1; sz < size; sz <<= 1) {
1282  const int den = 4 * sz * sz;
1283  for (int y = 0; y < sz; y++) {
1284  for (int x = 0; x < sz; x++) {
1285  const AVRational64 cur = m[y * size + x];
1286  m[(y + sz) * size + x + sz] = av_add_q64(cur, av_make_q64(1, den));
1287  m[(y ) * size + x + sz] = av_add_q64(cur, av_make_q64(2, den));
1288  m[(y + sz) * size + x ] = av_add_q64(cur, av_make_q64(3, den));
1289  }
1290  }
1291  }
1292 
1293  /**
1294  * To correctly round, we need to evenly distribute the result on [0, 1),
1295  * giving an average value of 1/2.
1296  *
1297  * After the above construction, we have a matrix with average value:
1298  * [ 0/N + 1/N + 2/N + ... (N-1)/N ] / N = (N-1)/(2N)
1299  * where N = size * size is the total number of entries.
1300  *
1301  * To make the average value equal to 1/2 = N/(2N), add a bias of 1/(2N).
1302  */
1303  for (int i = 0; i < num_entries; i++)
1304  m[i] = av_add_q64(m[i], av_make_q64(1, 2 * num_entries));
1305 
1306  return m;
1307 }
1308 
1309 static bool trc_is_hdr(enum AVColorTransferCharacteristic trc)
1310 {
1311  static_assert(AVCOL_TRC_NB == 19, "Update this list when adding TRCs");
1312  static_assert(AVCOL_TRC_EXT_NB == 257, "Update this list when adding TRCs");
1313  switch (trc) {
1314  case AVCOL_TRC_LOG:
1315  case AVCOL_TRC_LOG_SQRT:
1316  case AVCOL_TRC_V_LOG:
1317  case AVCOL_TRC_SMPTEST2084:
1319  return true;
1320  default:
1321  return false;
1322  }
1323 }
1324 
1325 static int fmt_dither(SwsContext *ctx, SwsOpList *ops,
1326  const SwsPixelType type,
1327  const SwsFormat *src, const SwsFormat *dst)
1328 {
1329  SwsDither mode = ctx->dither;
1331  const int bpc = dst->desc->comp[0].depth;
1332 
1333  if (mode == SWS_DITHER_AUTO) {
1334  /* Visual threshold of perception: 12 bits for SDR, 14 bits for HDR */
1335  const int jnd_bits = trc_is_hdr(dst->color.trc) ? 14 : 12;
1336  mode = bpc >= jnd_bits ? SWS_DITHER_NONE : SWS_DITHER_BAYER;
1337  }
1338 
1339  switch (mode) {
1340  case SWS_DITHER_NONE:
1341  if (ctx->flags & SWS_ACCURATE_RND) {
1342  /* Add constant 0.5 for correct rounding */
1344  if (!bias)
1345  return AVERROR(ENOMEM);
1346  *bias = (AVRational64) {1, 2};
1347  return ff_sws_op_list_append(ops, &(SwsOp) {
1348  .op = SWS_OP_DITHER,
1349  .type = type,
1350  .dither.matrix = bias,
1351  .dither.min = *bias,
1352  .dither.max = *bias,
1353  });
1354  } else {
1355  return 0; /* No-op */
1356  }
1357  case SWS_DITHER_BAYER:
1358  /* Hardcode 16x16 matrix for now; in theory we could adjust this
1359  * based on the expected level of precision in the output, since lower
1360  * bit depth outputs can suffice with smaller dither matrices; however
1361  * in practice we probably want to use error diffusion for such low bit
1362  * depths anyway */
1363  dither.size_log2 = 4;
1364  dither.matrix = generate_bayer_matrix(dither.size_log2);
1365  if (!dither.matrix)
1366  return AVERROR(ENOMEM);
1367 
1368  const int size = 1 << dither.size_log2;
1369  dither.min = dither.max = dither.matrix[0];
1370  for (int i = 1; i < size * size; i++) {
1371  if (av_cmp_q64(dither.min, dither.matrix[i]) > 0)
1372  dither.min = dither.matrix[i];
1373  if (av_cmp_q64(dither.matrix[i], dither.max) > 0)
1374  dither.max = dither.matrix[i];
1375  }
1376 
1377  /* Brute-forced offsets; minimizes quantization error across a 16x16
1378  * bayer dither pattern for standard RGBA and YUVA pixel formats */
1379  const int offsets_16x16[4] = {0, 3, 2, 5};
1380  for (int i = 0; i < 4; i++) {
1381  av_assert0(offsets_16x16[i] <= INT8_MAX);
1382  dither.y_offset[i] = offsets_16x16[i];
1383  }
1384 
1385  const AVPixFmtDescriptor *src_desc = fmt_desc_decoded(src->format);
1386  if (src_desc->nb_components < 3 && bpc >= 8) {
1387  /**
1388  * For high-bit-depth sources without chroma, use same matrix
1389  * offset for all color channels. This prevents introducing color
1390  * noise in grayscale images; and also allows optimizing the dither
1391  * operation. Skipped for low bit depth (<8 bpc) as the loss in
1392  * PSNR, from the inability to diffuse error among all three
1393  * channels, can be substantial.
1394  *
1395  * This shifts: { X, Y, Z, W } -> { X, X, X, Y }
1396  */
1397  dither.y_offset[3] = dither.y_offset[1];
1398  dither.y_offset[1] = dither.y_offset[2] = dither.y_offset[0];
1399  }
1400 
1401  return ff_sws_op_list_append(ops, &(SwsOp) {
1402  .op = SWS_OP_DITHER,
1403  .type = type,
1404  .dither = dither,
1405  });
1406  case SWS_DITHER_ED:
1407  case SWS_DITHER_A_DITHER:
1408  case SWS_DITHER_X_DITHER:
1409  return AVERROR(ENOTSUP);
1410 
1411  case SWS_DITHER_NB:
1412  break;
1413  }
1414 
1415  av_unreachable("Invalid dither mode");
1416  return AVERROR(EINVAL);
1417 }
1418 
1419 #define Q64(x) av_make_q64((x).num, (x).den)
1420 
1421 static inline SwsLinearOp
1422 linear_mat3(const AVRational m00, const AVRational m01, const AVRational m02,
1423  const AVRational m10, const AVRational m11, const AVRational m12,
1424  const AVRational m20, const AVRational m21, const AVRational m22)
1425 {
1426  SwsLinearOp c = {{
1427  { Q64(m00), Q64(m01), Q64(m02), Q(0), Q(0) },
1428  { Q64(m10), Q64(m11), Q64(m12), Q(0), Q(0) },
1429  { Q64(m20), Q64(m21), Q64(m22), Q(0), Q(0) },
1430  { Q(0), Q(0), Q(0), Q(1), Q(0) },
1431  }};
1432 
1433  c.mask = ff_sws_linear_mask(&c);
1434  return c;
1435 }
1436 
1437 void ff_sws_chroma_pos(const SwsFormat *fmt, bool *incomplete,
1438  int *out_x_pos, int *out_y_pos)
1439 {
1440  enum AVChromaLocation chroma_loc = fmt->loc;
1441  const int sub_x = fmt->desc->log2_chroma_w;
1442  const int sub_y = fmt->desc->log2_chroma_h;
1443  int x_pos, y_pos;
1444 
1445  /* Explicitly default to center siting for compatibility with swscale */
1446  if (chroma_loc == AVCHROMA_LOC_UNSPECIFIED) {
1447  chroma_loc = AVCHROMA_LOC_CENTER;
1448  *incomplete |= sub_x || sub_y;
1449  }
1450 
1451  /* av_chroma_location_enum_to_pos() always gives us values in the range from
1452  * 0 to 256, but we need to adjust this to the true value range of the
1453  * subsampling grid, which may be larger for h/v_sub > 1 */
1454  av_chroma_location_enum_to_pos(&x_pos, &y_pos, chroma_loc);
1455  x_pos *= (1 << sub_x) - 1;
1456  y_pos *= (1 << sub_y) - 1;
1457 
1458  /* Fix vertical chroma position for interlaced frames */
1459  if (sub_y && fmt->interlaced) {
1460  /* When vertically subsampling, chroma samples are effectively only
1461  * placed next to even rows. To access them from the odd field, we need
1462  * to account for this shift by offsetting the distance of one luma row.
1463  *
1464  * For 4x vertical subsampling (v_sub == 2), they are only placed
1465  * next to every *other* even row, so we need to shift by three luma
1466  * rows to get to the chroma sample. */
1467  if (fmt->field == FIELD_BOTTOM)
1468  y_pos += (256 << sub_y) - 256;
1469 
1470  /* Luma row distance is doubled for fields, so halve offsets */
1471  y_pos >>= 1;
1472  }
1473 
1474  *out_x_pos = x_pos;
1475  *out_y_pos = y_pos;
1476 }
1477 
1479  SwsOpList *ops, const SwsFormat *fmt, bool *incomplete)
1480 {
1482  const SwsPixelType pixel_type = fmt_pixel_type(fmt->format);
1483  if (!pixel_type)
1484  return AVERROR(ENOTSUP);
1485 
1486  const AVRational q0 = av_make_q(0, 1);
1487  const AVRational q1 = av_make_q(1, 1);
1488  const AVRational q2 = av_make_q(2, 1);
1489 
1490  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1491  .op = SWS_OP_CONVERT,
1492  .type = pixel_type,
1493  .convert.to = type,
1494  }));
1495 
1496  /* Decode pixel format into standardized range */
1497  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1498  .type = type,
1499  .op = SWS_OP_LINEAR,
1500  .lin = fmt_decode_range(fmt, incomplete),
1501  }));
1502 
1503  /* Final step, decode colorspace */
1504  switch (fmt->csp) {
1505  case AVCOL_SPC_RGB:
1506  return 0;
1507  case AVCOL_SPC_UNSPECIFIED:
1509  *incomplete = true;
1511  case AVCOL_SPC_FCC:
1512  case AVCOL_SPC_BT470BG:
1513  case AVCOL_SPC_SMPTE170M:
1514  case AVCOL_SPC_BT709:
1515  case AVCOL_SPC_SMPTE240M:
1516  case AVCOL_SPC_BT2020_NCL: {
1517  AVRational crg = av_sub_q(q0, av_div_q(c->cr, c->cg));
1518  AVRational cbg = av_sub_q(q0, av_div_q(c->cb, c->cg));
1519  AVRational m02 = av_mul_q(q2, av_sub_q(q1, c->cr));
1520  AVRational m21 = av_mul_q(q2, av_sub_q(q1, c->cb));
1521  AVRational m11 = av_mul_q(cbg, m21);
1522  AVRational m12 = av_mul_q(crg, m02);
1523 
1524  return ff_sws_op_list_append(ops, &(SwsOp) {
1525  .type = type,
1526  .op = SWS_OP_LINEAR,
1527  .lin = linear_mat3(
1528  q1, q0, m02,
1529  q1, m11, m12,
1530  q1, m21, q0
1531  ),
1532  });
1533  }
1534 
1535  case AVCOL_SPC_YCGCO:
1536  return ff_sws_op_list_append(ops, &(SwsOp) {
1537  .type = type,
1538  .op = SWS_OP_LINEAR,
1539  .lin = linear_mat3(
1540  q1, av_make_q(-1, 1), av_make_q( 1, 1),
1541  q1, av_make_q( 1, 1), av_make_q( 0, 1),
1542  q1, av_make_q(-1, 1), av_make_q(-1, 1)
1543  ),
1544  });
1545 
1546  case AVCOL_SPC_BT2020_CL:
1547  case AVCOL_SPC_SMPTE2085:
1550  case AVCOL_SPC_ICTCP:
1551  case AVCOL_SPC_IPT_C2:
1552  case AVCOL_SPC_YCGCO_RE:
1553  case AVCOL_SPC_YCGCO_RO:
1554  return AVERROR(ENOTSUP);
1555 
1556  case AVCOL_SPC_RESERVED:
1557  return AVERROR(EINVAL);
1558 
1559  case AVCOL_SPC_NB:
1560  break;
1561  }
1562 
1563  av_unreachable("Corrupt AVColorSpace value?");
1564  return AVERROR(EINVAL);
1565 }
1566 
1568  SwsOpList *ops, const SwsFormat *src,
1569  const SwsFormat *dst, bool *incomplete)
1570 {
1572  const SwsPixelType pixel_type = fmt_pixel_type(dst->format);
1573  if (!pixel_type)
1574  return AVERROR(ENOTSUP);
1575 
1576  switch (dst->csp) {
1577  case AVCOL_SPC_RGB:
1578  break;
1579  case AVCOL_SPC_UNSPECIFIED:
1581  *incomplete = true;
1583  case AVCOL_SPC_FCC:
1584  case AVCOL_SPC_BT470BG:
1585  case AVCOL_SPC_SMPTE170M:
1586  case AVCOL_SPC_BT709:
1587  case AVCOL_SPC_SMPTE240M:
1588  case AVCOL_SPC_BT2020_NCL: {
1589  AVRational cb1 = av_sub_q(c->cb, av_make_q(1, 1));
1590  AVRational cr1 = av_sub_q(c->cr, av_make_q(1, 1));
1591  AVRational m20 = av_make_q(1,2);
1592  AVRational m10 = av_mul_q(m20, av_div_q(c->cr, cb1));
1593  AVRational m11 = av_mul_q(m20, av_div_q(c->cg, cb1));
1594  AVRational m21 = av_mul_q(m20, av_div_q(c->cg, cr1));
1595  AVRational m22 = av_mul_q(m20, av_div_q(c->cb, cr1));
1596 
1597  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1598  .type = type,
1599  .op = SWS_OP_LINEAR,
1600  .lin = linear_mat3(
1601  c->cr, c->cg, c->cb,
1602  m10, m11, m20,
1603  m20, m21, m22
1604  ),
1605  }));
1606  break;
1607  }
1608 
1609  case AVCOL_SPC_YCGCO:
1610  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1611  .type = type,
1612  .op = SWS_OP_LINEAR,
1613  .lin = linear_mat3(
1614  av_make_q( 1, 4), av_make_q(1, 2), av_make_q( 1, 4),
1615  av_make_q( 1, 2), av_make_q(0, 1), av_make_q(-1, 2),
1616  av_make_q(-1, 4), av_make_q(1, 2), av_make_q(-1, 4)
1617  ),
1618  }));
1619  break;
1620 
1621  case AVCOL_SPC_BT2020_CL:
1622  case AVCOL_SPC_SMPTE2085:
1625  case AVCOL_SPC_ICTCP:
1626  case AVCOL_SPC_IPT_C2:
1627  case AVCOL_SPC_YCGCO_RE:
1628  case AVCOL_SPC_YCGCO_RO:
1629  return AVERROR(ENOTSUP);
1630 
1631  case AVCOL_SPC_RESERVED:
1632  case AVCOL_SPC_NB:
1633  return AVERROR(EINVAL);
1634  }
1635 
1636  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1637  .type = type,
1638  .op = SWS_OP_LINEAR,
1639  .lin = fmt_encode_range(dst, incomplete),
1640  }));
1641 
1642  if (!(dst->desc->flags & AV_PIX_FMT_FLAG_FLOAT)) {
1643  SwsClampOp range = {0};
1644 
1645  const bool is_ya = dst->desc->nb_components == 2;
1646  for (int i = 0; i < dst->desc->nb_components; i++) {
1647  /* Clamp to legal pixel range */
1648  const int idx = i * (is_ya ? 3 : 1);
1649  range.limit[idx] = intmax_q64(dst->desc->comp[i].depth);
1650  }
1651 
1652  RET(fmt_dither(ctx, ops, type, src, dst));
1653  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1654  .op = SWS_OP_MAX,
1655  .type = type,
1656  .clamp = {{ Q(0), Q(0), Q(0), Q(0) }},
1657  }));
1658 
1659  RET(ff_sws_op_list_append(ops, &(SwsOp) {
1660  .op = SWS_OP_MIN,
1661  .type = type,
1662  .clamp = range,
1663  }));
1664  }
1665 
1666  return ff_sws_op_list_append(ops, &(SwsOp) {
1667  .type = type,
1668  .op = SWS_OP_CONVERT,
1669  .convert.to = pixel_type,
1670  });
1671 }
1672 
1673 static SwsScaler get_scaler_fallback(SwsContext *ctx)
1674 {
1675  if (ctx->scaler != SWS_SCALE_AUTO)
1676  return ctx->scaler;
1677 
1678  /* Backwards compatibility with legacy flags API */
1679  if (ctx->flags & SWS_BILINEAR) {
1680  return SWS_SCALE_BILINEAR;
1681  } else if (ctx->flags & (SWS_BICUBIC | SWS_BICUBLIN)) {
1682  return SWS_SCALE_BICUBIC;
1683  } else if (ctx->flags & SWS_POINT) {
1684  return SWS_SCALE_POINT;
1685  } else if (ctx->flags & SWS_AREA) {
1686  return SWS_SCALE_AREA;
1687  } else if (ctx->flags & SWS_GAUSS) {
1688  return SWS_SCALE_GAUSSIAN;
1689  } else if (ctx->flags & SWS_SINC) {
1690  return SWS_SCALE_SINC;
1691  } else if (ctx->flags & SWS_LANCZOS) {
1692  return SWS_SCALE_LANCZOS;
1693  } else if (ctx->flags & SWS_SPLINE) {
1694  return SWS_SCALE_SPLINE;
1695  } else {
1696  return SWS_SCALE_AUTO;
1697  }
1698 }
1699 
1700 static int add_filter(SwsContext *ctx, SwsPixelType type, SwsOpList *ops,
1701  SwsOpType filter, int src_size, int dst_size)
1702 {
1703  if (src_size == dst_size)
1704  return 0; /* no-op */
1705 
1706  SwsFilterParams params = {
1707  .scaler = get_scaler_fallback(ctx),
1708  .src_size = src_size,
1709  .dst_size = dst_size,
1710  };
1711 
1712  for (int i = 0; i < SWS_NUM_SCALER_PARAMS; i++)
1713  params.scaler_params[i] = ctx->scaler_params[i];
1714 
1715  SwsFilterWeights *kernel;
1716  int ret = ff_sws_filter_generate(ctx, &params, &kernel);
1717  if (ret == AVERROR(ENOTSUP)) {
1718  /* Filter size exceeds limit; cascade with geometric mean size */
1719  int mean = sqrt((int64_t) src_size * dst_size);
1720  if (mean == src_size || mean == dst_size)
1721  return AVERROR_BUG; /* sanity, prevent infinite loop */
1722  ret = add_filter(ctx, type, ops, filter, src_size, mean);
1723  if (ret < 0)
1724  return ret;
1725  return add_filter(ctx, type, ops, filter, mean, dst_size);
1726  } else if (ret < 0) {
1727  return ret;
1728  }
1729 
1730  return ff_sws_op_list_append(ops, &(SwsOp) {
1731  .type = type,
1732  .op = filter,
1733  .filter.kernel = kernel,
1734  .filter.type = type,
1735  });
1736 }
1737 
1739  const SwsFormat *src, const SwsFormat *dst)
1740 {
1741  /**
1742  * Always perform horizontal scaling first, since it's much more likely to
1743  * benefit from small integer optimizations; we should maybe flip the order
1744  * here if we're downscaling the vertical resolution by a lot, though.
1745  */
1746  int ret = add_filter(ctx, type, ops, SWS_OP_FILTER_H, src->width, dst->width);
1747  if (ret < 0)
1748  return ret;
1749 
1750  return add_filter(ctx, type, ops, SWS_OP_FILTER_V, src->height, dst->height);
1751 }
1752 
1754  const SwsFormat *dst, SwsOpList **out_ops,
1755  bool *incomplete)
1756 {
1757  /* The new code does not yet support alpha blending */
1758  if (src->desc->flags & AV_PIX_FMT_FLAG_ALPHA &&
1759  ctx->alpha_blend != SWS_ALPHA_BLEND_NONE)
1760  return AVERROR(ENOTSUP);
1761 
1763  if (!ops)
1764  return AVERROR(ENOMEM);
1765  ops->src = *src;
1766  ops->dst = *dst;
1767 
1769  int ret = ff_sws_decode_pixfmt(ops, src);
1770  if (ret < 0)
1771  goto fail;
1772  ret = ff_sws_decode_colors(ctx, type, ops, src, incomplete);
1773  if (ret < 0)
1774  goto fail;
1775  ret = ff_sws_add_filters(ctx, type, ops, src, dst);
1776  if (ret < 0)
1777  goto fail;
1778  ret = ff_sws_encode_colors(ctx, type, ops, src, dst, incomplete);
1779  if (ret < 0)
1780  goto fail;
1781  ret = ff_sws_encode_pixfmt(ops, dst);
1782  if (ret < 0)
1783  goto fail;
1784 
1785  *out_ops = ops;
1786  return 0;
1787 
1788 fail:
1789  ff_sws_op_list_free(&ops);
1790  return ret;
1791 }
1792 
1793 #else /* !CONFIG_UNSTABLE */
1794 
1796 {
1797  return 0;
1798 }
1799 
1800 #endif
AVCOL_PRI_RESERVED
@ AVCOL_PRI_RESERVED
Definition: pixfmt.h:640
SWS_OP_READ
@ SWS_OP_READ
Definition: ops.h:39
AVLumaCoefficients::cr
AVRational cr
Definition: csp.h:49
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
AV_PIX_FMT_XYZ12LE
@ AV_PIX_FMT_XYZ12LE
packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as lit...
Definition: pixfmt.h:196
AV_PIX_FMT_YUV420P9LE
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:154
AVDynamicHDRPlus::params
AVHDRPlusColorTransformParams params[3]
The color transform parameters for every processing window.
Definition: hdr_dynamic_metadata.h:264
AV_PIX_FMT_XV30LE
@ AV_PIX_FMT_XV30LE
packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channe...
Definition: pixfmt.h:415
ff_sws_op_list_free
void ff_sws_op_list_free(SwsOpList **p_ops)
Definition: ops.c:649
q1
static const uint8_t q1[256]
Definition: twofish.c:100
RET
#define RET(x)
Definition: format.c:36
AV_PIX_FMT_GRAY10BE
@ AV_PIX_FMT_GRAY10BE
Y , 10bpp, big-endian.
Definition: pixfmt.h:320
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AV_PIX_FMT_BAYER_GBRG16LE
@ AV_PIX_FMT_BAYER_GBRG16LE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:293
SWS_OP_SWIZZLE
@ SWS_OP_SWIZZLE
Definition: ops.h:42
AV_PIX_FMT_BGR48LE
@ AV_PIX_FMT_BGR48LE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:146
SWS_DITHER_AUTO
@ SWS_DITHER_AUTO
Definition: swscale.h:81
ff_sws_op_list_alloc
SwsOpList * ff_sws_op_list_alloc(void)
Definition: ops.c:636
SWS_SCALE_AUTO
@ SWS_SCALE_AUTO
Definition: swscale.h:97
AV_PIX_FMT_P416BE
@ AV_PIX_FMT_P416BE
interleaved chroma YUV 4:4:4, 48bpp, big-endian
Definition: pixfmt.h:398
AVERROR
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
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
AV_PIX_FMT_BGRA64BE
@ AV_PIX_FMT_BGRA64BE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:204
SWS_OP_LSHIFT
@ SWS_OP_LSHIFT
Definition: ops.h:47
SWS_OP_UNPACK
@ SWS_OP_UNPACK
Definition: ops.h:45
SwsClearOp
Definition: ops.h:160
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:100
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:666
ff_fmt_from_frame
SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
This function also sanitizes and strips the input data, removing irrelevant fields for certain format...
Definition: format.c:345
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:247
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:659
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:79
AV_PIX_FMT_RGB444LE
@ AV_PIX_FMT_RGB444LE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:136
SwsOpList::comps_src
SwsComps comps_src
Source component metadata associated with pixel values from each corresponding component (in plane/me...
Definition: ops.h:284
AV_PIX_FMT_GBRP16BE
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:171
AVCOL_SPC_YCGCO_RE
@ AVCOL_SPC_YCGCO_RE
YCgCo-R, even addition of bits.
Definition: pixfmt.h:718
SwsFormat::interlaced
int interlaced
Definition: format.h:79
AVColorPrimariesDesc
Struct that contains both white point location and primaries location, providing the complete descrip...
Definition: csp.h:78
SWS_PIXEL_NONE
@ SWS_PIXEL_NONE
Definition: uops.h:39
AV_PIX_FMT_GBRP10BE
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:169
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3456
SWS_OP_CLEAR
@ SWS_OP_CLEAR
Definition: ops.h:51
SWS_SCALE_BILINEAR
@ SWS_SCALE_BILINEAR
bilinear filtering
Definition: swscale.h:98
AV_PIX_FMT_YUV422P14LE
@ AV_PIX_FMT_YUV422P14LE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:274
av_div_q
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
AV_PIX_FMT_YUV444P12MSBBE
@ AV_PIX_FMT_YUV444P12MSBBE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, big-endian
Definition: pixfmt.h:493
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
SwsSwizzleOp::z
uint8_t z
Definition: ops.h:149
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
int64_t
long long int64_t
Definition: coverity.c:34
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
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:743
AV_PIX_FMT_RGBF16LE
@ AV_PIX_FMT_RGBF16LE
IEEE-754 half precision packed RGB 16:16:16, 48bpp, RGBRGB..., little-endian.
Definition: pixfmt.h:452
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
AVHDRPlusColorTransformParams
Color transform parameters at a processing window in a dynamic metadata for SMPTE 2094-40.
Definition: hdr_dynamic_metadata.h:59
ff_sws_decode_colors
int ff_sws_decode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *fmt, bool *incomplete)
Append a set of operations for transforming decoded pixel values to/from normalized RGB in the specif...
mode
Definition: swscale.c:71
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
AVCOL_TRC_NB
@ AVCOL_TRC_NB
Not part of ABI.
Definition: pixfmt.h:688
SwsFormat::range
enum AVColorRange range
Definition: format.h:83
AV_PIX_FMT_YUVA444P10BE
@ AV_PIX_FMT_YUVA444P10BE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:185
AV_PIX_FMT_RGBA64BE
@ AV_PIX_FMT_RGBA64BE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:202
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
AV_PIX_FMT_YUV440P12BE
@ AV_PIX_FMT_YUV440P12BE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:301
AV_PIX_FMT_GBRAPF32LE
@ AV_PIX_FMT_GBRAPF32LE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian.
Definition: pixfmt.h:344
AV_PIX_FMT_X2BGR10BE
@ AV_PIX_FMT_X2BGR10BE
packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:387
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
SWS_DITHER_NONE
@ SWS_DITHER_NONE
Definition: swscale.h:80
SWS_OP_DITHER
@ SWS_OP_DITHER
Definition: ops.h:59
AV_PIX_FMT_GBRPF32BE
@ AV_PIX_FMT_GBRPF32BE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
Definition: pixfmt.h:341
av_csp_luma_coeffs_from_avcsp
const struct AVLumaCoefficients * av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp)
Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant desc...
Definition: csp.c:58
SwsFilterWeights
Represents a computed filter kernel.
Definition: filters.h:85
AV_PIX_FMT_P412BE
@ AV_PIX_FMT_P412BE
interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian
Definition: pixfmt.h:429
SWS_BILINEAR
@ SWS_BILINEAR
bilinear filtering
Definition: swscale.h:200
sws_test_primaries
int sws_test_primaries(enum AVColorPrimaries prim, int output)
Test if a given set of color primaries is supported.
Definition: format.c:603
AVCOL_SPC_NB
@ AVCOL_SPC_NB
Not part of ABI.
Definition: pixfmt.h:720
b
#define b
Definition: input.c:43
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:669
AV_PIX_FMT_P010BE
@ AV_PIX_FMT_P010BE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:308
AV_PIX_FMT_MONOWHITE
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
Definition: pixfmt.h:82
AV_PIX_FMT_YUV420P14BE
@ AV_PIX_FMT_YUV420P14BE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:269
integer
int integer
Definition: swresample_internal.h:37
AV_PIX_FMT_YUV420P16LE
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:128
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:701
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
AV_PIX_FMT_GBRP14BE
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:281
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AVLumaCoefficients
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
Definition: csp.h:48
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
SwsFilterParams
Definition: filters.h:45
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:636
AV_PIX_FMT_YUV422P9BE
@ AV_PIX_FMT_YUV422P9BE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:163
AV_PIX_FMT_YUVA444P9BE
@ AV_PIX_FMT_YUVA444P9BE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:179
av_sub_q
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
Definition: rational.c:101
AV_PIX_FMT_BAYER_GRBG16BE
@ AV_PIX_FMT_BAYER_GRBG16BE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:296
format.h
SWS_BICUBLIN
@ SWS_BICUBLIN
bicubic luma, bilinear chroma
Definition: swscale.h:205
AV_PIX_FMT_GRAY10LE
@ AV_PIX_FMT_GRAY10LE
Y , 10bpp, little-endian.
Definition: pixfmt.h:321
AV_PIX_FMT_GRAYF32LE
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
Definition: pixfmt.h:364
AV_PIX_FMT_GBRAP14BE
@ AV_PIX_FMT_GBRAP14BE
planar GBR 4:4:4:4 56bpp, big-endian
Definition: pixfmt.h:432
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:712
SWS_ALPHA_BLEND_NONE
@ SWS_ALPHA_BLEND_NONE
Definition: swscale.h:89
ff_sws_pixel_type_size
int ff_sws_pixel_type_size(SwsPixelType type)
Definition: ops.c:77
sws_test_hw_format
int sws_test_hw_format(enum AVPixelFormat format)
Test if a given hardware pixel format is supported by any backend, excluding unstable backends.
Definition: format.c:575
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
AV_PIX_FMT_RGB555BE
@ AV_PIX_FMT_RGB555BE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:114
AV_PIX_FMT_RGBAF16LE
@ AV_PIX_FMT_RGBAF16LE
IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian.
Definition: pixfmt.h:404
ff_sws_filter_generate
int ff_sws_filter_generate(void *log, const SwsFilterParams *params, SwsFilterWeights **out)
Generate a filter kernel for the given parameters.
Definition: filters.c:187
AV_PIX_FMT_AYUV64LE
@ AV_PIX_FMT_AYUV64LE
packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:302
AV_PIX_FMT_YUV444P16LE
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:132
AV_PIX_FMT_BAYER_GBRG16BE
@ AV_PIX_FMT_BAYER_GBRG16BE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:294
legacy_format_entries
static const LegacyFormatEntry legacy_format_entries[]
Definition: format.c:50
AV_PIX_FMT_AYUV64BE
@ AV_PIX_FMT_AYUV64BE
packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:303
AV_PIX_FMT_GBRAP12LE
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:311
AV_PIX_FMT_GRAY16BE
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
Definition: pixfmt.h:104
SwsColor::gamut
AVPrimaryCoefficients gamut
Definition: format.h:63
primaries
enum AVColorPrimaries primaries
Definition: mediacodec_wrapper.c:2612
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:706
AVCOL_SPC_RESERVED
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
Definition: pixfmt.h:704
SwsSwizzleOp::w
uint8_t w
Definition: ops.h:149
sanitize_fmt
static void sanitize_fmt(SwsFormat *fmt, const AVPixFmtDescriptor *desc)
Definition: format.c:305
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_YUV420P12LE
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:268
FIELD_TOP
@ FIELD_TOP
Definition: format.h:56
infer_prim_ref
static int infer_prim_ref(SwsColor *csp, const SwsColor *ref)
Definition: format.c:488
SwsDitherOp
Definition: ops.h:178
test_format_legacy
static int test_format_legacy(enum AVPixelFormat format, int output)
Definition: format.c:556
SwsDither
SwsDither
Definition: swscale.h:77
AV_PIX_FMT_GRAY9LE
@ AV_PIX_FMT_GRAY9LE
Y , 9bpp, little-endian.
Definition: pixfmt.h:339
AVCOL_RANGE_NB
@ AVCOL_RANGE_NB
Not part of ABI.
Definition: pixfmt.h:778
SwsReadWriteOp
Definition: ops.h:105
SwsSwizzleOp
Definition: ops.h:141
ff_sws_pixel_type_is_int
bool ff_sws_pixel_type_is_int(SwsPixelType type)
Definition: ops.c:92
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
SwsColor::trc
enum AVColorTransferCharacteristic trc
Definition: format.h:62
SWS_DITHER_X_DITHER
@ SWS_DITHER_X_DITHER
Definition: swscale.h:85
AVCOL_TRC_LOG_SQRT
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
Definition: pixfmt.h:677
AV_PIX_FMT_YUVA444P16BE
@ AV_PIX_FMT_YUVA444P16BE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:191
SWS_BACKEND_LEGACY
@ SWS_BACKEND_LEGACY
Legacy bespoke format-specific code.
Definition: swscale.h:112
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV_PIX_FMT_YUV444P10BE
@ AV_PIX_FMT_YUV444P10BE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:161
refstruct.h
AV_PIX_FMT_YUV420P10LE
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:156
AV_PIX_FMT_VUYA
@ AV_PIX_FMT_VUYA
packed VUYA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), VUYAVUYA...
Definition: pixfmt.h:401
av_refstruct_allocz
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
Definition: refstruct.h:105
AV_PIX_FMT_YUV444P12LE
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:276
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
SWS_RW_PACKED
@ SWS_RW_PACKED
Definition: ops.h:101
Q
#define Q(q)
AV_PIX_FMT_YUV422P12BE
@ AV_PIX_FMT_YUV422P12BE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:271
AV_PIX_FMT_YUV444P14LE
@ AV_PIX_FMT_YUV444P14LE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:278
SwsFrame
Represents a view into a single field of frame data.
Definition: format.h:224
SwsBackend
SwsBackend
Definition: swscale.h:110
SWS_SCALE_BICUBIC
@ SWS_SCALE_BICUBIC
2-tap cubic BC-spline
Definition: swscale.h:99
ff_sws_add_filters
int ff_sws_add_filters(SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *src, const SwsFormat *dst)
Append a set of operations for scaling pixels to a different resolution.
AV_PIX_FMT_BGR8
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:90
avassert.h
ff_sws_op_list_generate
int ff_sws_op_list_generate(SwsContext *ctx, const SwsFormat *src, const SwsFormat *dst, SwsOpList **out_ops, bool *incomplete)
Generate an SwsOpList defining a conversion from src to dst.
SWS_AREA
@ SWS_AREA
area averaging
Definition: swscale.h:204
AV_PIX_FMT_BAYER_RGGB16BE
@ AV_PIX_FMT_BAYER_RGGB16BE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:292
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
SwsFormat::height
int height
Definition: format.h:78
AVCOL_PRI_RESERVED0
@ AVCOL_PRI_RESERVED0
Definition: pixfmt.h:637
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_PIX_FMT_GBRAP16BE
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:213
dither
static const uint16_t dither[8][8]
Definition: vf_gradfun.c:46
AV_PIX_FMT_XV30BE
@ AV_PIX_FMT_XV30BE
packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), big-endian, variant of Y410 where alpha channel i...
Definition: pixfmt.h:414
AV_PIX_FMT_YUV444P10MSBBE
@ AV_PIX_FMT_YUV444P10MSBBE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, big-endian
Definition: pixfmt.h:491
AV_PIX_FMT_GBRP16LE
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:172
av_chroma_location_enum_to_pos
int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
Definition: pixdesc.c:3898
AVCOL_PRI_NB
@ AVCOL_PRI_NB
Not part of ABI.
Definition: pixfmt.h:654
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
av_csp_primaries_desc_from_id
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
Definition: csp.c:95
AV_PIX_FMT_P416LE
@ AV_PIX_FMT_P416LE
interleaved chroma YUV 4:4:4, 48bpp, little-endian
Definition: pixfmt.h:399
AV_PIX_FMT_BAYER_RGGB16LE
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:291
SWS_SCALE_LANCZOS
@ SWS_SCALE_LANCZOS
3-tap sinc/sinc
Definition: swscale.h:104
SWS_SWIZZLE
#define SWS_SWIZZLE(X, Y, Z, W)
Definition: ops.h:153
AV_PIX_FMT_P210LE
@ AV_PIX_FMT_P210LE
interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, little-endian
Definition: pixfmt.h:390
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1465
AV_PIX_FMT_BAYER_BGGR8
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
Definition: pixfmt.h:285
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:707
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
AV_PIX_FMT_NV20BE
@ AV_PIX_FMT_NV20BE
interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:200
info
MIPS optimizations info
Definition: mips.txt:2
test_format_ops
static int test_format_ops(enum AVPixelFormat format, int output)
Definition: format.c:1795
AV_PIX_FMT_P016BE
@ AV_PIX_FMT_P016BE
like NV12, with 16bpp per component, big-endian
Definition: pixfmt.h:324
LegacyFormatEntry::is_supported_in
uint8_t is_supported_in
Definition: format.c:44
bits
uint8_t bits
Definition: vp3data.h:128
SWS_DITHER_BAYER
@ SWS_DITHER_BAYER
Definition: swscale.h:82
AV_PIX_FMT_GBRP12LE
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:280
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
av_cmp_q64
int av_cmp_q64(AVRational64 a, AVRational64 b)
Compare two 64-bit rationals.
Definition: rational64.c:108
SWS_OP_MIN
@ SWS_OP_MIN
Definition: ops.h:53
AV_PIX_FMT_YUVA420P16BE
@ AV_PIX_FMT_YUVA420P16BE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:187
sws_test_colorspace
int sws_test_colorspace(enum AVColorSpace csp, int output)
Test if a given color space is supported.
Definition: format.c:586
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
SWS_BACKEND_ALL
@ SWS_BACKEND_ALL
Definition: swscale.h:129
AV_PIX_FMT_RGB4
@ AV_PIX_FMT_RGB4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:94
SWS_OP_LINEAR
@ SWS_OP_LINEAR
Definition: ops.h:58
LegacyFormatEntry::is_supported_out
uint8_t is_supported_out
Definition: format.c:45
field
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 field
Definition: writing_filters.txt:78
AVLumaCoefficients::cg
AVRational cg
Definition: csp.h:49
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
SWS_OP_FILTER_H
@ SWS_OP_FILTER_H
Definition: ops.h:62
AV_PIX_FMT_GBRP10LE
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:170
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
av_mul_q64
AVRational64 av_mul_q64(AVRational64 b, AVRational64 c)
Multiply two 64-bit rationals.
Definition: rational64.c:124
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:645
AV_PIX_FMT_GBRAPF16LE
@ AV_PIX_FMT_GBRAPF16LE
IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, little-endian.
Definition: pixfmt.h:469
AVCOL_SPC_IPT_C2
@ AVCOL_SPC_IPT_C2
SMPTE ST 2128, IPT-C2.
Definition: pixfmt.h:717
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
q0
static const uint8_t q0[256]
Definition: twofish.c:81
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AVCOL_SPC_CHROMA_DERIVED_CL
@ AVCOL_SPC_CHROMA_DERIVED_CL
Chromaticity-derived constant luminance system.
Definition: pixfmt.h:715
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:643
AV_PIX_FMT_YUV444P10LE
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:162
AV_PIX_FMT_BAYER_RGGB8
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
Definition: pixfmt.h:286
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:644
AV_PIX_FMT_YUVA422P10LE
@ AV_PIX_FMT_YUVA422P10LE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:184
if
if(ret)
Definition: filter_design.txt:179
AV_PIX_FMT_GBRP10MSBLE
@ AV_PIX_FMT_GBRP10MSBLE
planar GBR 4:4:4 30bpp, lowest bits zero, little-endian
Definition: pixfmt.h:496
SWS_OP_PACK
@ SWS_OP_PACK
Definition: ops.h:46
AV_PIX_FMT_BAYER_GRBG16LE
@ AV_PIX_FMT_BAYER_GRBG16LE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:295
AV_PIX_FMT_YUV444P9BE
@ AV_PIX_FMT_YUV444P9BE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:159
SwsColor::frame_peak
AVRational frame_peak
Definition: format.h:66
AV_PIX_FMT_YUV422P10BE
@ AV_PIX_FMT_YUV422P10BE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:157
fail
#define fail
Definition: test.h:478
test_range
static int test_range(enum AVColorRange range)
Definition: format.c:617
AV_PIX_FMT_YUV422P16LE
@ AV_PIX_FMT_YUV422P16LE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:130
AV_PIX_FMT_RGB565LE
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:113
AVDynamicHDRPlus::application_version
uint8_t application_version
Application version in the application defining document in ST-2094 suite.
Definition: hdr_dynamic_metadata.h:253
AV_PIX_FMT_Y216LE
@ AV_PIX_FMT_Y216LE
packed YUV 4:2:2 like YUYV422, 32bpp, little-endian
Definition: pixfmt.h:461
AV_PIX_FMT_GBRAPF32BE
@ AV_PIX_FMT_GBRAPF32BE
IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian.
Definition: pixfmt.h:343
AV_PIX_FMT_GBRAP12BE
@ AV_PIX_FMT_GBRAP12BE
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:310
AV_PIX_FMT_P012LE
@ AV_PIX_FMT_P012LE
like NV12, with 12bpp per component, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:408
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
SWS_BACKEND_STABLE
@ SWS_BACKEND_STABLE
Definition: swscale.h:113
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
AV_PIX_FMT_GBRAPF16BE
@ AV_PIX_FMT_GBRAPF16BE
IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, big-endian.
Definition: pixfmt.h:468
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
bias
static int bias(int x, int c)
Definition: vqcdec.c:115
SWS_BICUBIC
@ SWS_BICUBIC
2-tap cubic B-spline
Definition: swscale.h:201
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_unreachable
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition: avassert.h:116
sws_is_noop
int sws_is_noop(const AVFrame *dst, const AVFrame *src)
Check if a given conversion is a noop.
Definition: format.c:652
AV_PIX_FMT_P210BE
@ AV_PIX_FMT_P210BE
interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, big-endian
Definition: pixfmt.h:389
AV_PIX_FMT_RGB48LE
@ AV_PIX_FMT_RGB48LE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:110
AV_PIX_FMT_YA16LE
@ AV_PIX_FMT_YA16LE
16 bits gray, 16 bits alpha (little-endian)
Definition: pixfmt.h:210
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
AV_PIX_FMT_MONOBLACK
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
Definition: pixfmt.h:83
ff_infer_colors
bool ff_infer_colors(SwsColor *src, SwsColor *dst)
Definition: format.c:537
AV_PIX_FMT_YUVA422P12LE
@ AV_PIX_FMT_YUVA422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian
Definition: pixfmt.h:367
av_fallthrough
#define av_fallthrough
Definition: attributes.h:67
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:638
AV_PIX_FMT_BGR565LE
@ AV_PIX_FMT_BGR565LE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:118
AV_PIX_FMT_RGBA64LE
@ AV_PIX_FMT_RGBA64LE
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:203
AV_PIX_FMT_YUVA444P12BE
@ AV_PIX_FMT_YUVA444P12BE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian
Definition: pixfmt.h:368
sws_test_format
int sws_test_format(enum AVPixelFormat format, int output)
Test if a given (software) pixel format is supported by any backend, excluding unstable backends.
Definition: format.c:570
AV_PIX_FMT_YUVA444P9LE
@ AV_PIX_FMT_YUVA444P9LE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:180
AV_PIX_FMT_Y210LE
@ AV_PIX_FMT_Y210LE
packed YUV 4:2:2 like YUYV422, 20bpp, data in the high bits, little-endian
Definition: pixfmt.h:382
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
SWS_OP_FILTER_V
@ SWS_OP_FILTER_V
Definition: ops.h:63
AV_PIX_FMT_YUVA420P16LE
@ AV_PIX_FMT_YUVA420P16LE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:188
SwsScaler
SwsScaler
Definition: swscale.h:96
AV_PIX_FMT_RGB8
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
Definition: pixfmt.h:93
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:709
SwsOpType
SwsOpType
Copyright (C) 2025 Niklas Haas.
Definition: ops.h:35
AV_PIX_FMT_BGR4
@ AV_PIX_FMT_BGR4
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:91
attributes.h
AV_PIX_FMT_YUV440P10LE
@ AV_PIX_FMT_YUV440P10LE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:298
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_BGR555BE
@ AV_PIX_FMT_BGR555BE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:119
AV_PIX_FMT_YUVA420P9LE
@ AV_PIX_FMT_YUVA420P9LE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
Definition: pixfmt.h:176
AV_PIX_FMT_GBRP12MSBLE
@ AV_PIX_FMT_GBRP12MSBLE
planar GBR 4:4:4 36bpp, lowest bits zero, little-endian
Definition: pixfmt.h:498
AV_PIX_FMT_YAF16BE
@ AV_PIX_FMT_YAF16BE
IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, big-endian.
Definition: pixfmt.h:485
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:743
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
AV_PIX_FMT_YUV420P14LE
@ AV_PIX_FMT_YUV420P14LE
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:270
AV_PIX_FMT_YUV444P14BE
@ AV_PIX_FMT_YUV444P14BE
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:277
AV_PIX_FMT_BGR4_BYTE
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:92
AVCIExy::x
AVRational x
Definition: csp.h:57
SWS_SCALE_SINC
@ SWS_SCALE_SINC
unwindowed sinc
Definition: swscale.h:103
AV_PIX_FMT_X2RGB10LE
@ AV_PIX_FMT_X2RGB10LE
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:384
AV_PIX_FMT_P212LE
@ AV_PIX_FMT_P212LE
interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, little-endian
Definition: pixfmt.h:427
AV_PIX_FMT_YUV420P9BE
@ AV_PIX_FMT_YUV420P9BE
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition: pixfmt.h:153
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:683
AVPrimaryCoefficients::b
AVCIExy b
Definition: csp.h:65
SwsPackOp::pattern
uint8_t pattern[4]
Packed bits are assumed to be LSB-aligned within the underlying integer type; i.e.
Definition: ops.h:138
AV_PIX_FMT_YUV444P10MSBLE
@ AV_PIX_FMT_YUV444P10MSBLE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, little-endian
Definition: pixfmt.h:492
AVPrimaryCoefficients::r
AVCIExy r
Definition: csp.h:65
FIELD_BOTTOM
@ FIELD_BOTTOM
Definition: format.h:57
AV_PIX_FMT_RGBF32BE
@ AV_PIX_FMT_RGBF32BE
IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian.
Definition: pixfmt.h:420
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
AV_PIX_FMT_YUV440P12LE
@ AV_PIX_FMT_YUV440P12LE
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:300
LegacyFormatEntry::is_supported_endianness
uint8_t is_supported_endianness
Definition: format.c:46
test_loc
static int test_loc(enum AVChromaLocation loc)
Definition: format.c:622
AV_PIX_FMT_GBRP10MSBBE
@ AV_PIX_FMT_GBRP10MSBBE
planar GBR 4:4:4 30bpp, lowest bits zero, big-endian
Definition: pixfmt.h:495
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
shift
static int shift(int a, int b)
Definition: bonk.c:261
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
AV_PIX_FMT_BAYER_BGGR16LE
@ AV_PIX_FMT_BAYER_BGGR16LE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:289
SwsClampOp
Definition: ops.h:170
AV_PIX_FMT_YUV420P12BE
@ AV_PIX_FMT_YUV420P12BE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:267
AVCOL_TRC_SMPTEST2084
@ AVCOL_TRC_SMPTEST2084
Definition: pixfmt.h:684
AVCOL_SPC_YCGCO_RO
@ AVCOL_SPC_YCGCO_RO
YCgCo-R, odd addition of bits.
Definition: pixfmt.h:719
AV_PIX_FMT_YUV422P10LE
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:158
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
AVDynamicHDRPlus::num_windows
uint8_t num_windows
The number of processing windows.
Definition: hdr_dynamic_metadata.h:259
AVCOL_TRC_LOG
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
Definition: pixfmt.h:676
AV_PIX_FMT_RGB444BE
@ AV_PIX_FMT_RGB444BE
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:137
AV_PIX_FMT_XV36BE
@ AV_PIX_FMT_XV36BE
packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian,...
Definition: pixfmt.h:417
AV_PIX_FMT_YUV422P14BE
@ AV_PIX_FMT_YUV422P14BE
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:273
AV_PIX_FMT_YA16BE
@ AV_PIX_FMT_YA16BE
16 bits gray, 16 bits alpha (big-endian)
Definition: pixfmt.h:209
ff_sws_linear_mask
uint32_t ff_sws_linear_mask(const SwsLinearOp *c)
Definition: ops.c:789
size
int size
Definition: twinvq_data.h:10344
SwsShiftOp
Definition: ops.h:156
SWS_POINT
@ SWS_POINT
nearest neighbor
Definition: swscale.h:203
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV_PIX_FMT_GRAY12LE
@ AV_PIX_FMT_GRAY12LE
Y , 12bpp, little-endian.
Definition: pixfmt.h:319
SWS_OP_RSHIFT
@ SWS_OP_RSHIFT
Definition: ops.h:48
SWS_SPLINE
@ SWS_SPLINE
unwindowed natural cubic spline
Definition: swscale.h:209
SwsOpList::src
SwsFormat src
Definition: ops.h:270
AV_PIX_FMT_GBRP9BE
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:167
AV_PIX_FMT_FLAG_BITSTREAM
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:124
AVFrameSideData::data
uint8_t * data
Definition: frame.h:323
AVPrimaryCoefficients::g
AVCIExy g
Definition: csp.h:65
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:797
SwsFormat
Definition: format.h:77
AV_PIX_FMT_YUV420P10BE
@ AV_PIX_FMT_YUV420P10BE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:155
AV_PIX_FMT_RGBAF16BE
@ AV_PIX_FMT_RGBAF16BE
IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian.
Definition: pixfmt.h:403
AV_PIX_FMT_GBRP12MSBBE
@ AV_PIX_FMT_GBRP12MSBBE
planar GBR 4:4:4 36bpp, lowest bits zero, big-endian
Definition: pixfmt.h:497
AVRational64
64-bit Rational number (pair of numerator and denominator).
Definition: rational64.h:52
range
enum AVColorRange range
Definition: mediacodec_wrapper.c:2594
SWS_OP_WRITE
@ SWS_OP_WRITE
Definition: ops.h:40
AV_PIX_FMT_NV16
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:198
AV_PIX_FMT_BGR444BE
@ AV_PIX_FMT_BGR444BE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:139
SWS_COMP
#define SWS_COMP(X)
Definition: uops.h:70
SWS_PIXEL_U32
@ SWS_PIXEL_U32
Definition: uops.h:42
AV_PIX_FMT_GBRP9LE
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:168
SwsFormat::loc
enum AVChromaLocation loc
Definition: format.h:85
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:511
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_GBRAP10LE
@ AV_PIX_FMT_GBRAP10LE
planar GBR 4:4:4:4 40bpp, little-endian
Definition: pixfmt.h:314
ff_sws_test_pixfmt_backend
int ff_sws_test_pixfmt_backend(const SwsBackend backends, enum AVPixelFormat format, int output)
Definition: format.c:561
AVCOL_TRC_EXT_NB
@ AVCOL_TRC_EXT_NB
Not part of ABI.
Definition: pixfmt.h:693
SwsColor
Definition: format.h:60
sws_test_transfer
int sws_test_transfer(enum AVColorTransferCharacteristic trc, int output)
Test if a given color transfer function is supported.
Definition: format.c:610
AV_PIX_FMT_BGR565BE
@ AV_PIX_FMT_BGR565BE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:117
offset
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 offset
Definition: writing_filters.txt:86
SWS_DITHER_NB
@ SWS_DITHER_NB
Definition: swscale.h:86
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:3475
AV_PIX_FMT_YAF32LE
@ AV_PIX_FMT_YAF32LE
IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, little-endian.
Definition: pixfmt.h:483
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
sws_isSupportedInput
int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported input format, 0 otherwise.
Definition: format.c:287
AV_PIX_FMT_P012BE
@ AV_PIX_FMT_P012BE
like NV12, with 12bpp per component, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:409
AV_PIX_FMT_P410LE
@ AV_PIX_FMT_P410LE
interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-endian
Definition: pixfmt.h:393
SwsLinearOp
Definition: ops.h:185
AV_PIX_FMT_YUVA420P10LE
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:182
add_filter
static int add_filter(AudioNEqualizerContext *s, AVFilterLink *inlink)
Definition: af_anequalizer.c:539
AVCOL_SPC_CHROMA_DERIVED_NCL
@ AVCOL_SPC_CHROMA_DERIVED_NCL
Chromaticity-derived non-constant luminance system.
Definition: pixfmt.h:714
SwsColor::frame_avg
AVRational frame_avg
Definition: format.h:67
AV_PIX_FMT_FLAG_BAYER
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
Definition: pixdesc.h:152
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:668
AVChromaLocation
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:796
AV_PIX_FMT_AYUV
@ AV_PIX_FMT_AYUV
packed AYUV 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), AYUVAYUV...
Definition: pixfmt.h:442
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
AV_PIX_FMT_BGRA64LE
@ AV_PIX_FMT_BGRA64LE
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Definition: pixfmt.h:205
AV_PIX_FMT_YUVA422P10BE
@ AV_PIX_FMT_YUVA422P10BE
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:183
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:708
AV_PIX_FMT_UYVA
@ AV_PIX_FMT_UYVA
packed UYVA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), UYVAUYVA...
Definition: pixfmt.h:444
AV_PIX_FMT_YUVA444P12LE
@ AV_PIX_FMT_YUVA444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian
Definition: pixfmt.h:369
ff_test_fmt
int ff_test_fmt(const SwsBackend backends, const SwsFormat *fmt, int output)
Statically test if a given format is supported by the given set of backends.
Definition: format.c:627
AV_PIX_FMT_YUVA422P9BE
@ AV_PIX_FMT_YUVA422P9BE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:177
SWS_SCALE_POINT
@ SWS_SCALE_POINT
nearest neighbor (point sampling)
Definition: swscale.h:100
ff_fmt_from_pixfmt
void ff_fmt_from_pixfmt(enum AVPixelFormat pixfmt, SwsFormat *fmt)
Subset of ff_fmt_from_frame() that sets default metadata for the format.
Definition: format.c:480
unpack
static int unpack(const uint8_t *src, const uint8_t *src_end, uint8_t *dst, int width, int height)
Unpack buffer.
Definition: eatgv.c:73
AV_PIX_FMT_RGB555LE
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:115
sws_isSupportedEndiannessConversion
int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt)
Definition: format.c:299
SwsFormat::format
enum AVPixelFormat format
Definition: format.h:81
AV_PIX_FMT_RGB48BE
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:109
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:711
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:700
SwsPackOp
Definition: ops.h:133
AV_PIX_FMT_GRAY9BE
@ AV_PIX_FMT_GRAY9BE
Y , 9bpp, big-endian.
Definition: pixfmt.h:338
AV_PIX_FMT_NV24
@ AV_PIX_FMT_NV24
planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:371
SWS_PIXEL_U8
@ SWS_PIXEL_U8
Definition: uops.h:40
SwsFormat::desc
const AVPixFmtDescriptor * desc
Definition: format.h:86
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:58
AV_PIX_FMT_YAF16LE
@ AV_PIX_FMT_YAF16LE
IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, little-endian.
Definition: pixfmt.h:486
AV_PIX_FMT_BAYER_GBRG8
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
Definition: pixfmt.h:287
sws_isSupportedOutput
int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
Return a positive value if pix_fmt is a supported output format, 0 otherwise.
Definition: format.c:293
AV_PIX_FMT_NV20LE
@ AV_PIX_FMT_NV20LE
interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:199
ff_sws_encode_colors
int ff_sws_encode_colors(SwsContext *ctx, SwsPixelType type, SwsOpList *ops, const SwsFormat *src, const SwsFormat *dst, bool *incomplete)
ops_internal.h
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
AV_PIX_FMT_XYZ12BE
@ AV_PIX_FMT_XYZ12BE
packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big...
Definition: pixfmt.h:197
SwsFilterParams::scaler_params
double scaler_params[SWS_NUM_SCALER_PARAMS]
Definition: filters.h:50
AV_PIX_FMT_X2RGB10BE
@ AV_PIX_FMT_X2RGB10BE
packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:385
SwsReadWriteMode
SwsReadWriteMode
Definition: ops.h:90
SwsFormat::width
int width
Definition: format.h:78
sws_test_frame
int sws_test_frame(const AVFrame *frame, int output)
Helper function to run all sws_test_* against a frame, as well as testing the basic frame properties ...
Definition: format.c:639
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
SwsOp
Definition: ops.h:210
AV_PIX_FMT_RGB4_BYTE
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:95
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:703
AV_PIX_FMT_YUV444P16BE
@ AV_PIX_FMT_YUV444P16BE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:133
AV_PIX_FMT_GBRPF32LE
@ AV_PIX_FMT_GBRPF32LE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian.
Definition: pixfmt.h:342
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:689
AV_PIX_FMT_NV42
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition: pixfmt.h:372
av_csp_eotf_function
void(* av_csp_eotf_function)(double Lw, double Lb, double c[3])
Function pointer representing an ITU EOTF transfer for a given reference display configuration.
Definition: csp.h:178
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
SWS_SCALE_GAUSSIAN
@ SWS_SCALE_GAUSSIAN
2-tap gaussian approximation
Definition: swscale.h:102
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
AV_PIX_FMT_GBRAP16LE
@ AV_PIX_FMT_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:214
AVRational64::den
int64_t den
Denominator.
Definition: rational64.h:54
SWS_DITHER_ED
@ SWS_DITHER_ED
Definition: swscale.h:83
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
AV_PIX_FMT_GRAY12BE
@ AV_PIX_FMT_GRAY12BE
Y , 12bpp, big-endian.
Definition: pixfmt.h:318
AV_PIX_FMT_YVYU422
@ AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:207
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:641
SwsComps::flags
SwsCompFlags flags[4]
Definition: ops.h:83
ret
ret
Definition: filter_design.txt:187
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:367
SwsComps::min
AVRational64 min[4]
Definition: ops.h:87
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
AV_PIX_FMT_Y212LE
@ AV_PIX_FMT_Y212LE
packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:412
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
AV_PIX_FMT_BAYER_BGGR16BE
@ AV_PIX_FMT_BAYER_BGGR16BE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:290
SwsOpList::dst
SwsFormat dst
Definition: ops.h:270
AV_PIX_FMT_P410BE
@ AV_PIX_FMT_P410BE
interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, big-endian
Definition: pixfmt.h:392
SWS_OP_MAX
@ SWS_OP_MAX
Definition: ops.h:54
AV_PIX_FMT_P016LE
@ AV_PIX_FMT_P016LE
like NV12, with 16bpp per component, little-endian
Definition: pixfmt.h:323
ff_fmt_equal
static int ff_fmt_equal(const SwsFormat *fmt1, const SwsFormat *fmt2)
Definition: format.h:125
AVCIExy::y
AVRational y
Definition: csp.h:57
AV_PIX_FMT_GRAYF32BE
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
Definition: pixfmt.h:363
AV_PIX_FMT_GRAYF16BE
@ AV_PIX_FMT_GRAYF16BE
IEEE-754 half precision Y, 16bpp, big-endian.
Definition: pixfmt.h:471
SWS_RW_PALETTE
@ SWS_RW_PALETTE
Definition: ops.h:102
AV_PIX_FMT_RGBF16BE
@ AV_PIX_FMT_RGBF16BE
IEEE-754 half precision packed RGB 16:16:16, 48bpp, RGBRGB..., big-endian.
Definition: pixfmt.h:451
AV_PIX_FMT_GBRP12BE
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:279
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
AV_PIX_FMT_YUV444P12BE
@ AV_PIX_FMT_YUV444P12BE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:275
av_make_q64
static AVRational64 av_make_q64(int64_t num, int64_t den)
Create an AVRational64.
Definition: rational64.h:64
SwsFormat::field
int field
Definition: format.h:80
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:159
SWS_DITHER_A_DITHER
@ SWS_DITHER_A_DITHER
Definition: swscale.h:84
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:687
SwsComps
Definition: ops.h:82
AVCOL_PRI_EXT_NB
@ AVCOL_PRI_EXT_NB
Not part of ABI.
Definition: pixfmt.h:659
AV_PIX_FMT_FLAG_XYZ
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
Definition: pixdesc.h:163
AVCHROMA_LOC_CENTER
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:799
SWS_NUM_SCALER_PARAMS
#define SWS_NUM_SCALER_PARAMS
Extra parameters for fine-tuning certain scalers.
Definition: swscale.h:247
mode
mode
Definition: ebur128.h:83
SWS_COMP_SWAPPED
@ SWS_COMP_SWAPPED
Definition: ops.h:77
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:705
AV_PIX_FMT_XV48LE
@ AV_PIX_FMT_XV48LE
packed XVYU 4:4:4, 64bpp, little-endian, variant of Y416 where alpha channel is left undefined
Definition: pixfmt.h:464
SwsSwizzleOp::y
uint8_t y
Definition: ops.h:149
AV_PIX_FMT_YUV444P9LE
@ AV_PIX_FMT_YUV444P9LE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:160
SWS_OP_SWAP_BYTES
@ SWS_OP_SWAP_BYTES
Definition: ops.h:41
SwsFormat::hw_format
enum AVPixelFormat hw_format
Definition: format.h:82
SwsFormat::color
SwsColor color
Definition: format.h:87
SWS_SCALE_SPLINE
@ SWS_SCALE_SPLINE
unwindowned natural cubic spline
Definition: swscale.h:105
SWS_GAUSS
@ SWS_GAUSS
gaussian approximation
Definition: swscale.h:206
hdr_dynamic_metadata.h
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
AV_PIX_FMT_FLAG_PLANAR
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:132
AV_PIX_FMT_P216LE
@ AV_PIX_FMT_P216LE
interleaved chroma YUV 4:2:2, 32bpp, little-endian
Definition: pixfmt.h:396
mean
static float mean(const float *input, int size)
Definition: vf_nnedi.c:861
AV_PIX_FMT_RGBF32LE
@ AV_PIX_FMT_RGBF32LE
IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian.
Definition: pixfmt.h:421
AV_PIX_FMT_V30XBE
@ AV_PIX_FMT_V30XBE
packed VYUX 4:4:4 like XV30, 32bpp, (msb)10V 10Y 10U 2X(lsb), big-endian
Definition: pixfmt.h:448
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
ff_sws_encode_pixfmt
int ff_sws_encode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
SwsSwizzleOp::x
uint8_t x
Definition: ops.h:149
AV_PIX_FMT_YUVA420P10BE
@ AV_PIX_FMT_YUVA420P10BE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:181
SwsFormat::csp
enum AVColorSpace csp
Definition: format.h:84
SwsColor::min_luma
AVRational min_luma
Definition: format.h:64
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
SWS_COMP_EXACT
@ SWS_COMP_EXACT
Definition: ops.h:75
AV_PIX_FMT_RGB565BE
@ AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:112
AV_PIX_FMT_YUV420P16BE
@ AV_PIX_FMT_YUV420P16BE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:129
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AV_PIX_FMT_YUV422P16BE
@ AV_PIX_FMT_YUV422P16BE
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:131
AV_PIX_FMT_P212BE
@ AV_PIX_FMT_P212BE
interleaved chroma YUV 4:2:2, 24bpp, data in the high bits, big-endian
Definition: pixfmt.h:426
desc
const char * desc
Definition: libsvtav1.c:83
SwsReadWriteOp::elems
uint8_t elems
Definition: ops.h:116
AV_PIX_FMT_GRAY16LE
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Definition: pixfmt.h:105
AV_PIX_FMT_X2BGR10LE
@ AV_PIX_FMT_X2BGR10LE
packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:386
AV_PIX_FMT_V30XLE
@ AV_PIX_FMT_V30XLE
packed VYUX 4:4:4 like XV30, 32bpp, (msb)10V 10Y 10U 2X(lsb), little-endian
Definition: pixfmt.h:449
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
AV_PIX_FMT_P010LE
@ AV_PIX_FMT_P010LE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:307
SwsColor::max_luma
AVRational max_luma
Definition: format.h:65
mastering_display_metadata.h
AV_PIX_FMT_XV48BE
@ AV_PIX_FMT_XV48BE
packed XVYU 4:4:4, 64bpp, big-endian, variant of Y416 where alpha channel is left undefined
Definition: pixfmt.h:463
AV_PIX_FMT_YUVA444P10LE
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:186
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:321
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
SWS_PIXEL_F32
@ SWS_PIXEL_F32
Definition: uops.h:43
AV_PIX_FMT_BGR555LE
@ AV_PIX_FMT_BGR555LE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:120
LegacyFormatEntry
Definition: format.c:43
AVCOL_TRC_V_LOG
@ AVCOL_TRC_V_LOG
Definition: pixfmt.h:692
AV_PIX_FMT_YAF32BE
@ AV_PIX_FMT_YAF32BE
IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, big-endian.
Definition: pixfmt.h:482
AV_PIX_FMT_P216BE
@ AV_PIX_FMT_P216BE
interleaved chroma YUV 4:2:2, 32bpp, big-endian
Definition: pixfmt.h:395
av_add_q
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
Definition: rational.c:93
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV_PIX_FMT_P412LE
@ AV_PIX_FMT_P412LE
interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian
Definition: pixfmt.h:430
AV_PIX_FMT_GRAY14LE
@ AV_PIX_FMT_GRAY14LE
Y , 14bpp, little-endian.
Definition: pixfmt.h:361
AV_PIX_FMT_GRAYF16LE
@ AV_PIX_FMT_GRAYF16LE
IEEE-754 half precision Y, 16bpp, little-endian.
Definition: pixfmt.h:472
AVColorPrimariesDesc::prim
AVPrimaryCoefficients prim
Definition: csp.h:80
AVCOL_SPC_SMPTE2085
@ AVCOL_SPC_SMPTE2085
SMPTE 2085, Y'D'zD'x.
Definition: pixfmt.h:713
AVRational64::num
int64_t num
Numerator.
Definition: rational64.h:53
SwsComps::max
AVRational64 max[4]
Definition: ops.h:87
AV_PIX_FMT_XV36LE
@ AV_PIX_FMT_XV36LE
packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian,...
Definition: pixfmt.h:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
AV_PIX_FMT_GRAY14BE
@ AV_PIX_FMT_GRAY14BE
Y , 14bpp, big-endian.
Definition: pixfmt.h:360
SwsSwizzleOp::in
uint8_t in[4]
Definition: ops.h:148
SWS_OP_CONVERT
@ SWS_OP_CONVERT
Definition: ops.h:52
AV_PIX_FMT_YUVA422P16BE
@ AV_PIX_FMT_YUVA422P16BE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:189
AV_PIX_FMT_YUV440P10BE
@ AV_PIX_FMT_YUV440P10BE
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:299
AV_PIX_FMT_YUV422P9LE
@ AV_PIX_FMT_YUV422P9LE
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:164
AV_PIX_FMT_YUVA422P16LE
@ AV_PIX_FMT_YUVA422P16LE
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:190
AV_PIX_FMT_GBRP14LE
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:282
av_csp_itu_eotf
av_csp_eotf_function av_csp_itu_eotf(enum AVColorTransferCharacteristic trc)
Returns the ITU EOTF corresponding to a given TRC.
Definition: csp.c:684
AV_PIX_FMT_YUV444P12MSBLE
@ AV_PIX_FMT_YUV444P12MSBLE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, little-endian
Definition: pixfmt.h:494
RGBA
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:42
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AVCHROMA_LOC_NB
@ AVCHROMA_LOC_NB
Not part of ABI.
Definition: pixfmt.h:804
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
SWS_SCALE_AREA
@ SWS_SCALE_AREA
area averaging
Definition: swscale.h:101
AV_PIX_FMT_GBRAP10BE
@ AV_PIX_FMT_GBRAP10BE
planar GBR 4:4:4:4 40bpp, big-endian
Definition: pixfmt.h:313
AVCOL_TRC_SMPTE428
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
Definition: pixfmt.h:685
SWS_ACCURATE_RND
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition: swscale.h:179
SWS_LANCZOS
@ SWS_LANCZOS
3-tap sinc/sinc
Definition: swscale.h:208
ff_sws_decode_pixfmt
int ff_sws_decode_pixfmt(SwsOpList *ops, const SwsFormat *fmt)
Append a set of operations for decoding/encoding raw pixels.
AVLumaCoefficients::cb
AVRational cb
Definition: csp.h:49
AV_PIX_FMT_YUVA444P16LE
@ AV_PIX_FMT_YUVA444P16LE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:192
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:115
AV_PIX_FMT_GBRPF16BE
@ AV_PIX_FMT_GBRPF16BE
IEEE-754 half precision planer GBR 4:4:4, 48bpp, big-endian.
Definition: pixfmt.h:466
SwsOpList
Helper struct for representing a list of operations.
Definition: ops.h:265
AV_PIX_FMT_VUYX
@ AV_PIX_FMT_VUYX
packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined
Definition: pixfmt.h:406
AV_PIX_FMT_VYU444
@ AV_PIX_FMT_VYU444
packed VYU 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), VYUVYU...
Definition: pixfmt.h:446
AV_PIX_FMT_YUVA422P12BE
@ AV_PIX_FMT_YUVA422P12BE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian
Definition: pixfmt.h:366
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:702
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:742
SWS_SINC
@ SWS_SINC
unwindowed sinc
Definition: swscale.h:207
SwsContext
Main external API structure.
Definition: swscale.h:229
SWS_PIXEL_U16
@ SWS_PIXEL_U16
Definition: uops.h:41
AV_PIX_FMT_FLAG_PAL
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:120
AV_PIX_FMT_BGR444LE
@ AV_PIX_FMT_BGR444LE
packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:138
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:716
SwsFilterParams::scaler
SwsScaler scaler
The filter kernel and parameters to use.
Definition: filters.h:49
AV_PIX_FMT_YUV422P12LE
@ AV_PIX_FMT_YUV422P12LE
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:272
AV_PIX_FMT_YUVA420P9BE
@ AV_PIX_FMT_YUVA420P9BE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:175
AV_PIX_FMT_BAYER_GRBG8
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
Definition: pixfmt.h:288
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
csputils.h
src
#define src
Definition: vp8dsp.c:248
AVCOL_PRI_EXT_BASE
@ AVCOL_PRI_EXT_BASE
Definition: pixfmt.h:657
AV_PIX_FMT_GBRAP14LE
@ AV_PIX_FMT_GBRAP14LE
planar GBR 4:4:4:4 56bpp, little-endian
Definition: pixfmt.h:433
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
ff_sws_chroma_pos
void ff_sws_chroma_pos(const SwsFormat *fmt, bool *incomplete, int *out_xpos, int *out_ypos)
Wrapper around av_chroma_location_enum_to_pos() that accounts for the per-field offset introduced by ...
AV_PIX_FMT_GBRPF16LE
@ AV_PIX_FMT_GBRPF16LE
IEEE-754 half precision planer GBR 4:4:4, 48bpp, little-endian.
Definition: pixfmt.h:467
infer_trc_ref
static int infer_trc_ref(SwsColor *csp, const SwsColor *ref)
Definition: format.c:512
SwsColor::prim
enum AVColorPrimaries prim
Definition: format.h:61
av_inv_q64
static av_always_inline AVRational64 av_inv_q64(AVRational64 q)
Invert a 64-bit rational.
Definition: rational64.h:131
av_csp_itu_eotf_inv
av_csp_eotf_function av_csp_itu_eotf_inv(enum AVColorTransferCharacteristic trc)
Returns the mathematical inverse of the corresponding EOTF.
Definition: csp.c:710
AV_PIX_FMT_UYYVYY411
@ AV_PIX_FMT_UYYVYY411
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Definition: pixfmt.h:89
AV_PIX_FMT_BGR48BE
@ AV_PIX_FMT_BGR48BE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:145
ff_fmt_clear
static void ff_fmt_clear(SwsFormat *fmt)
Definition: format.h:90
av_add_q64
AVRational64 av_add_q64(AVRational64 b, AVRational64 c)
Add two 64-bit rationals.
Definition: rational64.c:135
AV_PIX_FMT_YUVA422P9LE
@ AV_PIX_FMT_YUVA422P9LE
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:178
ff_sws_frame_from_avframe
void ff_sws_frame_from_avframe(SwsFrame *dst, const AVFrame *src)
Initialize a SwsFrame from an AVFrame.
Definition: format.c:666