yuv2rgb.c
Go to the documentation of this file.
1 /*
2  * software YUV to RGB converter
3  *
4  * Copyright (C) 2009 Konstantin Shishkov
5  *
6  * 1,4,8bpp support and context / deglobalize stuff
7  * by Michael Niedermayer (michaelni@gmx.at)
8  *
9  * This file is part of FFmpeg.
10  *
11  * FFmpeg is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * FFmpeg is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with FFmpeg; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <inttypes.h>
29 
30 #include "libavutil/cpu.h"
31 #include "libavutil/bswap.h"
32 #include "config.h"
33 #include "rgb2rgb.h"
34 #include "swscale.h"
35 #include "swscale_internal.h"
36 #include "libavutil/pixdesc.h"
37 
38 extern const uint8_t dither_2x2_4[3][8];
39 extern const uint8_t dither_2x2_8[3][8];
40 extern const uint8_t dither_4x4_16[5][8];
41 extern const uint8_t dither_8x8_32[9][8];
42 extern const uint8_t dither_8x8_73[9][8];
43 extern const uint8_t dither_8x8_220[9][8];
44 
45 const int32_t ff_yuv2rgb_coeffs[8][4] = {
46  { 117504, 138453, 13954, 34903 }, /* no sequence_display_extension */
47  { 117504, 138453, 13954, 34903 }, /* ITU-R Rec. 709 (1990) */
48  { 104597, 132201, 25675, 53279 }, /* unspecified */
49  { 104597, 132201, 25675, 53279 }, /* reserved */
50  { 104448, 132798, 24759, 53109 }, /* FCC */
51  { 104597, 132201, 25675, 53279 }, /* ITU-R Rec. 624-4 System B, G */
52  { 104597, 132201, 25675, 53279 }, /* SMPTE 170M */
53  { 117579, 136230, 16907, 35559 } /* SMPTE 240M (1987) */
54 };
55 
57 {
58  if (colorspace > 7 || colorspace < 0)
59  colorspace = SWS_CS_DEFAULT;
61 }
62 
63 #define LOADCHROMA(i) \
64  U = pu[i]; \
65  V = pv[i]; \
66  r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \
67  g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \
68  b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM];
69 
70 #define PUTRGB(dst, src, i) \
71  Y = src[2 * i]; \
72  dst[2 * i] = r[Y] + g[Y] + b[Y]; \
73  Y = src[2 * i + 1]; \
74  dst[2 * i + 1] = r[Y] + g[Y] + b[Y];
75 
76 #define PUTRGB24(dst, src, i) \
77  Y = src[2 * i]; \
78  dst[6 * i + 0] = r[Y]; \
79  dst[6 * i + 1] = g[Y]; \
80  dst[6 * i + 2] = b[Y]; \
81  Y = src[2 * i + 1]; \
82  dst[6 * i + 3] = r[Y]; \
83  dst[6 * i + 4] = g[Y]; \
84  dst[6 * i + 5] = b[Y];
85 
86 #define PUTBGR24(dst, src, i) \
87  Y = src[2 * i]; \
88  dst[6 * i + 0] = b[Y]; \
89  dst[6 * i + 1] = g[Y]; \
90  dst[6 * i + 2] = r[Y]; \
91  Y = src[2 * i + 1]; \
92  dst[6 * i + 3] = b[Y]; \
93  dst[6 * i + 4] = g[Y]; \
94  dst[6 * i + 5] = r[Y];
95 
96 #define PUTRGBA(dst, ysrc, asrc, i, s) \
97  Y = ysrc[2 * i]; \
98  dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \
99  Y = ysrc[2 * i + 1]; \
100  dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s);
101 
102 #define PUTRGB48(dst, src, i) \
103  Y = src[ 2 * i]; \
104  dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \
105  dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
106  dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \
107  Y = src[ 2 * i + 1]; \
108  dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \
109  dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
110  dst[12 * i + 10] = dst[12 * i + 11] = b[Y];
111 
112 #define PUTBGR48(dst, src, i) \
113  Y = src[2 * i]; \
114  dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \
115  dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
116  dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \
117  Y = src[2 * i + 1]; \
118  dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \
119  dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
120  dst[12 * i + 10] = dst[12 * i + 11] = r[Y];
121 
122 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
123  static int func_name(SwsContext *c, const uint8_t *src[], \
124  int srcStride[], int srcSliceY, int srcSliceH, \
125  uint8_t *dst[], int dstStride[]) \
126  { \
127  int y; \
128  \
129  if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \
130  srcStride[1] *= 2; \
131  srcStride[2] *= 2; \
132  } \
133  for (y = 0; y < srcSliceH; y += 2) { \
134  dst_type *dst_1 = \
135  (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \
136  dst_type *dst_2 = \
137  (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \
138  dst_type av_unused *r, *g, *b; \
139  const uint8_t *py_1 = src[0] + y * srcStride[0]; \
140  const uint8_t *py_2 = py_1 + srcStride[0]; \
141  const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \
142  const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \
143  const uint8_t av_unused *pa_1, *pa_2; \
144  unsigned int h_size = c->dstW >> 3; \
145  if (alpha) { \
146  pa_1 = src[3] + y * srcStride[3]; \
147  pa_2 = pa_1 + srcStride[3]; \
148  } \
149  while (h_size--) { \
150  int av_unused U, V, Y; \
151 
152 #define ENDYUV2RGBLINE(dst_delta, ss) \
153  pu += 4 >> ss; \
154  pv += 4 >> ss; \
155  py_1 += 8 >> ss; \
156  py_2 += 8 >> ss; \
157  dst_1 += dst_delta >> ss; \
158  dst_2 += dst_delta >> ss; \
159  } \
160  if (c->dstW & (4 >> ss)) { \
161  int av_unused Y, U, V; \
162 
163 #define ENDYUV2RGBFUNC() \
164  } \
165  } \
166  return srcSliceH; \
167  }
168 
169 #define CLOSEYUV2RGBFUNC(dst_delta) \
170  ENDYUV2RGBLINE(dst_delta, 0) \
171  ENDYUV2RGBFUNC()
172 
173 YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0)
174  LOADCHROMA(0);
175  PUTRGB48(dst_1, py_1, 0);
176  PUTRGB48(dst_2, py_2, 0);
177 
178  LOADCHROMA(1);
179  PUTRGB48(dst_2, py_2, 1);
180  PUTRGB48(dst_1, py_1, 1);
181 
182  LOADCHROMA(2);
183  PUTRGB48(dst_1, py_1, 2);
184  PUTRGB48(dst_2, py_2, 2);
185 
186  LOADCHROMA(3);
187  PUTRGB48(dst_2, py_2, 3);
188  PUTRGB48(dst_1, py_1, 3);
189 ENDYUV2RGBLINE(48, 0)
190  LOADCHROMA(0);
191  PUTRGB48(dst_1, py_1, 0);
192  PUTRGB48(dst_2, py_2, 0);
193 
194  LOADCHROMA(1);
195  PUTRGB48(dst_2, py_2, 1);
196  PUTRGB48(dst_1, py_1, 1);
197 ENDYUV2RGBLINE(48, 1)
198  LOADCHROMA(0);
199  PUTRGB48(dst_1, py_1, 0);
200  PUTRGB48(dst_2, py_2, 0);
202 
203 YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0)
204  LOADCHROMA(0);
205  PUTBGR48(dst_1, py_1, 0);
206  PUTBGR48(dst_2, py_2, 0);
207 
208  LOADCHROMA(1);
209  PUTBGR48(dst_2, py_2, 1);
210  PUTBGR48(dst_1, py_1, 1);
211 
212  LOADCHROMA(2);
213  PUTBGR48(dst_1, py_1, 2);
214  PUTBGR48(dst_2, py_2, 2);
215 
216  LOADCHROMA(3);
217  PUTBGR48(dst_2, py_2, 3);
218  PUTBGR48(dst_1, py_1, 3);
219 ENDYUV2RGBLINE(48, 0)
220  LOADCHROMA(0);
221  PUTBGR48(dst_1, py_1, 0);
222  PUTBGR48(dst_2, py_2, 0);
223 
224  LOADCHROMA(1);
225  PUTBGR48(dst_2, py_2, 1);
226  PUTBGR48(dst_1, py_1, 1);
227 ENDYUV2RGBLINE(48, 1)
228  LOADCHROMA(0);
229  PUTBGR48(dst_1, py_1, 0);
230  PUTBGR48(dst_2, py_2, 0);
232 
233 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
234  LOADCHROMA(0);
235  PUTRGB(dst_1, py_1, 0);
236  PUTRGB(dst_2, py_2, 0);
237 
238  LOADCHROMA(1);
239  PUTRGB(dst_2, py_2, 1);
240  PUTRGB(dst_1, py_1, 1);
241 
242  LOADCHROMA(2);
243  PUTRGB(dst_1, py_1, 2);
244  PUTRGB(dst_2, py_2, 2);
245 
246  LOADCHROMA(3);
247  PUTRGB(dst_2, py_2, 3);
248  PUTRGB(dst_1, py_1, 3);
249 ENDYUV2RGBLINE(8, 0)
250  LOADCHROMA(0);
251  PUTRGB(dst_1, py_1, 0);
252  PUTRGB(dst_2, py_2, 0);
253 
254  LOADCHROMA(1);
255  PUTRGB(dst_2, py_2, 1);
256  PUTRGB(dst_1, py_1, 1);
257 ENDYUV2RGBLINE(8, 1)
258  LOADCHROMA(0);
259  PUTRGB(dst_1, py_1, 0);
260  PUTRGB(dst_2, py_2, 0);
262 
263 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
264  LOADCHROMA(0);
265  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
266  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
267 
268  LOADCHROMA(1);
269  PUTRGBA(dst_2, py_2, pa_1, 1, 24);
270  PUTRGBA(dst_1, py_1, pa_2, 1, 24);
271 
272  LOADCHROMA(2);
273  PUTRGBA(dst_1, py_1, pa_1, 2, 24);
274  PUTRGBA(dst_2, py_2, pa_2, 2, 24);
275 
276  LOADCHROMA(3);
277  PUTRGBA(dst_2, py_2, pa_1, 3, 24);
278  PUTRGBA(dst_1, py_1, pa_2, 3, 24);
279  pa_1 += 8; \
280  pa_2 += 8; \
281 ENDYUV2RGBLINE(8, 0)
282  LOADCHROMA(0);
283  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
284  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
285 
286  LOADCHROMA(1);
287  PUTRGBA(dst_2, py_2, pa_1, 1, 24);
288  PUTRGBA(dst_1, py_1, pa_2, 1, 24);
289  pa_1 += 4; \
290  pa_2 += 4; \
291 ENDYUV2RGBLINE(8, 1)
292  LOADCHROMA(0);
293  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
294  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
296 
297 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
298  LOADCHROMA(0);
299  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
300  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
301 
302  LOADCHROMA(1);
303  PUTRGBA(dst_2, py_2, pa_2, 1, 0);
304  PUTRGBA(dst_1, py_1, pa_1, 1, 0);
305 
306  LOADCHROMA(2);
307  PUTRGBA(dst_1, py_1, pa_1, 2, 0);
308  PUTRGBA(dst_2, py_2, pa_2, 2, 0);
309 
310  LOADCHROMA(3);
311  PUTRGBA(dst_2, py_2, pa_2, 3, 0);
312  PUTRGBA(dst_1, py_1, pa_1, 3, 0);
313  pa_1 += 8; \
314  pa_2 += 8; \
315 ENDYUV2RGBLINE(8, 0)
316  LOADCHROMA(0);
317  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
318  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
319 
320  LOADCHROMA(1);
321  PUTRGBA(dst_2, py_2, pa_2, 1, 0);
322  PUTRGBA(dst_1, py_1, pa_1, 1, 0);
323  pa_1 += 4; \
324  pa_2 += 4; \
325 ENDYUV2RGBLINE(8, 1)
326  LOADCHROMA(0);
327  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
328  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
330 
331 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
332  LOADCHROMA(0);
333  PUTRGB24(dst_1, py_1, 0);
334  PUTRGB24(dst_2, py_2, 0);
335 
336  LOADCHROMA(1);
337  PUTRGB24(dst_2, py_2, 1);
338  PUTRGB24(dst_1, py_1, 1);
339 
340  LOADCHROMA(2);
341  PUTRGB24(dst_1, py_1, 2);
342  PUTRGB24(dst_2, py_2, 2);
343 
344  LOADCHROMA(3);
345  PUTRGB24(dst_2, py_2, 3);
346  PUTRGB24(dst_1, py_1, 3);
347 ENDYUV2RGBLINE(24, 0)
348  LOADCHROMA(0);
349  PUTRGB24(dst_1, py_1, 0);
350  PUTRGB24(dst_2, py_2, 0);
351 
352  LOADCHROMA(1);
353  PUTRGB24(dst_2, py_2, 1);
354  PUTRGB24(dst_1, py_1, 1);
355 ENDYUV2RGBLINE(24, 1)
356  LOADCHROMA(0);
357  PUTRGB24(dst_1, py_1, 0);
358  PUTRGB24(dst_2, py_2, 0);
360 
361 // only trivial mods from yuv2rgb_c_24_rgb
362 YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)
363  LOADCHROMA(0);
364  PUTBGR24(dst_1, py_1, 0);
365  PUTBGR24(dst_2, py_2, 0);
366 
367  LOADCHROMA(1);
368  PUTBGR24(dst_2, py_2, 1);
369  PUTBGR24(dst_1, py_1, 1);
370 
371  LOADCHROMA(2);
372  PUTBGR24(dst_1, py_1, 2);
373  PUTBGR24(dst_2, py_2, 2);
374 
375  LOADCHROMA(3);
376  PUTBGR24(dst_2, py_2, 3);
377  PUTBGR24(dst_1, py_1, 3);
378 ENDYUV2RGBLINE(24, 0)
379  LOADCHROMA(0);
380  PUTBGR24(dst_1, py_1, 0);
381  PUTBGR24(dst_2, py_2, 0);
382 
383  LOADCHROMA(1);
384  PUTBGR24(dst_2, py_2, 1);
385  PUTBGR24(dst_1, py_1, 1);
386 ENDYUV2RGBLINE(24, 1)
387  LOADCHROMA(0);
388  PUTBGR24(dst_1, py_1, 0);
389  PUTBGR24(dst_2, py_2, 0);
391 
392 YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
393  const uint8_t *d16 = dither_2x2_8[y & 1];
394  const uint8_t *e16 = dither_2x2_4[y & 1];
395  const uint8_t *f16 = dither_2x2_8[(y & 1)^1];
396 
397 #define PUTRGB16(dst, src, i, o) \
398  Y = src[2 * i]; \
399  dst[2 * i] = r[Y + d16[0 + o]] + \
400  g[Y + e16[0 + o]] + \
401  b[Y + f16[0 + o]]; \
402  Y = src[2 * i + 1]; \
403  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
404  g[Y + e16[1 + o]] + \
405  b[Y + f16[1 + o]];
406  LOADCHROMA(0);
407  PUTRGB16(dst_1, py_1, 0, 0);
408  PUTRGB16(dst_2, py_2, 0, 0 + 8);
409 
410  LOADCHROMA(1);
411  PUTRGB16(dst_2, py_2, 1, 2 + 8);
412  PUTRGB16(dst_1, py_1, 1, 2);
413 
414  LOADCHROMA(2);
415  PUTRGB16(dst_1, py_1, 2, 4);
416  PUTRGB16(dst_2, py_2, 2, 4 + 8);
417 
418  LOADCHROMA(3);
419  PUTRGB16(dst_2, py_2, 3, 6 + 8);
420  PUTRGB16(dst_1, py_1, 3, 6);
422 
423 YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
424  const uint8_t *d16 = dither_2x2_8[y & 1];
425  const uint8_t *e16 = dither_2x2_8[(y & 1)^1];
426 
427 #define PUTRGB15(dst, src, i, o) \
428  Y = src[2 * i]; \
429  dst[2 * i] = r[Y + d16[0 + o]] + \
430  g[Y + d16[1 + o]] + \
431  b[Y + e16[0 + o]]; \
432  Y = src[2 * i + 1]; \
433  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
434  g[Y + d16[0 + o]] + \
435  b[Y + e16[1 + o]];
436  LOADCHROMA(0);
437  PUTRGB15(dst_1, py_1, 0, 0);
438  PUTRGB15(dst_2, py_2, 0, 0 + 8);
439 
440  LOADCHROMA(1);
441  PUTRGB15(dst_2, py_2, 1, 2 + 8);
442  PUTRGB15(dst_1, py_1, 1, 2);
443 
444  LOADCHROMA(2);
445  PUTRGB15(dst_1, py_1, 2, 4);
446  PUTRGB15(dst_2, py_2, 2, 4 + 8);
447 
448  LOADCHROMA(3);
449  PUTRGB15(dst_2, py_2, 3, 6 + 8);
450  PUTRGB15(dst_1, py_1, 3, 6);
452 
453 // r, g, b, dst_1, dst_2
454 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
455  const uint8_t *d16 = dither_4x4_16[y & 3];
456 
457 #define PUTRGB12(dst, src, i, o) \
458  Y = src[2 * i]; \
459  dst[2 * i] = r[Y + d16[0 + o]] + \
460  g[Y + d16[0 + o]] + \
461  b[Y + d16[0 + o]]; \
462  Y = src[2 * i + 1]; \
463  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
464  g[Y + d16[1 + o]] + \
465  b[Y + d16[1 + o]];
466 
467  LOADCHROMA(0);
468  PUTRGB12(dst_1, py_1, 0, 0);
469  PUTRGB12(dst_2, py_2, 0, 0 + 8);
470 
471  LOADCHROMA(1);
472  PUTRGB12(dst_2, py_2, 1, 2 + 8);
473  PUTRGB12(dst_1, py_1, 1, 2);
474 
475  LOADCHROMA(2);
476  PUTRGB12(dst_1, py_1, 2, 4);
477  PUTRGB12(dst_2, py_2, 2, 4 + 8);
478 
479  LOADCHROMA(3);
480  PUTRGB12(dst_2, py_2, 3, 6 + 8);
481  PUTRGB12(dst_1, py_1, 3, 6);
483 
484 // r, g, b, dst_1, dst_2
485 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
486  const uint8_t *d32 = dither_8x8_32[y & 7];
487  const uint8_t *d64 = dither_8x8_73[y & 7];
488 
489 #define PUTRGB8(dst, src, i, o) \
490  Y = src[2 * i]; \
491  dst[2 * i] = r[Y + d32[0 + o]] + \
492  g[Y + d32[0 + o]] + \
493  b[Y + d64[0 + o]]; \
494  Y = src[2 * i + 1]; \
495  dst[2 * i + 1] = r[Y + d32[1 + o]] + \
496  g[Y + d32[1 + o]] + \
497  b[Y + d64[1 + o]];
498 
499  LOADCHROMA(0);
500  PUTRGB8(dst_1, py_1, 0, 0);
501  PUTRGB8(dst_2, py_2, 0, 0 + 8);
502 
503  LOADCHROMA(1);
504  PUTRGB8(dst_2, py_2, 1, 2 + 8);
505  PUTRGB8(dst_1, py_1, 1, 2);
506 
507  LOADCHROMA(2);
508  PUTRGB8(dst_1, py_1, 2, 4);
509  PUTRGB8(dst_2, py_2, 2, 4 + 8);
510 
511  LOADCHROMA(3);
512  PUTRGB8(dst_2, py_2, 3, 6 + 8);
513  PUTRGB8(dst_1, py_1, 3, 6);
515 
516 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
517  const uint8_t * d64 = dither_8x8_73[y & 7];
518  const uint8_t *d128 = dither_8x8_220[y & 7];
519  int acc;
520 
521 #define PUTRGB4D(dst, src, i, o) \
522  Y = src[2 * i]; \
523  acc = r[Y + d128[0 + o]] + \
524  g[Y + d64[0 + o]] + \
525  b[Y + d128[0 + o]]; \
526  Y = src[2 * i + 1]; \
527  acc |= (r[Y + d128[1 + o]] + \
528  g[Y + d64[1 + o]] + \
529  b[Y + d128[1 + o]]) << 4; \
530  dst[i] = acc;
531 
532  LOADCHROMA(0);
533  PUTRGB4D(dst_1, py_1, 0, 0);
534  PUTRGB4D(dst_2, py_2, 0, 0 + 8);
535 
536  LOADCHROMA(1);
537  PUTRGB4D(dst_2, py_2, 1, 2 + 8);
538  PUTRGB4D(dst_1, py_1, 1, 2);
539 
540  LOADCHROMA(2);
541  PUTRGB4D(dst_1, py_1, 2, 4);
542  PUTRGB4D(dst_2, py_2, 2, 4 + 8);
543 
544  LOADCHROMA(3);
545  PUTRGB4D(dst_2, py_2, 3, 6 + 8);
546  PUTRGB4D(dst_1, py_1, 3, 6);
548 
549 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
550  const uint8_t *d64 = dither_8x8_73[y & 7];
551  const uint8_t *d128 = dither_8x8_220[y & 7];
552 
553 #define PUTRGB4DB(dst, src, i, o) \
554  Y = src[2 * i]; \
555  dst[2 * i] = r[Y + d128[0 + o]] + \
556  g[Y + d64[0 + o]] + \
557  b[Y + d128[0 + o]]; \
558  Y = src[2 * i + 1]; \
559  dst[2 * i + 1] = r[Y + d128[1 + o]] + \
560  g[Y + d64[1 + o]] + \
561  b[Y + d128[1 + o]];
562 
563  LOADCHROMA(0);
564  PUTRGB4DB(dst_1, py_1, 0, 0);
565  PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
566 
567  LOADCHROMA(1);
568  PUTRGB4DB(dst_2, py_2, 1, 2 + 8);
569  PUTRGB4DB(dst_1, py_1, 1, 2);
570 
571  LOADCHROMA(2);
572  PUTRGB4DB(dst_1, py_1, 2, 4);
573  PUTRGB4DB(dst_2, py_2, 2, 4 + 8);
574 
575  LOADCHROMA(3);
576  PUTRGB4DB(dst_2, py_2, 3, 6 + 8);
577  PUTRGB4DB(dst_1, py_1, 3, 6);
579 
580 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
581  const uint8_t *d128 = dither_8x8_220[y & 7];
582  char out_1 = 0, out_2 = 0;
583  g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
584 
585 #define PUTRGB1(out, src, i, o) \
586  Y = src[2 * i]; \
587  out += out + g[Y + d128[0 + o]]; \
588  Y = src[2 * i + 1]; \
589  out += out + g[Y + d128[1 + o]];
590 
591  PUTRGB1(out_1, py_1, 0, 0);
592  PUTRGB1(out_2, py_2, 0, 0 + 8);
593 
594  PUTRGB1(out_2, py_2, 1, 2 + 8);
595  PUTRGB1(out_1, py_1, 1, 2);
596 
597  PUTRGB1(out_1, py_1, 2, 4);
598  PUTRGB1(out_2, py_2, 2, 4 + 8);
599 
600  PUTRGB1(out_2, py_2, 3, 6 + 8);
601  PUTRGB1(out_1, py_1, 3, 6);
602 
603  dst_1[0] = out_1;
604  dst_2[0] = out_2;
606 
608 {
609  SwsFunc t = NULL;
610 
611  if (HAVE_MMX)
612  t = ff_yuv2rgb_init_mmx(c);
613  else if (HAVE_VIS)
614  t = ff_yuv2rgb_init_vis(c);
615  else if (HAVE_ALTIVEC)
617  else if (ARCH_BFIN)
619 
620  if (t)
621  return t;
622 
624  "No accelerated colorspace conversion found from %s to %s.\n",
625  av_get_pix_fmt_name(c->srcFormat), av_get_pix_fmt_name(c->dstFormat));
626 
627  switch (c->dstFormat) {
628  case AV_PIX_FMT_BGR48BE:
629  case AV_PIX_FMT_BGR48LE:
630  return yuv2rgb_c_bgr48;
631  case AV_PIX_FMT_RGB48BE:
632  case AV_PIX_FMT_RGB48LE:
633  return yuv2rgb_c_48;
634  case AV_PIX_FMT_ARGB:
635  case AV_PIX_FMT_ABGR:
636  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat))
637  return yuva2argb_c;
638  case AV_PIX_FMT_RGBA:
639  case AV_PIX_FMT_BGRA:
640  return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32;
641  case AV_PIX_FMT_RGB24:
642  return yuv2rgb_c_24_rgb;
643  case AV_PIX_FMT_BGR24:
644  return yuv2rgb_c_24_bgr;
645  case AV_PIX_FMT_RGB565:
646  case AV_PIX_FMT_BGR565:
647  return yuv2rgb_c_16_ordered_dither;
648  case AV_PIX_FMT_RGB555:
649  case AV_PIX_FMT_BGR555:
650  return yuv2rgb_c_15_ordered_dither;
651  case AV_PIX_FMT_RGB444:
652  case AV_PIX_FMT_BGR444:
653  return yuv2rgb_c_12_ordered_dither;
654  case AV_PIX_FMT_RGB8:
655  case AV_PIX_FMT_BGR8:
656  return yuv2rgb_c_8_ordered_dither;
657  case AV_PIX_FMT_RGB4:
658  case AV_PIX_FMT_BGR4:
659  return yuv2rgb_c_4_ordered_dither;
662  return yuv2rgb_c_4b_ordered_dither;
664  return yuv2rgb_c_1_ordered_dither;
665  }
666  return NULL;
667 }
668 
669 static void fill_table(uint8_t* table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize,
670  const int64_t inc, void *y_tab)
671 {
672  int i;
673  uint8_t *y_table = y_tab;
674 
675  y_table -= elemsize * (inc >> 9);
676 
677  for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
678  int64_t cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
679  table[i] = y_table + elemsize * (cb >> 16);
680  }
681 }
682 
683 static void fill_gv_table(int table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc)
684 {
685  int i;
686  int off = -(inc >> 9);
687 
688  for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
689  int64_t cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
690  table[i] = elemsize * (off + (cb >> 16));
691  }
692 }
693 
694 static uint16_t roundToInt16(int64_t f)
695 {
696  int r = (f + (1 << 15)) >> 16;
697 
698  if (r < -0x7FFF)
699  return 0x8000;
700  else if (r > 0x7FFF)
701  return 0x7FFF;
702  else
703  return r;
704 }
705 
706 av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
707  int fullRange, int brightness,
708  int contrast, int saturation)
709 {
710  const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
712  c->dstFormat == AV_PIX_FMT_BGR24 ||
719  c->dstFormat == AV_PIX_FMT_RGB8 ||
720  c->dstFormat == AV_PIX_FMT_RGB4 ||
723  const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
724  c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
725  c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
726  c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
727  c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
728  c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
729  const int bpp = c->dstFormatBpp;
730  uint8_t *y_table;
731  uint16_t *y_table16;
732  uint32_t *y_table32;
733  int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha;
734  const int yoffs = fullRange ? 384 : 326;
735 
736  int64_t crv = inv_table[0];
737  int64_t cbu = inv_table[1];
738  int64_t cgu = -inv_table[2];
739  int64_t cgv = -inv_table[3];
740  int64_t cy = 1 << 16;
741  int64_t oy = 0;
742  int64_t yb = 0;
743 
744  if (!fullRange) {
745  cy = (cy * 255) / 219;
746  oy = 16 << 16;
747  } else {
748  crv = (crv * 224) / 255;
749  cbu = (cbu * 224) / 255;
750  cgu = (cgu * 224) / 255;
751  cgv = (cgv * 224) / 255;
752  }
753 
754  cy = (cy * contrast) >> 16;
755  crv = (crv * contrast * saturation) >> 32;
756  cbu = (cbu * contrast * saturation) >> 32;
757  cgu = (cgu * contrast * saturation) >> 32;
758  cgv = (cgv * contrast * saturation) >> 32;
759  oy -= 256 * brightness;
760 
761  c->uOffset = 0x0400040004000400LL;
762  c->vOffset = 0x0400040004000400LL;
763  c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
764  c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
765  c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
766  c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
767  c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
768  c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
769 
770  c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
771  c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
772  c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
773  c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
774  c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
775  c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
776 
777  //scale coefficients by cy
778  crv = ((crv << 16) + 0x8000) / cy;
779  cbu = ((cbu << 16) + 0x8000) / cy;
780  cgu = ((cgu << 16) + 0x8000) / cy;
781  cgv = ((cgv << 16) + 0x8000) / cy;
782 
783  av_free(c->yuvTable);
784 
785  switch (bpp) {
786  case 1:
787  c->yuvTable = av_malloc(1024);
788  y_table = c->yuvTable;
789  yb = -(384 << 16) - oy;
790  for (i = 0; i < 1024 - 110; i++) {
791  y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
792  yb += cy;
793  }
794  fill_table(c->table_gU, 1, cgu, y_table + yoffs);
795  fill_gv_table(c->table_gV, 1, cgv);
796  break;
797  case 4:
798  case 4 | 128:
799  rbase = isRgb ? 3 : 0;
800  gbase = 1;
801  bbase = isRgb ? 0 : 3;
802  c->yuvTable = av_malloc(1024 * 3);
803  y_table = c->yuvTable;
804  yb = -(384 << 16) - oy;
805  for (i = 0; i < 1024 - 110; i++) {
806  int yval = av_clip_uint8((yb + 0x8000) >> 16);
807  y_table[i + 110] = (yval >> 7) << rbase;
808  y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
809  y_table[i + 110 + 2048] = (yval >> 7) << bbase;
810  yb += cy;
811  }
812  fill_table(c->table_rV, 1, crv, y_table + yoffs);
813  fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
814  fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
815  fill_gv_table(c->table_gV, 1, cgv);
816  break;
817  case 8:
818  rbase = isRgb ? 5 : 0;
819  gbase = isRgb ? 2 : 3;
820  bbase = isRgb ? 0 : 6;
821  c->yuvTable = av_malloc(1024 * 3);
822  y_table = c->yuvTable;
823  yb = -(384 << 16) - oy;
824  for (i = 0; i < 1024 - 38; i++) {
825  int yval = av_clip_uint8((yb + 0x8000) >> 16);
826  y_table[i + 16] = ((yval + 18) / 36) << rbase;
827  y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
828  y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
829  yb += cy;
830  }
831  fill_table(c->table_rV, 1, crv, y_table + yoffs);
832  fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
833  fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
834  fill_gv_table(c->table_gV, 1, cgv);
835  break;
836  case 12:
837  rbase = isRgb ? 8 : 0;
838  gbase = 4;
839  bbase = isRgb ? 0 : 8;
840  c->yuvTable = av_malloc(1024 * 3 * 2);
841  y_table16 = c->yuvTable;
842  yb = -(384 << 16) - oy;
843  for (i = 0; i < 1024; i++) {
844  uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
845  y_table16[i] = (yval >> 4) << rbase;
846  y_table16[i + 1024] = (yval >> 4) << gbase;
847  y_table16[i + 2048] = (yval >> 4) << bbase;
848  yb += cy;
849  }
850  if (isNotNe)
851  for (i = 0; i < 1024 * 3; i++)
852  y_table16[i] = av_bswap16(y_table16[i]);
853  fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
854  fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
855  fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
856  fill_gv_table(c->table_gV, 2, cgv);
857  break;
858  case 15:
859  case 16:
860  rbase = isRgb ? bpp - 5 : 0;
861  gbase = 5;
862  bbase = isRgb ? 0 : (bpp - 5);
863  c->yuvTable = av_malloc(1024 * 3 * 2);
864  y_table16 = c->yuvTable;
865  yb = -(384 << 16) - oy;
866  for (i = 0; i < 1024; i++) {
867  uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
868  y_table16[i] = (yval >> 3) << rbase;
869  y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
870  y_table16[i + 2048] = (yval >> 3) << bbase;
871  yb += cy;
872  }
873  if (isNotNe)
874  for (i = 0; i < 1024 * 3; i++)
875  y_table16[i] = av_bswap16(y_table16[i]);
876  fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
877  fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
878  fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
879  fill_gv_table(c->table_gV, 2, cgv);
880  break;
881  case 24:
882  case 48:
883  c->yuvTable = av_malloc(1024);
884  y_table = c->yuvTable;
885  yb = -(384 << 16) - oy;
886  for (i = 0; i < 1024; i++) {
887  y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
888  yb += cy;
889  }
890  fill_table(c->table_rV, 1, crv, y_table + yoffs);
891  fill_table(c->table_gU, 1, cgu, y_table + yoffs);
892  fill_table(c->table_bU, 1, cbu, y_table + yoffs);
893  fill_gv_table(c->table_gV, 1, cgv);
894  break;
895  case 32:
896  base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
897  c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
898  rbase = base + (isRgb ? 16 : 0);
899  gbase = base + 8;
900  bbase = base + (isRgb ? 0 : 16);
901  needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
902  if (!needAlpha)
903  abase = (base + 24) & 31;
904  c->yuvTable = av_malloc(1024 * 3 * 4);
905  y_table32 = c->yuvTable;
906  yb = -(384 << 16) - oy;
907  for (i = 0; i < 1024; i++) {
908  unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
909  y_table32[i] = (yval << rbase) +
910  (needAlpha ? 0 : (255u << abase));
911  y_table32[i + 1024] = yval << gbase;
912  y_table32[i + 2048] = yval << bbase;
913  yb += cy;
914  }
915  fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
916  fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
917  fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
918  fill_gv_table(c->table_gV, 4, cgv);
919  break;
920  default:
921  c->yuvTable = NULL;
922  if(!isPlanar(c->dstFormat) || bpp <= 24)
923  av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
924  return -1;
925  }
926  return 0;
927 }
dst_1[0]
Definition: yuv2rgb.c:603
char out_2
Definition: yuv2rgb.c:582
const int32_t ff_yuv2rgb_coeffs[8][4]
Definition: yuv2rgb.c:45
#define YUVRGB_TABLE_HEADROOM
pa_1
Definition: yuv2rgb.c:279
const uint8_t dither_4x4_16[5][8]
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:88
av_cold SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
Definition: yuv2rgb_vis.c:188
const uint8_t * e16
Definition: yuv2rgb.c:394
#define ARCH_BFIN
Definition: config.h:20
int acc
Definition: yuv2rgb.c:519
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
Definition: pixfmt.h:117
#define HAVE_ALTIVEC
Definition: config.h:56
uint8_t * table_bU[256+2 *YUVRGB_TABLE_HEADROOM]
Sinusoidal phase f
#define av_bswap16
Definition: sh4/bswap.h:31
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define PUTRGB15(dst, src, i, o)
Definition: yuv2rgb.c:427
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 ...
Definition: pixfmt.h:138
#define PUTBGR24(dst, src, i)
Definition: yuv2rgb.c:86
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:270
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:91
static void fill_table(uint8_t *table[256+2 *YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc, void *y_tab)
Definition: yuv2rgb.c:669
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:115
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
Definition: pixfmt.h:89
#define PUTRGB(dst, src, i)
Definition: yuv2rgb.c:70
uint8_t
#define av_cold
Definition: attributes.h:78
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:112
static void fill_gv_table(int table[256+2 *YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc)
Definition: yuv2rgb.c:683
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
Definition: pixfmt.h:137
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:114
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:98
#define PUTRGB16(dst, src, i, o)
Definition: yuv2rgb.c:397
av_cold SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
external API header
enum AVPixelFormat dstFormat
Destination pixel format.
uint8_t * table_gU[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGBA(dst, ysrc, asrc, i, s)
Definition: yuv2rgb.c:96
#define isALPHA(x)
Definition: swscale-test.c:47
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:262
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
Definition: mem.c:183
#define AV_PIX_FMT_NE(be, le)
Definition: pixfmt.h:256
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
Definition: yuv2rgb.c:56
#define PUTBGR48(dst, src, i)
Definition: yuv2rgb.c:112
const uint8_t * d64
Definition: yuv2rgb.c:487
const uint8_t dither_8x8_73[9][8]
static const struct endianess table[]
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:99
const uint8_t dither_8x8_32[9][8]
const char * r
Definition: vf_curves.c:94
g
Definition: yuv2rgb.c:583
#define ENDYUV2RGBFUNC()
Definition: yuv2rgb.c:163
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:96
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:143
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:97
#define YUV2RGBFUNC(func_name, dst_type, alpha)
Definition: yuv2rgb.c:122
static uint16_t roundToInt16(int64_t f)
Definition: yuv2rgb.c:694
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:92
t
Definition: genspecsines3.m:6
int32_t
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
Definition: x86/yuv2rgb.c:72
int table_gV[256+2 *YUVRGB_TABLE_HEADROOM]
float u
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
uint8_t * table_rV[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGB4D(dst, src, i, o)
Definition: yuv2rgb.c:521
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:142
av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
Definition: yuv2rgb.c:706
#define HAVE_VIS
Definition: config.h:58
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
const uint8_t * d16
Definition: yuv2rgb.c:393
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:273
const uint8_t * f16
Definition: yuv2rgb.c:395
NULL
Definition: eval.c:55
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:87
SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
Definition: yuv2rgb_bfin.c:171
#define CLOSEYUV2RGBFUNC(dst_delta)
Definition: yuv2rgb.c:169
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
Definition: yuv2rgb.c:607
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
FIXME Range Coding of cb
Definition: snow.txt:367
#define PUTRGB12(dst, src, i, o)
Definition: yuv2rgb.c:457
#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
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:73
synthesis window for stochastic i
byte swapping routines
#define SWS_CS_DEFAULT
Definition: swscale.h:109
#define ENDYUV2RGBLINE(dst_delta, ss)
Definition: yuv2rgb.c:152
pa_2
Definition: yuv2rgb.c:280
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:272
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
Definition: pixfmt.h:116
#define PUTRGB48(dst, src, i)
Definition: yuv2rgb.c:102
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:78
#define CONFIG_SWSCALE_ALPHA
Definition: config.h:394
const uint8_t dither_2x2_4[3][8]
#define PUTRGB4DB(dst, src, i, o)
Definition: yuv2rgb.c:553
static double c[64]
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:111
#define PUTRGB8(dst, src, i, o)
Definition: yuv2rgb.c:489
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:274
enum AVPixelFormat srcFormat
Source pixel format.
const uint8_t * d128
Definition: yuv2rgb.c:518
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:90
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:269
function y
Definition: D.m:1
#define PUTRGB1(out, src, i, o)
Definition: yuv2rgb.c:585
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:260
char out_1
Definition: yuv2rgb.c:582
const uint8_t dither_8x8_220[9][8]
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:268
#define LOADCHROMA(i)
Definition: yuv2rgb.c:63
const uint8_t dither_2x2_8[3][8]
#define av_uninit(x)
Definition: attributes.h:137
dst_2[0]
Definition: yuv2rgb.c:604
const uint8_t * d32
Definition: yuv2rgb.c:486
enum AVColorSpace colorspace
Definition: dirac.c:98
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 PUTRGB24(dst, src, i)
Definition: yuv2rgb.c:76
#define HAVE_MMX
Definition: config.h:48