FFmpeg
swscale_unscaled.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
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 <inttypes.h>
22 #include <string.h>
23 #include <math.h>
24 #include <stdio.h>
25 #include "config.h"
26 #include "libavutil/attributes.h"
27 #include "swscale.h"
28 #include "swscale_internal.h"
29 #include "rgb2rgb.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/mathematics.h"
33 #include "libavutil/mem_internal.h"
34 #include "libavutil/bswap.h"
35 #include "libavutil/pixdesc.h"
36 #include "libavutil/avassert.h"
37 #include "libavutil/avconfig.h"
38 
39 DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={
40 {
41  { 0, 1, 0, 1, 0, 1, 0, 1,},
42  { 1, 0, 1, 0, 1, 0, 1, 0,},
43  { 0, 1, 0, 1, 0, 1, 0, 1,},
44  { 1, 0, 1, 0, 1, 0, 1, 0,},
45  { 0, 1, 0, 1, 0, 1, 0, 1,},
46  { 1, 0, 1, 0, 1, 0, 1, 0,},
47  { 0, 1, 0, 1, 0, 1, 0, 1,},
48  { 1, 0, 1, 0, 1, 0, 1, 0,},
49 },{
50  { 1, 2, 1, 2, 1, 2, 1, 2,},
51  { 3, 0, 3, 0, 3, 0, 3, 0,},
52  { 1, 2, 1, 2, 1, 2, 1, 2,},
53  { 3, 0, 3, 0, 3, 0, 3, 0,},
54  { 1, 2, 1, 2, 1, 2, 1, 2,},
55  { 3, 0, 3, 0, 3, 0, 3, 0,},
56  { 1, 2, 1, 2, 1, 2, 1, 2,},
57  { 3, 0, 3, 0, 3, 0, 3, 0,},
58 },{
59  { 2, 4, 3, 5, 2, 4, 3, 5,},
60  { 6, 0, 7, 1, 6, 0, 7, 1,},
61  { 3, 5, 2, 4, 3, 5, 2, 4,},
62  { 7, 1, 6, 0, 7, 1, 6, 0,},
63  { 2, 4, 3, 5, 2, 4, 3, 5,},
64  { 6, 0, 7, 1, 6, 0, 7, 1,},
65  { 3, 5, 2, 4, 3, 5, 2, 4,},
66  { 7, 1, 6, 0, 7, 1, 6, 0,},
67 },{
68  { 4, 8, 7, 11, 4, 8, 7, 11,},
69  { 12, 0, 15, 3, 12, 0, 15, 3,},
70  { 6, 10, 5, 9, 6, 10, 5, 9,},
71  { 14, 2, 13, 1, 14, 2, 13, 1,},
72  { 4, 8, 7, 11, 4, 8, 7, 11,},
73  { 12, 0, 15, 3, 12, 0, 15, 3,},
74  { 6, 10, 5, 9, 6, 10, 5, 9,},
75  { 14, 2, 13, 1, 14, 2, 13, 1,},
76 },{
77  { 9, 17, 15, 23, 8, 16, 14, 22,},
78  { 25, 1, 31, 7, 24, 0, 30, 6,},
79  { 13, 21, 11, 19, 12, 20, 10, 18,},
80  { 29, 5, 27, 3, 28, 4, 26, 2,},
81  { 8, 16, 14, 22, 9, 17, 15, 23,},
82  { 24, 0, 30, 6, 25, 1, 31, 7,},
83  { 12, 20, 10, 18, 13, 21, 11, 19,},
84  { 28, 4, 26, 2, 29, 5, 27, 3,},
85 },{
86  { 18, 34, 30, 46, 17, 33, 29, 45,},
87  { 50, 2, 62, 14, 49, 1, 61, 13,},
88  { 26, 42, 22, 38, 25, 41, 21, 37,},
89  { 58, 10, 54, 6, 57, 9, 53, 5,},
90  { 16, 32, 28, 44, 19, 35, 31, 47,},
91  { 48, 0, 60, 12, 51, 3, 63, 15,},
92  { 24, 40, 20, 36, 27, 43, 23, 39,},
93  { 56, 8, 52, 4, 59, 11, 55, 7,},
94 },{
95  { 18, 34, 30, 46, 17, 33, 29, 45,},
96  { 50, 2, 62, 14, 49, 1, 61, 13,},
97  { 26, 42, 22, 38, 25, 41, 21, 37,},
98  { 58, 10, 54, 6, 57, 9, 53, 5,},
99  { 16, 32, 28, 44, 19, 35, 31, 47,},
100  { 48, 0, 60, 12, 51, 3, 63, 15,},
101  { 24, 40, 20, 36, 27, 43, 23, 39,},
102  { 56, 8, 52, 4, 59, 11, 55, 7,},
103 },{
104  { 36, 68, 60, 92, 34, 66, 58, 90,},
105  { 100, 4,124, 28, 98, 2,122, 26,},
106  { 52, 84, 44, 76, 50, 82, 42, 74,},
107  { 116, 20,108, 12,114, 18,106, 10,},
108  { 32, 64, 56, 88, 38, 70, 62, 94,},
109  { 96, 0,120, 24,102, 6,126, 30,},
110  { 48, 80, 40, 72, 54, 86, 46, 78,},
111  { 112, 16,104, 8,118, 22,110, 14,},
112 }};
113 
114 
115 static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
116  uint8_t val)
117 {
118  int i;
119  uint8_t *ptr = plane + stride * y;
120  for (i = 0; i < height; i++) {
121  memset(ptr, val, width);
122  ptr += stride;
123  }
124 }
125 
126 void ff_copyPlane(const uint8_t *src, int srcStride,
127  int srcSliceY, int srcSliceH, int width,
128  uint8_t *dst, int dstStride)
129 {
130  if (!srcSliceH)
131  return;
132  av_assert0(srcSliceH > 0);
133 
134  dst += dstStride * srcSliceY;
135  if (dstStride == srcStride && srcStride > 0) {
136  memcpy(dst, src, (srcSliceH - 1) * dstStride + width);
137  } else {
138  int i;
139  for (i = 0; i < srcSliceH; i++) {
140  memcpy(dst, src, width);
141  src += srcStride;
142  dst += dstStride;
143  }
144  }
145 }
146 
147 static int planarToNv12Wrapper(SwsInternal *c, const uint8_t *const src[],
148  const int srcStride[], int srcSliceY,
149  int srcSliceH, uint8_t *const dstParam[],
150  const int dstStride[])
151 {
152  uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
153 
154  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
155  dstParam[0], dstStride[0]);
156 
157  if (c->opts.dst_format == AV_PIX_FMT_NV12)
158  interleaveBytes(src[1], src[2], dst, c->chrSrcW, (srcSliceH + 1) / 2,
159  srcStride[1], srcStride[2], dstStride[1]);
160  else
161  interleaveBytes(src[2], src[1], dst, c->chrSrcW, (srcSliceH + 1) / 2,
162  srcStride[2], srcStride[1], dstStride[1]);
163 
164  return srcSliceH;
165 }
166 
167 static int nv12ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[],
168  const int srcStride[], int srcSliceY,
169  int srcSliceH, uint8_t *const dstParam[],
170  const int dstStride[])
171 {
172  uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
173  uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
174 
175  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
176  dstParam[0], dstStride[0]);
177 
178  if (c->opts.src_format == AV_PIX_FMT_NV12)
179  deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, (srcSliceH + 1) / 2,
180  srcStride[1], dstStride[1], dstStride[2]);
181  else
182  deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, (srcSliceH + 1) / 2,
183  srcStride[1], dstStride[2], dstStride[1]);
184 
185  return srcSliceH;
186 }
187 
188 static int planarToNv24Wrapper(SwsInternal *c, const uint8_t *const src[],
189  const int srcStride[], int srcSliceY,
190  int srcSliceH, uint8_t *const dstParam[],
191  const int dstStride[])
192 {
193  uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY;
194 
195  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
196  dstParam[0], dstStride[0]);
197 
198  if (c->opts.dst_format == AV_PIX_FMT_NV24)
199  interleaveBytes(src[1], src[2], dst, c->chrSrcW, srcSliceH,
200  srcStride[1], srcStride[2], dstStride[1]);
201  else
202  interleaveBytes(src[2], src[1], dst, c->chrSrcW, srcSliceH,
203  srcStride[2], srcStride[1], dstStride[1]);
204 
205  return srcSliceH;
206 }
207 
208 static int nv24ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[],
209  const int srcStride[], int srcSliceY,
210  int srcSliceH, uint8_t *const dstParam[],
211  const int dstStride[])
212 {
213  uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY;
214  uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY;
215 
216  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
217  dstParam[0], dstStride[0]);
218 
219  if (c->opts.src_format == AV_PIX_FMT_NV24)
220  deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, srcSliceH,
221  srcStride[1], dstStride[1], dstStride[2]);
222  else
223  deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, srcSliceH,
224  srcStride[1], dstStride[2], dstStride[1]);
225 
226  return srcSliceH;
227 }
228 
229 static void nv24_to_yuv420p_chroma(uint8_t *dst1, int dstStride1,
230  uint8_t *dst2, int dstStride2,
231  const uint8_t *src, int srcStride,
232  int w, int h)
233 {
234  const uint8_t *src1 = src;
235  const uint8_t *src2 = src + srcStride;
236  // average 4 pixels into 1 (interleaved U and V)
237  for (int y = 0; y < h; y += 2) {
238  if (y + 1 == h)
239  src2 = src1;
240  for (int x = 0; x < w; x++) {
241  dst1[x] = (src1[4 * x + 0] + src1[4 * x + 2] +
242  src2[4 * x + 0] + src2[4 * x + 2]) >> 2;
243  dst2[x] = (src1[4 * x + 1] + src1[4 * x + 3] +
244  src2[4 * x + 1] + src2[4 * x + 3]) >> 2;
245  }
246  src1 += srcStride * 2;
247  src2 += srcStride * 2;
248  dst1 += dstStride1;
249  dst2 += dstStride2;
250  }
251 }
252 
253 static int nv24ToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
254  const int srcStride[], int srcSliceY, int srcSliceH,
255  uint8_t *const dstParam[], const int dstStride[])
256 {
257  uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
258  uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
259 
260  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
261  dstParam[0], dstStride[0]);
262 
263  if (c->opts.src_format == AV_PIX_FMT_NV24)
264  nv24_to_yuv420p_chroma(dst1, dstStride[1], dst2, dstStride[2],
265  src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
266  else
267  nv24_to_yuv420p_chroma(dst2, dstStride[2], dst1, dstStride[1],
268  src[1], srcStride[1], c->opts.src_w / 2, srcSliceH);
269 
270  return srcSliceH;
271 }
272 
273 static int planarToP01xWrapper(SwsInternal *c, const uint8_t *const src8[],
274  const int srcStride[], int srcSliceY,
275  int srcSliceH, uint8_t *const dstParam8[],
276  const int dstStride[])
277 {
278  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
279  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
280  const uint16_t **src = (const uint16_t**)src8;
281  uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
282  uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
283  int x, y;
284 
285  /* Calculate net shift required for values. */
286  const int shift[3] = {
287  dst_format->comp[0].depth + dst_format->comp[0].shift -
288  src_format->comp[0].depth - src_format->comp[0].shift,
289  dst_format->comp[1].depth + dst_format->comp[1].shift -
290  src_format->comp[1].depth - src_format->comp[1].shift,
291  dst_format->comp[2].depth + dst_format->comp[2].shift -
292  src_format->comp[2].depth - src_format->comp[2].shift,
293  };
294 
295  av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
296  dstStride[0] % 2 || dstStride[1] % 2));
297 
298  for (y = 0; y < srcSliceH; y++) {
299  uint16_t *tdstY = dstY;
300  const uint16_t *tsrc0 = src[0];
301  for (x = c->opts.src_w; x > 0; x--) {
302  *tdstY++ = *tsrc0++ << shift[0];
303  }
304  src[0] += srcStride[0] / 2;
305  dstY += dstStride[0] / 2;
306 
307  if (!(y & 1)) {
308  uint16_t *tdstUV = dstUV;
309  const uint16_t *tsrc1 = src[1];
310  const uint16_t *tsrc2 = src[2];
311  for (x = c->opts.src_w / 2; x > 0; x--) {
312  *tdstUV++ = *tsrc1++ << shift[1];
313  *tdstUV++ = *tsrc2++ << shift[2];
314  }
315  src[1] += srcStride[1] / 2;
316  src[2] += srcStride[2] / 2;
317  dstUV += dstStride[1] / 2;
318  }
319  }
320 
321  return srcSliceH;
322 }
323 
324 #if AV_HAVE_BIGENDIAN
325 #define output_pixel(p, v) do { \
326  uint16_t *pp = (p); \
327  AV_WL16(pp, (v)); \
328  } while(0)
329 #else
330 #define output_pixel(p, v) (*p) = (v)
331 #endif
332 
333 static int planar8ToP01xleWrapper(SwsInternal *c, const uint8_t *const src[],
334  const int srcStride[], int srcSliceY,
335  int srcSliceH, uint8_t *const dstParam8[],
336  const int dstStride[])
337 {
338  const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2];
339  uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
340  uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
341  int x, y, t;
342 
343  av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
344 
345  for (y = 0; y < srcSliceH; y++) {
346  uint16_t *tdstY = dstY;
347  const uint8_t *tsrc0 = src0;
348  for (x = c->opts.src_w; x > 0; x--) {
349  t = *tsrc0++;
350  output_pixel(tdstY++, t << 8);
351  }
352  src0 += srcStride[0];
353  dstY += dstStride[0] / 2;
354 
355  if (!(y & 1)) {
356  uint16_t *tdstUV = dstUV;
357  const uint8_t *tsrc1 = src1;
358  const uint8_t *tsrc2 = src2;
359  for (x = c->opts.src_w / 2; x > 0; x--) {
360  t = *tsrc1++;
361  output_pixel(tdstUV++, t << 8);
362  t = *tsrc2++;
363  output_pixel(tdstUV++, t << 8);
364  }
365  src1 += srcStride[1];
366  src2 += srcStride[2];
367  dstUV += dstStride[1] / 2;
368  }
369  }
370 
371  return srcSliceH;
372 }
373 
374 #undef output_pixel
375 
376 static int planarToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[],
377  const int srcStride[], int srcSliceY, int srcSliceH,
378  uint8_t *const dstParam[], const int dstStride[])
379 {
380  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
381 
382  yv12toyuy2(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
383  srcStride[1], dstStride[0]);
384 
385  return srcSliceH;
386 }
387 
388 static int planarToUyvyWrapper(SwsInternal *c, const uint8_t *const src[],
389  const int srcStride[], int srcSliceY, int srcSliceH,
390  uint8_t *const dstParam[], const int dstStride[])
391 {
392  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
393 
394  yv12touyvy(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
395  srcStride[1], dstStride[0]);
396 
397  return srcSliceH;
398 }
399 
400 static int yuv422pToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[],
401  const int srcStride[], int srcSliceY, int srcSliceH,
402  uint8_t *const dstParam[], const int dstStride[])
403 {
404  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
405 
406  yuv422ptoyuy2(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
407  srcStride[1], dstStride[0]);
408 
409  return srcSliceH;
410 }
411 
412 static int yuv422pToUyvyWrapper(SwsInternal *c, const uint8_t *const src[],
413  const int srcStride[], int srcSliceY, int srcSliceH,
414  uint8_t *const dstParam[], const int dstStride[])
415 {
416  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
417 
418  yuv422ptouyvy(src[0], src[1], src[2], dst, c->opts.src_w, srcSliceH, srcStride[0],
419  srcStride[1], dstStride[0]);
420 
421  return srcSliceH;
422 }
423 
424 static int yuyvToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
425  const int srcStride[], int srcSliceY, int srcSliceH,
426  uint8_t *const dstParam[], const int dstStride[])
427 {
428  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
429  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
430  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
431 
432  yuyvtoyuv420(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
433  dstStride[1], srcStride[0]);
434 
435  if (dstParam[3])
436  fillPlane(dstParam[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
437 
438  return srcSliceH;
439 }
440 
441 static int yuyvToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[],
442  const int srcStride[], int srcSliceY, int srcSliceH,
443  uint8_t *const dstParam[], const int dstStride[])
444 {
445  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
446  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
447  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
448 
449  yuyvtoyuv422(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
450  dstStride[1], srcStride[0]);
451 
452  return srcSliceH;
453 }
454 
455 static int uyvyToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[],
456  const int srcStride[], int srcSliceY, int srcSliceH,
457  uint8_t *const dstParam[], const int dstStride[])
458 {
459  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
460  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
461  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
462 
463  uyvytoyuv420(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
464  dstStride[1], srcStride[0]);
465 
466  if (dstParam[3])
467  fillPlane(dstParam[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
468 
469  return srcSliceH;
470 }
471 
472 static int uyvyToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[],
473  const int srcStride[], int srcSliceY, int srcSliceH,
474  uint8_t *const dstParam[], const int dstStride[])
475 {
476  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
477  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
478  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
479 
480  uyvytoyuv422(ydst, udst, vdst, src[0], c->opts.src_w, srcSliceH, dstStride[0],
481  dstStride[1], srcStride[0]);
482 
483  return srcSliceH;
484 }
485 
486 static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels,
487  const uint8_t *palette)
488 {
489  int i;
490  for (i = 0; i < num_pixels; i++)
491  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
492 }
493 
494 static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels,
495  const uint8_t *palette)
496 {
497  int i;
498 
499  for (i = 0; i < num_pixels; i++)
500  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
501 }
502 
503 static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
504  const uint8_t *palette)
505 {
506  int i;
507 
508  for (i = 0; i < num_pixels; i++) {
509  //FIXME slow?
510  dst[0] = palette[src[i << 1] * 4 + 0];
511  dst[1] = palette[src[i << 1] * 4 + 1];
512  dst[2] = palette[src[i << 1] * 4 + 2];
513  dst += 3;
514  }
515 }
516 
517 static void gray8aToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
518  uint8_t *dst2, uint8_t *dstA, int num_pixels,
519  const uint8_t *palette)
520 {
521  for (int i = 0; i < num_pixels; i++) {
522  const uint8_t *rgb = &palette[src[i << 1] * 4];
523  dst0[i] = rgb[0];
524  dst1[i] = rgb[1];
525  dst2[i] = rgb[2];
526  if (dstA)
527  dstA[i] = src[(i << 1) + 1];
528  }
529 }
530 
531 static void pal8ToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
532  uint8_t *dst2, uint8_t *dstA, int num_pixels,
533  const uint8_t *palette)
534 {
535  for (int i = 0; i < num_pixels; i++) {
536  const uint8_t *rgba = &palette[src[i] * 4];
537  dst0[i] = rgba[0];
538  dst1[i] = rgba[1];
539  dst2[i] = rgba[2];
540  if (dstA)
541  dstA[i] = rgba[3];
542  }
543 }
544 
545 static int bswap_16bpc(SwsInternal *c, const uint8_t *const src[],
546  const int srcStride[], int srcSliceY, int srcSliceH,
547  uint8_t *const dst[], const int dstStride[])
548 {
549  int i, j, p;
550 
551  for (p = 0; p < 4; p++) {
552  int srcstr = srcStride[p] / 2;
553  int dststr = dstStride[p] / 2;
554  uint16_t *dstPtr = (uint16_t *) dst[p];
555  const uint16_t *srcPtr = (const uint16_t *) src[p];
556  int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
557  if(!dstPtr || !srcPtr)
558  continue;
559  dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
560  for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
561  for (j = 0; j < min_stride; j++) {
562  dstPtr[j] = av_bswap16(srcPtr[j]);
563  }
564  srcPtr += srcstr;
565  dstPtr += dststr;
566  }
567  }
568 
569  return srcSliceH;
570 }
571 
572 static int bswap_32bpc(SwsInternal *c, const uint8_t *const src[],
573  const int srcStride[], int srcSliceY, int srcSliceH,
574  uint8_t *const dst[], const int dstStride[])
575 {
576  int i, j, p;
577 
578  for (p = 0; p < 4; p++) {
579  int srcstr = srcStride[p] / 4;
580  int dststr = dstStride[p] / 4;
581  uint32_t *dstPtr = (uint32_t *) dst[p];
582  const uint32_t *srcPtr = (const uint32_t *) src[p];
583  int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
584  if(!dstPtr || !srcPtr)
585  continue;
586  dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
587  for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
588  for (j = 0; j < min_stride; j++) {
589  dstPtr[j] = av_bswap32(srcPtr[j]);
590  }
591  srcPtr += srcstr;
592  dstPtr += dststr;
593  }
594  }
595 
596  return srcSliceH;
597 }
598 
599 
600 static int palToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[],
601  int srcSliceY, int srcSliceH, uint8_t *const dst[],
602  const int dstStride[])
603 {
604  const enum AVPixelFormat srcFormat = c->opts.src_format;
605  const enum AVPixelFormat dstFormat = c->opts.dst_format;
606  void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
607  const uint8_t *palette) = NULL;
608  int i;
609  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
610  const uint8_t *srcPtr = src[0];
611 
612  if (srcFormat == AV_PIX_FMT_YA8) {
613  switch (dstFormat) {
614  case AV_PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
615  case AV_PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
616  case AV_PIX_FMT_BGR32_1: conv = gray8aToPacked32_1; break;
617  case AV_PIX_FMT_RGB32_1: conv = gray8aToPacked32_1; break;
618  case AV_PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
619  case AV_PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
620  }
621  } else if (usePal(srcFormat)) {
622  switch (dstFormat) {
623  case AV_PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
624  case AV_PIX_FMT_BGR32 : conv = sws_convertPalette8ToPacked32; break;
627  case AV_PIX_FMT_RGB24 : conv = sws_convertPalette8ToPacked24; break;
628  case AV_PIX_FMT_BGR24 : conv = sws_convertPalette8ToPacked24; break;
629  }
630  }
631 
632  if (!conv)
633  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
634  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
635  else {
636  for (i = 0; i < srcSliceH; i++) {
637  conv(srcPtr, dstPtr, c->opts.src_w, (uint8_t *) c->pal_rgb);
638  srcPtr += srcStride[0];
639  dstPtr += dstStride[0];
640  }
641  }
642 
643  return srcSliceH;
644 }
645 
646 static int palToGbrpWrapper(SwsInternal *c, const uint8_t *const src[],
647  const int srcStride[], int srcSliceY, int srcSliceH,
648  uint8_t *const dst[], const int dstStride[])
649 {
650  const enum AVPixelFormat srcFormat = c->opts.src_format;
651  const enum AVPixelFormat dstFormat = c->opts.dst_format;
652  void (*conv)(const uint8_t *src, uint8_t *dstG, uint8_t *dstB, uint8_t *dstR,
653  uint8_t *dstA, int num_pixels, const uint8_t *palette) = NULL;
654 
655  const int num_planes = isALPHA(dstFormat) ? 4 : 3;
656  const uint8_t *srcPtr = src[0];
657  uint8_t *dstPtr[4] = {0};
658  for (int i = 0; i < num_planes; i++)
659  dstPtr[i] = dst[i] + dstStride[i] * srcSliceY;
660 
661  if (srcFormat == AV_PIX_FMT_YA8) {
662  switch (dstFormat) {
663  case AV_PIX_FMT_GBRP: conv = gray8aToPlanar8; break;
664  case AV_PIX_FMT_GBRAP: conv = gray8aToPlanar8; break;
665  }
666  } else if (usePal(srcFormat)) {
667  switch (dstFormat) {
668  case AV_PIX_FMT_GBRP: conv = pal8ToPlanar8; break;
669  case AV_PIX_FMT_GBRAP: conv = pal8ToPlanar8; break;
670  }
671  }
672 
673  av_assert1(conv);
674  for (int y = 0; y < srcSliceH; y++) {
675  conv(srcPtr, dstPtr[0], dstPtr[1], dstPtr[2], dstPtr[3], c->opts.src_w,
676  (uint8_t *) c->pal_rgb);
677  srcPtr += srcStride[0];
678  for (int i = 0; i < num_planes; i++)
679  dstPtr[i] += dstStride[i];
680  }
681 
682  return srcSliceH;
683 }
684 
685 static void packed16togbra16(const uint8_t *src, int srcStride,
686  uint16_t *dst[], const int dstStride[], int srcSliceH,
687  int src_alpha, int swap, int shift, int width)
688 {
689  int x, h, i;
690  int dst_alpha = dst[3] != NULL;
691  for (h = 0; h < srcSliceH; h++) {
692  uint16_t *src_line = (uint16_t *)(src + srcStride * h);
693  switch (swap) {
694  case 3:
695  if (src_alpha && dst_alpha) {
696  for (x = 0; x < width; x++) {
697  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
698  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
699  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
700  dst[3][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
701  }
702  } else if (dst_alpha) {
703  for (x = 0; x < width; x++) {
704  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
705  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
706  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
707  dst[3][x] = av_bswap16(0xFFFF >> shift);
708  }
709  } else if (src_alpha) {
710  for (x = 0; x < width; x++) {
711  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
712  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
713  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
714  src_line++;
715  }
716  } else {
717  for (x = 0; x < width; x++) {
718  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
719  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
720  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
721  }
722  }
723  break;
724  case 2:
725  if (src_alpha && dst_alpha) {
726  for (x = 0; x < width; x++) {
727  dst[0][x] = av_bswap16(*src_line++ >> shift);
728  dst[1][x] = av_bswap16(*src_line++ >> shift);
729  dst[2][x] = av_bswap16(*src_line++ >> shift);
730  dst[3][x] = av_bswap16(*src_line++ >> shift);
731  }
732  } else if (dst_alpha) {
733  for (x = 0; x < width; x++) {
734  dst[0][x] = av_bswap16(*src_line++ >> shift);
735  dst[1][x] = av_bswap16(*src_line++ >> shift);
736  dst[2][x] = av_bswap16(*src_line++ >> shift);
737  dst[3][x] = av_bswap16(0xFFFF >> shift);
738  }
739  } else if (src_alpha) {
740  for (x = 0; x < width; x++) {
741  dst[0][x] = av_bswap16(*src_line++ >> shift);
742  dst[1][x] = av_bswap16(*src_line++ >> shift);
743  dst[2][x] = av_bswap16(*src_line++ >> shift);
744  src_line++;
745  }
746  } else {
747  for (x = 0; x < width; x++) {
748  dst[0][x] = av_bswap16(*src_line++ >> shift);
749  dst[1][x] = av_bswap16(*src_line++ >> shift);
750  dst[2][x] = av_bswap16(*src_line++ >> shift);
751  }
752  }
753  break;
754  case 1:
755  if (src_alpha && dst_alpha) {
756  for (x = 0; x < width; x++) {
757  dst[0][x] = av_bswap16(*src_line++) >> shift;
758  dst[1][x] = av_bswap16(*src_line++) >> shift;
759  dst[2][x] = av_bswap16(*src_line++) >> shift;
760  dst[3][x] = av_bswap16(*src_line++) >> shift;
761  }
762  } else if (dst_alpha) {
763  for (x = 0; x < width; x++) {
764  dst[0][x] = av_bswap16(*src_line++) >> shift;
765  dst[1][x] = av_bswap16(*src_line++) >> shift;
766  dst[2][x] = av_bswap16(*src_line++) >> shift;
767  dst[3][x] = 0xFFFF >> shift;
768  }
769  } else if (src_alpha) {
770  for (x = 0; x < width; x++) {
771  dst[0][x] = av_bswap16(*src_line++) >> shift;
772  dst[1][x] = av_bswap16(*src_line++) >> shift;
773  dst[2][x] = av_bswap16(*src_line++) >> shift;
774  src_line++;
775  }
776  } else {
777  for (x = 0; x < width; x++) {
778  dst[0][x] = av_bswap16(*src_line++) >> shift;
779  dst[1][x] = av_bswap16(*src_line++) >> shift;
780  dst[2][x] = av_bswap16(*src_line++) >> shift;
781  }
782  }
783  break;
784  default:
785  if (src_alpha && dst_alpha) {
786  for (x = 0; x < width; x++) {
787  dst[0][x] = *src_line++ >> shift;
788  dst[1][x] = *src_line++ >> shift;
789  dst[2][x] = *src_line++ >> shift;
790  dst[3][x] = *src_line++ >> shift;
791  }
792  } else if (dst_alpha) {
793  for (x = 0; x < width; x++) {
794  dst[0][x] = *src_line++ >> shift;
795  dst[1][x] = *src_line++ >> shift;
796  dst[2][x] = *src_line++ >> shift;
797  dst[3][x] = 0xFFFF >> shift;
798  }
799  } else if (src_alpha) {
800  for (x = 0; x < width; x++) {
801  dst[0][x] = *src_line++ >> shift;
802  dst[1][x] = *src_line++ >> shift;
803  dst[2][x] = *src_line++ >> shift;
804  src_line++;
805  }
806  } else {
807  for (x = 0; x < width; x++) {
808  dst[0][x] = *src_line++ >> shift;
809  dst[1][x] = *src_line++ >> shift;
810  dst[2][x] = *src_line++ >> shift;
811  }
812  }
813  }
814  for (i = 0; i < 4 && dst[i]; i++)
815  dst[i] += dstStride[i] >> 1;
816  }
817 }
818 
819 static void packed30togbra10(const uint8_t *src, int srcStride,
820  uint16_t *dst[], const int dstStride[], int srcSliceH,
821  int swap, int bpc, int width)
822 {
823  int x, h, i;
824  int dst_alpha = dst[3] != NULL;
825  int scale_high = bpc - 10, scale_low = 10 - scale_high;
826  uint16_t alpha_val = (1U << bpc) - 1;
827  for (h = 0; h < srcSliceH; h++) {
828  uint32_t *src_line = (uint32_t *)(src + srcStride * h);
829  unsigned component;
830 
831  switch (swap) {
832  case 3:
833  case 2:
834  if (dst_alpha) {
835  for (x = 0; x < width; x++) {
836  unsigned p = AV_RL32(src_line);
837  component = (p >> 20) & 0x3FF;
838  dst[0][x] = av_bswap16(component << scale_high | component >> scale_low);
839  component = (p >> 10) & 0x3FF;
840  dst[1][x] = av_bswap16(component << scale_high | component >> scale_low);
841  component = p & 0x3FF;
842  dst[2][x] = av_bswap16(component << scale_high | component >> scale_low);
843  dst[3][x] = av_bswap16(alpha_val);
844  src_line++;
845  }
846  } else {
847  for (x = 0; x < width; x++) {
848  unsigned p = AV_RL32(src_line);
849  component = (p >> 20) & 0x3FF;
850  dst[0][x] = av_bswap16(component << scale_high | component >> scale_low);
851  component = (p >> 10) & 0x3FF;
852  dst[1][x] = av_bswap16(component << scale_high | component >> scale_low);
853  component = p & 0x3FF;
854  dst[2][x] = av_bswap16(component << scale_high | component >> scale_low);
855  src_line++;
856  }
857  }
858  break;
859  default:
860  if (dst_alpha) {
861  for (x = 0; x < width; x++) {
862  unsigned p = AV_RL32(src_line);
863  component = (p >> 20) & 0x3FF;
864  dst[0][x] = component << scale_high | component >> scale_low;
865  component = (p >> 10) & 0x3FF;
866  dst[1][x] = component << scale_high | component >> scale_low;
867  component = p & 0x3FF;
868  dst[2][x] = component << scale_high | component >> scale_low;
869  dst[3][x] = alpha_val;
870  src_line++;
871  }
872  } else {
873  for (x = 0; x < width; x++) {
874  unsigned p = AV_RL32(src_line);
875  component = (p >> 20) & 0x3FF;
876  dst[0][x] = component << scale_high | component >> scale_low;
877  component = (p >> 10) & 0x3FF;
878  dst[1][x] = component << scale_high | component >> scale_low;
879  component = p & 0x3FF;
880  dst[2][x] = component << scale_high | component >> scale_low;
881  src_line++;
882  }
883  }
884  break;
885  }
886  for (i = 0; i < 4 && dst[i]; i++)
887  dst[i] += dstStride[i] >> 1;
888  }
889 }
890 
891 static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
892  const int srcStride[], int srcSliceY, int srcSliceH,
893  uint8_t *const dst[], const int dstStride[])
894 {
895  uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
896  uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
897  int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
898  int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
899  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
900  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
901  int bpc = dst_format->comp[0].depth;
902  int alpha = src_format->flags & AV_PIX_FMT_FLAG_ALPHA;
903  int swap = 0;
904  int i;
905 
906  if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
907  !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
908  swap++;
909  if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
910  !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
911  swap += 2;
912 
913  if ((dst_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
915  av_log(c, AV_LOG_ERROR, "unsupported conversion to planar RGB %s -> %s\n",
916  src_format->name, dst_format->name);
917  return srcSliceH;
918  }
919 
920  for (i = 0; i < 4 && dst[i]; i++) {
921  dst2013[i] += stride2013[i] * srcSliceY / 2;
922  dst1023[i] += stride1023[i] * srcSliceY / 2;
923  }
924 
925  switch (c->opts.src_format) {
926  case AV_PIX_FMT_RGB48LE:
927  case AV_PIX_FMT_RGB48BE:
928  case AV_PIX_FMT_RGBA64LE:
929  case AV_PIX_FMT_RGBA64BE:
930  packed16togbra16(src[0], srcStride[0],
931  dst2013, stride2013, srcSliceH, alpha, swap,
932  16 - bpc, c->opts.src_w);
933  break;
935  av_assert0(bpc >= 10);
936  packed30togbra10(src[0], srcStride[0],
937  dst2013, stride2013, srcSliceH, swap,
938  bpc, c->opts.src_w);
939  break;
940  case AV_PIX_FMT_BGR48LE:
941  case AV_PIX_FMT_BGR48BE:
942  case AV_PIX_FMT_BGRA64LE:
943  case AV_PIX_FMT_BGRA64BE:
944  packed16togbra16(src[0], srcStride[0],
945  dst1023, stride1023, srcSliceH, alpha, swap,
946  16 - bpc, c->opts.src_w);
947  break;
949  av_assert0(bpc >= 10);
950  packed30togbra10(src[0], srcStride[0],
951  dst1023, stride1023, srcSliceH, swap,
952  bpc, c->opts.src_w);
953  break;
954  default:
956  "unsupported conversion to planar RGB %s -> %s\n",
957  src_format->name, dst_format->name);
958  }
959 
960  return srcSliceH;
961 }
962 
963 static void gbr16ptopacked16(const uint16_t *src[], const int srcStride[],
964  uint8_t *dst, int dstStride, int srcSliceH,
965  int alpha, int swap, int bpp, int width)
966 {
967  int x, h, i;
968  int src_alpha = src[3] != NULL;
969  int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
970  for (h = 0; h < srcSliceH; h++) {
971  uint16_t *dest = (uint16_t *)(dst + dstStride * h);
972  uint16_t component;
973 
974  switch(swap) {
975  case 3:
976  if (alpha && !src_alpha) {
977  for (x = 0; x < width; x++) {
978  component = av_bswap16(src[0][x]);
979  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
980  component = av_bswap16(src[1][x]);
981  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
982  component = av_bswap16(src[2][x]);
983  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
984  *dest++ = 0xffff;
985  }
986  } else if (alpha && src_alpha) {
987  for (x = 0; x < width; x++) {
988  component = av_bswap16(src[0][x]);
989  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
990  component = av_bswap16(src[1][x]);
991  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
992  component = av_bswap16(src[2][x]);
993  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
994  component = av_bswap16(src[3][x]);
995  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
996  }
997  } else {
998  for (x = 0; x < width; x++) {
999  component = av_bswap16(src[0][x]);
1000  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1001  component = av_bswap16(src[1][x]);
1002  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1003  component = av_bswap16(src[2][x]);
1004  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
1005  }
1006  }
1007  break;
1008  case 2:
1009  if (alpha && !src_alpha) {
1010  for (x = 0; x < width; x++) {
1011  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1012  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1013  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1014  *dest++ = 0xffff;
1015  }
1016  } else if (alpha && src_alpha) {
1017  for (x = 0; x < width; x++) {
1018  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1019  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1020  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1021  *dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
1022  }
1023  } else {
1024  for (x = 0; x < width; x++) {
1025  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
1026  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
1027  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
1028  }
1029  }
1030  break;
1031  case 1:
1032  if (alpha && !src_alpha) {
1033  for (x = 0; x < width; x++) {
1034  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1035  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1036  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1037  *dest++ = 0xffff;
1038  }
1039  } else if (alpha && src_alpha) {
1040  for (x = 0; x < width; x++) {
1041  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1042  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1043  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1044  *dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
1045  }
1046  } else {
1047  for (x = 0; x < width; x++) {
1048  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
1049  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
1050  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
1051  }
1052  }
1053  break;
1054  default:
1055  if (alpha && !src_alpha) {
1056  for (x = 0; x < width; x++) {
1057  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1058  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1059  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1060  *dest++ = 0xffff;
1061  }
1062  } else if (alpha && src_alpha) {
1063  for (x = 0; x < width; x++) {
1064  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1065  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1066  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1067  *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
1068  }
1069  } else {
1070  for (x = 0; x < width; x++) {
1071  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
1072  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
1073  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
1074  }
1075  }
1076  }
1077  for (i = 0; i < 3 + src_alpha; i++)
1078  src[i] += srcStride[i] >> 1;
1079  }
1080 }
1081 
1082 static void gbr16ptopacked30(const uint16_t *src[], const int srcStride[],
1083  uint8_t *dst, int dstStride, int srcSliceH,
1084  int swap, int bpp, int width)
1085 {
1086  int x, h, i;
1087  int shift = bpp - 10;
1088  av_assert0(bpp >= 0);
1089  for (h = 0; h < srcSliceH; h++) {
1090  uint8_t *dest = dst + dstStride * h;
1091 
1092  switch(swap) {
1093  case 3:
1094  case 1:
1095  for (x = 0; x < width; x++) {
1096  unsigned C0 = av_bswap16(src[0][x]) >> shift;
1097  unsigned C1 = av_bswap16(src[1][x]) >> shift;
1098  unsigned C2 = av_bswap16(src[2][x]) >> shift;
1099  AV_WL32(dest + 4 * x, (3U << 30) + (C0 << 20) + (C1 << 10) + C2);
1100  }
1101  break;
1102  default:
1103  for (x = 0; x < width; x++) {
1104  unsigned C0 = src[0][x] >> shift;
1105  unsigned C1 = src[1][x] >> shift;
1106  unsigned C2 = src[2][x] >> shift;
1107  AV_WL32(dest + 4 * x, (3U << 30) + (C0 << 20) + (C1 << 10) + C2);
1108  }
1109  break;
1110  }
1111  for (i = 0; i < 3; i++)
1112  src[i] += srcStride[i] >> 1;
1113  }
1114 }
1115 
1116 
1117 static int planarRgb16ToRgb16Wrapper(SwsInternal *c, const uint8_t *const src[],
1118  const int srcStride[], int srcSliceY, int srcSliceH,
1119  uint8_t *const dst[], const int dstStride[])
1120 {
1121  const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
1122  const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
1123  int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1124  int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1125  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->opts.src_format);
1126  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->opts.dst_format);
1127  int bits_per_sample = src_format->comp[0].depth;
1128  int swap = 0;
1129  if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
1130  !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
1131  swap++;
1132  if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
1133  !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
1134  swap += 2;
1135 
1136  if ((src_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
1138  bits_per_sample <= 8) {
1139  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1140  src_format->name, dst_format->name);
1141  return srcSliceH;
1142  }
1143  switch (c->opts.dst_format) {
1144  case AV_PIX_FMT_BGR48LE:
1145  case AV_PIX_FMT_BGR48BE:
1146  gbr16ptopacked16(src102, stride102,
1147  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1148  srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1149  break;
1150  case AV_PIX_FMT_RGB48LE:
1151  case AV_PIX_FMT_RGB48BE:
1152  gbr16ptopacked16(src201, stride201,
1153  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1154  srcSliceH, 0, swap, bits_per_sample, c->opts.src_w);
1155  break;
1156  case AV_PIX_FMT_RGBA64LE:
1157  case AV_PIX_FMT_RGBA64BE:
1158  gbr16ptopacked16(src201, stride201,
1159  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1160  srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1161  break;
1162  case AV_PIX_FMT_BGRA64LE:
1163  case AV_PIX_FMT_BGRA64BE:
1164  gbr16ptopacked16(src102, stride102,
1165  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1166  srcSliceH, 1, swap, bits_per_sample, c->opts.src_w);
1167  break;
1168  case AV_PIX_FMT_X2RGB10LE:
1169  gbr16ptopacked30(src201, stride201,
1170  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1171  srcSliceH, swap, bits_per_sample, c->opts.src_w);
1172  break;
1173  case AV_PIX_FMT_X2BGR10LE:
1174  gbr16ptopacked30(src102, stride102,
1175  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1176  srcSliceH, swap, bits_per_sample, c->opts.src_w);
1177  break;
1178  default:
1180  "unsupported planar RGB conversion %s -> %s\n",
1181  src_format->name, dst_format->name);
1182  }
1183 
1184  return srcSliceH;
1185 }
1186 
1187 static void gbr24ptopacked24(const uint8_t *src[], const int srcStride[],
1188  uint8_t *dst, int dstStride, int srcSliceH,
1189  int width)
1190 {
1191  int x, h, i;
1192  for (h = 0; h < srcSliceH; h++) {
1193  uint8_t *dest = dst + dstStride * h;
1194  for (x = 0; x < width; x++) {
1195  *dest++ = src[0][x];
1196  *dest++ = src[1][x];
1197  *dest++ = src[2][x];
1198  }
1199 
1200  for (i = 0; i < 3; i++)
1201  src[i] += srcStride[i];
1202  }
1203 }
1204 
1205 static void gbr24ptopacked32(const uint8_t *src[], const int srcStride[],
1206  uint8_t *dst, int dstStride, int srcSliceH,
1207  int alpha_first, int width)
1208 {
1209  int x, h, i;
1210  for (h = 0; h < srcSliceH; h++) {
1211  uint8_t *dest = dst + dstStride * h;
1212 
1213  if (alpha_first) {
1214  for (x = 0; x < width; x++) {
1215  *dest++ = 0xff;
1216  *dest++ = src[0][x];
1217  *dest++ = src[1][x];
1218  *dest++ = src[2][x];
1219  }
1220  } else {
1221  for (x = 0; x < width; x++) {
1222  *dest++ = src[0][x];
1223  *dest++ = src[1][x];
1224  *dest++ = src[2][x];
1225  *dest++ = 0xff;
1226  }
1227  }
1228 
1229  for (i = 0; i < 3; i++)
1230  src[i] += srcStride[i];
1231  }
1232 }
1233 
1234 static void gbraptopacked32(const uint8_t *src[], const int srcStride[],
1235  uint8_t *dst, int dstStride, int srcSliceH,
1236  int alpha_first, int width)
1237 {
1238  int x, h, i;
1239  for (h = 0; h < srcSliceH; h++) {
1240  uint8_t *dest = dst + dstStride * h;
1241 
1242  if (alpha_first) {
1243  for (x = 0; x < width; x++) {
1244  *dest++ = src[3][x];
1245  *dest++ = src[0][x];
1246  *dest++ = src[1][x];
1247  *dest++ = src[2][x];
1248  }
1249  } else {
1250  for (x = 0; x < width; x++) {
1251  *dest++ = src[0][x];
1252  *dest++ = src[1][x];
1253  *dest++ = src[2][x];
1254  *dest++ = src[3][x];
1255  }
1256  }
1257 
1258  for (i = 0; i < 4; i++)
1259  src[i] += srcStride[i];
1260  }
1261 }
1262 
1263 static int planarRgbaToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1264  const int srcStride[], int srcSliceY, int srcSliceH,
1265  uint8_t *const dst[], const int dstStride[])
1266 {
1267  int alpha_first = 0;
1268  const uint8_t *src102[] = { src[1], src[0], src[2], src[3] };
1269  const uint8_t *src201[] = { src[2], src[0], src[1], src[3] };
1270  int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1271  int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1272 
1273  if (c->opts.src_format != AV_PIX_FMT_GBRAP) {
1274  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1275  av_get_pix_fmt_name(c->opts.src_format),
1276  av_get_pix_fmt_name(c->opts.dst_format));
1277  return srcSliceH;
1278  }
1279 
1280  switch (c->opts.dst_format) {
1281  case AV_PIX_FMT_BGR24:
1282  gbr24ptopacked24(src102, stride102,
1283  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1284  srcSliceH, c->opts.src_w);
1285  break;
1286 
1287  case AV_PIX_FMT_RGB24:
1288  gbr24ptopacked24(src201, stride201,
1289  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1290  srcSliceH, c->opts.src_w);
1291  break;
1292 
1293  case AV_PIX_FMT_ARGB:
1294  alpha_first = 1;
1296  case AV_PIX_FMT_RGBA:
1297  gbraptopacked32(src201, stride201,
1298  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1299  srcSliceH, alpha_first, c->opts.src_w);
1300  break;
1301 
1302  case AV_PIX_FMT_ABGR:
1303  alpha_first = 1;
1305  case AV_PIX_FMT_BGRA:
1306  gbraptopacked32(src102, stride102,
1307  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1308  srcSliceH, alpha_first, c->opts.src_w);
1309  break;
1310 
1311  default:
1313  "unsupported planar RGB conversion %s -> %s\n",
1314  av_get_pix_fmt_name(c->opts.src_format),
1315  av_get_pix_fmt_name(c->opts.dst_format));
1316  }
1317 
1318  return srcSliceH;
1319 }
1320 
1321 static int planarRgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1322  const int srcStride[], int srcSliceY, int srcSliceH,
1323  uint8_t *const dst[], const int dstStride[])
1324 {
1325  int alpha_first = 0;
1326  const uint8_t *src102[] = { src[1], src[0], src[2] };
1327  const uint8_t *src201[] = { src[2], src[0], src[1] };
1328  int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
1329  int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
1330 
1331  if (c->opts.src_format != AV_PIX_FMT_GBRP) {
1332  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1333  av_get_pix_fmt_name(c->opts.src_format),
1334  av_get_pix_fmt_name(c->opts.dst_format));
1335  return srcSliceH;
1336  }
1337 
1338  switch (c->opts.dst_format) {
1339  case AV_PIX_FMT_BGR24:
1340  gbr24ptopacked24(src102, stride102,
1341  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1342  srcSliceH, c->opts.src_w);
1343  break;
1344 
1345  case AV_PIX_FMT_RGB24:
1346  gbr24ptopacked24(src201, stride201,
1347  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1348  srcSliceH, c->opts.src_w);
1349  break;
1350 
1351  case AV_PIX_FMT_ARGB:
1352  alpha_first = 1;
1354  case AV_PIX_FMT_RGBA:
1355  gbr24ptopacked32(src201, stride201,
1356  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1357  srcSliceH, alpha_first, c->opts.src_w);
1358  break;
1359 
1360  case AV_PIX_FMT_ABGR:
1361  alpha_first = 1;
1363  case AV_PIX_FMT_BGRA:
1364  gbr24ptopacked32(src102, stride102,
1365  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1366  srcSliceH, alpha_first, c->opts.src_w);
1367  break;
1368 
1369  default:
1371  "unsupported planar RGB conversion %s -> %s\n",
1372  av_get_pix_fmt_name(c->opts.src_format),
1373  av_get_pix_fmt_name(c->opts.dst_format));
1374  }
1375 
1376  return srcSliceH;
1377 }
1378 
1380  const uint8_t *const src[], const int srcStride[],
1381  int srcSliceY, int srcSliceH,
1382  uint8_t *const dst[], const int dstStride[])
1383 {
1384  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
1385  dst[0], dstStride[0]);
1386  ff_copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->opts.src_w,
1387  dst[1], dstStride[1]);
1388  ff_copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->opts.src_w,
1389  dst[2], dstStride[2]);
1390  if (dst[3]) {
1391  if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
1392  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
1393  fillPlane16(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 1,
1394  desc_dst->comp[3].depth, isBE(c->opts.dst_format));
1395  } else {
1396  fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
1397  }
1398  }
1399 
1400  return srcSliceH;
1401 }
1402 
1403 static void packedtogbr24p(const uint8_t *src, int srcStride,
1404  uint8_t *const dst[], const int dstStride[], int srcSliceH,
1405  int alpha_first, int inc_size, int width)
1406 {
1407  uint8_t *dest[3];
1408  int x, h;
1409 
1410  dest[0] = dst[0];
1411  dest[1] = dst[1];
1412  dest[2] = dst[2];
1413 
1414  if (alpha_first)
1415  src++;
1416 
1417  for (h = 0; h < srcSliceH; h++) {
1418  for (x = 0; x < width; x++) {
1419  dest[0][x] = src[0];
1420  dest[1][x] = src[1];
1421  dest[2][x] = src[2];
1422 
1423  src += inc_size;
1424  }
1425  src += srcStride - width * inc_size;
1426  dest[0] += dstStride[0];
1427  dest[1] += dstStride[1];
1428  dest[2] += dstStride[2];
1429  }
1430 }
1431 
1432 static int rgbToPlanarRgbWrapper(SwsInternal *c, const uint8_t *const src[],
1433  const int srcStride[], int srcSliceY, int srcSliceH,
1434  uint8_t *const dst[], const int dstStride[])
1435 {
1436  int alpha_first = 0;
1437  int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1438  int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1439  uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1440  dst[0] + srcSliceY * dstStride[0],
1441  dst[2] + srcSliceY * dstStride[2] };
1442  uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1443  dst[0] + srcSliceY * dstStride[0],
1444  dst[1] + srcSliceY * dstStride[1] };
1445 
1446  switch (c->opts.src_format) {
1447  case AV_PIX_FMT_RGB24:
1448  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1449  stride201, srcSliceH, alpha_first, 3, c->opts.src_w);
1450  break;
1451  case AV_PIX_FMT_BGR24:
1452  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1453  stride102, srcSliceH, alpha_first, 3, c->opts.src_w);
1454  break;
1455  case AV_PIX_FMT_ARGB:
1456  alpha_first = 1;
1458  case AV_PIX_FMT_RGBA:
1459  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1460  stride201, srcSliceH, alpha_first, 4, c->opts.src_w);
1461  break;
1462  case AV_PIX_FMT_ABGR:
1463  alpha_first = 1;
1465  case AV_PIX_FMT_BGRA:
1466  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1467  stride102, srcSliceH, alpha_first, 4, c->opts.src_w);
1468  break;
1469  default:
1471  "unsupported planar RGB conversion %s -> %s\n",
1472  av_get_pix_fmt_name(c->opts.src_format),
1473  av_get_pix_fmt_name(c->opts.dst_format));
1474  }
1475 
1476  return srcSliceH;
1477 }
1478 
1479 static void packed24togbrap(const uint8_t *src, int srcStride,
1480  uint8_t *const dst[], const int dstStride[],
1481  int srcSliceH, int width)
1482 {
1483  uint8_t *dest[4];
1484  int x, h;
1485 
1486  dest[0] = dst[0];
1487  dest[1] = dst[1];
1488  dest[2] = dst[2];
1489  dest[3] = dst[3];
1490 
1491  for (h = 0; h < srcSliceH; h++) {
1492  for (x = 0; x < width; x++) {
1493  dest[0][x] = src[x * 3 + 0];
1494  dest[1][x] = src[x * 3 + 1];
1495  dest[2][x] = src[x * 3 + 2];
1496  dest[3][x] = 0xff;
1497  }
1498  src += srcStride;
1499  dest[0] += dstStride[0];
1500  dest[1] += dstStride[1];
1501  dest[2] += dstStride[2];
1502  dest[3] += dstStride[3];
1503  }
1504 }
1505 
1506 static void packed32togbrap(const uint8_t *src, int srcStride,
1507  uint8_t *const dst[], const int dstStride[],
1508  int srcSliceH, int alpha_first, int width)
1509 {
1510  uint8_t *dest[4];
1511  int x, h;
1512 
1513  dest[0] = dst[0];
1514  dest[1] = dst[1];
1515  dest[2] = dst[2];
1516  dest[3] = dst[3];
1517 
1518  for (h = 0; h < srcSliceH; h++) {
1519  if (alpha_first) {
1520  for (x = 0; x < width; x++) {
1521  dest[0][x] = src[x * 4 + 1];
1522  dest[1][x] = src[x * 4 + 2];
1523  dest[2][x] = src[x * 4 + 3];
1524  dest[3][x] = src[x * 4 + 0];
1525  }
1526  } else {
1527  for (x = 0; x < width; x++) {
1528  dest[0][x] = src[x * 4 + 0];
1529  dest[1][x] = src[x * 4 + 1];
1530  dest[2][x] = src[x * 4 + 2];
1531  dest[3][x] = src[x * 4 + 3];
1532  }
1533  }
1534  src += srcStride;
1535  dest[0] += dstStride[0];
1536  dest[1] += dstStride[1];
1537  dest[2] += dstStride[2];
1538  dest[3] += dstStride[3];
1539  }
1540 }
1541 
1542 static int rgbToPlanarRgbaWrapper(SwsInternal *c, const uint8_t *const src[],
1543  const int srcStride[], int srcSliceY, int srcSliceH,
1544  uint8_t *const dst[], const int dstStride[])
1545 {
1546  int alpha_first = 0;
1547  int stride102[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
1548  int stride201[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
1549  uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1550  dst[0] + srcSliceY * dstStride[0],
1551  dst[2] + srcSliceY * dstStride[2],
1552  dst[3] + srcSliceY * dstStride[3] };
1553  uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1554  dst[0] + srcSliceY * dstStride[0],
1555  dst[1] + srcSliceY * dstStride[1],
1556  dst[3] + srcSliceY * dstStride[3] };
1557 
1558  switch (c->opts.src_format) {
1559  case AV_PIX_FMT_RGB24:
1560  packed24togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1561  stride201, srcSliceH, c->opts.src_w);
1562  break;
1563  case AV_PIX_FMT_BGR24:
1564  packed24togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1565  stride102, srcSliceH, c->opts.src_w);
1566  break;
1567  case AV_PIX_FMT_ARGB:
1568  alpha_first = 1;
1570  case AV_PIX_FMT_RGBA:
1571  packed32togbrap((const uint8_t *) src[0], srcStride[0], dst201,
1572  stride201, srcSliceH, alpha_first, c->opts.src_w);
1573  break;
1574  case AV_PIX_FMT_ABGR:
1575  alpha_first = 1;
1577  case AV_PIX_FMT_BGRA:
1578  packed32togbrap((const uint8_t *) src[0], srcStride[0], dst102,
1579  stride102, srcSliceH, alpha_first, c->opts.src_w);
1580  break;
1581  default:
1583  "unsupported planar RGB conversion %s -> %s\n",
1584  av_get_pix_fmt_name(c->opts.src_format),
1585  av_get_pix_fmt_name(c->opts.dst_format));
1586  }
1587 
1588  return srcSliceH;
1589 }
1590 
1591 #define BAYER_GBRG
1592 #define BAYER_8
1593 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1594 #include "bayer_template.c"
1595 
1596 #define BAYER_GBRG
1597 #define BAYER_16LE
1598 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1599 #include "bayer_template.c"
1600 
1601 #define BAYER_GBRG
1602 #define BAYER_16BE
1603 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1604 #include "bayer_template.c"
1605 
1606 #define BAYER_GRBG
1607 #define BAYER_8
1608 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1609 #include "bayer_template.c"
1610 
1611 #define BAYER_GRBG
1612 #define BAYER_16LE
1613 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1614 #include "bayer_template.c"
1615 
1616 #define BAYER_GRBG
1617 #define BAYER_16BE
1618 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1619 #include "bayer_template.c"
1620 
1621 #define BAYER_BGGR
1622 #define BAYER_8
1623 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1624 #include "bayer_template.c"
1625 
1626 #define BAYER_BGGR
1627 #define BAYER_16LE
1628 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1629 #include "bayer_template.c"
1630 
1631 #define BAYER_BGGR
1632 #define BAYER_16BE
1633 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1634 #include "bayer_template.c"
1635 
1636 #define BAYER_RGGB
1637 #define BAYER_8
1638 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1639 #include "bayer_template.c"
1640 
1641 #define BAYER_RGGB
1642 #define BAYER_16LE
1643 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1644 #include "bayer_template.c"
1645 
1646 #define BAYER_RGGB
1647 #define BAYER_16BE
1648 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1649 #include "bayer_template.c"
1650 
1651 static int bayer_to_rgb24_wrapper(SwsInternal *c, const uint8_t *const src[],
1652  const int srcStride[], int srcSliceY, int srcSliceH,
1653  uint8_t *const dst[], const int dstStride[])
1654 {
1655  uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1656  const uint8_t *srcPtr= src[0];
1657  int i;
1658  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1659  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1660 
1661  switch(c->opts.src_format) {
1662 #define CASE(pixfmt, prefix) \
1663  case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1664  interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1665  break;
1667  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1668  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1670  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1671  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1673  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1674  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1676  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1677  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1678 #undef CASE
1679  default: return 0;
1680  }
1681 
1682  av_assert0(srcSliceH > 1);
1683 
1684  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1685  srcPtr += 2 * srcStride[0];
1686  dstPtr += 2 * dstStride[0];
1687 
1688  for (i = 2; i < srcSliceH - 2; i += 2) {
1689  interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1690  srcPtr += 2 * srcStride[0];
1691  dstPtr += 2 * dstStride[0];
1692  }
1693 
1694  if (i + 1 == srcSliceH) {
1695  copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1696  } else if (i < srcSliceH)
1697  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1698  return srcSliceH;
1699 }
1700 
1701 static int bayer_to_rgb48_wrapper(SwsInternal *c, const uint8_t *const src[],
1702  const int srcStride[], int srcSliceY, int srcSliceH,
1703  uint8_t *const dst[], const int dstStride[])
1704 {
1705  uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1706  const uint8_t *srcPtr= src[0];
1707  int i;
1708  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1709  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1710 
1711  switch(c->opts.src_format) {
1712 #define CASE(pixfmt, prefix) \
1713  case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
1714  interpolate = bayer_##prefix##_to_rgb48_interpolate; \
1715  break;
1717  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1718  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1720  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1721  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1723  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1724  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1726  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1727  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1728 #undef CASE
1729  default: return 0;
1730  }
1731 
1732  av_assert0(srcSliceH > 1);
1733 
1734  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1735  srcPtr += 2 * srcStride[0];
1736  dstPtr += 2 * dstStride[0];
1737 
1738  for (i = 2; i < srcSliceH - 2; i += 2) {
1739  interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1740  srcPtr += 2 * srcStride[0];
1741  dstPtr += 2 * dstStride[0];
1742  }
1743 
1744  if (i + 1 == srcSliceH) {
1745  copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->opts.src_w);
1746  } else if (i < srcSliceH)
1747  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->opts.src_w);
1748  return srcSliceH;
1749 }
1750 
1751 static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[],
1752  const int srcStride[], int srcSliceY, int srcSliceH,
1753  uint8_t *const dst[], const int dstStride[])
1754 {
1755  const uint8_t *srcPtr= src[0];
1756  uint8_t *dstY= dst[0] + srcSliceY * dstStride[0];
1757  uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1758  uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1759  int i;
1760  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, const int32_t *rgb2yuv);
1761  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, const int32_t *rgb2yuv);
1762 
1763  switch(c->opts.src_format) {
1764 #define CASE(pixfmt, prefix) \
1765  case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1766  interpolate = bayer_##prefix##_to_yv12_interpolate; \
1767  break;
1769  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1770  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1772  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1773  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1775  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1776  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1778  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1779  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1780 #undef CASE
1781  default: return 0;
1782  }
1783 
1784  av_assert0(srcSliceH > 1);
1785 
1786  copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1787  srcPtr += 2 * srcStride[0];
1788  dstY += 2 * dstStride[0];
1789  dstU += dstStride[1];
1790  dstV += dstStride[1];
1791 
1792  for (i = 2; i < srcSliceH - 2; i += 2) {
1793  interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1794  srcPtr += 2 * srcStride[0];
1795  dstY += 2 * dstStride[0];
1796  dstU += dstStride[1];
1797  dstV += dstStride[1];
1798  }
1799 
1800  if (i + 1 == srcSliceH) {
1801  copy(srcPtr, -srcStride[0], dstY, dstU, dstV, -dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1802  } else if (i < srcSliceH)
1803  copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->opts.src_w, c->input_rgb2yuv_table);
1804  return srcSliceH;
1805 }
1806 
1807 #define isRGBA32(x) ( \
1808  (x) == AV_PIX_FMT_ARGB \
1809  || (x) == AV_PIX_FMT_RGBA \
1810  || (x) == AV_PIX_FMT_BGRA \
1811  || (x) == AV_PIX_FMT_ABGR \
1812  )
1813 
1814 #define isRGBA64(x) ( \
1815  (x) == AV_PIX_FMT_RGBA64LE \
1816  || (x) == AV_PIX_FMT_RGBA64BE \
1817  || (x) == AV_PIX_FMT_BGRA64LE \
1818  || (x) == AV_PIX_FMT_BGRA64BE \
1819  )
1820 
1821 #define isRGB48(x) ( \
1822  (x) == AV_PIX_FMT_RGB48LE \
1823  || (x) == AV_PIX_FMT_RGB48BE \
1824  || (x) == AV_PIX_FMT_BGR48LE \
1825  || (x) == AV_PIX_FMT_BGR48BE \
1826  )
1827 
1828 #define isAYUV(x) ( \
1829  (x) == AV_PIX_FMT_AYUV \
1830  || (x) == AV_PIX_FMT_VUYA \
1831  || (x) == AV_PIX_FMT_VUYX \
1832  || (x) == AV_PIX_FMT_UYVA \
1833  )
1834 
1835 #define isX2RGB(x) ( \
1836  (x) == AV_PIX_FMT_X2RGB10LE \
1837  || (x) == AV_PIX_FMT_X2BGR10LE \
1838  )
1839 
1840 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1841 typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1843 {
1844  const enum AVPixelFormat srcFormat = c->opts.src_format;
1845  const enum AVPixelFormat dstFormat = c->opts.dst_format;
1846  const int srcId = c->srcFormatBpp;
1847  const int dstId = c->dstFormatBpp;
1848  rgbConvFn conv = NULL;
1849 
1850 #define IS_NOT_NE(bpp, desc) \
1851  (((bpp + 7) >> 3) == 2 && \
1852  (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1853 
1854 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1855 
1856  if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
1857  if ( CONV_IS(ABGR, RGBA)
1858  || CONV_IS(ARGB, BGRA)
1859  || CONV_IS(BGRA, ARGB)
1860  || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
1861  else if (CONV_IS(ABGR, ARGB)
1862  || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
1863  else if (CONV_IS(ABGR, BGRA)
1864  || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
1865  else if (CONV_IS(BGRA, RGBA)
1866  || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
1867  else if (CONV_IS(BGRA, ABGR)
1868  || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
1869  } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
1870  if (CONV_IS(RGB48LE, BGR48LE)
1871  || CONV_IS(BGR48LE, RGB48LE)
1872  || CONV_IS(RGB48BE, BGR48BE)
1873  || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
1874  else if (CONV_IS(RGB48LE, BGR48BE)
1875  || CONV_IS(BGR48LE, RGB48BE)
1876  || CONV_IS(RGB48BE, BGR48LE)
1877  || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
1878  } else if (isRGB48(srcFormat) && isRGBA64(dstFormat)) {
1879  if (CONV_IS(RGB48LE, BGRA64LE)
1880  || CONV_IS(BGR48LE, RGBA64LE)
1881  || CONV_IS(RGB48BE, BGRA64BE)
1882  || CONV_IS(BGR48BE, RGBA64BE)) conv = rgb48tobgr64_nobswap;
1883  else if (CONV_IS(RGB48LE, BGRA64BE)
1884  || CONV_IS(BGR48LE, RGBA64BE)
1885  || CONV_IS(RGB48BE, BGRA64LE)
1886  || CONV_IS(BGR48BE, RGBA64LE)) conv = rgb48tobgr64_bswap;
1887  if (CONV_IS(RGB48LE, RGBA64LE)
1888  || CONV_IS(BGR48LE, BGRA64LE)
1889  || CONV_IS(RGB48BE, RGBA64BE)
1890  || CONV_IS(BGR48BE, BGRA64BE)) conv = rgb48to64_nobswap;
1891  else if (CONV_IS(RGB48LE, RGBA64BE)
1892  || CONV_IS(BGR48LE, BGRA64BE)
1893  || CONV_IS(RGB48BE, RGBA64LE)
1894  || CONV_IS(BGR48BE, BGRA64LE)) conv = rgb48to64_bswap;
1895  } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
1896  if (CONV_IS(RGBA64LE, BGR48LE)
1897  || CONV_IS(BGRA64LE, RGB48LE)
1898  || CONV_IS(RGBA64BE, BGR48BE)
1899  || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
1900  else if (CONV_IS(RGBA64LE, BGR48BE)
1901  || CONV_IS(BGRA64LE, RGB48BE)
1902  || CONV_IS(RGBA64BE, BGR48LE)
1903  || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
1904  else if (CONV_IS(RGBA64LE, RGB48LE)
1905  || CONV_IS(BGRA64LE, BGR48LE)
1906  || CONV_IS(RGBA64BE, RGB48BE)
1907  || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
1908  else if (CONV_IS(RGBA64LE, RGB48BE)
1909  || CONV_IS(BGRA64LE, BGR48BE)
1910  || CONV_IS(RGBA64BE, RGB48LE)
1911  || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
1912  } else if (isX2RGB(srcFormat) && isRGB48(dstFormat)) {
1913  if (CONV_IS(X2RGB10LE, RGB48LE)
1914  || CONV_IS(X2BGR10LE, BGR48LE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_bswap
1916  else if (CONV_IS(X2RGB10LE, RGB48BE)
1917  || CONV_IS(X2BGR10LE, BGR48BE)) conv = HAVE_BIGENDIAN ? x2rgb10to48_nobswap
1919  else if (CONV_IS(X2RGB10LE, BGR48LE)
1920  || CONV_IS(X2BGR10LE, RGB48LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_bswap
1922  else if (CONV_IS(X2RGB10LE, BGR48BE)
1923  || CONV_IS(X2BGR10LE, RGB48BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr48_nobswap
1925  } else if (isX2RGB(srcFormat) && isRGBA64(dstFormat)) {
1926  if (CONV_IS(X2RGB10LE, RGBA64LE)
1927  || CONV_IS(X2BGR10LE, BGRA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_bswap
1929  else if (CONV_IS(X2RGB10LE, RGBA64BE)
1930  || CONV_IS(X2BGR10LE, BGRA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10to64_nobswap
1932  else if (CONV_IS(X2RGB10LE, BGRA64LE)
1933  || CONV_IS(X2BGR10LE, RGBA64LE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_bswap
1935  else if (CONV_IS(X2RGB10LE, BGRA64BE)
1936  || CONV_IS(X2BGR10LE, RGBA64BE)) conv = HAVE_BIGENDIAN ? x2rgb10tobgr64_nobswap
1938  } else if (isAYUV(srcFormat) && isAYUV(dstFormat)) {
1939  /* VUYX only for dst, to avoid copying undefined bytes */
1940  if ( CONV_IS(AYUV, VUYA)
1941  || CONV_IS(AYUV, VUYX)
1942  || CONV_IS(VUYA, AYUV)) conv = shuffle_bytes_3210;
1943  else if (CONV_IS(AYUV, UYVA)) conv = shuffle_bytes_2130;
1944  else if (CONV_IS(VUYA, UYVA)) conv = shuffle_bytes_1203;
1945  else if (CONV_IS(UYVA, AYUV)) conv = shuffle_bytes_3102;
1946  else if (CONV_IS(UYVA, VUYA)
1947  || CONV_IS(UYVA, VUYX)) conv = shuffle_bytes_2013;
1948  } else
1949  /* BGR -> BGR */
1950  if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
1951  (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
1952  switch (srcId | (dstId << 16)) {
1953  case 0x000F000C: conv = rgb12to15; break;
1954  case 0x000F0010: conv = rgb16to15; break;
1955  case 0x000F0018: conv = rgb24to15; break;
1956  case 0x000F0020: conv = rgb32to15; break;
1957  case 0x0010000F: conv = rgb15to16; break;
1958  case 0x00100018: conv = rgb24to16; break;
1959  case 0x00100020: conv = rgb32to16; break;
1960  case 0x0018000F: conv = rgb15to24; break;
1961  case 0x00180010: conv = rgb16to24; break;
1962  case 0x00180020: conv = rgb32to24; break;
1963  case 0x0020000F: conv = rgb15to32; break;
1964  case 0x00200010: conv = rgb16to32; break;
1965  case 0x00200018: conv = rgb24to32; break;
1966  }
1967  } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
1968  (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
1969  switch (srcId | (dstId << 16)) {
1970  case 0x000C000C: conv = rgb12tobgr12; break;
1971  case 0x000F000F: conv = rgb15tobgr15; break;
1972  case 0x000F0010: conv = rgb16tobgr15; break;
1973  case 0x000F0018: conv = rgb24tobgr15; break;
1974  case 0x000F0020: conv = rgb32tobgr15; break;
1975  case 0x0010000F: conv = rgb15tobgr16; break;
1976  case 0x00100010: conv = rgb16tobgr16; break;
1977  case 0x00100018: conv = rgb24tobgr16; break;
1978  case 0x00100020: conv = rgb32tobgr16; break;
1979  case 0x0018000F: conv = rgb15tobgr24; break;
1980  case 0x00180010: conv = rgb16tobgr24; break;
1981  case 0x00180018: conv = rgb24tobgr24; break;
1982  case 0x00180020: conv = rgb32tobgr24; break;
1983  case 0x0020000F: conv = rgb15tobgr32; break;
1984  case 0x00200010: conv = rgb16tobgr32; break;
1985  case 0x00200018: conv = rgb24tobgr32; break;
1986  }
1987  }
1988 
1989  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
1990  return NULL;
1991 
1992  // Maintain symmetry between endianness
1993  if (c->opts.flags & SWS_BITEXACT)
1994  if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0)
1995  return NULL;
1996 
1997  return conv;
1998 }
1999 
2000 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
2001 static int rgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[],
2002  int srcSliceY, int srcSliceH, uint8_t *const dst[],
2003  const int dstStride[])
2004 
2005 {
2006  const enum AVPixelFormat srcFormat = c->opts.src_format;
2007  const enum AVPixelFormat dstFormat = c->opts.dst_format;
2008  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2009  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2010  const int srcBpp = desc_src->comp[0].step;
2011  const int dstBpp = desc_dst->comp[0].step;
2012  rgbConvFn conv = findRgbConvFn(c);
2013 
2014  if (!conv) {
2015  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
2016  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
2017  } else {
2018  const uint8_t *srcPtr = src[0];
2019  uint8_t *dstPtr = dst[0];
2020  int src_bswap = IS_NOT_NE(srcBpp, desc_src);
2021  int dst_bswap = IS_NOT_NE(dstBpp, desc_dst);
2022 
2023  if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
2024  !isRGBA32(dstFormat))
2025  srcPtr += ALT32_CORR;
2026 
2027  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
2028  !isRGBA32(srcFormat)) {
2029  int i;
2030  av_assert0(ALT32_CORR == 1);
2031  for (i = 0; i < srcSliceH; i++)
2032  dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
2033  dstPtr += ALT32_CORR;
2034  }
2035 
2036  if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
2037  !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
2038  conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
2039  (srcSliceH - 1) * srcStride[0] + c->opts.src_w * srcBpp);
2040  else {
2041  int i, j;
2042  dstPtr += dstStride[0] * srcSliceY;
2043 
2044  for (i = 0; i < srcSliceH; i++) {
2045  if(src_bswap) {
2046  for(j=0; j<c->opts.src_w; j++)
2047  ((uint16_t*)c->formatConvBuffer)[j] = av_bswap16(((uint16_t*)srcPtr)[j]);
2048  conv(c->formatConvBuffer, dstPtr, c->opts.src_w * srcBpp);
2049  }else
2050  conv(srcPtr, dstPtr, c->opts.src_w * srcBpp);
2051  if(dst_bswap)
2052  for(j=0; j<c->opts.src_w; j++)
2053  ((uint16_t*)dstPtr)[j] = av_bswap16(((uint16_t*)dstPtr)[j]);
2054  srcPtr += srcStride[0];
2055  dstPtr += dstStride[0];
2056  }
2057  }
2058  }
2059  return srcSliceH;
2060 }
2061 
2062 static int bgr24ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[],
2063  const int srcStride[], int srcSliceY, int srcSliceH,
2064  uint8_t *const dst[], const int dstStride[])
2065 {
2067  src[0],
2068  dst[0] + srcSliceY * dstStride[0],
2069  dst[1] + (srcSliceY >> 1) * dstStride[1],
2070  dst[2] + (srcSliceY >> 1) * dstStride[2],
2071  c->opts.src_w, srcSliceH,
2072  dstStride[0], dstStride[1], srcStride[0],
2073  c->input_rgb2yuv_table);
2074  if (dst[3])
2075  fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
2076  return srcSliceH;
2077 }
2078 
2079 static int yvu9ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[],
2080  const int srcStride[], int srcSliceY, int srcSliceH,
2081  uint8_t *const dst[], const int dstStride[])
2082 {
2083  ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
2084  dst[0], dstStride[0]);
2085 
2086  planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->chrSrcW,
2087  srcSliceH >> 2, srcStride[1], dstStride[1]);
2088  planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->chrSrcW,
2089  srcSliceH >> 2, srcStride[2], dstStride[2]);
2090  if (dst[3])
2091  fillPlane(dst[3], dstStride[3], c->opts.src_w, srcSliceH, srcSliceY, 255);
2092  return srcSliceH;
2093 }
2094 
2095 static int uint_y_to_float_y_wrapper(SwsInternal *c, const uint8_t *const src[],
2096  const int srcStride[], int srcSliceY,
2097  int srcSliceH, uint8_t *const dst[], const int dstStride[])
2098 {
2099  int y, x;
2100  ptrdiff_t dstStrideFloat = dstStride[0] >> 2;
2101  const uint8_t *srcPtr = src[0];
2102  float *dstPtr = (float *)(dst[0] + dstStride[0] * srcSliceY);
2103 
2104  for (y = 0; y < srcSliceH; ++y){
2105  for (x = 0; x < c->opts.src_w; ++x){
2106  dstPtr[x] = c->uint2float_lut[srcPtr[x]];
2107  }
2108  srcPtr += srcStride[0];
2109  dstPtr += dstStrideFloat;
2110  }
2111 
2112  return srcSliceH;
2113 }
2114 
2116  const uint8_t *const src[],
2117  const int srcStride[], int srcSliceY,
2118  int srcSliceH, uint8_t *const dst[],
2119  const int dstStride[])
2120 {
2121  int y, x;
2122  ptrdiff_t srcStrideFloat = srcStride[0] >> 2;
2123  const float *srcPtr = (const float *)src[0];
2124  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
2125 
2126  for (y = 0; y < srcSliceH; ++y){
2127  for (x = 0; x < c->opts.src_w; ++x){
2128  dstPtr[x] = av_clip_uint8(lrintf(255.0f * srcPtr[x]));
2129  }
2130  srcPtr += srcStrideFloat;
2131  dstPtr += dstStride[0];
2132  }
2133 
2134  return srcSliceH;
2135 }
2136 
2137 /* unscaled copy like stuff (assumes nearly identical formats) */
2138 static int packedCopyWrapper(SwsInternal *c, const uint8_t *const src[],
2139  const int srcStride[], int srcSliceY, int srcSliceH,
2140  uint8_t *const dst[], const int dstStride[])
2141 {
2142  if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
2143  memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
2144  else {
2145  int i;
2146  const uint8_t *srcPtr = src[0];
2147  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
2148 
2149  const int length = FFMIN(FFABS(dstStride[0]), FFABS(srcStride[0]));
2150  for (i = 0; i < srcSliceH; i++) {
2151  memcpy(dstPtr, srcPtr, length);
2152  srcPtr += srcStride[0];
2153  dstPtr += dstStride[0];
2154  }
2155  }
2156  return srcSliceH;
2157 }
2158 
2159 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
2160  unsigned shift= src_depth-dst_depth, tmp;\
2161  unsigned bias = 1 << (shift - 1);\
2162  if (c->opts.dither == SWS_DITHER_NONE) {\
2163  for (i = 0; i < height; i++) {\
2164  for (j = 0; j < length-7; j+=8) {\
2165  tmp = ((bswap(src[j+0]) >> src_shift) + bias)>>shift; dst[j+0] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2166  tmp = ((bswap(src[j+1]) >> src_shift) + bias)>>shift; dst[j+1] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2167  tmp = ((bswap(src[j+2]) >> src_shift) + bias)>>shift; dst[j+2] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2168  tmp = ((bswap(src[j+3]) >> src_shift) + bias)>>shift; dst[j+3] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2169  tmp = ((bswap(src[j+4]) >> src_shift) + bias)>>shift; dst[j+4] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2170  tmp = ((bswap(src[j+5]) >> src_shift) + bias)>>shift; dst[j+5] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2171  tmp = ((bswap(src[j+6]) >> src_shift) + bias)>>shift; dst[j+6] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2172  tmp = ((bswap(src[j+7]) >> src_shift) + bias)>>shift; dst[j+7] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2173  }\
2174  for (; j < length; j++) {\
2175  tmp = (bswap(src[j]) + bias)>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth) << dst_shift);\
2176  }\
2177  dst += dstStride;\
2178  src += srcStride;\
2179  }\
2180  } else if (shiftonly) {\
2181  for (i = 0; i < height; i++) {\
2182  const uint8_t *dither= dithers[shift-1][i&7];\
2183  for (j = 0; j < length-7; j+=8) {\
2184  tmp = ((bswap(src[j+0]) >> src_shift) + dither[0])>>shift; dst[j+0] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2185  tmp = ((bswap(src[j+1]) >> src_shift) + dither[1])>>shift; dst[j+1] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2186  tmp = ((bswap(src[j+2]) >> src_shift) + dither[2])>>shift; dst[j+2] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2187  tmp = ((bswap(src[j+3]) >> src_shift) + dither[3])>>shift; dst[j+3] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2188  tmp = ((bswap(src[j+4]) >> src_shift) + dither[4])>>shift; dst[j+4] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2189  tmp = ((bswap(src[j+5]) >> src_shift) + dither[5])>>shift; dst[j+5] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2190  tmp = ((bswap(src[j+6]) >> src_shift) + dither[6])>>shift; dst[j+6] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2191  tmp = ((bswap(src[j+7]) >> src_shift) + dither[7])>>shift; dst[j+7] = dbswap((tmp - (tmp>>dst_depth)) << dst_shift);\
2192  }\
2193  for (; j < length; j++) {\
2194  tmp = (bswap(src[j]) + dither[j&7])>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth) << dst_shift);\
2195  }\
2196  dst += dstStride;\
2197  src += srcStride;\
2198  }\
2199  } else {\
2200  for (i = 0; i < height; i++) {\
2201  const uint8_t *dither= dithers[shift-1][i&7];\
2202  for (j = 0; j < length-7; j+=8) {\
2203  tmp = bswap(src[j+0]) >> src_shift; dst[j+0] = dbswap(((tmp - (tmp>>dst_depth) + dither[0])>>shift) << dst_shift);\
2204  tmp = bswap(src[j+1]) >> src_shift; dst[j+1] = dbswap(((tmp - (tmp>>dst_depth) + dither[1])>>shift) << dst_shift);\
2205  tmp = bswap(src[j+2]) >> src_shift; dst[j+2] = dbswap(((tmp - (tmp>>dst_depth) + dither[2])>>shift) << dst_shift);\
2206  tmp = bswap(src[j+3]) >> src_shift; dst[j+3] = dbswap(((tmp - (tmp>>dst_depth) + dither[3])>>shift) << dst_shift);\
2207  tmp = bswap(src[j+4]) >> src_shift; dst[j+4] = dbswap(((tmp - (tmp>>dst_depth) + dither[4])>>shift) << dst_shift);\
2208  tmp = bswap(src[j+5]) >> src_shift; dst[j+5] = dbswap(((tmp - (tmp>>dst_depth) + dither[5])>>shift) << dst_shift);\
2209  tmp = bswap(src[j+6]) >> src_shift; dst[j+6] = dbswap(((tmp - (tmp>>dst_depth) + dither[6])>>shift) << dst_shift);\
2210  tmp = bswap(src[j+7]) >> src_shift; dst[j+7] = dbswap(((tmp - (tmp>>dst_depth) + dither[7])>>shift) << dst_shift);\
2211  }\
2212  for (; j < length; j++) {\
2213  tmp = bswap(src[j]); dst[j] = dbswap((tmp - (tmp>>dst_depth) + dither[j&7])>>shift);\
2214  }\
2215  dst += dstStride;\
2216  src += srcStride;\
2217  }\
2218  }
2219 
2220 static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[],
2221  const int srcStride[], int srcSliceY, int srcSliceH,
2222  uint8_t *const dst[], const int dstStride[])
2223 {
2224  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->opts.src_format);
2225  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
2226  int plane, i, j;
2227  for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
2228  int length = (plane == 0 || plane == 3) ? c->opts.src_w : AV_CEIL_RSHIFT(c->opts.src_w, c->chrDstHSubSample);
2229  int y = (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
2230  int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
2231  const uint8_t *srcPtr = src[plane];
2232  uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
2233  int shiftonly = plane == 1 || plane == 2 || (!c->opts.src_range && plane == 0);
2234  if (plane == 1 && isSemiPlanarYUV(c->opts.dst_format))
2235  length *= 2;
2236 
2237  // ignore palette for GRAY8
2238  if (plane == 1 && desc_dst->nb_components < 3) continue;
2239  if (!src[plane] || (plane == 1 && desc_src->nb_components < 3) || (plane == 3 && desc_src->nb_components <= 3)) {
2240  if (is16BPS(c->opts.dst_format) || isNBPS(c->opts.dst_format)) {
2241  fillPlane16(dst[plane], dstStride[plane], length, height, y,
2242  plane == 3, desc_dst->comp[plane].depth,
2243  isBE(c->opts.dst_format));
2244  } else {
2245  fillPlane(dst[plane], dstStride[plane], length, height, y,
2246  (plane == 3) ? 255 : 128);
2247  }
2248  } else {
2249  if(isNBPS(c->opts.src_format) || isNBPS(c->opts.dst_format)
2250  || (is16BPS(c->opts.src_format) != is16BPS(c->opts.dst_format))
2251  ) {
2252  const int src_depth = desc_src->comp[plane].depth;
2253  const int dst_depth = desc_dst->comp[plane].depth;
2254  const int src_shift = desc_src->comp[plane].shift;
2255  const int dst_shift = desc_dst->comp[plane].shift;
2256  const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
2257  uint16_t *dstPtr2 = (uint16_t*)dstPtr;
2258 
2259  if (dst_depth == 8) {
2260  av_assert1(src_depth > 8);
2261  if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2262  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
2263  } else {
2264  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
2265  }
2266  } else if (src_depth == 8) {
2267  for (i = 0; i < height; i++) {
2268  #define COPY816(w)\
2269  if (shiftonly) {\
2270  for (j = 0; j < length; j++)\
2271  w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) << dst_shift);\
2272  } else {\
2273  for (j = 0; j < length; j++)\
2274  w(&dstPtr2[j], ((srcPtr[j]<<(dst_depth-8)) |\
2275  (srcPtr[j]>>(2*8-dst_depth))) << dst_shift);\
2276  }
2277  if(isBE(c->opts.dst_format)){
2278  COPY816(AV_WB16)
2279  } else {
2280  COPY816(AV_WL16)
2281  }
2282  dstPtr2 += dstStride[plane]/2;
2283  srcPtr += srcStride[plane];
2284  }
2285  } else if (src_depth <= dst_depth) {
2286  unsigned shift = dst_depth - src_depth;
2287  for (i = 0; i < height; i++) {
2288  j = 0;
2289  if(isBE(c->opts.src_format) == HAVE_BIGENDIAN &&
2290  isBE(c->opts.dst_format) == HAVE_BIGENDIAN &&
2291  shiftonly) {
2292 #if HAVE_FAST_64BIT
2293  for (; j < length - 3; j += 4) {
2294  uint64_t v = AV_RN64A(srcPtr2 + j) >> src_shift;
2295  AV_WN64A(dstPtr2 + j, (v << shift) << dst_shift);
2296  }
2297 #else
2298  for (; j < length - 1; j += 2) {
2299  uint32_t v = AV_RN32A(srcPtr2 + j) >> src_shift;
2300  AV_WN32A(dstPtr2 + j, (v << shift) << dst_shift);
2301  }
2302 #endif
2303  }
2304 #define COPY_UP(r,w) \
2305  if(shiftonly){\
2306  for (; j < length; j++){ \
2307  unsigned int v= r(&srcPtr2[j]) >> src_shift;\
2308  w(&dstPtr2[j], (v << shift) << dst_shift);\
2309  }\
2310  }else{\
2311  for (; j < length; j++){ \
2312  unsigned int v= r(&srcPtr2[j]) >> src_shift;\
2313  w(&dstPtr2[j], ((v << shift) | (v>>(2*src_depth-dst_depth))) << dst_shift);\
2314  }\
2315  }
2316  if(isBE(c->opts.src_format)){
2317  if(isBE(c->opts.dst_format)){
2319  } else {
2321  }
2322  } else {
2323  if(isBE(c->opts.dst_format)){
2325  } else {
2327  }
2328  }
2329  dstPtr2 += dstStride[plane]/2;
2330  srcPtr2 += srcStride[plane]/2;
2331  }
2332  } else { /* src_depth > dst_depth */
2333  if(isBE(c->opts.src_format) == HAVE_BIGENDIAN){
2334  if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2335  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
2336  } else {
2337  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
2338  }
2339  }else{
2340  if(isBE(c->opts.dst_format) == HAVE_BIGENDIAN){
2341  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
2342  } else {
2343  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
2344  }
2345  }
2346  }
2347  } else if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format) &&
2348  isBE(c->opts.src_format) != isBE(c->opts.dst_format)) {
2349 
2350  for (i = 0; i < height; i++) {
2351  for (j = 0; j < length; j++)
2352  ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
2353  srcPtr += srcStride[plane];
2354  dstPtr += dstStride[plane];
2355  }
2356  } else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format) &&
2357  isBE(c->opts.src_format) != isBE(c->opts.dst_format)) { /* swap float plane */
2358  for (i = 0; i < height; i++) {
2359  for (j = 0; j < length; j++)
2360  ((uint32_t *) dstPtr)[j] = av_bswap32(((const uint32_t *) srcPtr)[j]);
2361  srcPtr += srcStride[plane];
2362  dstPtr += dstStride[plane];
2363  }
2364  } else if (dstStride[plane] == srcStride[plane] &&
2365  srcStride[plane] > 0 && srcStride[plane] == length) {
2366  memcpy(dst[plane] + dstStride[plane] * y, src[plane],
2367  height * dstStride[plane]);
2368  } else {
2369  if (is16BPS(c->opts.src_format) && is16BPS(c->opts.dst_format))
2370  length *= 2;
2371  else if (isFloat(c->opts.src_format) && isFloat(c->opts.dst_format))
2372  length *= 4;
2373  else if (desc_src->comp[0].depth == 1)
2374  length >>= 3; // monowhite/black
2375  for (i = 0; i < height; i++) {
2376  memcpy(dstPtr, srcPtr, length);
2377  srcPtr += srcStride[plane];
2378  dstPtr += dstStride[plane];
2379  }
2380  }
2381  }
2382  }
2383  return srcSliceH;
2384 }
2385 
2386 
2387 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
2388  ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
2389  (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
2390 
2391 
2393 {
2394  const enum AVPixelFormat srcFormat = c->opts.src_format;
2395  const enum AVPixelFormat dstFormat = c->opts.dst_format;
2396  const int flags = c->opts.flags;
2397  const int dstH = c->opts.dst_h;
2398  const int dstW = c->opts.dst_w;
2399  int needsDither;
2400 
2401  needsDither = isAnyRGB(dstFormat) &&
2402  c->dstFormatBpp < 24 &&
2403  (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
2404 
2405  /* yv12_to_nv12 */
2406  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2407  (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
2408  c->convert_unscaled = planarToNv12Wrapper;
2409  }
2410  /* yv24_to_nv24 */
2411  if ((srcFormat == AV_PIX_FMT_YUV444P || srcFormat == AV_PIX_FMT_YUVA444P) &&
2412  (dstFormat == AV_PIX_FMT_NV24 || dstFormat == AV_PIX_FMT_NV42)) {
2413  c->convert_unscaled = planarToNv24Wrapper;
2414  }
2415  /* nv12_to_yv12 */
2416  if (dstFormat == AV_PIX_FMT_YUV420P &&
2417  (srcFormat == AV_PIX_FMT_NV12 || srcFormat == AV_PIX_FMT_NV21)) {
2418  c->convert_unscaled = nv12ToPlanarWrapper;
2419  }
2420  /* nv24_to_yv24 */
2421  if (dstFormat == AV_PIX_FMT_YUV444P &&
2422  (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42)) {
2423  c->convert_unscaled = nv24ToPlanarWrapper;
2424  }
2425  /* yuv2bgr */
2426  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
2427  srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
2428  !(flags & SWS_ACCURATE_RND) && (c->opts.dither == SWS_DITHER_BAYER || c->opts.dither == SWS_DITHER_AUTO) && !(dstH & 1)) {
2429  c->convert_unscaled = ff_yuv2rgb_get_func_ptr(c);
2430  c->dst_slice_align = 2;
2431  }
2432  /* yuv420p1x_to_p01x */
2433  if ((srcFormat == AV_PIX_FMT_YUV420P10 || srcFormat == AV_PIX_FMT_YUVA420P10 ||
2434  srcFormat == AV_PIX_FMT_YUV420P12 ||
2435  srcFormat == AV_PIX_FMT_YUV420P14 ||
2436  srcFormat == AV_PIX_FMT_YUV420P16 || srcFormat == AV_PIX_FMT_YUVA420P16) &&
2437  (dstFormat == AV_PIX_FMT_P010 || dstFormat == AV_PIX_FMT_P016)) {
2438  c->convert_unscaled = planarToP01xWrapper;
2439  }
2440  /* yuv420p_to_p01xle */
2441  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2442  (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P016LE)) {
2443  c->convert_unscaled = planar8ToP01xleWrapper;
2444  }
2445 
2446  if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) &&
2447  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2448  !(flags & SWS_BITEXACT)) {
2449  c->convert_unscaled = yvu9ToYv12Wrapper;
2450  c->dst_slice_align = 4;
2451  }
2452 
2453  /* bgr24toYV12 */
2454  if (srcFormat == AV_PIX_FMT_BGR24 &&
2455  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2456  !(flags & SWS_ACCURATE_RND) && !(dstW&1))
2457  c->convert_unscaled = bgr24ToYv12Wrapper;
2458 
2459  /* AYUV/VUYA/UYVA -> AYUV/VUYA/UYVA */
2460  if (isAYUV(srcFormat) && isAYUV(dstFormat) && findRgbConvFn(c))
2461  c->convert_unscaled = rgbToRgbWrapper;
2462 
2463  /* RGB/BGR -> RGB/BGR (no dither needed forms) */
2464  if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
2465  && (!needsDither || (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT))))
2466  c->convert_unscaled = rgbToRgbWrapper;
2467 
2468  /* RGB to planar RGB */
2469  if ((srcFormat == AV_PIX_FMT_GBRP && dstFormat == AV_PIX_FMT_GBRAP) ||
2470  (srcFormat == AV_PIX_FMT_GBRP10 && dstFormat == AV_PIX_FMT_GBRAP10) ||
2471  (srcFormat == AV_PIX_FMT_GBRP12 && dstFormat == AV_PIX_FMT_GBRAP12) ||
2472  (srcFormat == AV_PIX_FMT_GBRP14 && dstFormat == AV_PIX_FMT_GBRAP14) ||
2473  (srcFormat == AV_PIX_FMT_GBRP16 && dstFormat == AV_PIX_FMT_GBRAP16) ||
2474  (srcFormat == AV_PIX_FMT_GBRAP && dstFormat == AV_PIX_FMT_GBRP) ||
2475  (srcFormat == AV_PIX_FMT_GBRAP10 && dstFormat == AV_PIX_FMT_GBRP10) ||
2476  (srcFormat == AV_PIX_FMT_GBRAP12 && dstFormat == AV_PIX_FMT_GBRP12) ||
2477  (srcFormat == AV_PIX_FMT_GBRAP14 && dstFormat == AV_PIX_FMT_GBRP14) ||
2478  (srcFormat == AV_PIX_FMT_GBRAP16 && dstFormat == AV_PIX_FMT_GBRP16))
2479  c->convert_unscaled = planarRgbToplanarRgbWrapper;
2480 
2481 #define isByteRGB(f) ( \
2482  f == AV_PIX_FMT_RGB32 || \
2483  f == AV_PIX_FMT_RGB32_1 || \
2484  f == AV_PIX_FMT_RGB24 || \
2485  f == AV_PIX_FMT_BGR32 || \
2486  f == AV_PIX_FMT_BGR32_1 || \
2487  f == AV_PIX_FMT_BGR24)
2488 
2489  if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
2490  c->convert_unscaled = planarRgbToRgbWrapper;
2491 
2492  if (srcFormat == AV_PIX_FMT_GBRAP && isByteRGB(dstFormat))
2493  c->convert_unscaled = planarRgbaToRgbWrapper;
2494 
2495  if ((srcFormat == AV_PIX_FMT_RGB48LE || srcFormat == AV_PIX_FMT_RGB48BE ||
2496  srcFormat == AV_PIX_FMT_BGR48LE || srcFormat == AV_PIX_FMT_BGR48BE ||
2497  srcFormat == AV_PIX_FMT_RGBA64LE || srcFormat == AV_PIX_FMT_RGBA64BE ||
2498  srcFormat == AV_PIX_FMT_BGRA64LE || srcFormat == AV_PIX_FMT_BGRA64BE) &&
2499  (dstFormat == AV_PIX_FMT_GBRP9LE || dstFormat == AV_PIX_FMT_GBRP9BE ||
2500  dstFormat == AV_PIX_FMT_GBRP10LE || dstFormat == AV_PIX_FMT_GBRP10BE ||
2501  dstFormat == AV_PIX_FMT_GBRP12LE || dstFormat == AV_PIX_FMT_GBRP12BE ||
2502  dstFormat == AV_PIX_FMT_GBRP14LE || dstFormat == AV_PIX_FMT_GBRP14BE ||
2503  dstFormat == AV_PIX_FMT_GBRP16LE || dstFormat == AV_PIX_FMT_GBRP16BE ||
2504  dstFormat == AV_PIX_FMT_GBRAP10LE || dstFormat == AV_PIX_FMT_GBRAP10BE ||
2505  dstFormat == AV_PIX_FMT_GBRAP12LE || dstFormat == AV_PIX_FMT_GBRAP12BE ||
2506  dstFormat == AV_PIX_FMT_GBRAP14LE || dstFormat == AV_PIX_FMT_GBRAP14BE ||
2507  dstFormat == AV_PIX_FMT_GBRAP16LE || dstFormat == AV_PIX_FMT_GBRAP16BE ))
2508  c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2509 
2510  if (av_pix_fmt_desc_get(dstFormat)->comp[0].depth >= 10 &&
2511  isPlanarRGB(dstFormat) && !isFloat(dstFormat) &&
2512  (srcFormat == AV_PIX_FMT_X2RGB10LE || srcFormat == AV_PIX_FMT_X2BGR10LE))
2513  c->convert_unscaled = Rgb16ToPlanarRgb16Wrapper;
2514 
2515  if ((srcFormat == AV_PIX_FMT_GBRP9LE || srcFormat == AV_PIX_FMT_GBRP9BE ||
2516  srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
2517  srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
2518  srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
2519  srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
2520  srcFormat == AV_PIX_FMT_GBRAP10LE || srcFormat == AV_PIX_FMT_GBRAP10BE ||
2521  srcFormat == AV_PIX_FMT_GBRAP12LE || srcFormat == AV_PIX_FMT_GBRAP12BE ||
2522  srcFormat == AV_PIX_FMT_GBRAP14LE || srcFormat == AV_PIX_FMT_GBRAP14BE ||
2523  srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
2524  (dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE ||
2525  dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
2526  dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
2527  dstFormat == AV_PIX_FMT_BGRA64LE || dstFormat == AV_PIX_FMT_BGRA64BE))
2528  c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2529 
2530  if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth >= 10 &&
2531  isPlanarRGB(srcFormat) && !isFloat(srcFormat) &&
2532  (dstFormat == AV_PIX_FMT_X2RGB10LE || dstFormat == AV_PIX_FMT_X2BGR10LE))
2533  c->convert_unscaled = planarRgb16ToRgb16Wrapper;
2534 
2535  if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2536  isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
2537  c->convert_unscaled = rgbToPlanarRgbWrapper;
2538 
2539  if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2540  isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRAP)
2541  c->convert_unscaled = rgbToPlanarRgbaWrapper;
2542 
2543  if (isBayer(srcFormat)) {
2544  c->dst_slice_align = 2;
2545  if (dstFormat == AV_PIX_FMT_RGB24)
2546  c->convert_unscaled = bayer_to_rgb24_wrapper;
2547  else if (dstFormat == AV_PIX_FMT_RGB48)
2548  c->convert_unscaled = bayer_to_rgb48_wrapper;
2549  else if (dstFormat == AV_PIX_FMT_YUV420P)
2550  c->convert_unscaled = bayer_to_yv12_wrapper;
2551  else if (!isBayer(dstFormat)) {
2552  av_log(c, AV_LOG_ERROR, "unsupported bayer conversion\n");
2553  av_assert0(0);
2554  }
2555  }
2556 
2557  /* bswap 16 bits per pixel/component packed formats */
2558  if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_BGGR16) ||
2559  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_RGGB16) ||
2560  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GBRG16) ||
2561  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GRBG16) ||
2562  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
2563  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
2564  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
2565  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
2566  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
2567  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY9) ||
2568  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY10) ||
2569  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY12) ||
2570  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY14) ||
2571  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
2572  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16) ||
2573  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_AYUV64) ||
2574  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP9) ||
2575  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10) ||
2576  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) ||
2577  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP14) ||
2578  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP16) ||
2579  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10MSB) ||
2580  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12MSB) ||
2581  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP10) ||
2582  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP12) ||
2583  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP14) ||
2584  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) ||
2585  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
2586  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
2587  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
2588  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565) ||
2589  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
2590  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV36) ||
2591  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XV48) ||
2592  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XYZ12) ||
2593  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P9) ||
2594  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P10) ||
2595  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P12) ||
2596  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P14) ||
2597  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P16) ||
2598  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P9) ||
2599  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P10) ||
2600  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P12) ||
2601  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P14) ||
2602  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P16) ||
2603  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P10) ||
2604  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P12) ||
2605  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P9) ||
2606  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10) ||
2607  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12) ||
2608  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P14) ||
2609  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P16) ||
2610  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10MSB) ||
2611  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12MSB))
2612  c->convert_unscaled = bswap_16bpc;
2613 
2614  /* bswap 32 bits per pixel/component formats */
2615  if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRPF32) ||
2616  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAPF32))
2617  c->convert_unscaled = bswap_32bpc;
2618 
2619  if (usePal(srcFormat)) {
2620  switch (dstFormat) {
2621  case AV_PIX_FMT_GBRP:
2622  case AV_PIX_FMT_GBRAP:
2623  c->convert_unscaled = palToGbrpWrapper;
2624  break;
2625  default:
2626  if (isByteRGB(dstFormat))
2627  c->convert_unscaled = palToRgbWrapper;
2628  break;
2629  }
2630  }
2631 
2632  if (srcFormat == AV_PIX_FMT_YUV422P) {
2633  if (dstFormat == AV_PIX_FMT_YUYV422)
2634  c->convert_unscaled = yuv422pToYuy2Wrapper;
2635  else if (dstFormat == AV_PIX_FMT_UYVY422)
2636  c->convert_unscaled = yuv422pToUyvyWrapper;
2637  }
2638 
2639  /* uint Y to float Y */
2640  if (srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32){
2641  c->convert_unscaled = uint_y_to_float_y_wrapper;
2642  }
2643 
2644  /* float Y to uint Y */
2645  if (srcFormat == AV_PIX_FMT_GRAYF32 && dstFormat == AV_PIX_FMT_GRAY8){
2646  c->convert_unscaled = float_y_to_uint_y_wrapper;
2647  }
2648 
2649  /* LQ converters if -sws 0 or -sws 4*/
2650  if (c->opts.flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
2651  /* yv12_to_yuy2 */
2652  if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
2653  if (dstFormat == AV_PIX_FMT_YUYV422)
2654  c->convert_unscaled = planarToYuy2Wrapper;
2655  else if (dstFormat == AV_PIX_FMT_UYVY422)
2656  c->convert_unscaled = planarToUyvyWrapper;
2657  }
2658  }
2659  if (srcFormat == AV_PIX_FMT_YUYV422 &&
2660  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2661  c->convert_unscaled = yuyvToYuv420Wrapper;
2662  if (srcFormat == AV_PIX_FMT_UYVY422 &&
2663  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2664  c->convert_unscaled = uyvyToYuv420Wrapper;
2665  if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
2666  c->convert_unscaled = yuyvToYuv422Wrapper;
2667  if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
2668  c->convert_unscaled = uyvyToYuv422Wrapper;
2669  if (dstFormat == AV_PIX_FMT_YUV420P &&
2670  (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42))
2671  c->convert_unscaled = nv24ToYuv420Wrapper;
2672 
2673 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
2674 
2675  /* simple copy */
2676  if ( srcFormat == dstFormat ||
2677  (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
2678  (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
2679  (isFloat(srcFormat) == isFloat(dstFormat) && isFloat16(srcFormat) == isFloat16(dstFormat)) && ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
2680  (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
2681  (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
2682  (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
2683  c->chrDstHSubSample == c->chrSrcHSubSample &&
2684  c->chrDstVSubSample == c->chrSrcVSubSample &&
2685  isSemiPlanarYUV(srcFormat) == isSemiPlanarYUV(dstFormat) &&
2686  isSwappedChroma(srcFormat) == isSwappedChroma(dstFormat))))
2687  {
2688  if (isPacked(c->opts.src_format)) {
2689  c->convert_unscaled = packedCopyWrapper;
2690  } else { /* Planar YUV or gray */
2691  c->convert_unscaled = planarCopyWrapper;
2692  if (c->opts.dither != SWS_DITHER_NONE)
2693  c->dst_slice_align = 8 << c->chrDstVSubSample;
2694  }
2695  }
2696 
2698 
2699 #if ARCH_PPC
2701 #elif ARCH_ARM
2703 #elif ARCH_AARCH64
2705 #endif
2706 }
2707 
2708 /* Convert the palette to the same packed 32-bit format as the palette */
2709 void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst,
2710  int num_pixels, const uint8_t *palette)
2711 {
2712  int i;
2713 
2714  for (i = 0; i < num_pixels; i++)
2715  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
2716 }
2717 
2718 /* Palette format: ABCD -> dst format: ABC */
2719 void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst,
2720  int num_pixels, const uint8_t *palette)
2721 {
2722  int i;
2723 
2724  for (i = 0; i < num_pixels; i++) {
2725  //FIXME slow?
2726  dst[0] = palette[src[i] * 4 + 0];
2727  dst[1] = palette[src[i] * 4 + 1];
2728  dst[2] = palette[src[i] * 4 + 2];
2729  dst += 3;
2730  }
2731 }
isBayer
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:860
flags
const SwsFlags flags[]
Definition: swscale.c:72
rgbToPlanarRgbaWrapper
static int rgbToPlanarRgbaWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1542
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:565
nv24ToPlanarWrapper
static int nv24ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:208
rgb12tobgr12
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:311
isX2RGB
#define isX2RGB(x)
Definition: swscale_unscaled.c:1835
gray8aToPlanar8
static void gray8aToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, uint8_t *dst2, uint8_t *dstA, int num_pixels, const uint8_t *palette)
Definition: swscale_unscaled.c:517
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
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
isPlanarRGB
static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:928
rgb32tobgr24
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:35
shuffle_bytes_3012
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:57
SWS_DITHER_AUTO
@ SWS_DITHER_AUTO
Definition: swscale.h:81
isPacked
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:905
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:140
ff_get_unscaled_swscale_ppc
av_cold void ff_get_unscaled_swscale_ppc(SwsInternal *c)
Definition: yuv2yuv_altivec.c:188
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
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:422
C2
#define C2
Definition: mpegaudiodsp_template.c:239
mem_internal.h
packedtogbr24p
static void packedtogbr24p(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int alpha_first, int inc_size, int width)
Definition: swscale_unscaled.c:1403
gbr24ptopacked24
static void gbr24ptopacked24(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
Definition: swscale_unscaled.c:1187
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_BGR32
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:513
yv12toyuy2
void(* yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
Definition: rgb2rgb.c:65
AV_PIX_FMT_GBRP16BE
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:171
rgb15to24
void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:276
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
nv24ToYuv420Wrapper
static int nv24ToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:253
src1
const pixel * src1
Definition: h264pred_template.c:420
AV_PIX_FMT_YUV444P10MSB
#define AV_PIX_FMT_YUV444P10MSB
Definition: pixfmt.h:554
planarRgbaToRgbWrapper
static int planarRgbaToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1263
pixdesc.h
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
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:595
SWS_DITHER_NONE
@ SWS_DITHER_NONE
Definition: swscale.h:80
planarToNv12Wrapper
static int planarToNv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:147
rgb16tobgr32
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:179
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:590
AVPixFmtDescriptor::name
const char * name
Definition: pixdesc.h:70
SWS_BITEXACT
@ SWS_BITEXACT
Definition: swscale.h:157
CONV_IS
#define CONV_IS(src, dst)
planar8ToP01xleWrapper
static int planar8ToP01xleWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam8[], const int dstStride[])
Definition: swscale_unscaled.c:333
x2rgb10tobgr64_bswap
void x2rgb10tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
shuffle_bytes_3210
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:58
pal8ToPlanar8
static void pal8ToPlanar8(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, uint8_t *dst2, uint8_t *dstA, int num_pixels, const uint8_t *palette)
Definition: swscale_unscaled.c:531
rgb2yuv
static const char rgb2yuv[]
Definition: vf_scale_vulkan.c:86
rgb48tobgr48_nobswap
void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
AVComponentDescriptor::step
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:40
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:539
AV_PIX_FMT_RGB32_1
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:512
rgb32tobgr16
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:36
yuyvtoyuv422
void(* yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition: rgb2rgb.c:103
rgbToPlanarRgbWrapper
static int rgbToPlanarRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1432
AV_WN32A
#define AV_WN32A(p, v)
Definition: intreadwrite.h:534
AV_PIX_FMT_GBRP14BE
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:281
rgb24tobgr16
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:40
planarToP01xWrapper
static int planarToP01xWrapper(SwsInternal *c, const uint8_t *const src8[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam8[], const int dstStride[])
Definition: swscale_unscaled.c:273
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
rgb15to32
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:52
mathematics.h
sws_convertPalette8ToPacked24
void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
Definition: swscale_unscaled.c:2719
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
AV_PIX_FMT_BAYER_GRBG16
#define AV_PIX_FMT_BAYER_GRBG16
Definition: pixfmt.h:574
AV_PIX_FMT_GBRAP14BE
@ AV_PIX_FMT_GBRAP14BE
planar GBR 4:4:4:4 56bpp, big-endian
Definition: pixfmt.h:432
yv12touyvy
void(* yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Height should be a multiple of 2 and width should be a multiple of 16.
Definition: rgb2rgb.c:69
bayer_template.c
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:518
AV_PIX_FMT_YUV444P12MSB
#define AV_PIX_FMT_YUV444P12MSB
Definition: pixfmt.h:555
rgb32to16
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:45
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
x2rgb10tobgr48_nobswap
void x2rgb10tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_GBRAP12LE
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:311
yuyvToYuv420Wrapper
static int yuyvToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:424
SWS_FAST_BILINEAR
@ SWS_FAST_BILINEAR
Scaler selection options.
Definition: swscale.h:176
isRGBA32
#define isRGBA32(x)
Definition: swscale_unscaled.c:1807
is16BPS
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:745
rgb
Definition: rpzaenc.c:60
bswap_32bpc
static int bswap_32bpc(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:572
planarToUyvyWrapper
static int planarToUyvyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:388
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:560
shuffle_bytes_2130
void(* shuffle_bytes_2130)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:61
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
isRGBA64
#define isRGBA64(x)
Definition: swscale_unscaled.c:1814
C1
#define C1
Definition: mpegaudiodsp_template.c:238
AV_PIX_FMT_GBRP12MSB
#define AV_PIX_FMT_GBRP12MSB
Definition: pixfmt.h:569
float_y_to_uint_y_wrapper
static int float_y_to_uint_y_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2115
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:558
palToRgbWrapper
static int palToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:600
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:537
rgb16tobgr16
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:234
yuv422pToYuy2Wrapper
static int yuv422pToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:400
x2rgb10tobgr48_bswap
void x2rgb10tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
val
static double val(void *priv, double ch)
Definition: aeval.c:77
isNBPS
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:759
AV_PIX_FMT_XV48
#define AV_PIX_FMT_XV48
Definition: pixfmt.h:611
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:522
rgb48tobgr64_bswap
void rgb48tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
DITHER_COPY
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
Definition: swscale_unscaled.c:2159
bgr24ToYv12Wrapper
static int bgr24ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2062
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:542
isRGB48
#define isRGB48(x)
Definition: swscale_unscaled.c:1821
avassert.h
packed32togbrap
static void packed32togbrap(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int alpha_first, int width)
Definition: swscale_unscaled.c:1506
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
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
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:551
gbraptopacked32
static void gbraptopacked32(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
Definition: swscale_unscaled.c:1234
rgb16tobgr24
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:42
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:562
AV_PIX_FMT_GBRAP16BE
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:213
intreadwrite.h
AV_PIX_FMT_GBRP16LE
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:172
AV_PIX_FMT_GBRAP14
#define AV_PIX_FMT_GBRAP14
Definition: pixfmt.h:564
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:563
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_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
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:552
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
AV_PIX_FMT_BAYER_BGGR8
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
Definition: pixfmt.h:285
nv24_to_yuv420p_chroma
static void nv24_to_yuv420p_chroma(uint8_t *dst1, int dstStride1, uint8_t *dst2, int dstStride2, const uint8_t *src, int srcStride, int w, int h)
Definition: swscale_unscaled.c:229
shuffle_bytes_1230
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:56
Rgb16ToPlanarRgb16Wrapper
static int Rgb16ToPlanarRgb16Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:891
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
rgb15tobgr24
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:43
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:536
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:550
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:521
isAYUV
#define isAYUV(x)
Definition: swscale_unscaled.c:1828
yuv422ptoyuy2
void(* yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
Definition: rgb2rgb.c:73
shuffle_bytes_2103
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:55
rgb32tobgr15
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:37
bayer_to_yv12_wrapper
static int bayer_to_yv12_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1751
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
rgb48to64_bswap
void rgb48to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:582
av_fallthrough
#define av_fallthrough
Definition: attributes.h:67
AV_PIX_FMT_BGR32_1
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:514
uyvyToYuv420Wrapper
static int uyvyToYuv420Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:455
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_BAYER_RGGB8
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
Definition: pixfmt.h:286
rgb16to24
void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:220
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
AV_PIX_FMT_BAYER_BGGR16
#define AV_PIX_FMT_BAYER_BGGR16
Definition: pixfmt.h:571
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:519
rgb12to15
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:201
interleaveBytes
void(* interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int src1Stride, int src2Stride, int dstStride)
Definition: rgb2rgb.c:88
isSemiPlanarYUV
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:791
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_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:561
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:529
shuffle_bytes_3102
void(* shuffle_bytes_3102)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:59
packed30togbra10
static void packed30togbra10(const uint8_t *src, int srcStride, uint16_t *dst[], const int dstStride[], int srcSliceH, int swap, int bpc, int width)
Definition: swscale_unscaled.c:819
AV_PIX_FMT_GBRAP12BE
@ AV_PIX_FMT_GBRAP12BE
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:310
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:530
NULL
#define NULL
Definition: coverity.c:32
rgb16to15
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:50
yvu9ToYv12Wrapper
static int yvu9ToYv12Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2079
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
isFloat16
static av_always_inline int isFloat16(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:889
AV_WB16
#define AV_WB16(p, v)
Definition: intreadwrite.h:401
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
uint_y_to_float_y_wrapper
static int uint_y_to_float_y_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2095
gray8aToPacked24
static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Definition: swscale_unscaled.c:503
ff_get_unscaled_swscale_aarch64
void ff_get_unscaled_swscale_aarch64(SwsInternal *c)
Definition: swscale_unscaled.c:264
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
bayer_to_rgb48_wrapper
static int bayer_to_rgb48_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1701
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_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:541
AV_PIX_FMT_BAYER_GBRG16
#define AV_PIX_FMT_BAYER_GBRG16
Definition: pixfmt.h:573
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
rgbConvFn
void(* rgbConvFn)(const uint8_t *, uint8_t *, int)
Definition: swscale_unscaled.c:1841
x2rgb10to64_nobswap
void x2rgb10to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
ff_get_unscaled_swscale_arm
void ff_get_unscaled_swscale_arm(SwsInternal *c)
Definition: swscale_unscaled.c:185
COPY816
#define COPY816(w)
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
yuyvtoyuv420
void(* yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition: rgb2rgb.c:100
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:557
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
rgb15tobgr16
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:290
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
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
rgb64tobgr48_bswap
void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
ff_sws_init_xyzdsp
av_cold void ff_sws_init_xyzdsp(SwsInternal *c)
Definition: swscale.c:863
planarCopyWrapper
static int planarCopyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2220
dithers
static const uint8_t dithers[8][8][8]
Definition: swscale_unscaled.c:39
rgb24tobgr32
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:38
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
rgb64to48_nobswap
void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
isBE
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:766
f
f
Definition: af_crystalizer.c:122
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:186
height
#define height
Definition: dsp.h:89
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
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
fillPlane16
static void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian)
Definition: swscale_internal.h:1067
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
usePal
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:936
av_bswap32
#define av_bswap32
Definition: bswap.h:47
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
isAnyRGB
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:874
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:578
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:544
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:525
SWS_POINT
@ SWS_POINT
nearest neighbor
Definition: swscale.h:180
AV_PIX_FMT_BGR555
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:532
x2rgb10tobgr64_nobswap
void x2rgb10tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:546
gray8aToPacked32_1
static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Definition: swscale_unscaled.c:494
AV_PIX_FMT_GBRP9BE
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:167
AV_RN64A
#define AV_RN64A(p)
Definition: intreadwrite.h:526
rgb64tobgr48_nobswap
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_AYUV64
#define AV_PIX_FMT_AYUV64
Definition: pixfmt.h:601
shuffle_bytes_0321
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:54
IS_DIFFERENT_ENDIANESS
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
Definition: swscale_unscaled.c:2387
rgb32to24
void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:141
nv12ToPlanarWrapper
static int nv12ToPlanarWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:167
rgb15tobgr15
void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:300
findRgbConvFn
static rgbConvFn findRgbConvFn(SwsInternal *c)
Definition: swscale_unscaled.c:1842
AV_PIX_FMT_GBRP9LE
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:168
AV_WL16
#define AV_WL16(p, v)
Definition: intreadwrite.h:408
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:511
isBGRinInt
static av_always_inline int isBGRinInt(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:838
yuyvToYuv422Wrapper
static int yuyvToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:441
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
CASE
#define CASE(pixfmt, prefix)
isSwappedChroma
static av_always_inline int isSwappedChroma(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:973
attributes.h
rgb24to16
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:47
interpolate
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:85
bayer_to_rgb24_wrapper
static int bayer_to_rgb24_wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1651
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
uyvytoyuv422
void(* uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition: rgb2rgb.c:97
planarToYuy2Wrapper
static int planarToYuy2Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:376
AV_PIX_FMT_XYZ12
#define AV_PIX_FMT_XYZ12
Definition: pixfmt.h:599
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:534
AVComponentDescriptor::shift
int shift
Number of least significant bits that must be shifted away to get the value.
Definition: pixdesc.h:52
C0
#define C0
ff_rgb24toyv12
void(* ff_rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, int width, int height, int lumStride, int chromStride, int srcStride, const int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
Definition: rgb2rgb.c: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
ff_copyPlane
void ff_copyPlane(const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
Definition: swscale_unscaled.c:126
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
AV_PIX_FMT_YA16
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:524
gbr16ptopacked16
static void gbr16ptopacked16(const uint16_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha, int swap, int bpp, int width)
Definition: swscale_unscaled.c:963
rgb24to15
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:48
src2
const pixel * src2
Definition: h264pred_template.c:421
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:559
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
AV_PIX_FMT_BGR444
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:533
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:58
AV_PIX_FMT_BAYER_GBRG8
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
Definition: pixfmt.h:287
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:527
planarRgb16ToRgb16Wrapper
static int planarRgb16ToRgb16Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1117
rgb32to15
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:46
rgb48tobgr64_nobswap
void rgb48tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
swscale_internal.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
yuv422pToUyvyWrapper
static int yuv422pToUyvyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:412
fillPlane
static void fillPlane(uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
Definition: swscale_unscaled.c:115
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
AV_PIX_FMT_BGR565
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:531
AV_PIX_FMT_NV42
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition: pixfmt.h:372
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:538
isFloat
static av_always_inline int isFloat(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:882
gbr16ptopacked30
static void gbr16ptopacked30(const uint16_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int swap, int bpp, int width)
Definition: swscale_unscaled.c:1082
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:604
AV_PIX_FMT_RGB565
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:526
output_pixel
#define output_pixel(p, v)
Definition: swscale_unscaled.c:330
AV_RN32A
#define AV_RN32A(p)
Definition: intreadwrite.h:522
AV_PIX_FMT_GBRAP16LE
@ AV_PIX_FMT_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:214
SwsInternal
Definition: swscale_internal.h:335
bswap.h
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_BAYER_BGGR16BE
@ AV_PIX_FMT_BAYER_BGGR16BE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:290
AV_PIX_FMT_P016LE
@ AV_PIX_FMT_P016LE
like NV12, with 16bpp per component, little-endian
Definition: pixfmt.h:323
deinterleaveBytes
void(* deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, int width, int height, int srcStride, int dst1Stride, int dst2Stride)
Definition: rgb2rgb.c:91
isPlanarGray
#define isPlanarGray(x)
x2rgb10to48_bswap
void x2rgb10to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
rgb48to64_nobswap
void rgb48to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
rgb48tobgr48_bswap
void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:543
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_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
U
#define U(x)
Definition: vpx_arith.h:37
uyvytoyuv420
void(* uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src, int width, int height, int lumStride, int chromStride, int srcStride)
Definition: rgb2rgb.c:94
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:548
AV_WN64A
#define AV_WN64A(p, v)
Definition: intreadwrite.h:538
rgb16to32
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:49
gray8aToPacked32
static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Definition: swscale_unscaled.c:486
uyvyToYuv422Wrapper
static int uyvyToYuv422Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:472
isPackedRGB
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:921
rgb24to32
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:159
packed16togbra16
static void packed16togbra16(const uint8_t *src, int srcStride, uint16_t *dst[], const int dstStride[], int srcSliceH, int src_alpha, int swap, int shift, int width)
Definition: swscale_unscaled.c:685
rgb24tobgr15
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:41
shuffle_bytes_2013
void(* shuffle_bytes_2013)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:60
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:579
rgb15tobgr32
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:254
rgb15to16
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:51
shuffle_bytes_1203
void(* shuffle_bytes_1203)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:62
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
COPY_UP
#define COPY_UP(r, w)
yuv422ptouyvy
void(* yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, int width, int height, int lumStride, int chromStride, int dstStride)
Width should be a multiple of 16.
Definition: rgb2rgb.c:77
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
x2rgb10to48_nobswap
void x2rgb10to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
ALT32_CORR
#define ALT32_CORR
Definition: swscale_internal.h:62
av_clip_uint8
#define av_clip_uint8
Definition: common.h:106
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
rgb24tobgr24
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:39
src0
const pixel *const src0
Definition: h264pred_template.c:419
isPlanarYUV
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
Definition: vf_dnn_processing.c:162
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:602
ff_yuv2rgb_get_func_ptr
SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c)
rgb64to48_bswap
void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
planarRgbToplanarRgbWrapper
static int planarRgbToplanarRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1379
avutil.h
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_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
bswap_16bpc
static int bswap_16bpc(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:545
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
w
uint8_t w
Definition: llvidencdsp.c:39
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
isRGBinInt
static av_always_inline int isRGBinInt(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:816
x2rgb10to64_bswap
void x2rgb10to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
AV_PIX_FMT_GBRP14LE
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:282
int32_t
int32_t
Definition: audioconvert.c:56
IS_NOT_NE
#define IS_NOT_NE(bpp, desc)
RGBA
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:42
ff_get_unscaled_swscale
void ff_get_unscaled_swscale(SwsInternal *c)
Set c->convert_unscaled to an unscaled converter if one exists for the specific source and destinatio...
Definition: swscale_unscaled.c:2392
planarToNv24Wrapper
static int planarToNv24Wrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dstParam[], const int dstStride[])
Definition: swscale_unscaled.c:188
AV_PIX_FMT_XV36
#define AV_PIX_FMT_XV36
Definition: pixfmt.h:610
planar2x
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)
Definition: rgb2rgb.c:86
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
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
planarRgbToRgbWrapper
static int planarRgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:1321
AV_PIX_FMT_GBRAP10BE
@ AV_PIX_FMT_GBRAP10BE
planar GBR 4:4:4:4 40bpp, big-endian
Definition: pixfmt.h:313
SWS_ACCURATE_RND
@ SWS_ACCURATE_RND
Force bit-exact output.
Definition: swscale.h:156
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:545
h
h
Definition: vp9dsp_template.c:2070
AV_PIX_FMT_GBRP10MSB
#define AV_PIX_FMT_GBRP10MSB
Definition: pixfmt.h:568
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:549
stride
#define stride
Definition: h264pred_template.c:536
isPlanar
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:914
sws_convertPalette8ToPacked32
void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
Definition: swscale_unscaled.c:2709
gbr24ptopacked32
static void gbr24ptopacked32(const uint8_t *src[], const int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
Definition: swscale_unscaled.c:1205
width
#define width
Definition: dsp.h:89
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:520
AV_PIX_FMT_BAYER_RGGB16
#define AV_PIX_FMT_BAYER_RGGB16
Definition: pixfmt.h:572
av_bswap16
#define av_bswap16
Definition: bswap.h:28
packed24togbrap
static void packed24togbrap(const uint8_t *src, int srcStride, uint8_t *const dst[], const int dstStride[], int srcSliceH, int width)
Definition: swscale_unscaled.c:1479
palToGbrpWrapper
static int palToGbrpWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:646
rgbToRgbWrapper
static int rgbToRgbWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2001
AV_PIX_FMT_BAYER_GRBG8
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
Definition: pixfmt.h:288
rgb2rgb.h
src
#define src
Definition: vp8dsp.c:248
AV_PIX_FMT_GBRAP14LE
@ AV_PIX_FMT_GBRAP14LE
planar GBR 4:4:4:4 56bpp, little-endian
Definition: pixfmt.h:433
swscale.h
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:547
isByteRGB
#define isByteRGB(f)
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:3376
AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:98
isALPHA
static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
Definition: swscale_internal.h:896
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
rgb16tobgr15
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:244
packedCopyWrapper
static int packedCopyWrapper(SwsInternal *c, const uint8_t *const src[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[])
Definition: swscale_unscaled.c:2138
AV_PIX_FMT_RGB444
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:528