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