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