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