swscale_unscaled.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <inttypes.h>
22 #include <string.h>
23 #include <math.h>
24 #include <stdio.h>
25 #include "config.h"
26 #include "swscale.h"
27 #include "swscale_internal.h"
28 #include "rgb2rgb.h"
29 #include "libavutil/intreadwrite.h"
30 #include "libavutil/cpu.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/mathematics.h"
33 #include "libavutil/bswap.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/avassert.h"
36 
37 DECLARE_ALIGNED(8, const uint8_t, dithers)[8][8][8]={
38 {
39  { 0, 1, 0, 1, 0, 1, 0, 1,},
40  { 1, 0, 1, 0, 1, 0, 1, 0,},
41  { 0, 1, 0, 1, 0, 1, 0, 1,},
42  { 1, 0, 1, 0, 1, 0, 1, 0,},
43  { 0, 1, 0, 1, 0, 1, 0, 1,},
44  { 1, 0, 1, 0, 1, 0, 1, 0,},
45  { 0, 1, 0, 1, 0, 1, 0, 1,},
46  { 1, 0, 1, 0, 1, 0, 1, 0,},
47 },{
48  { 1, 2, 1, 2, 1, 2, 1, 2,},
49  { 3, 0, 3, 0, 3, 0, 3, 0,},
50  { 1, 2, 1, 2, 1, 2, 1, 2,},
51  { 3, 0, 3, 0, 3, 0, 3, 0,},
52  { 1, 2, 1, 2, 1, 2, 1, 2,},
53  { 3, 0, 3, 0, 3, 0, 3, 0,},
54  { 1, 2, 1, 2, 1, 2, 1, 2,},
55  { 3, 0, 3, 0, 3, 0, 3, 0,},
56 },{
57  { 2, 4, 3, 5, 2, 4, 3, 5,},
58  { 6, 0, 7, 1, 6, 0, 7, 1,},
59  { 3, 5, 2, 4, 3, 5, 2, 4,},
60  { 7, 1, 6, 0, 7, 1, 6, 0,},
61  { 2, 4, 3, 5, 2, 4, 3, 5,},
62  { 6, 0, 7, 1, 6, 0, 7, 1,},
63  { 3, 5, 2, 4, 3, 5, 2, 4,},
64  { 7, 1, 6, 0, 7, 1, 6, 0,},
65 },{
66  { 4, 8, 7, 11, 4, 8, 7, 11,},
67  { 12, 0, 15, 3, 12, 0, 15, 3,},
68  { 6, 10, 5, 9, 6, 10, 5, 9,},
69  { 14, 2, 13, 1, 14, 2, 13, 1,},
70  { 4, 8, 7, 11, 4, 8, 7, 11,},
71  { 12, 0, 15, 3, 12, 0, 15, 3,},
72  { 6, 10, 5, 9, 6, 10, 5, 9,},
73  { 14, 2, 13, 1, 14, 2, 13, 1,},
74 },{
75  { 9, 17, 15, 23, 8, 16, 14, 22,},
76  { 25, 1, 31, 7, 24, 0, 30, 6,},
77  { 13, 21, 11, 19, 12, 20, 10, 18,},
78  { 29, 5, 27, 3, 28, 4, 26, 2,},
79  { 8, 16, 14, 22, 9, 17, 15, 23,},
80  { 24, 0, 30, 6, 25, 1, 31, 7,},
81  { 12, 20, 10, 18, 13, 21, 11, 19,},
82  { 28, 4, 26, 2, 29, 5, 27, 3,},
83 },{
84  { 18, 34, 30, 46, 17, 33, 29, 45,},
85  { 50, 2, 62, 14, 49, 1, 61, 13,},
86  { 26, 42, 22, 38, 25, 41, 21, 37,},
87  { 58, 10, 54, 6, 57, 9, 53, 5,},
88  { 16, 32, 28, 44, 19, 35, 31, 47,},
89  { 48, 0, 60, 12, 51, 3, 63, 15,},
90  { 24, 40, 20, 36, 27, 43, 23, 39,},
91  { 56, 8, 52, 4, 59, 11, 55, 7,},
92 },{
93  { 18, 34, 30, 46, 17, 33, 29, 45,},
94  { 50, 2, 62, 14, 49, 1, 61, 13,},
95  { 26, 42, 22, 38, 25, 41, 21, 37,},
96  { 58, 10, 54, 6, 57, 9, 53, 5,},
97  { 16, 32, 28, 44, 19, 35, 31, 47,},
98  { 48, 0, 60, 12, 51, 3, 63, 15,},
99  { 24, 40, 20, 36, 27, 43, 23, 39,},
100  { 56, 8, 52, 4, 59, 11, 55, 7,},
101 },{
102  { 36, 68, 60, 92, 34, 66, 58, 90,},
103  { 100, 4,124, 28, 98, 2,122, 26,},
104  { 52, 84, 44, 76, 50, 82, 42, 74,},
105  { 116, 20,108, 12,114, 18,106, 10,},
106  { 32, 64, 56, 88, 38, 70, 62, 94,},
107  { 96, 0,120, 24,102, 6,126, 30,},
108  { 48, 80, 40, 72, 54, 86, 46, 78,},
109  { 112, 16,104, 8,118, 22,110, 14,},
110 }};
111 
112 const uint16_t dither_scale[15][16]={
113 { 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,},
114 { 2, 3, 7, 7, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,},
115 { 3, 3, 4, 15, 15, 29, 57, 57, 57, 113, 113, 113, 113, 113, 113, 113,},
116 { 3, 4, 4, 5, 31, 31, 61, 121, 241, 241, 241, 241, 481, 481, 481, 481,},
117 { 3, 4, 5, 5, 6, 63, 63, 125, 249, 497, 993, 993, 993, 993, 993, 1985,},
118 { 3, 5, 6, 6, 6, 7, 127, 127, 253, 505, 1009, 2017, 4033, 4033, 4033, 4033,},
119 { 3, 5, 6, 7, 7, 7, 8, 255, 255, 509, 1017, 2033, 4065, 8129,16257,16257,},
120 { 3, 5, 6, 8, 8, 8, 8, 9, 511, 511, 1021, 2041, 4081, 8161,16321,32641,},
121 { 3, 5, 7, 8, 9, 9, 9, 9, 10, 1023, 1023, 2045, 4089, 8177,16353,32705,},
122 { 3, 5, 7, 8, 10, 10, 10, 10, 10, 11, 2047, 2047, 4093, 8185,16369,32737,},
123 { 3, 5, 7, 8, 10, 11, 11, 11, 11, 11, 12, 4095, 4095, 8189,16377,32753,},
124 { 3, 5, 7, 9, 10, 12, 12, 12, 12, 12, 12, 13, 8191, 8191,16381,32761,},
125 { 3, 5, 7, 9, 10, 12, 13, 13, 13, 13, 13, 13, 14,16383,16383,32765,},
126 { 3, 5, 7, 9, 10, 12, 14, 14, 14, 14, 14, 14, 14, 15,32767,32767,},
127 { 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,},
128 };
129 
130 
131 static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
132  uint8_t val)
133 {
134  int i;
135  uint8_t *ptr = plane + stride * y;
136  for (i = 0; i < height; i++) {
137  memset(ptr, val, width);
138  ptr += stride;
139  }
140 }
141 
142 static void copyPlane(const uint8_t *src, int srcStride,
143  int srcSliceY, int srcSliceH, int width,
144  uint8_t *dst, int dstStride)
145 {
146  dst += dstStride * srcSliceY;
147  if (dstStride == srcStride && srcStride > 0) {
148  memcpy(dst, src, srcSliceH * dstStride);
149  } else {
150  int i;
151  for (i = 0; i < srcSliceH; i++) {
152  memcpy(dst, src, width);
153  src += srcStride;
154  dst += dstStride;
155  }
156  }
157 }
158 
160  int srcStride[], int srcSliceY,
161  int srcSliceH, uint8_t *dstParam[],
162  int dstStride[])
163 {
164  uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
165 
166  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
167  dstParam[0], dstStride[0]);
168 
169  if (c->dstFormat == AV_PIX_FMT_NV12)
170  interleaveBytes(src[1], src[2], dst, c->srcW / 2, srcSliceH / 2,
171  srcStride[1], srcStride[2], dstStride[0]);
172  else
173  interleaveBytes(src[2], src[1], dst, c->srcW / 2, srcSliceH / 2,
174  srcStride[2], srcStride[1], dstStride[0]);
175 
176  return srcSliceH;
177 }
178 
180  int srcStride[], int srcSliceY, int srcSliceH,
181  uint8_t *dstParam[], int dstStride[])
182 {
183  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
184 
185  yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
186  srcStride[1], dstStride[0]);
187 
188  return srcSliceH;
189 }
190 
192  int srcStride[], int srcSliceY, int srcSliceH,
193  uint8_t *dstParam[], int dstStride[])
194 {
195  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
196 
197  yv12touyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
198  srcStride[1], dstStride[0]);
199 
200  return srcSliceH;
201 }
202 
204  int srcStride[], int srcSliceY, int srcSliceH,
205  uint8_t *dstParam[], int dstStride[])
206 {
207  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
208 
209  yuv422ptoyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
210  srcStride[1], dstStride[0]);
211 
212  return srcSliceH;
213 }
214 
216  int srcStride[], int srcSliceY, int srcSliceH,
217  uint8_t *dstParam[], int dstStride[])
218 {
219  uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
220 
221  yuv422ptouyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
222  srcStride[1], dstStride[0]);
223 
224  return srcSliceH;
225 }
226 
228  int srcStride[], int srcSliceY, int srcSliceH,
229  uint8_t *dstParam[], int dstStride[])
230 {
231  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
232  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
233  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
234 
235  yuyvtoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
236  dstStride[1], srcStride[0]);
237 
238  if (dstParam[3])
239  fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
240 
241  return srcSliceH;
242 }
243 
245  int srcStride[], int srcSliceY, int srcSliceH,
246  uint8_t *dstParam[], int dstStride[])
247 {
248  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
249  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
250  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
251 
252  yuyvtoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
253  dstStride[1], srcStride[0]);
254 
255  return srcSliceH;
256 }
257 
259  int srcStride[], int srcSliceY, int srcSliceH,
260  uint8_t *dstParam[], int dstStride[])
261 {
262  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
263  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
264  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
265 
266  uyvytoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
267  dstStride[1], srcStride[0]);
268 
269  if (dstParam[3])
270  fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
271 
272  return srcSliceH;
273 }
274 
276  int srcStride[], int srcSliceY, int srcSliceH,
277  uint8_t *dstParam[], int dstStride[])
278 {
279  uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
280  uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
281  uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
282 
283  uyvytoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
284  dstStride[1], srcStride[0]);
285 
286  return srcSliceH;
287 }
288 
289 static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels,
290  const uint8_t *palette)
291 {
292  int i;
293  for (i = 0; i < num_pixels; i++)
294  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
295 }
296 
297 static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels,
298  const uint8_t *palette)
299 {
300  int i;
301 
302  for (i = 0; i < num_pixels; i++)
303  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
304 }
305 
306 static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
307  const uint8_t *palette)
308 {
309  int i;
310 
311  for (i = 0; i < num_pixels; i++) {
312  //FIXME slow?
313  dst[0] = palette[src[i << 1] * 4 + 0];
314  dst[1] = palette[src[i << 1] * 4 + 1];
315  dst[2] = palette[src[i << 1] * 4 + 2];
316  dst += 3;
317  }
318 }
319 
320 static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
321  int srcStride[], int srcSliceY, int srcSliceH,
322  uint8_t *dst[], int dstStride[])
323 {
324  int i, j;
325  int srcstr = srcStride[0] >> 1;
326  int dststr = dstStride[0] >> 1;
327  uint16_t *dstPtr = (uint16_t *) dst[0];
328  const uint16_t *srcPtr = (const uint16_t *) src[0];
329  int min_stride = FFMIN(srcstr, dststr);
330 
331  for (i = 0; i < srcSliceH; i++) {
332  for (j = 0; j < min_stride; j++) {
333  dstPtr[j] = av_bswap16(srcPtr[j]);
334  }
335  srcPtr += srcstr;
336  dstPtr += dststr;
337  }
338 
339  return srcSliceH;
340 }
341 
342 static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
343  int srcSliceY, int srcSliceH, uint8_t *dst[],
344  int dstStride[])
345 {
346  const enum AVPixelFormat srcFormat = c->srcFormat;
347  const enum AVPixelFormat dstFormat = c->dstFormat;
348  void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
349  const uint8_t *palette) = NULL;
350  int i;
351  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
352  const uint8_t *srcPtr = src[0];
353 
354  if (srcFormat == AV_PIX_FMT_GRAY8A) {
355  switch (dstFormat) {
356  case AV_PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
357  case AV_PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
360  case AV_PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
361  case AV_PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
362  }
363  } else if (usePal(srcFormat)) {
364  switch (dstFormat) {
371  }
372  }
373 
374  if (!conv)
375  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
376  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
377  else {
378  for (i = 0; i < srcSliceH; i++) {
379  conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
380  srcPtr += srcStride[0];
381  dstPtr += dstStride[0];
382  }
383  }
384 
385  return srcSliceH;
386 }
387 
388 static void gbr24ptopacked24(const uint8_t *src[], int srcStride[],
389  uint8_t *dst, int dstStride, int srcSliceH,
390  int width)
391 {
392  int x, h, i;
393  for (h = 0; h < srcSliceH; h++) {
394  uint8_t *dest = dst + dstStride * h;
395  for (x = 0; x < width; x++) {
396  *dest++ = src[0][x];
397  *dest++ = src[1][x];
398  *dest++ = src[2][x];
399  }
400 
401  for (i = 0; i < 3; i++)
402  src[i] += srcStride[i];
403  }
404 }
405 
406 static void gbr24ptopacked32(const uint8_t *src[], int srcStride[],
407  uint8_t *dst, int dstStride, int srcSliceH,
408  int alpha_first, int width)
409 {
410  int x, h, i;
411  for (h = 0; h < srcSliceH; h++) {
412  uint8_t *dest = dst + dstStride * h;
413 
414  if (alpha_first) {
415  for (x = 0; x < width; x++) {
416  *dest++ = 0xff;
417  *dest++ = src[0][x];
418  *dest++ = src[1][x];
419  *dest++ = src[2][x];
420  }
421  } else {
422  for (x = 0; x < width; x++) {
423  *dest++ = src[0][x];
424  *dest++ = src[1][x];
425  *dest++ = src[2][x];
426  *dest++ = 0xff;
427  }
428  }
429 
430  for (i = 0; i < 3; i++)
431  src[i] += srcStride[i];
432  }
433 }
434 
436  int srcStride[], int srcSliceY, int srcSliceH,
437  uint8_t *dst[], int dstStride[])
438 {
439  int alpha_first = 0;
440  const uint8_t *src102[] = { src[1], src[0], src[2] };
441  const uint8_t *src201[] = { src[2], src[0], src[1] };
442  int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
443  int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
444 
445  if (c->srcFormat != AV_PIX_FMT_GBRP) {
446  av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
449  return srcSliceH;
450  }
451 
452  switch (c->dstFormat) {
453  case AV_PIX_FMT_BGR24:
454  gbr24ptopacked24(src102, stride102,
455  dst[0] + srcSliceY * dstStride[0], dstStride[0],
456  srcSliceH, c->srcW);
457  break;
458 
459  case AV_PIX_FMT_RGB24:
460  gbr24ptopacked24(src201, stride201,
461  dst[0] + srcSliceY * dstStride[0], dstStride[0],
462  srcSliceH, c->srcW);
463  break;
464 
465  case AV_PIX_FMT_ARGB:
466  alpha_first = 1;
467  case AV_PIX_FMT_RGBA:
468  gbr24ptopacked32(src201, stride201,
469  dst[0] + srcSliceY * dstStride[0], dstStride[0],
470  srcSliceH, alpha_first, c->srcW);
471  break;
472 
473  case AV_PIX_FMT_ABGR:
474  alpha_first = 1;
475  case AV_PIX_FMT_BGRA:
476  gbr24ptopacked32(src102, stride102,
477  dst[0] + srcSliceY * dstStride[0], dstStride[0],
478  srcSliceH, alpha_first, c->srcW);
479  break;
480 
481  default:
482  av_log(c, AV_LOG_ERROR,
483  "unsupported planar RGB conversion %s -> %s\n",
486  }
487 
488  return srcSliceH;
489 }
490 
491 static void packedtogbr24p(const uint8_t *src, int srcStride,
492  uint8_t *dst[], int dstStride[], int srcSliceH,
493  int alpha_first, int inc_size, int width)
494 {
495  uint8_t *dest[3];
496  int x, h;
497 
498  dest[0] = dst[0];
499  dest[1] = dst[1];
500  dest[2] = dst[2];
501 
502  if (alpha_first)
503  src++;
504 
505  for (h = 0; h < srcSliceH; h++) {
506  for (x = 0; x < width; x++) {
507  dest[0][x] = src[0];
508  dest[1][x] = src[1];
509  dest[2][x] = src[2];
510 
511  src += inc_size;
512  }
513  src += srcStride - width * inc_size;
514  dest[0] += dstStride[0];
515  dest[1] += dstStride[1];
516  dest[2] += dstStride[2];
517  }
518 }
519 
521  int srcStride[], int srcSliceY, int srcSliceH,
522  uint8_t *dst[], int dstStride[])
523 {
524  int alpha_first = 0;
525  int stride102[] = { dstStride[1], dstStride[0], dstStride[2] };
526  int stride201[] = { dstStride[2], dstStride[0], dstStride[1] };
527  uint8_t *dst102[] = { dst[1] + srcSliceY * dstStride[1],
528  dst[0] + srcSliceY * dstStride[0],
529  dst[2] + srcSliceY * dstStride[2] };
530  uint8_t *dst201[] = { dst[2] + srcSliceY * dstStride[2],
531  dst[0] + srcSliceY * dstStride[0],
532  dst[1] + srcSliceY * dstStride[1] };
533 
534  switch (c->srcFormat) {
535  case AV_PIX_FMT_RGB24:
536  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
537  stride201, srcSliceH, alpha_first, 3, c->srcW);
538  break;
539  case AV_PIX_FMT_BGR24:
540  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
541  stride102, srcSliceH, alpha_first, 3, c->srcW);
542  break;
543  case AV_PIX_FMT_ARGB:
544  alpha_first = 1;
545  case AV_PIX_FMT_RGBA:
546  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst201,
547  stride201, srcSliceH, alpha_first, 4, c->srcW);
548  break;
549  case AV_PIX_FMT_ABGR:
550  alpha_first = 1;
551  case AV_PIX_FMT_BGRA:
552  packedtogbr24p((const uint8_t *) src[0], srcStride[0], dst102,
553  stride102, srcSliceH, alpha_first, 4, c->srcW);
554  break;
555  default:
556  av_log(c, AV_LOG_ERROR,
557  "unsupported planar RGB conversion %s -> %s\n",
560  }
561 
562  return srcSliceH;
563 }
564 
565 #define isRGBA32(x) ( \
566  (x) == AV_PIX_FMT_ARGB \
567  || (x) == AV_PIX_FMT_RGBA \
568  || (x) == AV_PIX_FMT_BGRA \
569  || (x) == AV_PIX_FMT_ABGR \
570  )
571 
572 #define isRGBA64(x) ( \
573  (x) == AV_PIX_FMT_RGBA64LE \
574  || (x) == AV_PIX_FMT_RGBA64BE \
575  || (x) == AV_PIX_FMT_BGRA64LE \
576  || (x) == AV_PIX_FMT_BGRA64BE \
577  )
578 
579 #define isRGB48(x) ( \
580  (x) == AV_PIX_FMT_RGB48LE \
581  || (x) == AV_PIX_FMT_RGB48BE \
582  || (x) == AV_PIX_FMT_BGR48LE \
583  || (x) == AV_PIX_FMT_BGR48BE \
584  )
585 
586 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
587 typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
589 {
590  const enum AVPixelFormat srcFormat = c->srcFormat;
591  const enum AVPixelFormat dstFormat = c->dstFormat;
592  const int srcId = c->srcFormatBpp;
593  const int dstId = c->dstFormatBpp;
594  rgbConvFn conv = NULL;
595 
596 #define IS_NOT_NE(bpp, desc) \
597  (((bpp + 7) >> 3) == 2 && \
598  (!(desc->flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))
599 
600 #define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
601 
602  if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
603  if ( CONV_IS(ABGR, RGBA)
604  || CONV_IS(ARGB, BGRA)
605  || CONV_IS(BGRA, ARGB)
606  || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
607  else if (CONV_IS(ABGR, ARGB)
608  || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
609  else if (CONV_IS(ABGR, BGRA)
610  || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
611  else if (CONV_IS(BGRA, RGBA)
612  || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
613  else if (CONV_IS(BGRA, ABGR)
614  || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
615  } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
616  if (CONV_IS(RGB48LE, BGR48LE)
617  || CONV_IS(BGR48LE, RGB48LE)
618  || CONV_IS(RGB48BE, BGR48BE)
619  || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
620  else if (CONV_IS(RGB48LE, BGR48BE)
621  || CONV_IS(BGR48LE, RGB48BE)
622  || CONV_IS(RGB48BE, BGR48LE)
623  || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
624  } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
625  if (CONV_IS(RGBA64LE, BGR48LE)
626  || CONV_IS(BGRA64LE, RGB48LE)
627  || CONV_IS(RGBA64BE, BGR48BE)
628  || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
629  else if (CONV_IS(RGBA64LE, BGR48BE)
630  || CONV_IS(BGRA64LE, RGB48BE)
631  || CONV_IS(RGBA64BE, BGR48LE)
632  || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
633  else if (CONV_IS(RGBA64LE, RGB48LE)
634  || CONV_IS(BGRA64LE, BGR48LE)
635  || CONV_IS(RGBA64BE, RGB48BE)
636  || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
637  else if (CONV_IS(RGBA64LE, RGB48BE)
638  || CONV_IS(BGRA64LE, BGR48BE)
639  || CONV_IS(RGBA64BE, RGB48LE)
640  || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
641  } else
642  /* BGR -> BGR */
643  if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
644  (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
645  switch (srcId | (dstId << 16)) {
646  case 0x000F000C: conv = rgb12to15; break;
647  case 0x000F0010: conv = rgb16to15; break;
648  case 0x000F0018: conv = rgb24to15; break;
649  case 0x000F0020: conv = rgb32to15; break;
650  case 0x0010000F: conv = rgb15to16; break;
651  case 0x00100018: conv = rgb24to16; break;
652  case 0x00100020: conv = rgb32to16; break;
653  case 0x0018000F: conv = rgb15to24; break;
654  case 0x00180010: conv = rgb16to24; break;
655  case 0x00180020: conv = rgb32to24; break;
656  case 0x0020000F: conv = rgb15to32; break;
657  case 0x00200010: conv = rgb16to32; break;
658  case 0x00200018: conv = rgb24to32; break;
659  }
660  } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
661  (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
662  switch (srcId | (dstId << 16)) {
663  case 0x000C000C: conv = rgb12tobgr12; break;
664  case 0x000F000F: conv = rgb15tobgr15; break;
665  case 0x000F0010: conv = rgb16tobgr15; break;
666  case 0x000F0018: conv = rgb24tobgr15; break;
667  case 0x000F0020: conv = rgb32tobgr15; break;
668  case 0x0010000F: conv = rgb15tobgr16; break;
669  case 0x00100010: conv = rgb16tobgr16; break;
670  case 0x00100018: conv = rgb24tobgr16; break;
671  case 0x00100020: conv = rgb32tobgr16; break;
672  case 0x0018000F: conv = rgb15tobgr24; break;
673  case 0x00180010: conv = rgb16tobgr24; break;
674  case 0x00180018: conv = rgb24tobgr24; break;
675  case 0x00180020: conv = rgb32tobgr24; break;
676  case 0x0020000F: conv = rgb15tobgr32; break;
677  case 0x00200010: conv = rgb16tobgr32; break;
678  case 0x00200018: conv = rgb24tobgr32; break;
679  }
680  }
681 
682  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
683  return NULL;
684 
685  return conv;
686 }
687 
688 /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
689 static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
690  int srcSliceY, int srcSliceH, uint8_t *dst[],
691  int dstStride[])
692 
693 {
694  const enum AVPixelFormat srcFormat = c->srcFormat;
695  const enum AVPixelFormat dstFormat = c->dstFormat;
696  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
697  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
698  const int srcBpp = (c->srcFormatBpp + 7) >> 3;
699  const int dstBpp = (c->dstFormatBpp + 7) >> 3;
701 
702  if (!conv) {
703  av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
704  av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
705  } else {
706  const uint8_t *srcPtr = src[0];
707  uint8_t *dstPtr = dst[0];
708  int src_bswap = IS_NOT_NE(c->srcFormatBpp, desc_src);
709  int dst_bswap = IS_NOT_NE(c->dstFormatBpp, desc_dst);
710 
711  if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
712  !isRGBA32(dstFormat))
713  srcPtr += ALT32_CORR;
714 
715  if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
716  !isRGBA32(srcFormat))
717  dstPtr += ALT32_CORR;
718 
719  if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
720  !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
721  conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
722  srcSliceH * srcStride[0]);
723  else {
724  int i, j;
725  dstPtr += dstStride[0] * srcSliceY;
726 
727  for (i = 0; i < srcSliceH; i++) {
728  if(src_bswap) {
729  for(j=0; j<c->srcW; j++)
730  ((uint16_t*)c->formatConvBuffer)[j] = av_bswap16(((uint16_t*)srcPtr)[j]);
731  conv(c->formatConvBuffer, dstPtr, c->srcW * srcBpp);
732  }else
733  conv(srcPtr, dstPtr, c->srcW * srcBpp);
734  if(dst_bswap)
735  for(j=0; j<c->srcW; j++)
736  ((uint16_t*)dstPtr)[j] = av_bswap16(((uint16_t*)dstPtr)[j]);
737  srcPtr += srcStride[0];
738  dstPtr += dstStride[0];
739  }
740  }
741  }
742  return srcSliceH;
743 }
744 
745 static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
746  int srcStride[], int srcSliceY, int srcSliceH,
747  uint8_t *dst[], int dstStride[])
748 {
750  src[0],
751  dst[0] + srcSliceY * dstStride[0],
752  dst[1] + (srcSliceY >> 1) * dstStride[1],
753  dst[2] + (srcSliceY >> 1) * dstStride[2],
754  c->srcW, srcSliceH,
755  dstStride[0], dstStride[1], srcStride[0],
756  c->input_rgb2yuv_table);
757  if (dst[3])
758  fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
759  return srcSliceH;
760 }
761 
762 static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
763  int srcStride[], int srcSliceY, int srcSliceH,
764  uint8_t *dst[], int dstStride[])
765 {
766  copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
767  dst[0], dstStride[0]);
768 
769  planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->chrSrcW,
770  srcSliceH >> 2, srcStride[1], dstStride[1]);
771  planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->chrSrcW,
772  srcSliceH >> 2, srcStride[2], dstStride[2]);
773  if (dst[3])
774  fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
775  return srcSliceH;
776 }
777 
778 /* unscaled copy like stuff (assumes nearly identical formats) */
779 static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
780  int srcStride[], int srcSliceY, int srcSliceH,
781  uint8_t *dst[], int dstStride[])
782 {
783  if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
784  memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
785  else {
786  int i;
787  const uint8_t *srcPtr = src[0];
788  uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
789  int length = 0;
790 
791  /* universal length finder */
792  while (length + c->srcW <= FFABS(dstStride[0]) &&
793  length + c->srcW <= FFABS(srcStride[0]))
794  length += c->srcW;
795  av_assert1(length != 0);
796 
797  for (i = 0; i < srcSliceH; i++) {
798  memcpy(dstPtr, srcPtr, length);
799  srcPtr += srcStride[0];
800  dstPtr += dstStride[0];
801  }
802  }
803  return srcSliceH;
804 }
805 
806 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
807  uint16_t scale= dither_scale[dst_depth-1][src_depth-1];\
808  int shift= src_depth-dst_depth + dither_scale[src_depth-2][dst_depth-1];\
809  for (i = 0; i < height; i++) {\
810  const uint8_t *dither= dithers[src_depth-9][i&7];\
811  for (j = 0; j < length-7; j+=8){\
812  dst[j+0] = dbswap((bswap(src[j+0]) + dither[0])*scale>>shift);\
813  dst[j+1] = dbswap((bswap(src[j+1]) + dither[1])*scale>>shift);\
814  dst[j+2] = dbswap((bswap(src[j+2]) + dither[2])*scale>>shift);\
815  dst[j+3] = dbswap((bswap(src[j+3]) + dither[3])*scale>>shift);\
816  dst[j+4] = dbswap((bswap(src[j+4]) + dither[4])*scale>>shift);\
817  dst[j+5] = dbswap((bswap(src[j+5]) + dither[5])*scale>>shift);\
818  dst[j+6] = dbswap((bswap(src[j+6]) + dither[6])*scale>>shift);\
819  dst[j+7] = dbswap((bswap(src[j+7]) + dither[7])*scale>>shift);\
820  }\
821  for (; j < length; j++)\
822  dst[j] = dbswap((bswap(src[j]) + dither[j&7])*scale>>shift);\
823  dst += dstStride;\
824  src += srcStride;\
825  }
826 
827 static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
828  int srcStride[], int srcSliceY, int srcSliceH,
829  uint8_t *dst[], int dstStride[])
830 {
831  const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
832  const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
833  int plane, i, j;
834  for (plane = 0; plane < 4; plane++) {
835  int length = (plane == 0 || plane == 3) ? c->srcW : -((-c->srcW ) >> c->chrDstHSubSample);
836  int y = (plane == 0 || plane == 3) ? srcSliceY: -((-srcSliceY) >> c->chrDstVSubSample);
837  int height = (plane == 0 || plane == 3) ? srcSliceH: -((-srcSliceH) >> c->chrDstVSubSample);
838  const uint8_t *srcPtr = src[plane];
839  uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
840  int shiftonly= plane==1 || plane==2 || (!c->srcRange && plane==0);
841 
842  if (!dst[plane])
843  continue;
844  // ignore palette for GRAY8
845  if (plane == 1 && !dst[2]) continue;
846  if (!src[plane] || (plane == 1 && !src[2])) {
847  if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
848  fillPlane16(dst[plane], dstStride[plane], length, height, y,
849  plane == 3, desc_dst->comp[plane].depth_minus1,
850  isBE(c->dstFormat));
851  } else {
852  fillPlane(dst[plane], dstStride[plane], length, height, y,
853  (plane == 3) ? 255 : 128);
854  }
855  } else {
856  if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
857  || (is16BPS(c->srcFormat) != is16BPS(c->dstFormat))
858  ) {
859  const int src_depth = desc_src->comp[plane].depth_minus1 + 1;
860  const int dst_depth = desc_dst->comp[plane].depth_minus1 + 1;
861  const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
862  uint16_t *dstPtr2 = (uint16_t*)dstPtr;
863 
864  if (dst_depth == 8) {
865  if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
866  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
867  } else {
868  DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
869  }
870  } else if (src_depth == 8) {
871  for (i = 0; i < height; i++) {
872  #define COPY816(w)\
873  if(shiftonly){\
874  for (j = 0; j < length; j++)\
875  w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
876  }else{\
877  for (j = 0; j < length; j++)\
878  w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
879  (srcPtr[j]>>(2*8-dst_depth)));\
880  }
881  if(isBE(c->dstFormat)){
883  } else {
885  }
886  dstPtr2 += dstStride[plane]/2;
887  srcPtr += srcStride[plane];
888  }
889  } else if (src_depth <= dst_depth) {
890  int orig_length = length;
891  for (i = 0; i < height; i++) {
892  if(isBE(c->srcFormat) == HAVE_BIGENDIAN &&
893  isBE(c->dstFormat) == HAVE_BIGENDIAN &&
894  shiftonly) {
895  unsigned shift = dst_depth - src_depth;
896  length = orig_length;
897 #if HAVE_FAST_64BIT
898 #define FAST_COPY_UP(shift) \
899  for (j = 0; j < length - 3; j += 4) { \
900  uint64_t v = AV_RN64A(srcPtr2 + j); \
901  AV_WN64A(dstPtr2 + j, v << shift); \
902  } \
903  length &= 3;
904 #else
905 #define FAST_COPY_UP(shift) \
906  for (j = 0; j < length - 1; j += 2) { \
907  uint32_t v = AV_RN32A(srcPtr2 + j); \
908  AV_WN32A(dstPtr2 + j, v << shift); \
909  } \
910  length &= 1;
911 #endif
912  switch (shift)
913  {
914  case 6: FAST_COPY_UP(6); break;
915  case 7: FAST_COPY_UP(7); break;
916  }
917  }
918 #define COPY_UP(r,w) \
919  if(shiftonly){\
920  for (j = 0; j < length; j++){ \
921  unsigned int v= r(&srcPtr2[j]);\
922  w(&dstPtr2[j], v<<(dst_depth-src_depth));\
923  }\
924  }else{\
925  for (j = 0; j < length; j++){ \
926  unsigned int v= r(&srcPtr2[j]);\
927  w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
928  (v>>(2*src_depth-dst_depth)));\
929  }\
930  }
931  if(isBE(c->srcFormat)){
932  if(isBE(c->dstFormat)){
934  } else {
936  }
937  } else {
938  if(isBE(c->dstFormat)){
940  } else {
942  }
943  }
944  dstPtr2 += dstStride[plane]/2;
945  srcPtr2 += srcStride[plane]/2;
946  }
947  } else {
948  if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
949  if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
950  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
951  } else {
952  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
953  }
954  }else{
955  if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
956  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
957  } else {
958  DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
959  }
960  }
961  }
962  } else if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat) &&
963  isBE(c->srcFormat) != isBE(c->dstFormat)) {
964 
965  for (i = 0; i < height; i++) {
966  for (j = 0; j < length; j++)
967  ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
968  srcPtr += srcStride[plane];
969  dstPtr += dstStride[plane];
970  }
971  } else if (dstStride[plane] == srcStride[plane] &&
972  srcStride[plane] > 0 && srcStride[plane] == length) {
973  memcpy(dst[plane] + dstStride[plane] * y, src[plane],
974  height * dstStride[plane]);
975  } else {
976  if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
977  length *= 2;
978  else if (!desc_src->comp[0].depth_minus1)
979  length >>= 3; // monowhite/black
980  for (i = 0; i < height; i++) {
981  memcpy(dstPtr, srcPtr, length);
982  srcPtr += srcStride[plane];
983  dstPtr += dstStride[plane];
984  }
985  }
986  }
987  }
988  return srcSliceH;
989 }
990 
991 
992 #define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
993  ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
994  (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
995 
996 
998 {
999  const enum AVPixelFormat srcFormat = c->srcFormat;
1000  const enum AVPixelFormat dstFormat = c->dstFormat;
1001  const int flags = c->flags;
1002  const int dstH = c->dstH;
1003  int needsDither;
1004 
1005  needsDither = isAnyRGB(dstFormat) &&
1006  c->dstFormatBpp < 24 &&
1007  (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
1008 
1009  /* yv12_to_nv12 */
1010  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
1011  (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
1013  }
1014  /* yuv2bgr */
1015  if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
1016  srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
1017  !(flags & (SWS_ACCURATE_RND|SWS_ERROR_DIFFUSION)) && !(dstH & 1)) {
1019  }
1020 
1021  if (srcFormat == AV_PIX_FMT_YUV410P &&
1022  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
1023  !(flags & SWS_BITEXACT)) {
1025  }
1026 
1027  /* bgr24toYV12 */
1028  if (srcFormat == AV_PIX_FMT_BGR24 &&
1029  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
1030  !(flags & SWS_ACCURATE_RND))
1032 
1033  /* RGB/BGR -> RGB/BGR (no dither needed forms) */
1034  if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
1035  && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
1037 
1038 #define isByteRGB(f) ( \
1039  f == AV_PIX_FMT_RGB32 || \
1040  f == AV_PIX_FMT_RGB32_1 || \
1041  f == AV_PIX_FMT_RGB24 || \
1042  f == AV_PIX_FMT_BGR32 || \
1043  f == AV_PIX_FMT_BGR32_1 || \
1044  f == AV_PIX_FMT_BGR24)
1045 
1046  if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
1048 
1049  if (av_pix_fmt_desc_get(srcFormat)->comp[0].depth_minus1 == 7 &&
1050  isPackedRGB(srcFormat) && dstFormat == AV_PIX_FMT_GBRP)
1052 
1053  /* bswap 16 bits per pixel/component packed formats */
1054  if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
1055  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
1056  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
1057  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
1058  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
1059  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
1060  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
1061  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
1062  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
1063  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
1064  IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565))
1066 
1067  if (usePal(srcFormat) && isByteRGB(dstFormat))
1068  c->swScale = palToRgbWrapper;
1069 
1070  if (srcFormat == AV_PIX_FMT_YUV422P) {
1071  if (dstFormat == AV_PIX_FMT_YUYV422)
1073  else if (dstFormat == AV_PIX_FMT_UYVY422)
1075  }
1076 
1077  /* LQ converters if -sws 0 or -sws 4*/
1078  if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
1079  /* yv12_to_yuy2 */
1080  if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
1081  if (dstFormat == AV_PIX_FMT_YUYV422)
1083  else if (dstFormat == AV_PIX_FMT_UYVY422)
1085  }
1086  }
1087  if (srcFormat == AV_PIX_FMT_YUYV422 &&
1088  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
1090  if (srcFormat == AV_PIX_FMT_UYVY422 &&
1091  (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
1093  if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
1095  if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
1097 
1098 #define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_GRAY8A)
1099  /* simple copy */
1100  if ( srcFormat == dstFormat ||
1101  (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
1102  (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
1103  (isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
1104  (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
1105  (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
1106  (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
1109  dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
1110  srcFormat != AV_PIX_FMT_NV12 && srcFormat != AV_PIX_FMT_NV21))
1111  {
1112  if (isPacked(c->srcFormat))
1114  else /* Planar YUV or gray */
1116  }
1117 
1118  if (ARCH_BFIN)
1120  if (HAVE_ALTIVEC)
1122 }
1123 
1124 /* Convert the palette to the same packed 32-bit format as the palette */
1126  int num_pixels, const uint8_t *palette)
1127 {
1128  int i;
1129 
1130  for (i = 0; i < num_pixels; i++)
1131  ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
1132 }
1133 
1134 /* Palette format: ABCD -> dst format: ABC */
1136  int num_pixels, const uint8_t *palette)
1137 {
1138  int i;
1139 
1140  for (i = 0; i < num_pixels; i++) {
1141  //FIXME slow?
1142  dst[0] = palette[src[i] * 4 + 0];
1143  dst[1] = palette[src[i] * 4 + 1];
1144  dst[2] = palette[src[i] * 4 + 2];
1145  dst += 3;
1146  }
1147 }
#define IS_NOT_NE(bpp, desc)
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:56
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:85
void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size)
const uint16_t dither_scale[15][16]
void(* rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:52
#define SWS_POINT
Definition: swscale.h:62
static int shift(int a, int b)
Definition: sonic.c:86
#define COPY816(w)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1778
static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define isPlanarGray(x)
static int conv(int samples, float **pcm, char *buf, int channels)
Definition: libvorbisdec.c:111
void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:174
uint32_t pal_rgb[256]
void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:306
void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size)
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
#define ARCH_BFIN
Definition: config.h:20
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:292
void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size)
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
#define SWS_FAST_BILINEAR
Definition: swscale.h:58
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:229
DECLARE_ALIGNED(8, const uint8_t, dithers)[8][8][8]
void(* rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:36
#define HAVE_ALTIVEC
Definition: config.h:56
static void gbr24ptopacked32(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int alpha_first, int width)
#define av_bswap16
Definition: sh4/bswap.h:31
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:293
static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
external API header
#define AV_RL16
#define isRGBA32(x)
static void gbr24ptopacked24(const uint8_t *src[], int srcStride[], uint8_t *dst, int dstStride, int srcSliceH, int width)
#define RGBA(r, g, b, a)
Definition: dvbsubdec.c:153
int srcRange
0 = MPG YUV range, 1 = JPG YUV range (source image).
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:270
SwsFunc swScale
Note that src, dst, srcStride, dstStride will be copied in the sws_scale() wrapper so they can be fre...
int stride
Definition: mace.c:144
void(* rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:42
void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:40
static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void(* shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:54
void(* rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:45
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:105
int chrDstVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination i...
static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void ff_bfin_get_unscaled_swscale(SwsContext *c)
Definition: swscale_bfin.c:74
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:86
uint8_t
#define isByteRGB(f)
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:60
static int rgbToPlanarRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
#define isRGBinInt(x)
void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:215
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:98
#define SWS_BITEXACT
Definition: swscale.h:84
static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:271
#define isAnyRGB(x)
external API header
enum AVPixelFormat dstFormat
Destination pixel format.
int chrSrcHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source imag...
#define COPY_UP(r, w)
int dstH
Height of destination luma/alpha planes.
Discrete Time axis x
void ff_get_unscaled_swscale(SwsContext *c)
Set c->swScale to an unscaled converter if one exists for the specific source and destination formats...
static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
uint16_t depth_minus1
number of bits in the component minus 1
Definition: pixdesc.h:43
#define CONV_IS(src, dst)
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:262
#define isBGRinInt(x)
static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static rgbConvFn findRgbConvFn(SwsContext *c)
static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
#define AV_RB16
#define FAST_COPY_UP(shift)
void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size)
#define AV_WL16(p, darg)
Definition: intreadwrite.h:250
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:99
void(* rgbConvFn)(const uint8_t *, uint8_t *, int)
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:93
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:267
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
static void fillPlane(uint8_t *plane, int stride, int width, int height, int y, uint8_t val)
static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void(* rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:43
void(* rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:37
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:76
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:96
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:97
#define isNBPS(x)
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.
void(* rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:47
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:72
static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:285
as above, but U and V bytes are swapped
Definition: pixfmt.h:94
#define SWS_ERROR_DIFFUSION
Definition: swscale.h:85
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:83
8bit gray, 8bit alpha
Definition: pixfmt.h:141
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:266
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
#define FFMIN(a, b)
Definition: common.h:58
uint8_t * formatConvBuffer
void ff_swscale_get_unscaled_altivec(SwsContext *c)
#define isRGBA64(x)
void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size)
#define SWS_ACCURATE_RND
Definition: swscale.h:83
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:64
#define FFABS(a)
Definition: common.h:53
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:196
void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:38
static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:273
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:261
static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
NULL
Definition: eval.c:55
void(* rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:50
static int width
Definition: tests/utils.c:158
dest
Definition: start.py:60
AVS_Value src
Definition: avisynth_c.h:523
typedef void(RENAME(mix_any_func_type))
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:102
static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:55
#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt)
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:69
void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:136
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:74
synthesis window for stochastic i
#define AV_WB16(p, darg)
Definition: intreadwrite.h:237
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:68
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
Definition: yuv2rgb.c:607
byte swapping routines
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:99
static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette)
void(* rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:48
void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:154
#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)
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:96
static void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian)
static int planarCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:272
static int flags
Definition: cpu.c:23
static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
void(* rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:49
void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:295
const uint8_t dithers[8][8][8]
void(* rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:39
int palette
Definition: v4l.c:61
void(* rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:41
static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:68
static double c[64]
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:274
enum AVPixelFormat srcFormat
Source pixel format.
static void packedtogbr24p(const uint8_t *src, int srcStride, uint8_t *dst[], int dstStride[], int srcSliceH, int alpha_first, int inc_size, int width)
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:269
void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
function y
Definition: D.m:1
static void copyPlane(const uint8_t *src, int srcStride, int srcSliceY, int srcSliceH, int width, uint8_t *dst, int dstStride)
static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
void(* rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:46
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:260
void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:249
static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dstParam[], int dstStride[])
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
int srcFormatBpp
Number of bits per pixel of the source pixel format.
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.
void(* planar2x)(const uint8_t *src, uint8_t *dst, int width, int height, int srcStride, int dstStride)
Definition: rgb2rgb.c:81
void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size)
void(* rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:35
static int packedCopyWrapper(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:268
static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
Definition: eamad.c:71
static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
const char int length
Definition: avisynth_c.h:668
#define HAVE_BIGENDIAN
Definition: config.h:116
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:1700
#define ALT32_CORR
int chrDstHSubSample
Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination...
int chrSrcW
Width of source chroma planes.
#define isPacked(x)
#define isRGB48(x)
int srcW
Width of source luma/alpha planes.
void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:239
int chrSrcVSubSample
Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image...
int flags
Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
void(* rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:51
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:105
void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
Definition: rgb2rgb.c:271