FFmpeg  4.4.9
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 "swscale.h"
27 #include "swscale_internal.h"
28 #include "rgb2rgb.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/cpu.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/imgutils.h"
36 #include "libavutil/pixdesc.h"
37 #include "libavutil/avassert.h"
38 #include "libavutil/avconfig.h"
39 
40 DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={
41 {
42  { 0, 1, 0, 1, 0, 1, 0, 1,},
43  { 1, 0, 1, 0, 1, 0, 1, 0,},
44  { 0, 1, 0, 1, 0, 1, 0, 1,},
45  { 1, 0, 1, 0, 1, 0, 1, 0,},
46  { 0, 1, 0, 1, 0, 1, 0, 1,},
47  { 1, 0, 1, 0, 1, 0, 1, 0,},
48  { 0, 1, 0, 1, 0, 1, 0, 1,},
49  { 1, 0, 1, 0, 1, 0, 1, 0,},
50 },{
51  { 1, 2, 1, 2, 1, 2, 1, 2,},
52  { 3, 0, 3, 0, 3, 0, 3, 0,},
53  { 1, 2, 1, 2, 1, 2, 1, 2,},
54  { 3, 0, 3, 0, 3, 0, 3, 0,},
55  { 1, 2, 1, 2, 1, 2, 1, 2,},
56  { 3, 0, 3, 0, 3, 0, 3, 0,},
57  { 1, 2, 1, 2, 1, 2, 1, 2,},
58  { 3, 0, 3, 0, 3, 0, 3, 0,},
59 },{
60  { 2, 4, 3, 5, 2, 4, 3, 5,},
61  { 6, 0, 7, 1, 6, 0, 7, 1,},
62  { 3, 5, 2, 4, 3, 5, 2, 4,},
63  { 7, 1, 6, 0, 7, 1, 6, 0,},
64  { 2, 4, 3, 5, 2, 4, 3, 5,},
65  { 6, 0, 7, 1, 6, 0, 7, 1,},
66  { 3, 5, 2, 4, 3, 5, 2, 4,},
67  { 7, 1, 6, 0, 7, 1, 6, 0,},
68 },{
69  { 4, 8, 7, 11, 4, 8, 7, 11,},
70  { 12, 0, 15, 3, 12, 0, 15, 3,},
71  { 6, 10, 5, 9, 6, 10, 5, 9,},
72  { 14, 2, 13, 1, 14, 2, 13, 1,},
73  { 4, 8, 7, 11, 4, 8, 7, 11,},
74  { 12, 0, 15, 3, 12, 0, 15, 3,},
75  { 6, 10, 5, 9, 6, 10, 5, 9,},
76  { 14, 2, 13, 1, 14, 2, 13, 1,},
77 },{
78  { 9, 17, 15, 23, 8, 16, 14, 22,},
79  { 25, 1, 31, 7, 24, 0, 30, 6,},
80  { 13, 21, 11, 19, 12, 20, 10, 18,},
81  { 29, 5, 27, 3, 28, 4, 26, 2,},
82  { 8, 16, 14, 22, 9, 17, 15, 23,},
83  { 24, 0, 30, 6, 25, 1, 31, 7,},
84  { 12, 20, 10, 18, 13, 21, 11, 19,},
85  { 28, 4, 26, 2, 29, 5, 27, 3,},
86 },{
87  { 18, 34, 30, 46, 17, 33, 29, 45,},
88  { 50, 2, 62, 14, 49, 1, 61, 13,},
89  { 26, 42, 22, 38, 25, 41, 21, 37,},
90  { 58, 10, 54, 6, 57, 9, 53, 5,},
91  { 16, 32, 28, 44, 19, 35, 31, 47,},
92  { 48, 0, 60, 12, 51, 3, 63, 15,},
93  { 24, 40, 20, 36, 27, 43, 23, 39,},
94  { 56, 8, 52, 4, 59, 11, 55, 7,},
95 },{
96  { 18, 34, 30, 46, 17, 33, 29, 45,},
97  { 50, 2, 62, 14, 49, 1, 61, 13,},
98  { 26, 42, 22, 38, 25, 41, 21, 37,},
99  { 58, 10, 54, 6, 57, 9, 53, 5,},
100  { 16, 32, 28, 44, 19, 35, 31, 47,},
101  { 48, 0, 60, 12, 51, 3, 63, 15,},
102  { 24, 40, 20, 36, 27, 43, 23, 39,},
103  { 56, 8, 52, 4, 59, 11, 55, 7,},
104 },{
105  { 36, 68, 60, 92, 34, 66, 58, 90,},
106  { 100, 4,124, 28, 98, 2,122, 26,},
107  { 52, 84, 44, 76, 50, 82, 42, 74,},
108  { 116, 20,108, 12,114, 18,106, 10,},
109  { 32, 64, 56, 88, 38, 70, 62, 94,},
110  { 96, 0,120, 24,102, 6,126, 30,},
111  { 48, 80, 40, 72, 54, 86, 46, 78,},
112  { 112, 16,104, 8,118, 22,110, 14,},
113 }};
114 
115 
116 static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
117  uint8_t val)
118 {
119  int i;
120  uint8_t *ptr = plane + stride * y;
121  for (i = 0; i < height; i++) {
122  memset(ptr, val, width);
123  ptr += stride;
124  }
125 }
126 
127 static void copyPlane(const uint8_t *src, int srcStride,
128  int srcSliceY, int srcSliceH, int width,
129  uint8_t *dst, int dstStride)
130 {
131  if (!srcSliceH)
132  return;
133  av_assert0(srcSliceH > 0);
134 
135  dst += dstStride * srcSliceY;
136  if (dstStride == srcStride && srcStride > 0) {
137  memcpy(dst, src, (srcSliceH - 1) * dstStride + width);
138  } else {
139  int i;
140  for (i = 0; i < srcSliceH; i++) {
141  memcpy(dst, src, width);
142  src += srcStride;
143  dst += dstStride;
144  }
145  }
146 }
147 
149  int srcStride[], int srcSliceY,
150  int srcSliceH, uint8_t *dstParam[],
151  int dstStride[])
152 {
153  uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
154 
155  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
156  dstParam[0], dstStride[0]);
157 
158  if (c->dstFormat == AV_PIX_FMT_NV12)
159  interleaveBytes(src[1], src[2], dst, c->chrSrcW, (srcSliceH + 1) / 2,
160  srcStride[1], srcStride[2], dstStride[1]);
161  else
162  interleaveBytes(src[2], src[1], dst, c->chrSrcW, (srcSliceH + 1) / 2,
163  srcStride[2], srcStride[1], dstStride[1]);
164 
165  return srcSliceH;
166 }
167 
169  int srcStride[], int srcSliceY,
170  int srcSliceH, uint8_t *dstParam[],
171  int dstStride[])
172 {
173  uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY / 2;
174  uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY / 2;
175 
176  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
177  dstParam[0], dstStride[0]);
178 
179  if (c->srcFormat == AV_PIX_FMT_NV12)
180  deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, (srcSliceH + 1) / 2,
181  srcStride[1], dstStride[1], dstStride[2]);
182  else
183  deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, (srcSliceH + 1) / 2,
184  srcStride[1], dstStride[2], dstStride[1]);
185 
186  return srcSliceH;
187 }
188 
190  int srcStride[], int srcSliceY,
191  int srcSliceH, uint8_t *dstParam[],
192  int dstStride[])
193 {
194  uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY;
195 
196  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
197  dstParam[0], dstStride[0]);
198 
199  if (c->dstFormat == AV_PIX_FMT_NV24)
200  interleaveBytes(src[1], src[2], dst, c->chrSrcW, srcSliceH,
201  srcStride[1], srcStride[2], dstStride[1]);
202  else
203  interleaveBytes(src[2], src[1], dst, c->chrSrcW, srcSliceH,
204  srcStride[2], srcStride[1], dstStride[1]);
205 
206  return srcSliceH;
207 }
208 
210  int srcStride[], int srcSliceY,
211  int srcSliceH, uint8_t *dstParam[],
212  int dstStride[])
213 {
214  uint8_t *dst1 = dstParam[1] + dstStride[1] * srcSliceY;
215  uint8_t *dst2 = dstParam[2] + dstStride[2] * srcSliceY;
216 
217  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
218  dstParam[0], dstStride[0]);
219 
220  if (c->srcFormat == AV_PIX_FMT_NV24)
221  deinterleaveBytes(src[1], dst1, dst2, c->chrSrcW, srcSliceH,
222  srcStride[1], dstStride[1], dstStride[2]);
223  else
224  deinterleaveBytes(src[1], dst2, dst1, c->chrSrcW, srcSliceH,
225  srcStride[1], dstStride[2], dstStride[1]);
226 
227  return srcSliceH;
228 }
229 
230 static int planarToP01xWrapper(SwsContext *c, const uint8_t *src8[],
231  int srcStride[], int srcSliceY,
232  int srcSliceH, uint8_t *dstParam8[],
233  int dstStride[])
234 {
235  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->srcFormat);
236  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->dstFormat);
237  const uint16_t **src = (const uint16_t**)src8;
238  uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
239  uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
240  int x, y;
241 
242  /* Calculate net shift required for values. */
243  const int shift[3] = {
244  dst_format->comp[0].depth + dst_format->comp[0].shift -
245  src_format->comp[0].depth - src_format->comp[0].shift,
246  dst_format->comp[1].depth + dst_format->comp[1].shift -
247  src_format->comp[1].depth - src_format->comp[1].shift,
248  dst_format->comp[2].depth + dst_format->comp[2].shift -
249  src_format->comp[2].depth - src_format->comp[2].shift,
250  };
251 
252  av_assert0(!(srcStride[0] % 2 || srcStride[1] % 2 || srcStride[2] % 2 ||
253  dstStride[0] % 2 || dstStride[1] % 2));
254 
255  for (y = 0; y < srcSliceH; y++) {
256  uint16_t *tdstY = dstY;
257  const uint16_t *tsrc0 = src[0];
258  for (x = c->srcW; x > 0; x--) {
259  *tdstY++ = *tsrc0++ << shift[0];
260  }
261  src[0] += srcStride[0] / 2;
262  dstY += dstStride[0] / 2;
263 
264  if (!(y & 1)) {
265  uint16_t *tdstUV = dstUV;
266  const uint16_t *tsrc1 = src[1];
267  const uint16_t *tsrc2 = src[2];
268  for (x = c->srcW / 2; x > 0; x--) {
269  *tdstUV++ = *tsrc1++ << shift[1];
270  *tdstUV++ = *tsrc2++ << shift[2];
271  }
272  src[1] += srcStride[1] / 2;
273  src[2] += srcStride[2] / 2;
274  dstUV += dstStride[1] / 2;
275  }
276  }
277 
278  return srcSliceH;
279 }
280 
281 #if AV_HAVE_BIGENDIAN
282 #define output_pixel(p, v) do { \
283  uint16_t *pp = (p); \
284  AV_WL16(pp, (v)); \
285  } while(0)
286 #else
287 #define output_pixel(p, v) (*p) = (v)
288 #endif
289 
291  int srcStride[], int srcSliceY,
292  int srcSliceH, uint8_t *dstParam8[],
293  int dstStride[])
294 {
295  uint16_t *dstY = (uint16_t*)(dstParam8[0] + dstStride[0] * srcSliceY);
296  uint16_t *dstUV = (uint16_t*)(dstParam8[1] + dstStride[1] * srcSliceY / 2);
297  int x, y, t;
298 
299  av_assert0(!(dstStride[0] % 2 || dstStride[1] % 2));
300 
301  for (y = 0; y < srcSliceH; y++) {
302  uint16_t *tdstY = dstY;
303  const uint8_t *tsrc0 = src[0];
304  for (x = c->srcW; x > 0; x--) {
305  t = *tsrc0++;
306  output_pixel(tdstY++, t | (t << 8));
307  }
308  src[0] += srcStride[0];
309  dstY += dstStride[0] / 2;
310 
311  if (!(y & 1)) {
312  uint16_t *tdstUV = dstUV;
313  const uint8_t *tsrc1 = src[1];
314  const uint8_t *tsrc2 = src[2];
315  for (x = c->srcW / 2; x > 0; x--) {
316  t = *tsrc1++;
317  output_pixel(tdstUV++, t | (t << 8));
318  t = *tsrc2++;
319  output_pixel(tdstUV++, t | (t << 8));
320  }
321  src[1] += srcStride[1];
322  src[2] += srcStride[2];
323  dstUV += dstStride[1] / 2;
324  }
325  }
326 
327  return srcSliceH;
328 }
329 
330 #undef output_pixel
331 
333  int srcStride[], int srcSliceY, int srcSliceH,
334  uint8_t *dstParam[], int dstStride[])
335 {
336  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
337 
338  yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
339  srcStride[1], dstStride[0]);
340 
341  return srcSliceH;
342 }
343 
345  int srcStride[], int srcSliceY, int srcSliceH,
346  uint8_t *dstParam[], int dstStride[])
347 {
348  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
349 
350  yv12touyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
351  srcStride[1], dstStride[0]);
352 
353  return srcSliceH;
354 }
355 
357  int srcStride[], int srcSliceY, int srcSliceH,
358  uint8_t *dstParam[], int dstStride[])
359 {
360  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
361 
362  yuv422ptoyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
363  srcStride[1], dstStride[0]);
364 
365  return srcSliceH;
366 }
367 
369  int srcStride[], int srcSliceY, int srcSliceH,
370  uint8_t *dstParam[], int dstStride[])
371 {
372  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
373 
374  yuv422ptouyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
375  srcStride[1], dstStride[0]);
376 
377  return srcSliceH;
378 }
379 
381  int srcStride[], int srcSliceY, int srcSliceH,
382  uint8_t *dstParam[], int dstStride[])
383 {
384  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
385  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
386  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
387 
388  yuyvtoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
389  dstStride[1], srcStride[0]);
390 
391  if (dstParam[3])
392  fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
393 
394  return srcSliceH;
395 }
396 
398  int srcStride[], int srcSliceY, int srcSliceH,
399  uint8_t *dstParam[], int dstStride[])
400 {
401  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
402  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
403  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
404 
405  yuyvtoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
406  dstStride[1], srcStride[0]);
407 
408  return srcSliceH;
409 }
410 
412  int srcStride[], int srcSliceY, int srcSliceH,
413  uint8_t *dstParam[], int dstStride[])
414 {
415  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
416  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
417  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
418 
419  uyvytoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
420  dstStride[1], srcStride[0]);
421 
422  if (dstParam[3])
423  fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
424 
425  return srcSliceH;
426 }
427 
429  int srcStride[], int srcSliceY, int srcSliceH,
430  uint8_t *dstParam[], int dstStride[])
431 {
432  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
433  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
434  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
435 
436  uyvytoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
437  dstStride[1], srcStride[0]);
438 
439  return srcSliceH;
440 }
441 
442 static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels,
443  const uint8_t *palette)
444 {
445  int i;
446  for (i = 0; i < num_pixels; i++)
447  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
448 }
449 
450 static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels,
451  const uint8_t *palette)
452 {
453  int i;
454 
455  for (i = 0; i < num_pixels; i++)
456  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
457 }
458 
459 static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
460  const uint8_t *palette)
461 {
462  int i;
463 
464  for (i = 0; i < num_pixels; i++) {
465  //FIXME slow?
466  dst[0] = palette[src[i << 1] * 4 + 0];
467  dst[1] = palette[src[i << 1] * 4 + 1];
468  dst[2] = palette[src[i << 1] * 4 + 2];
469  dst += 3;
470  }
471 }
472 
473 static int bswap_16bpc(SwsContext *c, const uint8_t *src[],
474  int srcStride[], int srcSliceY, int srcSliceH,
475  uint8_t *dst[], int dstStride[])
476 {
477  int i, j, p;
478 
479  for (p = 0; p < 4; p++) {
480  int srcstr = srcStride[p] / 2;
481  int dststr = dstStride[p] / 2;
482  uint16_t *dstPtr = (uint16_t *) dst[p];
483  const uint16_t *srcPtr = (const uint16_t *) src[p];
484  int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
485  if(!dstPtr || !srcPtr)
486  continue;
487  dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
488  for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
489  for (j = 0; j < min_stride; j++) {
490  dstPtr[j] = av_bswap16(srcPtr[j]);
491  }
492  srcPtr += srcstr;
493  dstPtr += dststr;
494  }
495  }
496 
497  return srcSliceH;
498 }
499 
500 static int bswap_32bpc(SwsContext *c, const uint8_t *src[],
501  int srcStride[], int srcSliceY, int srcSliceH,
502  uint8_t *dst[], int dstStride[])
503 {
504  int i, j, p;
505 
506  for (p = 0; p < 4; p++) {
507  int srcstr = srcStride[p] / 4;
508  int dststr = dstStride[p] / 4;
509  uint32_t *dstPtr = (uint32_t *) dst[p];
510  const uint32_t *srcPtr = (const uint32_t *) src[p];
511  int min_stride = FFMIN(FFABS(srcstr), FFABS(dststr));
512  if(!dstPtr || !srcPtr)
513  continue;
514  dstPtr += (srcSliceY >> c->chrDstVSubSample) * dststr;
515  for (i = 0; i < (srcSliceH >> c->chrDstVSubSample); i++) {
516  for (j = 0; j < min_stride; j++) {
517  dstPtr[j] = av_bswap32(srcPtr[j]);
518  }
519  srcPtr += srcstr;
520  dstPtr += dststr;
521  }
522  }
523 
524  return srcSliceH;
525 }
526 
527 
528 static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
529  int srcSliceY, int srcSliceH, uint8_t *dst[],
530  int dstStride[])
531 {
532  const enum AVPixelFormat srcFormat = c->srcFormat;
533  const enum AVPixelFormat dstFormat = c->dstFormat;
534  void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
535  const uint8_t *palette) = NULL;
536  int i;
537  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
538  const uint8_t *srcPtr = src[0];
539 
540  if (srcFormat == AV_PIX_FMT_YA8) {
541  switch (dstFormat) {
542  case AV_PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
543  case AV_PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
546  case AV_PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
547  case AV_PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
548  }
549  } else if (usePal(srcFormat)) {
550  switch (dstFormat) {
557  }
558  }
559 
560  if (!conv)
561  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
562  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
563  else {
564  for (i = 0; i < srcSliceH; i++) {
565  conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
566  srcPtr += srcStride[0];
567  dstPtr += dstStride[0];
568  }
569  }
570 
571  return srcSliceH;
572 }
573 
574 static void packed16togbra16(const uint8_t *src, int srcStride,
575  uint16_t *dst[], int dstStride[], int srcSliceH,
576  int src_alpha, int swap, int shift, int width)
577 {
578  int x, h, i;
579  int dst_alpha = dst[3] != NULL;
580  for (h = 0; h < srcSliceH; h++) {
581  uint16_t *src_line = (uint16_t *)(src + srcStride * h);
582  switch (swap) {
583  case 3:
584  if (src_alpha && dst_alpha) {
585  for (x = 0; x < width; x++) {
586  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
587  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
588  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
589  dst[3][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
590  }
591  } else if (dst_alpha) {
592  for (x = 0; x < width; x++) {
593  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
594  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
595  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
596  dst[3][x] = av_bswap16(0xFFFF >> shift);
597  }
598  } else if (src_alpha) {
599  for (x = 0; x < width; x++) {
600  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
601  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
602  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
603  src_line++;
604  }
605  } else {
606  for (x = 0; x < width; x++) {
607  dst[0][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
608  dst[1][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
609  dst[2][x] = av_bswap16(av_bswap16(*src_line++) >> shift);
610  }
611  }
612  break;
613  case 2:
614  if (src_alpha && dst_alpha) {
615  for (x = 0; x < width; x++) {
616  dst[0][x] = av_bswap16(*src_line++ >> shift);
617  dst[1][x] = av_bswap16(*src_line++ >> shift);
618  dst[2][x] = av_bswap16(*src_line++ >> shift);
619  dst[3][x] = av_bswap16(*src_line++ >> shift);
620  }
621  } else if (dst_alpha) {
622  for (x = 0; x < width; x++) {
623  dst[0][x] = av_bswap16(*src_line++ >> shift);
624  dst[1][x] = av_bswap16(*src_line++ >> shift);
625  dst[2][x] = av_bswap16(*src_line++ >> shift);
626  dst[3][x] = av_bswap16(0xFFFF >> shift);
627  }
628  } else if (src_alpha) {
629  for (x = 0; x < width; x++) {
630  dst[0][x] = av_bswap16(*src_line++ >> shift);
631  dst[1][x] = av_bswap16(*src_line++ >> shift);
632  dst[2][x] = av_bswap16(*src_line++ >> shift);
633  src_line++;
634  }
635  } else {
636  for (x = 0; x < width; x++) {
637  dst[0][x] = av_bswap16(*src_line++ >> shift);
638  dst[1][x] = av_bswap16(*src_line++ >> shift);
639  dst[2][x] = av_bswap16(*src_line++ >> shift);
640  }
641  }
642  break;
643  case 1:
644  if (src_alpha && dst_alpha) {
645  for (x = 0; x < width; x++) {
646  dst[0][x] = av_bswap16(*src_line++) >> shift;
647  dst[1][x] = av_bswap16(*src_line++) >> shift;
648  dst[2][x] = av_bswap16(*src_line++) >> shift;
649  dst[3][x] = av_bswap16(*src_line++) >> shift;
650  }
651  } else if (dst_alpha) {
652  for (x = 0; x < width; x++) {
653  dst[0][x] = av_bswap16(*src_line++) >> shift;
654  dst[1][x] = av_bswap16(*src_line++) >> shift;
655  dst[2][x] = av_bswap16(*src_line++) >> shift;
656  dst[3][x] = 0xFFFF >> shift;
657  }
658  } else if (src_alpha) {
659  for (x = 0; x < width; x++) {
660  dst[0][x] = av_bswap16(*src_line++) >> shift;
661  dst[1][x] = av_bswap16(*src_line++) >> shift;
662  dst[2][x] = av_bswap16(*src_line++) >> shift;
663  src_line++;
664  }
665  } else {
666  for (x = 0; x < width; x++) {
667  dst[0][x] = av_bswap16(*src_line++) >> shift;
668  dst[1][x] = av_bswap16(*src_line++) >> shift;
669  dst[2][x] = av_bswap16(*src_line++) >> shift;
670  }
671  }
672  break;
673  default:
674  if (src_alpha && dst_alpha) {
675  for (x = 0; x < width; x++) {
676  dst[0][x] = *src_line++ >> shift;
677  dst[1][x] = *src_line++ >> shift;
678  dst[2][x] = *src_line++ >> shift;
679  dst[3][x] = *src_line++ >> shift;
680  }
681  } else if (dst_alpha) {
682  for (x = 0; x < width; x++) {
683  dst[0][x] = *src_line++ >> shift;
684  dst[1][x] = *src_line++ >> shift;
685  dst[2][x] = *src_line++ >> shift;
686  dst[3][x] = 0xFFFF >> shift;
687  }
688  } else if (src_alpha) {
689  for (x = 0; x < width; x++) {
690  dst[0][x] = *src_line++ >> shift;
691  dst[1][x] = *src_line++ >> shift;
692  dst[2][x] = *src_line++ >> shift;
693  src_line++;
694  }
695  } else {
696  for (x = 0; x < width; x++) {
697  dst[0][x] = *src_line++ >> shift;
698  dst[1][x] = *src_line++ >> shift;
699  dst[2][x] = *src_line++ >> shift;
700  }
701  }
702  }
703  for (i = 0; i < 4; i++)
704  dst[i] += dstStride[i] >> 1;
705  }
706 }
707 
709  int srcStride[], int srcSliceY, int srcSliceH,
710  uint8_t *dst[], int dstStride[])
711 {
712  uint16_t *dst2013[] = { (uint16_t *)dst[2], (uint16_t *)dst[0], (uint16_t *)dst[1], (uint16_t *)dst[3] };
713  uint16_t *dst1023[] = { (uint16_t *)dst[1], (uint16_t *)dst[0], (uint16_t *)dst[2], (uint16_t *)dst[3] };
714  int stride2013[] = { dstStride[2], dstStride[0], dstStride[1], dstStride[3] };
715  int stride1023[] = { dstStride[1], dstStride[0], dstStride[2], dstStride[3] };
716  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->srcFormat);
717  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->dstFormat);
718  int bpc = dst_format->comp[0].depth;
719  int alpha = src_format->flags & AV_PIX_FMT_FLAG_ALPHA;
720  int swap = 0;
721  int i;
722 
723  if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
724  !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
725  swap++;
726  if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
727  !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
728  swap += 2;
729 
730  if ((dst_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
732  av_log(c, AV_LOG_ERROR, "unsupported conversion to planar RGB %s -> %s\n",
733  src_format->name, dst_format->name);
734  return srcSliceH;
735  }
736 
737  for (i = 0; i < 4 && dst[i]; i++) {
738  dst2013[i] += stride2013[i] * srcSliceY / 2;
739  dst1023[i] += stride1023[i] * srcSliceY / 2;
740  }
741 
742  switch (c->srcFormat) {
743  case AV_PIX_FMT_RGB48LE:
744  case AV_PIX_FMT_RGB48BE:
745  case AV_PIX_FMT_RGBA64LE:
746  case AV_PIX_FMT_RGBA64BE:
747  packed16togbra16(src[0], srcStride[0],
748  dst2013, stride2013, srcSliceH, alpha, swap,
749  16 - bpc, c->srcW);
750  break;
751  case AV_PIX_FMT_BGR48LE:
752  case AV_PIX_FMT_BGR48BE:
753  case AV_PIX_FMT_BGRA64LE:
754  case AV_PIX_FMT_BGRA64BE:
755  packed16togbra16(src[0], srcStride[0],
756  dst1023, stride1023, srcSliceH, alpha, swap,
757  16 - bpc, c->srcW);
758  break;
759  default:
761  "unsupported conversion to planar RGB %s -> %s\n",
762  src_format->name, dst_format->name);
763  }
764 
765  return srcSliceH;
766 }
767 
768 static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
769  uint8_t *dst, int dstStride, int srcSliceH,
770  int alpha, int swap, int bpp, int width)
771 {
772  int x, h, i;
773  int src_alpha = src[3] != NULL;
774  int scale_high = 16 - bpp, scale_low = (bpp - 8) * 2;
775  for (h = 0; h < srcSliceH; h++) {
776  uint16_t *dest = (uint16_t *)(dst + dstStride * h);
777  uint16_t component;
778 
779  switch(swap) {
780  case 3:
781  if (alpha && !src_alpha) {
782  for (x = 0; x < width; x++) {
783  component = av_bswap16(src[0][x]);
784  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
785  component = av_bswap16(src[1][x]);
786  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
787  component = av_bswap16(src[2][x]);
788  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
789  *dest++ = 0xffff;
790  }
791  } else if (alpha && src_alpha) {
792  for (x = 0; x < width; x++) {
793  component = av_bswap16(src[0][x]);
794  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
795  component = av_bswap16(src[1][x]);
796  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
797  component = av_bswap16(src[2][x]);
798  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
799  component = av_bswap16(src[3][x]);
800  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
801  }
802  } else {
803  for (x = 0; x < width; x++) {
804  component = av_bswap16(src[0][x]);
805  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
806  component = av_bswap16(src[1][x]);
807  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
808  component = av_bswap16(src[2][x]);
809  *dest++ = av_bswap16(component << scale_high | component >> scale_low);
810  }
811  }
812  break;
813  case 2:
814  if (alpha && !src_alpha) {
815  for (x = 0; x < width; x++) {
816  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
817  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
818  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
819  *dest++ = 0xffff;
820  }
821  } else if (alpha && src_alpha) {
822  for (x = 0; x < width; x++) {
823  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
824  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
825  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
826  *dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
827  }
828  } else {
829  for (x = 0; x < width; x++) {
830  *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
831  *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
832  *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
833  }
834  }
835  break;
836  case 1:
837  if (alpha && !src_alpha) {
838  for (x = 0; x < width; x++) {
839  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
840  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
841  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
842  *dest++ = 0xffff;
843  }
844  } else if (alpha && src_alpha) {
845  for (x = 0; x < width; x++) {
846  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
847  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
848  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
849  *dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
850  }
851  } else {
852  for (x = 0; x < width; x++) {
853  *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
854  *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
855  *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
856  }
857  }
858  break;
859  default:
860  if (alpha && !src_alpha) {
861  for (x = 0; x < width; x++) {
862  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
863  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
864  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
865  *dest++ = 0xffff;
866  }
867  } else if (alpha && src_alpha) {
868  for (x = 0; x < width; x++) {
869  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
870  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
871  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
872  *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
873  }
874  } else {
875  for (x = 0; x < width; x++) {
876  *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
877  *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
878  *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
879  }
880  }
881  }
882  for (i = 0; i < 3 + src_alpha; i++)
883  src[i] += srcStride[i] >> 1;
884  }
885 }
886 
888  int srcStride[], int srcSliceY, int srcSliceH,
889  uint8_t *dst[], int dstStride[])
890 {
891  const uint16_t *src102[] = { (uint16_t *)src[1], (uint16_t *)src[0], (uint16_t *)src[2], (uint16_t *)src[3] };
892  const uint16_t *src201[] = { (uint16_t *)src[2], (uint16_t *)src[0], (uint16_t *)src[1], (uint16_t *)src[3] };
893  int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
894  int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
895  const AVPixFmtDescriptor *src_format = av_pix_fmt_desc_get(c->srcFormat);
896  const AVPixFmtDescriptor *dst_format = av_pix_fmt_desc_get(c->dstFormat);
897  int bits_per_sample = src_format->comp[0].depth;
898  int swap = 0;
899  if ( HAVE_BIGENDIAN && !(src_format->flags & AV_PIX_FMT_FLAG_BE) ||
900  !HAVE_BIGENDIAN && src_format->flags & AV_PIX_FMT_FLAG_BE)
901  swap++;
902  if ( HAVE_BIGENDIAN && !(dst_format->flags & AV_PIX_FMT_FLAG_BE) ||
903  !HAVE_BIGENDIAN && dst_format->flags & AV_PIX_FMT_FLAG_BE)
904  swap += 2;
905 
906  if ((src_format->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) !=
908  bits_per_sample <= 8) {
909  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
910  src_format->name, dst_format->name);
911  return srcSliceH;
912  }
913  switch (c->dstFormat) {
914  case AV_PIX_FMT_BGR48LE:
915  case AV_PIX_FMT_BGR48BE:
916  gbr16ptopacked16(src102, stride102,
917  dst[0] + srcSliceY * dstStride[0], dstStride[0],
918  srcSliceH, 0, swap, bits_per_sample, c->srcW);
919  break;
920  case AV_PIX_FMT_RGB48LE:
921  case AV_PIX_FMT_RGB48BE:
922  gbr16ptopacked16(src201, stride201,
923  dst[0] + srcSliceY * dstStride[0], dstStride[0],
924  srcSliceH, 0, swap, bits_per_sample, c->srcW);
925  break;
926  case AV_PIX_FMT_RGBA64LE:
927  case AV_PIX_FMT_RGBA64BE:
928  gbr16ptopacked16(src201, stride201,
929  dst[0] + srcSliceY * dstStride[0], dstStride[0],
930  srcSliceH, 1, swap, bits_per_sample, c->srcW);
931  break;
932  case AV_PIX_FMT_BGRA64LE:
933  case AV_PIX_FMT_BGRA64BE:
934  gbr16ptopacked16(src102, stride102,
935  dst[0] + srcSliceY * dstStride[0], dstStride[0],
936  srcSliceH, 1, swap, bits_per_sample, c->srcW);
937  break;
938  default:
940  "unsupported planar RGB conversion %s -> %s\n",
941  src_format->name, dst_format->name);
942  }
943 
944  return srcSliceH;
945 }
946 
947 static void gbr24ptopacked24(const uint8_t *src[], int srcStride[],
948  uint8_t *dst, int dstStride, int srcSliceH,
949  int width)
950 {
951  int x, h, i;
952  for (h = 0; h < srcSliceH; h++) {
953  uint8_t *dest = dst + dstStride * h;
954  for (x = 0; x < width; x++) {
955  *dest++ = src[0][x];
956  *dest++ = src[1][x];
957  *dest++ = src[2][x];
958  }
959 
960  for (i = 0; i < 3; i++)
961  src[i] += srcStride[i];
962  }
963 }
964 
965 static void gbr24ptopacked32(const uint8_t *src[], int srcStride[],
966  uint8_t *dst, int dstStride, int srcSliceH,
967  int alpha_first, int width)
968 {
969  int x, h, i;
970  for (h = 0; h < srcSliceH; h++) {
971  uint8_t *dest = dst + dstStride * h;
972 
973  if (alpha_first) {
974  for (x = 0; x < width; x++) {
975  *dest++ = 0xff;
976  *dest++ = src[0][x];
977  *dest++ = src[1][x];
978  *dest++ = src[2][x];
979  }
980  } else {
981  for (x = 0; x < width; x++) {
982  *dest++ = src[0][x];
983  *dest++ = src[1][x];
984  *dest++ = src[2][x];
985  *dest++ = 0xff;
986  }
987  }
988 
989  for (i = 0; i < 3; i++)
990  src[i] += srcStride[i];
991  }
992 }
993 
994 static void gbraptopacked32(const uint8_t *src[], int srcStride[],
995  uint8_t *dst, int dstStride, int srcSliceH,
996  int alpha_first, int width)
997 {
998  int x, h, i;
999  for (h = 0; h < srcSliceH; h++) {
1000  uint8_t *dest = dst + dstStride * h;
1001 
1002  if (alpha_first) {
1003  for (x = 0; x < width; x++) {
1004  *dest++ = src[3][x];
1005  *dest++ = src[0][x];
1006  *dest++ = src[1][x];
1007  *dest++ = src[2][x];
1008  }
1009  } else {
1010  for (x = 0; x < width; x++) {
1011  *dest++ = src[0][x];
1012  *dest++ = src[1][x];
1013  *dest++ = src[2][x];
1014  *dest++ = src[3][x];
1015  }
1016  }
1017 
1018  for (i = 0; i < 4; i++)
1019  src[i] += srcStride[i];
1020  }
1021 }
1022 
1024  int srcStride[], int srcSliceY, int srcSliceH,
1025  uint8_t *dst[], int dstStride[])
1026 {
1027  int alpha_first = 0;
1028  const uint8_t *src102[] = { src[1], src[0], src[2], src[3] };
1029  const uint8_t *src201[] = { src[2], src[0], src[1], src[3] };
1030  int stride102[] = { srcStride[1], srcStride[0], srcStride[2], srcStride[3] };
1031  int stride201[] = { srcStride[2], srcStride[0], srcStride[1], srcStride[3] };
1032 
1033  if (c->srcFormat != AV_PIX_FMT_GBRAP) {
1034  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1035  av_get_pix_fmt_name(c->srcFormat),
1036  av_get_pix_fmt_name(c->dstFormat));
1037  return srcSliceH;
1038  }
1039 
1040  switch (c->dstFormat) {
1041  case AV_PIX_FMT_BGR24:
1042  gbr24ptopacked24(src102, stride102,
1043  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1044  srcSliceH, c->srcW);
1045  break;
1046 
1047  case AV_PIX_FMT_RGB24:
1048  gbr24ptopacked24(src201, stride201,
1049  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1050  srcSliceH, c->srcW);
1051  break;
1052 
1053  case AV_PIX_FMT_ARGB:
1054  alpha_first = 1;
1055  case AV_PIX_FMT_RGBA:
1056  gbraptopacked32(src201, stride201,
1057  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1058  srcSliceH, alpha_first, c->srcW);
1059  break;
1060 
1061  case AV_PIX_FMT_ABGR:
1062  alpha_first = 1;
1063  case AV_PIX_FMT_BGRA:
1064  gbraptopacked32(src102, stride102,
1065  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1066  srcSliceH, alpha_first, c->srcW);
1067  break;
1068 
1069  default:
1071  "unsupported planar RGB conversion %s -> %s\n",
1072  av_get_pix_fmt_name(c->srcFormat),
1073  av_get_pix_fmt_name(c->dstFormat));
1074  }
1075 
1076  return srcSliceH;
1077 }
1078 
1080  int srcStride[], int srcSliceY, int srcSliceH,
1081  uint8_t *dst[], int dstStride[])
1082 {
1083  int alpha_first = 0;
1084  const uint8_t *src102[] = { src[1], src[0], src[2] };
1085  const uint8_t *src201[] = { src[2], src[0], src[1] };
1086  int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
1087  int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
1088 
1089  if (c->srcFormat != AV_PIX_FMT_GBRP) {
1090  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
1091  av_get_pix_fmt_name(c->srcFormat),
1092  av_get_pix_fmt_name(c->dstFormat));
1093  return srcSliceH;
1094  }
1095 
1096  switch (c->dstFormat) {
1097  case AV_PIX_FMT_BGR24:
1098  gbr24ptopacked24(src102, stride102,
1099  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1100  srcSliceH, c->srcW);
1101  break;
1102 
1103  case AV_PIX_FMT_RGB24:
1104  gbr24ptopacked24(src201, stride201,
1105  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1106  srcSliceH, c->srcW);
1107  break;
1108 
1109  case AV_PIX_FMT_ARGB:
1110  alpha_first = 1;
1111  case AV_PIX_FMT_RGBA:
1112  gbr24ptopacked32(src201, stride201,
1113  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1114  srcSliceH, alpha_first, c->srcW);
1115  break;
1116 
1117  case AV_PIX_FMT_ABGR:
1118  alpha_first = 1;
1119  case AV_PIX_FMT_BGRA:
1120  gbr24ptopacked32(src102, stride102,
1121  dst[0] + srcSliceY * dstStride[0], dstStride[0],
1122  srcSliceH, alpha_first, c->srcW);
1123  break;
1124 
1125  default:
1127  "unsupported planar RGB conversion %s -> %s\n",
1128  av_get_pix_fmt_name(c->srcFormat),
1129  av_get_pix_fmt_name(c->dstFormat));
1130  }
1131 
1132  return srcSliceH;
1133 }
1134 
1136  const uint8_t *src[], int srcStride[],
1137  int srcSliceY, int srcSliceH,
1138  uint8_t *dst[], int dstStride[])
1139 {
1140  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
1141  dst[0], dstStride[0]);
1142  copyPlane(src[1], srcStride[1], srcSliceY, srcSliceH, c->srcW,
1143  dst[1], dstStride[1]);
1144  copyPlane(src[2], srcStride[2], srcSliceY, srcSliceH, c->srcW,
1145  dst[2], dstStride[2]);
1146  if (dst[3])
1147  fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
1148 
1149  return srcSliceH;
1150 }
1151 
1152 static void packedtogbr24p(const uint8_t *src, int srcStride,
1153  uint8_t *dst[], int dstStride[], int srcSliceH,
1154  int alpha_first, int inc_size, int width)
1155 {
1156  uint8_t *dest[3];
1157  int x, h;
1158 
1159  dest[0] = dst[0];
1160  dest[1] = dst[1];
1161  dest[2] = dst[2];
1162 
1163  if (alpha_first)
1164  src++;
1165 
1166  for (h = 0; h < srcSliceH; h++) {
1167  for (x = 0; x < width; x++) {
1168  dest[0][x] = src[0];
1169  dest[1][x] = src[1];
1170  dest[2][x] = src[2];
1171 
1172  src += inc_size;
1173  }
1174  src += srcStride - width * inc_size;
1175  dest[0] += dstStride[0];
1176  dest[1] += dstStride[1];
1177  dest[2] += dstStride[2];
1178  }
1179 }
1180 
1182  int srcStride[], int srcSliceY, int srcSliceH,
1183  uint8_t *dst[], int dstStride[])
1184 {
1185  int alpha_first = 0;
1186  int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
1187  int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
1188  uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
1189  dst[0] + srcSliceY * dstStride[0],
1190  dst[2] + srcSliceY * dstStride[2] };
1191  uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
1192  dst[0] + srcSliceY * dstStride[0],
1193  dst[1] + srcSliceY * dstStride[1] };
1194 
1195  switch (c->srcFormat) {
1196  case AV_PIX_FMT_RGB24:
1197  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1198  stride201, srcSliceH, alpha_first, 3, c->srcW);
1199  break;
1200  case AV_PIX_FMT_BGR24:
1201  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1202  stride102, srcSliceH, alpha_first, 3, c->srcW);
1203  break;
1204  case AV_PIX_FMT_ARGB:
1205  alpha_first = 1;
1206  case AV_PIX_FMT_RGBA:
1207  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
1208  stride201, srcSliceH, alpha_first, 4, c->srcW);
1209  break;
1210  case AV_PIX_FMT_ABGR:
1211  alpha_first = 1;
1212  case AV_PIX_FMT_BGRA:
1213  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
1214  stride102, srcSliceH, alpha_first, 4, c->srcW);
1215  break;
1216  default:
1218  "unsupported planar RGB conversion %s -> %s\n",
1219  av_get_pix_fmt_name(c->srcFormat),
1220  av_get_pix_fmt_name(c->dstFormat));
1221  }
1222 
1223  return srcSliceH;
1224 }
1225 
1226 #define BAYER_GBRG
1227 #define BAYER_8
1228 #define BAYER_RENAME(x) bayer_gbrg8_to_##x
1229 #include "bayer_template.c"
1230 
1231 #define BAYER_GBRG
1232 #define BAYER_16LE
1233 #define BAYER_RENAME(x) bayer_gbrg16le_to_##x
1234 #include "bayer_template.c"
1235 
1236 #define BAYER_GBRG
1237 #define BAYER_16BE
1238 #define BAYER_RENAME(x) bayer_gbrg16be_to_##x
1239 #include "bayer_template.c"
1240 
1241 #define BAYER_GRBG
1242 #define BAYER_8
1243 #define BAYER_RENAME(x) bayer_grbg8_to_##x
1244 #include "bayer_template.c"
1245 
1246 #define BAYER_GRBG
1247 #define BAYER_16LE
1248 #define BAYER_RENAME(x) bayer_grbg16le_to_##x
1249 #include "bayer_template.c"
1250 
1251 #define BAYER_GRBG
1252 #define BAYER_16BE
1253 #define BAYER_RENAME(x) bayer_grbg16be_to_##x
1254 #include "bayer_template.c"
1255 
1256 #define BAYER_BGGR
1257 #define BAYER_8
1258 #define BAYER_RENAME(x) bayer_bggr8_to_##x
1259 #include "bayer_template.c"
1260 
1261 #define BAYER_BGGR
1262 #define BAYER_16LE
1263 #define BAYER_RENAME(x) bayer_bggr16le_to_##x
1264 #include "bayer_template.c"
1265 
1266 #define BAYER_BGGR
1267 #define BAYER_16BE
1268 #define BAYER_RENAME(x) bayer_bggr16be_to_##x
1269 #include "bayer_template.c"
1270 
1271 #define BAYER_RGGB
1272 #define BAYER_8
1273 #define BAYER_RENAME(x) bayer_rggb8_to_##x
1274 #include "bayer_template.c"
1275 
1276 #define BAYER_RGGB
1277 #define BAYER_16LE
1278 #define BAYER_RENAME(x) bayer_rggb16le_to_##x
1279 #include "bayer_template.c"
1280 
1281 #define BAYER_RGGB
1282 #define BAYER_16BE
1283 #define BAYER_RENAME(x) bayer_rggb16be_to_##x
1284 #include "bayer_template.c"
1285 
1286 static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
1287  int srcSliceH, uint8_t* dst[], int dstStride[])
1288 {
1289  uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1290  const uint8_t *srcPtr= src[0];
1291  int i;
1292  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1293  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1294 
1295  switch(c->srcFormat) {
1296 #define CASE(pixfmt, prefix) \
1297  case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \
1298  interpolate = bayer_##prefix##_to_rgb24_interpolate; \
1299  break;
1301  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1302  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1304  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1305  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1307  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1308  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1310  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1311  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1312 #undef CASE
1313  default: return 0;
1314  }
1315 
1316  av_assert0(srcSliceH > 1);
1317 
1318  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1319  srcPtr += 2 * srcStride[0];
1320  dstPtr += 2 * dstStride[0];
1321 
1322  for (i = 2; i < srcSliceH - 2; i += 2) {
1323  interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1324  srcPtr += 2 * srcStride[0];
1325  dstPtr += 2 * dstStride[0];
1326  }
1327 
1328  if (i + 1 == srcSliceH) {
1329  copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->srcW);
1330  } else if (i < srcSliceH)
1331  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1332  return srcSliceH;
1333 }
1334 
1335 static int bayer_to_rgb48_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
1336  int srcSliceH, uint8_t* dst[], int dstStride[])
1337 {
1338  uint8_t *dstPtr= dst[0] + srcSliceY * dstStride[0];
1339  const uint8_t *srcPtr= src[0];
1340  int i;
1341  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1342  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width);
1343 
1344  switch(c->srcFormat) {
1345 #define CASE(pixfmt, prefix) \
1346  case pixfmt: copy = bayer_##prefix##_to_rgb48_copy; \
1347  interpolate = bayer_##prefix##_to_rgb48_interpolate; \
1348  break;
1350  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1351  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1353  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1354  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1356  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1357  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1359  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1360  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1361 #undef CASE
1362  default: return 0;
1363  }
1364 
1365  av_assert0(srcSliceH > 1);
1366 
1367  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1368  srcPtr += 2 * srcStride[0];
1369  dstPtr += 2 * dstStride[0];
1370 
1371  for (i = 2; i < srcSliceH - 2; i += 2) {
1372  interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1373  srcPtr += 2 * srcStride[0];
1374  dstPtr += 2 * dstStride[0];
1375  }
1376 
1377  if (i + 1 == srcSliceH) {
1378  copy(srcPtr, -srcStride[0], dstPtr, -dstStride[0], c->srcW);
1379  } else if (i < srcSliceH)
1380  copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW);
1381  return srcSliceH;
1382 }
1383 
1384 static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
1385  int srcSliceH, uint8_t* dst[], int dstStride[])
1386 {
1387  const uint8_t *srcPtr= src[0];
1388  uint8_t *dstY= dst[0] + srcSliceY * dstStride[0];
1389  uint8_t *dstU= dst[1] + srcSliceY * dstStride[1] / 2;
1390  uint8_t *dstV= dst[2] + srcSliceY * dstStride[2] / 2;
1391  int i;
1392  void (*copy) (const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
1393  void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, int luma_stride, int width, int32_t *rgb2yuv);
1394 
1395  switch(c->srcFormat) {
1396 #define CASE(pixfmt, prefix) \
1397  case pixfmt: copy = bayer_##prefix##_to_yv12_copy; \
1398  interpolate = bayer_##prefix##_to_yv12_interpolate; \
1399  break;
1401  CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le)
1402  CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be)
1404  CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le)
1405  CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be)
1407  CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le)
1408  CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be)
1410  CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le)
1411  CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be)
1412 #undef CASE
1413  default: return 0;
1414  }
1415 
1416  av_assert0(srcSliceH > 1);
1417 
1418  copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
1419  srcPtr += 2 * srcStride[0];
1420  dstY += 2 * dstStride[0];
1421  dstU += dstStride[1];
1422  dstV += dstStride[1];
1423 
1424  for (i = 2; i < srcSliceH - 2; i += 2) {
1425  interpolate(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
1426  srcPtr += 2 * srcStride[0];
1427  dstY += 2 * dstStride[0];
1428  dstU += dstStride[1];
1429  dstV += dstStride[1];
1430  }
1431 
1432  if (i + 1 == srcSliceH) {
1433  copy(srcPtr, -srcStride[0], dstY, dstU, dstV, -dstStride[0], c->srcW, c->input_rgb2yuv_table);
1434  } else if (i < srcSliceH)
1435  copy(srcPtr, srcStride[0], dstY, dstU, dstV, dstStride[0], c->srcW, c->input_rgb2yuv_table);
1436  return srcSliceH;
1437 }
1438 
1439 #define isRGBA32(x) ( \
1440  (x) == AV_PIX_FMT_ARGB \
1441  || (x) == AV_PIX_FMT_RGBA \
1442  || (x) == AV_PIX_FMT_BGRA \
1443  || (x) == AV_PIX_FMT_ABGR \
1444  )
1445 
1446 #define isRGBA64(x) ( \
1447  (x) == AV_PIX_FMT_RGBA64LE \
1448  || (x) == AV_PIX_FMT_RGBA64BE \
1449  || (x) == AV_PIX_FMT_BGRA64LE \
1450  || (x) == AV_PIX_FMT_BGRA64BE \
1451  )
1452 
1453 #define isRGB48(x) ( \
1454  (x) == AV_PIX_FMT_RGB48LE \
1455  || (x) == AV_PIX_FMT_RGB48BE \
1456  || (x) == AV_PIX_FMT_BGR48LE \
1457  || (x) == AV_PIX_FMT_BGR48BE \
1458  )
1459 
1460 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1461 typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
1463 {
1464  const enum AVPixelFormat srcFormat = c->srcFormat;
1465  const enum AVPixelFormat dstFormat = c->dstFormat;
1466  const int srcId = c->srcFormatBpp;
1467  const int dstId = c->dstFormatBpp;
1468  rgbConvFn conv = NULL;
1469 
1470 #define IS_NOT_NE(bpp, desc) \
1471  (((bpp + 7) >> 3) == 2 && \
1472  (!(desc->flags & AV_PIX_FMT_FLAG_BE) != !HAVE_BIGENDIAN))
1473 
1474 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
1475 
1476  if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
1477  if ( CONV_IS(ABGR, RGBA)
1478  || CONV_IS(ARGB, BGRA)
1479  || CONV_IS(BGRA, ARGB)
1480  || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
1481  else if (CONV_IS(ABGR, ARGB)
1482  || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
1483  else if (CONV_IS(ABGR, BGRA)
1484  || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
1485  else if (CONV_IS(BGRA, RGBA)
1486  || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
1487  else if (CONV_IS(BGRA, ABGR)
1488  || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
1489  } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
1490  if (CONV_IS(RGB48LE, BGR48LE)
1491  || CONV_IS(BGR48LE, RGB48LE)
1492  || CONV_IS(RGB48BE, BGR48BE)
1493  || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
1494  else if (CONV_IS(RGB48LE, BGR48BE)
1495  || CONV_IS(BGR48LE, RGB48BE)
1496  || CONV_IS(RGB48BE, BGR48LE)
1497  || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
1498  } else if (isRGB48(srcFormat) && isRGBA64(dstFormat)) {
1499  if (CONV_IS(RGB48LE, BGRA64LE)
1500  || CONV_IS(BGR48LE, RGBA64LE)
1501  || CONV_IS(RGB48BE, BGRA64BE)
1502  || CONV_IS(BGR48BE, RGBA64BE)) conv = rgb48tobgr64_nobswap;
1503  else if (CONV_IS(RGB48LE, BGRA64BE)
1504  || CONV_IS(BGR48LE, RGBA64BE)
1505  || CONV_IS(RGB48BE, BGRA64LE)
1506  || CONV_IS(BGR48BE, RGBA64LE)) conv = rgb48tobgr64_bswap;
1507  if (CONV_IS(RGB48LE, RGBA64LE)
1508  || CONV_IS(BGR48LE, BGRA64LE)
1509  || CONV_IS(RGB48BE, RGBA64BE)
1510  || CONV_IS(BGR48BE, BGRA64BE)) conv = rgb48to64_nobswap;
1511  else if (CONV_IS(RGB48LE, RGBA64BE)
1512  || CONV_IS(BGR48LE, BGRA64BE)
1513  || CONV_IS(RGB48BE, RGBA64LE)
1514  || CONV_IS(BGR48BE, BGRA64LE)) conv = rgb48to64_bswap;
1515  } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
1516  if (CONV_IS(RGBA64LE, BGR48LE)
1517  || CONV_IS(BGRA64LE, RGB48LE)
1518  || CONV_IS(RGBA64BE, BGR48BE)
1519  || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
1520  else if (CONV_IS(RGBA64LE, BGR48BE)
1521  || CONV_IS(BGRA64LE, RGB48BE)
1522  || CONV_IS(RGBA64BE, BGR48LE)
1523  || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
1524  else if (CONV_IS(RGBA64LE, RGB48LE)
1525  || CONV_IS(BGRA64LE, BGR48LE)
1526  || CONV_IS(RGBA64BE, RGB48BE)
1527  || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
1528  else if (CONV_IS(RGBA64LE, RGB48BE)
1529  || CONV_IS(BGRA64LE, BGR48BE)
1530  || CONV_IS(RGBA64BE, RGB48LE)
1531  || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
1532  } else
1533  /* BGR -> BGR */
1534  if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
1535  (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
1536  switch (srcId | (dstId << 16)) {
1537  case 0x000F000C: conv = rgb12to15; break;
1538  case 0x000F0010: conv = rgb16to15; break;
1539  case 0x000F0018: conv = rgb24to15; break;
1540  case 0x000F0020: conv = rgb32to15; break;
1541  case 0x0010000F: conv = rgb15to16; break;
1542  case 0x00100018: conv = rgb24to16; break;
1543  case 0x00100020: conv = rgb32to16; break;
1544  case 0x0018000F: conv = rgb15to24; break;
1545  case 0x00180010: conv = rgb16to24; break;
1546  case 0x00180020: conv = rgb32to24; break;
1547  case 0x0020000F: conv = rgb15to32; break;
1548  case 0x00200010: conv = rgb16to32; break;
1549  case 0x00200018: conv = rgb24to32; break;
1550  }
1551  } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
1552  (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
1553  switch (srcId | (dstId << 16)) {
1554  case 0x000C000C: conv = rgb12tobgr12; break;
1555  case 0x000F000F: conv = rgb15tobgr15; break;
1556  case 0x000F0010: conv = rgb16tobgr15; break;
1557  case 0x000F0018: conv = rgb24tobgr15; break;
1558  case 0x000F0020: conv = rgb32tobgr15; break;
1559  case 0x0010000F: conv = rgb15tobgr16; break;
1560  case 0x00100010: conv = rgb16tobgr16; break;
1561  case 0x00100018: conv = rgb24tobgr16; break;
1562  case 0x00100020: conv = rgb32tobgr16; break;
1563  case 0x0018000F: conv = rgb15tobgr24; break;
1564  case 0x00180010: conv = rgb16tobgr24; break;
1565  case 0x00180018: conv = rgb24tobgr24; break;
1566  case 0x00180020: conv = rgb32tobgr24; break;
1567  case 0x0020000F: conv = rgb15tobgr32; break;
1568  case 0x00200010: conv = rgb16tobgr32; break;
1569  case 0x00200018: conv = rgb24tobgr32; break;
1570  }
1571  }
1572 
1573  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
1574  return NULL;
1575 
1576  // Maintain symmetry between endianness
1577  if (c->flags & SWS_BITEXACT)
1578  if ((dstFormat == AV_PIX_FMT_RGB32 || dstFormat == AV_PIX_FMT_BGR32 ) && !isRGBA32(srcFormat) && ALT32_CORR>0)
1579  return NULL;
1580 
1581  return conv;
1582 }
1583 
1584 static inline void rgb_pixel_to_alt32(rgbConvFn conv, const uint8_t *src, uint8_t *dst, int src_bpp)
1585 {
1586  uint32_t pix32;
1587  conv(src, (uint8_t *)&pix32, src_bpp);
1588  AV_WL32(dst, AV_RL32(&pix32) << 8 | 0xFF);
1589 }
1590 
1591 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
1592 static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
1593  int srcSliceY, int srcSliceH, uint8_t *dst[],
1594  int dstStride[])
1595 
1596 {
1597  const enum AVPixelFormat srcFormat = c->srcFormat;
1598  const enum AVPixelFormat dstFormat = c->dstFormat;
1599  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
1600  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
1601  const int srcBpp = (c->srcFormatBpp + 7) >> 3;
1602  const int dstBpp = (c->dstFormatBpp + 7) >> 3;
1604 
1605  if (!conv) {
1606  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
1607  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
1608  } else {
1609  const uint8_t *srcPtr = src[0];
1610  uint8_t *dstPtr = dst[0];
1611  int src_bswap = IS_NOT_NE(c->srcFormatBpp, desc_src);
1612  int dst_bswap = IS_NOT_NE(c->dstFormatBpp, desc_dst);
1613  int row_ending_plane = -1;
1614 
1615  if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
1616  !isRGBA32(dstFormat))
1617  srcPtr += ALT32_CORR;
1618 
1619  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
1620  !isRGBA32(srcFormat)) {
1621  int i;
1622  av_assert0(ALT32_CORR == 1);
1623  for (i = 0; i < srcSliceH; i++)
1624  dstPtr[dstStride[0] * (srcSliceY + i)] = 255;
1625  dstPtr += ALT32_CORR;
1626  row_ending_plane = dstStride[0] > 0 ? c->srcH - 1 : 0;
1627  }
1628 
1629  if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
1630  !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap) {
1631  const int last_row = srcSliceY + srcSliceH - 1;
1632  const int src_size = (srcSliceH - 1) * srcStride[0] + c->srcW * srcBpp;
1633  const int cut = last_row == row_ending_plane ? srcBpp : 0;
1634 
1635  conv(srcPtr, dstPtr + dstStride[0] * srcSliceY, src_size - cut);
1636  if (cut)
1637  rgb_pixel_to_alt32(conv, srcPtr + src_size - cut,
1638  dstPtr + dstStride[0] * last_row + (c->srcW - 1) * 4 - ALT32_CORR, srcBpp);
1639  } else {
1640  int i, j;
1641  dstPtr += dstStride[0] * srcSliceY;
1642 
1643  for (i = 0; i < srcSliceH; i++) {
1644  const uint8_t *row = srcPtr;
1645  const int conv_w = c->srcW - (srcSliceY + i == row_ending_plane);
1646 
1647  if(src_bswap) {
1648  for(j=0; j<c->srcW; j++)
1649  ((uint16_t*)c->formatConvBuffer)[j] = av_bswap16(((uint16_t*)srcPtr)[j]);
1650  row = c->formatConvBuffer;
1651  }
1652  conv(row, dstPtr, conv_w * srcBpp);
1653  if (conv_w < c->srcW)
1654  rgb_pixel_to_alt32(conv, row + conv_w * srcBpp, dstPtr + conv_w * 4 - ALT32_CORR, srcBpp);
1655  if(dst_bswap)
1656  for(j=0; j<c->srcW; j++)
1657  ((uint16_t*)dstPtr)[j] = av_bswap16(((uint16_t*)dstPtr)[j]);
1658  srcPtr += srcStride[0];
1659  dstPtr += dstStride[0];
1660  }
1661  }
1662  }
1663  return srcSliceH;
1664 }
1665 
1667  int srcStride[], int srcSliceY, int srcSliceH,
1668  uint8_t *dst[], int dstStride[])
1669 {
1671  src[0],
1672  dst[0] + srcSliceY * dstStride[0],
1673  dst[1] + (srcSliceY >> 1) * dstStride[1],
1674  dst[2] + (srcSliceY >> 1) * dstStride[2],
1675  c->srcW, srcSliceH,
1676  dstStride[0], dstStride[1], srcStride[0],
1677  c->input_rgb2yuv_table);
1678  if (dst[3])
1679  fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
1680  return srcSliceH;
1681 }
1682 
1683 static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
1684  int srcStride[], int srcSliceY, int srcSliceH,
1685  uint8_t *dst[], int dstStride[])
1686 {
1687  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
1688  dst[0], dstStride[0]);
1689 
1690  planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->chrSrcW,
1691  srcSliceH >> 2, srcStride[1], dstStride[1]);
1692  planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->chrSrcW,
1693  srcSliceH >> 2, srcStride[2], dstStride[2]);
1694  if (dst[3])
1695  fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
1696  return srcSliceH;
1697 }
1698 
1700  int srcStride[], int srcSliceY,
1701  int srcSliceH, uint8_t *dst[], int dstStride[])
1702 {
1703  int y, x;
1704  ptrdiff_t dstStrideFloat = dstStride[0] >> 2;
1705  const uint8_t *srcPtr = src[0];
1706  float *dstPtr = (float *)(dst[0] + dstStride[0] * srcSliceY);
1707 
1708  for (y = 0; y < srcSliceH; ++y){
1709  for (x = 0; x < c->srcW; ++x){
1710  dstPtr[x] = c->uint2float_lut[srcPtr[x]];
1711  }
1712  srcPtr += srcStride[0];
1713  dstPtr += dstStrideFloat;
1714  }
1715 
1716  return srcSliceH;
1717 }
1718 
1720  int srcStride[], int srcSliceY,
1721  int srcSliceH, uint8_t* dst[], int dstStride[])
1722 {
1723  int y, x;
1724  ptrdiff_t srcStrideFloat = srcStride[0] >> 2;
1725  const float *srcPtr = (const float *)src[0];
1726  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
1727 
1728  for (y = 0; y < srcSliceH; ++y){
1729  for (x = 0; x < c->srcW; ++x){
1730  dstPtr[x] = av_clip_uint8(lrintf(255.0f * srcPtr[x]));
1731  }
1732  srcPtr += srcStrideFloat;
1733  dstPtr += dstStride[0];
1734  }
1735 
1736  return srcSliceH;
1737 }
1738 
1739 /* unscaled copy like stuff (assumes nearly identical formats) */
1740 static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
1741  int srcStride[], int srcSliceY, int srcSliceH,
1742  uint8_t *dst[], int dstStride[])
1743 {
1744  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH,
1745  av_image_get_linesize(c->srcFormat, c->srcW, 0),
1746  dst[0], dstStride[0]);
1747  return srcSliceH;
1748 }
1749 
1750 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
1751  unsigned shift= src_depth-dst_depth, tmp;\
1752  if (c->dither == SWS_DITHER_NONE) {\
1753  for (i = 0; i < height; i++) {\
1754  for (j = 0; j < length-7; j+=8) {\
1755  dst[j+0] = dbswap(bswap(src[j+0])>>shift);\
1756  dst[j+1] = dbswap(bswap(src[j+1])>>shift);\
1757  dst[j+2] = dbswap(bswap(src[j+2])>>shift);\
1758  dst[j+3] = dbswap(bswap(src[j+3])>>shift);\
1759  dst[j+4] = dbswap(bswap(src[j+4])>>shift);\
1760  dst[j+5] = dbswap(bswap(src[j+5])>>shift);\
1761  dst[j+6] = dbswap(bswap(src[j+6])>>shift);\
1762  dst[j+7] = dbswap(bswap(src[j+7])>>shift);\
1763  }\
1764  for (; j < length; j++) {\
1765  dst[j] = dbswap(bswap(src[j])>>shift);\
1766  }\
1767  dst += dstStride;\
1768  src += srcStride;\
1769  }\
1770  } else if (shiftonly) {\
1771  for (i = 0; i < height; i++) {\
1772  const uint8_t *dither= dithers[shift-1][i&7];\
1773  for (j = 0; j < length-7; j+=8) {\
1774  tmp = (bswap(src[j+0]) + dither[0])>>shift; dst[j+0] = dbswap(tmp - (tmp>>dst_depth));\
1775  tmp = (bswap(src[j+1]) + dither[1])>>shift; dst[j+1] = dbswap(tmp - (tmp>>dst_depth));\
1776  tmp = (bswap(src[j+2]) + dither[2])>>shift; dst[j+2] = dbswap(tmp - (tmp>>dst_depth));\
1777  tmp = (bswap(src[j+3]) + dither[3])>>shift; dst[j+3] = dbswap(tmp - (tmp>>dst_depth));\
1778  tmp = (bswap(src[j+4]) + dither[4])>>shift; dst[j+4] = dbswap(tmp - (tmp>>dst_depth));\
1779  tmp = (bswap(src[j+5]) + dither[5])>>shift; dst[j+5] = dbswap(tmp - (tmp>>dst_depth));\
1780  tmp = (bswap(src[j+6]) + dither[6])>>shift; dst[j+6] = dbswap(tmp - (tmp>>dst_depth));\
1781  tmp = (bswap(src[j+7]) + dither[7])>>shift; dst[j+7] = dbswap(tmp - (tmp>>dst_depth));\
1782  }\
1783  for (; j < length; j++) {\
1784  tmp = (bswap(src[j]) + dither[j&7])>>shift; dst[j] = dbswap(tmp - (tmp>>dst_depth));\
1785  }\
1786  dst += dstStride;\
1787  src += srcStride;\
1788  }\
1789  } else {\
1790  for (i = 0; i < height; i++) {\
1791  const uint8_t *dither= dithers[shift-1][i&7];\
1792  for (j = 0; j < length-7; j+=8) {\
1793  tmp = bswap(src[j+0]); dst[j+0] = dbswap((tmp - (tmp>>dst_depth) + dither[0])>>shift);\
1794  tmp = bswap(src[j+1]); dst[j+1] = dbswap((tmp - (tmp>>dst_depth) + dither[1])>>shift);\
1795  tmp = bswap(src[j+2]); dst[j+2] = dbswap((tmp - (tmp>>dst_depth) + dither[2])>>shift);\
1796  tmp = bswap(src[j+3]); dst[j+3] = dbswap((tmp - (tmp>>dst_depth) + dither[3])>>shift);\
1797  tmp = bswap(src[j+4]); dst[j+4] = dbswap((tmp - (tmp>>dst_depth) + dither[4])>>shift);\
1798  tmp = bswap(src[j+5]); dst[j+5] = dbswap((tmp - (tmp>>dst_depth) + dither[5])>>shift);\
1799  tmp = bswap(src[j+6]); dst[j+6] = dbswap((tmp - (tmp>>dst_depth) + dither[6])>>shift);\
1800  tmp = bswap(src[j+7]); dst[j+7] = dbswap((tmp - (tmp>>dst_depth) + dither[7])>>shift);\
1801  }\
1802  for (; j < length; j++) {\
1803  tmp = bswap(src[j]); dst[j] = dbswap((tmp - (tmp>>dst_depth) + dither[j&7])>>shift);\
1804  }\
1805  dst += dstStride;\
1806  src += srcStride;\
1807  }\
1808  }
1809 
1810 static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
1811  int srcStride[], int srcSliceY, int srcSliceH,
1812  uint8_t *dst[], int dstStride[])
1813 {
1814  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
1815  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
1816  int plane, i, j;
1817  for (plane = 0; plane < 4 && dst[plane] != NULL; plane++) {
1818  int length = (plane == 0 || plane == 3) ? c->srcW : AV_CEIL_RSHIFT(c->srcW, c->chrDstHSubSample);
1819  int y = (plane == 0 || plane == 3) ? srcSliceY: AV_CEIL_RSHIFT(srcSliceY, c->chrDstVSubSample);
1820  int height = (plane == 0 || plane == 3) ? srcSliceH: AV_CEIL_RSHIFT(srcSliceH, c->chrDstVSubSample);
1821  const uint8_t *srcPtr = src[plane];
1822  uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
1823  int shiftonly = plane == 1 || plane == 2 || (!c->srcRange && plane == 0);
1824  if (plane == 1 && isSemiPlanarYUV(c->dstFormat))
1825  length *= 2;
1826 
1827  // ignore palette for GRAY8
1828  if (plane == 1 && desc_dst->nb_components < 3) continue;
1829  if (!src[plane] || (plane == 1 && desc_src->nb_components < 3)) {
1830  if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
1831  fillPlane16(dst[plane], dstStride[plane], length, height, y,
1832  plane == 3, desc_dst->comp[plane].depth,
1833  isBE(c->dstFormat));
1834  } else {
1835  fillPlane(dst[plane], dstStride[plane], length, height, y,
1836  (plane == 3) ? 255 : 128);
1837  }
1838  } else {
1839  if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
1840  || (is16BPS(c->srcFormat) != is16BPS(c->dstFormat))
1841  ) {
1842  const int src_depth = desc_src->comp[plane].depth;
1843  const int dst_depth = desc_dst->comp[plane].depth;
1844  const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
1845  uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1846 
1847  if (dst_depth == 8) {
1848  if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
1849  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
1850  } else {
1851  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
1852  }
1853  } else if (src_depth == 8) {
1854  for (i = 0; i < height; i++) {
1855  #define COPY816(w)\
1856  if (shiftonly) {\
1857  for (j = 0; j < length; j++)\
1858  w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
1859  } else {\
1860  for (j = 0; j < length; j++)\
1861  w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
1862  (srcPtr[j]>>(2*8-dst_depth)));\
1863  }
1864  if(isBE(c->dstFormat)){
1865  COPY816(AV_WB16)
1866  } else {
1867  COPY816(AV_WL16)
1868  }
1869  dstPtr2 += dstStride[plane]/2;
1870  srcPtr += srcStride[plane];
1871  }
1872  } else if (src_depth <= dst_depth) {
1873  for (i = 0; i < height; i++) {
1874  j = 0;
1875  if(isBE(c->srcFormat) == HAVE_BIGENDIAN &&
1876  isBE(c->dstFormat) == HAVE_BIGENDIAN &&
1877  shiftonly) {
1878  unsigned shift = dst_depth - src_depth;
1879 #if HAVE_FAST_64BIT
1880 #define FAST_COPY_UP(shift) \
1881  for (; j < length - 3; j += 4) { \
1882  uint64_t v = AV_RN64A(srcPtr2 + j); \
1883  AV_WN64A(dstPtr2 + j, v << shift); \
1884  }
1885 #else
1886 #define FAST_COPY_UP(shift) \
1887  for (; j < length - 1; j += 2) { \
1888  uint32_t v = AV_RN32A(srcPtr2 + j); \
1889  AV_WN32A(dstPtr2 + j, v << shift); \
1890  }
1891 #endif
1892  switch (shift)
1893  {
1894  case 6: FAST_COPY_UP(6); break;
1895  case 7: FAST_COPY_UP(7); break;
1896  }
1897  }
1898 #define COPY_UP(r,w) \
1899  if(shiftonly){\
1900  for (; j < length; j++){ \
1901  unsigned int v= r(&srcPtr2[j]);\
1902  w(&dstPtr2[j], v<<(dst_depth-src_depth));\
1903  }\
1904  }else{\
1905  for (; j < length; j++){ \
1906  unsigned int v= r(&srcPtr2[j]);\
1907  w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
1908  (v>>(2*src_depth-dst_depth)));\
1909  }\
1910  }
1911  if(isBE(c->srcFormat)){
1912  if(isBE(c->dstFormat)){
1914  } else {
1916  }
1917  } else {
1918  if(isBE(c->dstFormat)){
1920  } else {
1922  }
1923  }
1924  dstPtr2 += dstStride[plane]/2;
1925  srcPtr2 += srcStride[plane]/2;
1926  }
1927  } else {
1928  if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
1929  if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
1930  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
1931  } else {
1932  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
1933  }
1934  }else{
1935  if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
1936  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
1937  } else {
1938  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
1939  }
1940  }
1941  }
1942  } else if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat) &&
1943  isBE(c->srcFormat) != isBE(c->dstFormat)) {
1944 
1945  for (i = 0; i < height; i++) {
1946  for (j = 0; j < length; j++)
1947  ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
1948  srcPtr += srcStride[plane];
1949  dstPtr += dstStride[plane];
1950  }
1951  } else if (isFloat(c->srcFormat) && isFloat(c->dstFormat) &&
1952  isBE(c->srcFormat) != isBE(c->dstFormat)) { /* swap float plane */
1953  for (i = 0; i < height; i++) {
1954  for (j = 0; j < length; j++)
1955  ((uint32_t *) dstPtr)[j] = av_bswap32(((const uint32_t *) srcPtr)[j]);
1956  srcPtr += srcStride[plane];
1957  dstPtr += dstStride[plane];
1958  }
1959  } else if (dstStride[plane] == srcStride[plane] &&
1960  srcStride[plane] > 0 && srcStride[plane] == length) {
1961  memcpy(dst[plane] + dstStride[plane] * y, src[plane],
1962  height * dstStride[plane]);
1963  } else {
1964  if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
1965  length *= 2;
1966  else if (isFloat(c->srcFormat) && isFloat(c->dstFormat))
1967  length *= 4;
1968  else if (desc_src->comp[0].depth == 1)
1969  length >>= 3; // monowhite/black
1970  for (i = 0; i < height; i++) {
1971  memcpy(dstPtr, srcPtr, length);
1972  srcPtr += srcStride[plane];
1973  dstPtr += dstStride[plane];
1974  }
1975  }
1976  }
1977  }
1978  return srcSliceH;
1979 }
1980 
1981 
1982 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
1983  ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
1984  (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
1985 
1986 
1988 {
1989  const enum AVPixelFormat srcFormat = c->srcFormat;
1990  const enum AVPixelFormat dstFormat = c->dstFormat;
1991  const int flags = c->flags;
1992  const int dstH = c->dstH;
1993  int needsDither;
1994 
1995  needsDither = isAnyRGB(dstFormat) &&
1996  c->dstFormatBpp < 24 &&
1997  (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
1998 
1999  /* yv12_to_nv12 */
2000  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2001  (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
2002  c->swscale = planarToNv12Wrapper;
2003  }
2004  /* yv24_to_nv24 */
2005  if ((srcFormat == AV_PIX_FMT_YUV444P || srcFormat == AV_PIX_FMT_YUVA444P) &&
2006  (dstFormat == AV_PIX_FMT_NV24 || dstFormat == AV_PIX_FMT_NV42)) {
2007  c->swscale = planarToNv24Wrapper;
2008  }
2009  /* nv12_to_yv12 */
2010  if (dstFormat == AV_PIX_FMT_YUV420P &&
2011  (srcFormat == AV_PIX_FMT_NV12 || srcFormat == AV_PIX_FMT_NV21)) {
2012  c->swscale = nv12ToPlanarWrapper;
2013  }
2014  /* nv24_to_yv24 */
2015  if (dstFormat == AV_PIX_FMT_YUV444P &&
2016  (srcFormat == AV_PIX_FMT_NV24 || srcFormat == AV_PIX_FMT_NV42)) {
2017  c->swscale = nv24ToPlanarWrapper;
2018  }
2019  /* yuv2bgr */
2020  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
2021  srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
2022  !(flags & SWS_ACCURATE_RND) && (c->dither == SWS_DITHER_BAYER || c->dither == SWS_DITHER_AUTO) && !(dstH & 1)) {
2023  c->swscale = ff_yuv2rgb_get_func_ptr(c);
2024  }
2025  /* yuv420p1x_to_p01x */
2026  if ((srcFormat == AV_PIX_FMT_YUV420P10 || srcFormat == AV_PIX_FMT_YUVA420P10 ||
2027  srcFormat == AV_PIX_FMT_YUV420P12 ||
2028  srcFormat == AV_PIX_FMT_YUV420P14 ||
2029  srcFormat == AV_PIX_FMT_YUV420P16 || srcFormat == AV_PIX_FMT_YUVA420P16) &&
2030  (dstFormat == AV_PIX_FMT_P010 || dstFormat == AV_PIX_FMT_P016)) {
2031  c->swscale = planarToP01xWrapper;
2032  }
2033  /* yuv420p_to_p01xle */
2034  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
2035  (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P016LE)) {
2036  c->swscale = planar8ToP01xleWrapper;
2037  }
2038 
2039  if (srcFormat == AV_PIX_FMT_YUV410P && !(dstH & 3) &&
2040  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2041  !(flags & SWS_BITEXACT)) {
2042  c->swscale = yvu9ToYv12Wrapper;
2043  }
2044 
2045  /* bgr24toYV12 */
2046  if (srcFormat == AV_PIX_FMT_BGR24 &&
2047  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
2048  !(flags & SWS_ACCURATE_RND))
2049  c->swscale = bgr24ToYv12Wrapper;
2050 
2051  /* RGB/BGR -> RGB/BGR (no dither needed forms) */
2052  if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
2053  && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
2054  c->swscale = rgbToRgbWrapper;
2055 
2056  /* RGB to planar RGB */
2057  if ((srcFormat == AV_PIX_FMT_GBRP && dstFormat == AV_PIX_FMT_GBRAP) ||
2058  (srcFormat == AV_PIX_FMT_GBRAP && dstFormat == AV_PIX_FMT_GBRP))
2059  c->swscale = planarRgbToplanarRgbWrapper;
2060 
2061 #define isByteRGB(f) ( \
2062  f == AV_PIX_FMT_RGB32 || \
2063  f == AV_PIX_FMT_RGB32_1 || \
2064  f == AV_PIX_FMT_RGB24 || \
2065  f == AV_PIX_FMT_BGR32 || \
2066  f == AV_PIX_FMT_BGR32_1 || \
2067  f == AV_PIX_FMT_BGR24)
2068 
2069  if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
2070  c->swscale = planarRgbToRgbWrapper;
2071 
2072  if (srcFormat == AV_PIX_FMT_GBRAP && isByteRGB(dstFormat))
2073  c->swscale = planarRgbaToRgbWrapper;
2074 
2075  if ((srcFormat == AV_PIX_FMT_RGB48LE || srcFormat == AV_PIX_FMT_RGB48BE ||
2076  srcFormat == AV_PIX_FMT_BGR48LE || srcFormat == AV_PIX_FMT_BGR48BE ||
2077  srcFormat == AV_PIX_FMT_RGBA64LE || srcFormat == AV_PIX_FMT_RGBA64BE ||
2078  srcFormat == AV_PIX_FMT_BGRA64LE || srcFormat == AV_PIX_FMT_BGRA64BE) &&
2079  (dstFormat == AV_PIX_FMT_GBRP9LE || dstFormat == AV_PIX_FMT_GBRP9BE ||
2080  dstFormat == AV_PIX_FMT_GBRP10LE || dstFormat == AV_PIX_FMT_GBRP10BE ||
2081  dstFormat == AV_PIX_FMT_GBRP12LE || dstFormat == AV_PIX_FMT_GBRP12BE ||
2082  dstFormat == AV_PIX_FMT_GBRP14LE || dstFormat == AV_PIX_FMT_GBRP14BE ||
2083  dstFormat == AV_PIX_FMT_GBRP16LE || dstFormat == AV_PIX_FMT_GBRP16BE ||
2084  dstFormat == AV_PIX_FMT_GBRAP10LE || dstFormat == AV_PIX_FMT_GBRAP10BE ||
2085  dstFormat == AV_PIX_FMT_GBRAP12LE || dstFormat == AV_PIX_FMT_GBRAP12BE ||
2086  dstFormat == AV_PIX_FMT_GBRAP16LE || dstFormat == AV_PIX_FMT_GBRAP16BE ))
2087  c->swscale = Rgb16ToPlanarRgb16Wrapper;
2088 
2089  if ((srcFormat == AV_PIX_FMT_GBRP9LE || srcFormat == AV_PIX_FMT_GBRP9BE ||
2090  srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
2091  srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
2092  srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
2093  srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
2094  srcFormat == AV_PIX_FMT_GBRAP10LE || srcFormat == AV_PIX_FMT_GBRAP10BE ||
2095  srcFormat == AV_PIX_FMT_GBRAP12LE || srcFormat == AV_PIX_FMT_GBRAP12BE ||
2096  srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
2097  (dstFormat == AV_PIX_FMT_RGB48LE || dstFormat == AV_PIX_FMT_RGB48BE ||
2098  dstFormat == AV_PIX_FMT_BGR48LE || dstFormat == AV_PIX_FMT_BGR48BE ||
2099  dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
2100  dstFormat == AV_PIX_FMT_BGRA64LE || dstFormat == AV_PIX_FMT_BGRA64BE))
2101  c->swscale = planarRgb16ToRgb16Wrapper;
2102 
2103  if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth == 8 &&
2104  isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
2105  c->swscale = rgbToPlanarRgbWrapper;
2106 
2107  if (isBayer(srcFormat)) {
2108  if (dstFormat == AV_PIX_FMT_RGB24)
2109  c->swscale = bayer_to_rgb24_wrapper;
2110  else if (dstFormat == AV_PIX_FMT_RGB48)
2111  c->swscale = bayer_to_rgb48_wrapper;
2112  else if (dstFormat == AV_PIX_FMT_YUV420P)
2113  c->swscale = bayer_to_yv12_wrapper;
2114  else if (!isBayer(dstFormat)) {
2115  av_log(c, AV_LOG_ERROR, "unsupported bayer conversion\n");
2116  av_assert0(0);
2117  }
2118  }
2119 
2120  /* bswap 16 bits per pixel/component packed formats */
2121  if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_BGGR16) ||
2122  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_RGGB16) ||
2123  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GBRG16) ||
2124  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GRBG16) ||
2125  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
2126  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
2127  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
2128  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
2129  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
2130  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY9) ||
2131  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY10) ||
2132  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY12) ||
2133  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY14) ||
2134  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
2135  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YA16) ||
2136  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_AYUV64) ||
2137  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP9) ||
2138  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP10) ||
2139  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP12) ||
2140  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP14) ||
2141  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRP16) ||
2142  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP10) ||
2143  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP12) ||
2144  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) ||
2145  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
2146  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
2147  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
2148  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565) ||
2149  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
2150  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_XYZ12) ||
2151  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P9) ||
2152  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P10) ||
2153  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P12) ||
2154  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P14) ||
2155  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV420P16) ||
2156  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P9) ||
2157  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P10) ||
2158  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P12) ||
2159  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P14) ||
2160  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV422P16) ||
2161  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P10) ||
2162  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV440P12) ||
2163  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P9) ||
2164  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P10) ||
2165  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P12) ||
2166  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P14) ||
2167  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_YUV444P16))
2168  c->swscale = bswap_16bpc;
2169 
2170  /* bswap 32 bits per pixel/component formats */
2171  if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRPF32) ||
2172  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAPF32))
2173  c->swscale = bswap_32bpc;
2174 
2175  if (usePal(srcFormat) && isByteRGB(dstFormat))
2176  c->swscale = palToRgbWrapper;
2177 
2178  if (srcFormat == AV_PIX_FMT_YUV422P) {
2179  if (dstFormat == AV_PIX_FMT_YUYV422)
2180  c->swscale = yuv422pToYuy2Wrapper;
2181  else if (dstFormat == AV_PIX_FMT_UYVY422)
2182  c->swscale = yuv422pToUyvyWrapper;
2183  }
2184 
2185  /* uint Y to float Y */
2186  if (srcFormat == AV_PIX_FMT_GRAY8 && dstFormat == AV_PIX_FMT_GRAYF32){
2187  c->swscale = uint_y_to_float_y_wrapper;
2188  }
2189 
2190  /* float Y to uint Y */
2191  if (srcFormat == AV_PIX_FMT_GRAYF32 && dstFormat == AV_PIX_FMT_GRAY8){
2192  c->swscale = float_y_to_uint_y_wrapper;
2193  }
2194 
2195  /* LQ converters if -sws 0 or -sws 4*/
2196  if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
2197  /* yv12_to_yuy2 */
2198  if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
2199  if (dstFormat == AV_PIX_FMT_YUYV422)
2200  c->swscale = planarToYuy2Wrapper;
2201  else if (dstFormat == AV_PIX_FMT_UYVY422)
2202  c->swscale = planarToUyvyWrapper;
2203  }
2204  }
2205  if (srcFormat == AV_PIX_FMT_YUYV422 &&
2206  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2207  c->swscale = yuyvToYuv420Wrapper;
2208  if (srcFormat == AV_PIX_FMT_UYVY422 &&
2209  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
2210  c->swscale = uyvyToYuv420Wrapper;
2211  if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
2212  c->swscale = yuyvToYuv422Wrapper;
2213  if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
2214  c->swscale = uyvyToYuv422Wrapper;
2215 
2216 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_YA8 && (x) != AV_PIX_FMT_YA16LE && (x) != AV_PIX_FMT_YA16BE)
2217  /* simple copy */
2218  if ( srcFormat == dstFormat ||
2219  (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
2220  (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
2221  (isFloat(srcFormat) == isFloat(dstFormat)) && ((isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
2222  (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
2223  (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
2224  (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
2225  c->chrDstHSubSample == c->chrSrcHSubSample &&
2226  c->chrDstVSubSample == c->chrSrcVSubSample &&
2227  !isSemiPlanarYUV(srcFormat) && !isSemiPlanarYUV(dstFormat))))
2228  {
2229  if (isPacked(c->srcFormat))
2230  c->swscale = packedCopyWrapper;
2231  else /* Planar YUV or gray */
2232  c->swscale = planarCopyWrapper;
2233  }
2234 
2235  if (ARCH_PPC)
2237  if (ARCH_ARM)
2239  if (ARCH_AARCH64)
2241 }
2242 
2243 /* Convert the palette to the same packed 32-bit format as the palette */
2245  int num_pixels, const uint8_t *palette)
2246 {
2247  int i;
2248 
2249  for (i = 0; i < num_pixels; i++)
2250  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
2251 }
2252 
2253 /* Palette format: ABCD -> dst format: ABC */
2255  int num_pixels, const uint8_t *palette)
2256 {
2257  int i;
2258 
2259  for (i = 0; i < num_pixels; i++) {
2260  //FIXME slow?
2261  dst[0] = palette[src[i] * 4 + 0];
2262  dst[1] = palette[src[i] * 4 + 1];
2263  dst[2] = palette[src[i] * 4 + 2];
2264  dst += 3;
2265  }
2266 }
void ff_get_unscaled_swscale_aarch64(SwsContext *c)
static double val(void *priv, double ch)
Definition: aeval.c:76
void ff_get_unscaled_swscale_arm(SwsContext *c)
uint8_t
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
#define AV_RL16
Definition: intreadwrite.h:42
#define AV_RB16
Definition: intreadwrite.h:53
#define AV_RL32
Definition: intreadwrite.h:146
Convenience header that includes libavutil's core.
#define av_bswap32
Definition: bswap.h:33
byte swapping routines
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define av_clip_uint8
Definition: common.h:128
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define HAVE_BIGENDIAN
Definition: config.h:202
#define ARCH_AARCH64
Definition: config.h:18
#define ARCH_PPC
Definition: config.h:30
#define ARCH_ARM
Definition: config.h:20
#define NULL
Definition: coverity.c:32
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:39
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:85
int
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:117
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
Definition: imgutils.c:76
#define SWS_BITEXACT
Definition: swscale.h:84
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.
#define SWS_ACCURATE_RND
Definition: swscale.h:83
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.
#define SWS_FAST_BILINEAR
Definition: swscale.h:58
#define SWS_POINT
Definition: swscale.h:62
static const int16_t alpha[]
Definition: ilbcdata.h:55
misc image utilities
RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT RGB2YUV_SHIFT uint8_t const uint8_t const uint8_t const uint8_t int uint32_t * rgb2yuv
Definition: input.c:401
uint16_t * dstV
Definition: input.c:403
int i
Definition: input.c:407
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
#define AV_WB16(p, v)
Definition: intreadwrite.h:405
#define AV_WL16(p, v)
Definition: intreadwrite.h:412
#define lrintf(x)
Definition: libm_mips.h:70
static int conv(int samples, float **pcm, char *buf, int channels)
Definition: libvorbisdec.c:131
int stride
Definition: mace.c:144
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:2489
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:179
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:148
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:128
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:410
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:428
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:399
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:405
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:397
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:393
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:392
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:390
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:441
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:384
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:436
#define AV_PIX_FMT_BAYER_GRBG16
Definition: pixfmt.h:426
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
#define AV_PIX_FMT_XYZ12
Definition: pixfmt.h:445
#define AV_PIX_FMT_P010
Definition: pixfmt.h:448
#define AV_PIX_FMT_P016
Definition: pixfmt.h:449
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:381
#define AV_PIX_FMT_BAYER_BGGR16
Definition: pixfmt.h:423
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:389
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:374
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:396
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:385
#define AV_PIX_FMT_BAYER_RGGB16
Definition: pixfmt.h:424
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:431
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:407
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
Definition: pixfmt.h:262
@ 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:89
@ AV_PIX_FMT_P010LE
like NV12, with 10bpp per component, data in the high bits, zeros in the low bits,...
Definition: pixfmt.h:284
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
@ AV_PIX_FMT_GBRP10BE
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:172
@ AV_PIX_FMT_NV42
as above, but U and V bytes are swapped
Definition: pixfmt.h:349
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:90
@ AV_PIX_FMT_GBRP9LE
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:171
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
@ AV_PIX_FMT_BAYER_GRBG16LE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:270
@ AV_PIX_FMT_P016LE
like NV12, with 16bpp per component, little-endian
Definition: pixfmt.h:300
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
@ AV_PIX_FMT_GBRP12BE
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:254
@ AV_PIX_FMT_GBRAP12BE
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:287
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ 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:148
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:81
@ 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:102
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
@ 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:205
@ 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:348
@ 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:206
@ AV_PIX_FMT_GBRAP16BE
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:216
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:266
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
Definition: pixfmt.h:263
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
@ AV_PIX_FMT_GBRP12LE
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:255
@ 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:207
@ AV_PIX_FMT_BAYER_BGGR16BE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:265
@ AV_PIX_FMT_GBRP16BE
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:174
@ AV_PIX_FMT_GBRAP12LE
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:288
@ AV_PIX_FMT_GBRP9BE
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:170
@ 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:103
@ AV_PIX_FMT_BAYER_RGGB16BE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:267
@ 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:149
@ AV_PIX_FMT_GBRP14LE
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:257
@ AV_PIX_FMT_GBRP10LE
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:173
@ AV_PIX_FMT_GBRAP10BE
planar GBR 4:4:4:4 40bpp, big-endian
Definition: pixfmt.h:290
@ AV_PIX_FMT_BAYER_GRBG16BE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:271
@ 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:208
@ AV_PIX_FMT_GBRAP10LE
planar GBR 4:4:4:4 40bpp, little-endian
Definition: pixfmt.h:291
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
@ AV_PIX_FMT_BAYER_GBRG16LE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:268
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
@ AV_PIX_FMT_GBRAP16LE
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:217
@ AV_PIX_FMT_BAYER_BGGR16LE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian
Definition: pixfmt.h:264
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:143
@ AV_PIX_FMT_GBRP14BE
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:256
@ AV_PIX_FMT_BAYER_GBRG16BE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian
Definition: pixfmt.h:269
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
Definition: pixfmt.h:261
@ AV_PIX_FMT_GBRP16LE
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:175
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
Definition: pixfmt.h:260
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:408
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:373
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:375
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:391
#define AV_PIX_FMT_BAYER_GBRG16
Definition: pixfmt.h:425
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:386
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:411
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:394
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:401
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:388
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:429
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_AYUV64
Definition: pixfmt.h:447
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:372
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:387
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
typedef void(RENAME(mix_any_func_type))
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)
Definition: rgb2rgb.c:73
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:47
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:38
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:46
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:316
void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:146
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:48
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:104
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)
Definition: rgb2rgb.c:61
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:249
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:40
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)
Definition: rgb2rgb.c:69
void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:281
void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:305
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:259
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, int32_t *rgb2yuv)
Height should be a multiple of 2 and width should be a multiple of 2.
Definition: rgb2rgb.c:81
void(* shuffle_bytes_3210)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:58
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:239
void(* shuffle_bytes_3012)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:57
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:42
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:37
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:55
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:49
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)
Definition: rgb2rgb.c:65
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:110
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:36
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:184
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
void(* shuffle_bytes_1230)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:56
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:164
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:35
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:41
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:50
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:51
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)
Definition: rgb2rgb.c:86
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
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:52
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:113
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:107
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:45
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:43
void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:225
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:39
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:206
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:295
void(* shuffle_bytes_0321)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:54
void rgb48to64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr64_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48to64_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
#define av_bswap16
Definition: bswap.h:31
static int shift(int a, int b)
Definition: sonic.c:82
int shift
Number of least significant bits that must be shifted away to get the value.
Definition: pixdesc.h:53
int depth
Number of bits in the component.
Definition: pixdesc.h:58
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
const char * name
Definition: pixdesc.h:82
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
external API header
static av_always_inline int isBGRinInt(enum AVPixelFormat pix_fmt)
static av_always_inline int isBayer(enum AVPixelFormat pix_fmt)
static void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian)
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
static av_always_inline int isFloat(enum AVPixelFormat pix_fmt)
#define ALT32_CORR
static av_always_inline int isAnyRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
@ SWS_DITHER_AUTO
@ SWS_DITHER_BAYER
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
static av_always_inline int isSemiPlanarYUV(enum AVPixelFormat pix_fmt)
static av_always_inline int isRGBinInt(enum AVPixelFormat pix_fmt)
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
static av_always_inline int isNBPS(enum AVPixelFormat pix_fmt)
static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define IS_NOT_NE(bpp, desc)
static void copyPlane(const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
static void packedtogbr24p(const uint8_t *src, int srcStride, uint8_t *dst[], int dstStride[], int srcSliceH, int alpha_first, int inc_size, int width)
#define isRGBA64(x)
static rgbConvFn findRgbConvFn(SwsContext *c)
static const uint8_t dithers[8][8][8]
static int rgbToPlanarRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int float_y_to_uint_y_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void gbr24ptopacked32(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
#define CONV_IS(src, dst)
static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static void fillPlane(uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
static int planarToP01xWrapper(SwsContext *c, const uint8_t *src8[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam8[], int dstStride[])
static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void gbraptopacked32(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
#define COPY_UP(r, w)
static int bswap_16bpc(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define isByteRGB(f)
static int bswap_32bpc(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define isRGB48(x)
static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planarRgbToplanarRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define output_pixel(p, v)
static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swscale to an unscaled converter if one exists for the specific source and destination formats...
static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static int planarRgbaToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void gbr16ptopacked16(const uint16_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha, int swap, int bpp, int width)
static void packed16togbra16(const uint8_t *src, int srcStride, uint16_t *dst[], int dstStride[], int srcSliceH, int src_alpha, int swap, int shift, int width)
static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int planarRgb16ToRgb16Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static void gbr24ptopacked24(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
static int nv12ToPlanarWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int Rgb16ToPlanarRgb16Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
static int packedCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planarCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planarToNv24Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
#define CASE(pixfmt, prefix)
#define isPlanarGray(x)
void(* rgbConvFn)(const uint8_t *, uint8_t *, int)
static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
#define FAST_COPY_UP(shift)
static int uint_y_to_float_y_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define isRGBA32(x)
static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int planar8ToP01xleWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam8[], int dstStride[])
static int nv24ToPlanarWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static void rgb_pixel_to_alt32(rgbConvFn conv, const uint8_t *src, uint8_t *dst, int src_bpp)
static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int bayer_to_yv12_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int bayer_to_rgb48_wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define COPY816(w)
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
#define av_log(a,...)
#define src
Definition: vp8dsp.c:255
#define height
#define width
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:84
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
static void copy(const float *p1, float *p2, const int length)
static double c[64]
EMMS_IF_MMX return srcSliceH
av_cold void ff_get_unscaled_swscale_ppc(SwsContext *c)