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