FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 const int32_t ff_yuv2rgb_coeffs[8][4] = {
39  { 117504, 138453, 13954, 34903 }, /* no sequence_display_extension */
40  { 117504, 138453, 13954, 34903 }, /* ITU-R Rec. 709 (1990) */
41  { 104597, 132201, 25675, 53279 }, /* unspecified */
42  { 104597, 132201, 25675, 53279 }, /* reserved */
43  { 104448, 132798, 24759, 53109 }, /* FCC */
44  { 104597, 132201, 25675, 53279 }, /* ITU-R Rec. 624-4 System B, G */
45  { 104597, 132201, 25675, 53279 }, /* SMPTE 170M */
46  { 117579, 136230, 16907, 35559 } /* SMPTE 240M (1987) */
47 };
48 
50 {
51  if (colorspace > 7 || colorspace < 0)
52  colorspace = SWS_CS_DEFAULT;
54 }
55 
56 #define LOADCHROMA(i) \
57  U = pu[i]; \
58  V = pv[i]; \
59  r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \
60  g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \
61  b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM];
62 
63 #define PUTRGB(dst, src, i) \
64  Y = src[2 * i]; \
65  dst[2 * i] = r[Y] + g[Y] + b[Y]; \
66  Y = src[2 * i + 1]; \
67  dst[2 * i + 1] = r[Y] + g[Y] + b[Y];
68 
69 #define PUTRGB24(dst, src, i) \
70  Y = src[2 * i]; \
71  dst[6 * i + 0] = r[Y]; \
72  dst[6 * i + 1] = g[Y]; \
73  dst[6 * i + 2] = b[Y]; \
74  Y = src[2 * i + 1]; \
75  dst[6 * i + 3] = r[Y]; \
76  dst[6 * i + 4] = g[Y]; \
77  dst[6 * i + 5] = b[Y];
78 
79 #define PUTBGR24(dst, src, i) \
80  Y = src[2 * i]; \
81  dst[6 * i + 0] = b[Y]; \
82  dst[6 * i + 1] = g[Y]; \
83  dst[6 * i + 2] = r[Y]; \
84  Y = src[2 * i + 1]; \
85  dst[6 * i + 3] = b[Y]; \
86  dst[6 * i + 4] = g[Y]; \
87  dst[6 * i + 5] = r[Y];
88 
89 #define PUTRGBA(dst, ysrc, asrc, i, s) \
90  Y = ysrc[2 * i]; \
91  dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \
92  Y = ysrc[2 * i + 1]; \
93  dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s);
94 
95 #define PUTRGB48(dst, src, i) \
96  Y = src[ 2 * i]; \
97  dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \
98  dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
99  dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \
100  Y = src[ 2 * i + 1]; \
101  dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \
102  dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
103  dst[12 * i + 10] = dst[12 * i + 11] = b[Y];
104 
105 #define PUTBGR48(dst, src, i) \
106  Y = src[2 * i]; \
107  dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \
108  dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
109  dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \
110  Y = src[2 * i + 1]; \
111  dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \
112  dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
113  dst[12 * i + 10] = dst[12 * i + 11] = r[Y];
114 
115 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
116  static int func_name(SwsContext *c, const uint8_t *src[], \
117  int srcStride[], int srcSliceY, int srcSliceH, \
118  uint8_t *dst[], int dstStride[]) \
119  { \
120  int y; \
121  \
122  if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \
123  srcStride[1] *= 2; \
124  srcStride[2] *= 2; \
125  } \
126  for (y = 0; y < srcSliceH; y += 2) { \
127  dst_type *dst_1 = \
128  (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \
129  dst_type *dst_2 = \
130  (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \
131  dst_type av_unused *r, *g, *b; \
132  const uint8_t *py_1 = src[0] + y * srcStride[0]; \
133  const uint8_t *py_2 = py_1 + srcStride[0]; \
134  const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \
135  const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \
136  const uint8_t av_unused *pa_1, *pa_2; \
137  unsigned int h_size = c->dstW >> 3; \
138  if (alpha) { \
139  pa_1 = src[3] + y * srcStride[3]; \
140  pa_2 = pa_1 + srcStride[3]; \
141  } \
142  while (h_size--) { \
143  int av_unused U, V, Y; \
144 
145 #define ENDYUV2RGBLINE(dst_delta, ss) \
146  pu += 4 >> ss; \
147  pv += 4 >> ss; \
148  py_1 += 8 >> ss; \
149  py_2 += 8 >> ss; \
150  dst_1 += dst_delta >> ss; \
151  dst_2 += dst_delta >> ss; \
152  } \
153  if (c->dstW & (4 >> ss)) { \
154  int av_unused Y, U, V; \
155 
156 #define ENDYUV2RGBFUNC() \
157  } \
158  } \
159  return srcSliceH; \
160  }
161 
162 #define CLOSEYUV2RGBFUNC(dst_delta) \
163  ENDYUV2RGBLINE(dst_delta, 0) \
164  ENDYUV2RGBFUNC()
165 
166 YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0)
167  LOADCHROMA(0);
168  PUTRGB48(dst_1, py_1, 0);
169  PUTRGB48(dst_2, py_2, 0);
170 
171  LOADCHROMA(1);
172  PUTRGB48(dst_2, py_2, 1);
173  PUTRGB48(dst_1, py_1, 1);
174 
175  LOADCHROMA(2);
176  PUTRGB48(dst_1, py_1, 2);
177  PUTRGB48(dst_2, py_2, 2);
178 
179  LOADCHROMA(3);
180  PUTRGB48(dst_2, py_2, 3);
181  PUTRGB48(dst_1, py_1, 3);
182 ENDYUV2RGBLINE(48, 0)
183  LOADCHROMA(0);
184  PUTRGB48(dst_1, py_1, 0);
185  PUTRGB48(dst_2, py_2, 0);
186 
187  LOADCHROMA(1);
188  PUTRGB48(dst_2, py_2, 1);
189  PUTRGB48(dst_1, py_1, 1);
190 ENDYUV2RGBLINE(48, 1)
191  LOADCHROMA(0);
192  PUTRGB48(dst_1, py_1, 0);
193  PUTRGB48(dst_2, py_2, 0);
195 
196 YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0)
197  LOADCHROMA(0);
198  PUTBGR48(dst_1, py_1, 0);
199  PUTBGR48(dst_2, py_2, 0);
200 
201  LOADCHROMA(1);
202  PUTBGR48(dst_2, py_2, 1);
203  PUTBGR48(dst_1, py_1, 1);
204 
205  LOADCHROMA(2);
206  PUTBGR48(dst_1, py_1, 2);
207  PUTBGR48(dst_2, py_2, 2);
208 
209  LOADCHROMA(3);
210  PUTBGR48(dst_2, py_2, 3);
211  PUTBGR48(dst_1, py_1, 3);
212 ENDYUV2RGBLINE(48, 0)
213  LOADCHROMA(0);
214  PUTBGR48(dst_1, py_1, 0);
215  PUTBGR48(dst_2, py_2, 0);
216 
217  LOADCHROMA(1);
218  PUTBGR48(dst_2, py_2, 1);
219  PUTBGR48(dst_1, py_1, 1);
220 ENDYUV2RGBLINE(48, 1)
221  LOADCHROMA(0);
222  PUTBGR48(dst_1, py_1, 0);
223  PUTBGR48(dst_2, py_2, 0);
225 
226 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
227  LOADCHROMA(0);
228  PUTRGB(dst_1, py_1, 0);
229  PUTRGB(dst_2, py_2, 0);
230 
231  LOADCHROMA(1);
232  PUTRGB(dst_2, py_2, 1);
233  PUTRGB(dst_1, py_1, 1);
234 
235  LOADCHROMA(2);
236  PUTRGB(dst_1, py_1, 2);
237  PUTRGB(dst_2, py_2, 2);
238 
239  LOADCHROMA(3);
240  PUTRGB(dst_2, py_2, 3);
241  PUTRGB(dst_1, py_1, 3);
242 ENDYUV2RGBLINE(8, 0)
243  LOADCHROMA(0);
244  PUTRGB(dst_1, py_1, 0);
245  PUTRGB(dst_2, py_2, 0);
246 
247  LOADCHROMA(1);
248  PUTRGB(dst_2, py_2, 1);
249  PUTRGB(dst_1, py_1, 1);
250 ENDYUV2RGBLINE(8, 1)
251  LOADCHROMA(0);
252  PUTRGB(dst_1, py_1, 0);
253  PUTRGB(dst_2, py_2, 0);
255 
256 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
257  LOADCHROMA(0);
258  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
259  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
260 
261  LOADCHROMA(1);
262  PUTRGBA(dst_2, py_2, pa_2, 1, 24);
263  PUTRGBA(dst_1, py_1, pa_1, 1, 24);
264 
265  LOADCHROMA(2);
266  PUTRGBA(dst_1, py_1, pa_1, 2, 24);
267  PUTRGBA(dst_2, py_2, pa_2, 2, 24);
268 
269  LOADCHROMA(3);
270  PUTRGBA(dst_2, py_2, pa_2, 3, 24);
271  PUTRGBA(dst_1, py_1, pa_1, 3, 24);
272  pa_1 += 8;
273  pa_2 += 8;
274 ENDYUV2RGBLINE(8, 0)
275  LOADCHROMA(0);
276  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
277  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
278 
279  LOADCHROMA(1);
280  PUTRGBA(dst_2, py_2, pa_2, 1, 24);
281  PUTRGBA(dst_1, py_1, pa_1, 1, 24);
282  pa_1 += 4;
283  pa_2 += 4;
284 ENDYUV2RGBLINE(8, 1)
285  LOADCHROMA(0);
286  PUTRGBA(dst_1, py_1, pa_1, 0, 24);
287  PUTRGBA(dst_2, py_2, pa_2, 0, 24);
289 
290 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
291  LOADCHROMA(0);
292  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
293  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
294 
295  LOADCHROMA(1);
296  PUTRGBA(dst_2, py_2, pa_2, 1, 0);
297  PUTRGBA(dst_1, py_1, pa_1, 1, 0);
298 
299  LOADCHROMA(2);
300  PUTRGBA(dst_1, py_1, pa_1, 2, 0);
301  PUTRGBA(dst_2, py_2, pa_2, 2, 0);
302 
303  LOADCHROMA(3);
304  PUTRGBA(dst_2, py_2, pa_2, 3, 0);
305  PUTRGBA(dst_1, py_1, pa_1, 3, 0);
306  pa_1 += 8;
307  pa_2 += 8;
308 ENDYUV2RGBLINE(8, 0)
309  LOADCHROMA(0);
310  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
311  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
312 
313  LOADCHROMA(1);
314  PUTRGBA(dst_2, py_2, pa_2, 1, 0);
315  PUTRGBA(dst_1, py_1, pa_1, 1, 0);
316  pa_1 += 4;
317  pa_2 += 4;
318 ENDYUV2RGBLINE(8, 1)
319  LOADCHROMA(0);
320  PUTRGBA(dst_1, py_1, pa_1, 0, 0);
321  PUTRGBA(dst_2, py_2, pa_2, 0, 0);
323 
324 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
325  LOADCHROMA(0);
326  PUTRGB24(dst_1, py_1, 0);
327  PUTRGB24(dst_2, py_2, 0);
328 
329  LOADCHROMA(1);
330  PUTRGB24(dst_2, py_2, 1);
331  PUTRGB24(dst_1, py_1, 1);
332 
333  LOADCHROMA(2);
334  PUTRGB24(dst_1, py_1, 2);
335  PUTRGB24(dst_2, py_2, 2);
336 
337  LOADCHROMA(3);
338  PUTRGB24(dst_2, py_2, 3);
339  PUTRGB24(dst_1, py_1, 3);
340 ENDYUV2RGBLINE(24, 0)
341  LOADCHROMA(0);
342  PUTRGB24(dst_1, py_1, 0);
343  PUTRGB24(dst_2, py_2, 0);
344 
345  LOADCHROMA(1);
346  PUTRGB24(dst_2, py_2, 1);
347  PUTRGB24(dst_1, py_1, 1);
348 ENDYUV2RGBLINE(24, 1)
349  LOADCHROMA(0);
350  PUTRGB24(dst_1, py_1, 0);
351  PUTRGB24(dst_2, py_2, 0);
353 
354 // only trivial mods from yuv2rgb_c_24_rgb
355 YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)
356  LOADCHROMA(0);
357  PUTBGR24(dst_1, py_1, 0);
358  PUTBGR24(dst_2, py_2, 0);
359 
360  LOADCHROMA(1);
361  PUTBGR24(dst_2, py_2, 1);
362  PUTBGR24(dst_1, py_1, 1);
363 
364  LOADCHROMA(2);
365  PUTBGR24(dst_1, py_1, 2);
366  PUTBGR24(dst_2, py_2, 2);
367 
368  LOADCHROMA(3);
369  PUTBGR24(dst_2, py_2, 3);
370  PUTBGR24(dst_1, py_1, 3);
371 ENDYUV2RGBLINE(24, 0)
372  LOADCHROMA(0);
373  PUTBGR24(dst_1, py_1, 0);
374  PUTBGR24(dst_2, py_2, 0);
375 
376  LOADCHROMA(1);
377  PUTBGR24(dst_2, py_2, 1);
378  PUTBGR24(dst_1, py_1, 1);
379 ENDYUV2RGBLINE(24, 1)
380  LOADCHROMA(0);
381  PUTBGR24(dst_1, py_1, 0);
382  PUTBGR24(dst_2, py_2, 0);
384 
385 YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
386  const uint8_t *d16 = ff_dither_2x2_8[y & 1];
387  const uint8_t *e16 = ff_dither_2x2_4[y & 1];
388  const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1];
389 
390 #define PUTRGB16(dst, src, i, o) \
391  Y = src[2 * i]; \
392  dst[2 * i] = r[Y + d16[0 + o]] + \
393  g[Y + e16[0 + o]] + \
394  b[Y + f16[0 + o]]; \
395  Y = src[2 * i + 1]; \
396  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
397  g[Y + e16[1 + o]] + \
398  b[Y + f16[1 + o]];
399  LOADCHROMA(0);
400  PUTRGB16(dst_1, py_1, 0, 0);
401  PUTRGB16(dst_2, py_2, 0, 0 + 8);
402 
403  LOADCHROMA(1);
404  PUTRGB16(dst_2, py_2, 1, 2 + 8);
405  PUTRGB16(dst_1, py_1, 1, 2);
406 
407  LOADCHROMA(2);
408  PUTRGB16(dst_1, py_1, 2, 4);
409  PUTRGB16(dst_2, py_2, 2, 4 + 8);
410 
411  LOADCHROMA(3);
412  PUTRGB16(dst_2, py_2, 3, 6 + 8);
413  PUTRGB16(dst_1, py_1, 3, 6);
415 
416 YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
417  const uint8_t *d16 = ff_dither_2x2_8[y & 1];
418  const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1];
419 
420 #define PUTRGB15(dst, src, i, o) \
421  Y = src[2 * i]; \
422  dst[2 * i] = r[Y + d16[0 + o]] + \
423  g[Y + d16[1 + o]] + \
424  b[Y + e16[0 + o]]; \
425  Y = src[2 * i + 1]; \
426  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
427  g[Y + d16[0 + o]] + \
428  b[Y + e16[1 + o]];
429  LOADCHROMA(0);
430  PUTRGB15(dst_1, py_1, 0, 0);
431  PUTRGB15(dst_2, py_2, 0, 0 + 8);
432 
433  LOADCHROMA(1);
434  PUTRGB15(dst_2, py_2, 1, 2 + 8);
435  PUTRGB15(dst_1, py_1, 1, 2);
436 
437  LOADCHROMA(2);
438  PUTRGB15(dst_1, py_1, 2, 4);
439  PUTRGB15(dst_2, py_2, 2, 4 + 8);
440 
441  LOADCHROMA(3);
442  PUTRGB15(dst_2, py_2, 3, 6 + 8);
443  PUTRGB15(dst_1, py_1, 3, 6);
445 
446 // r, g, b, dst_1, dst_2
447 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
448  const uint8_t *d16 = ff_dither_4x4_16[y & 3];
449 
450 #define PUTRGB12(dst, src, i, o) \
451  Y = src[2 * i]; \
452  dst[2 * i] = r[Y + d16[0 + o]] + \
453  g[Y + d16[0 + o]] + \
454  b[Y + d16[0 + o]]; \
455  Y = src[2 * i + 1]; \
456  dst[2 * i + 1] = r[Y + d16[1 + o]] + \
457  g[Y + d16[1 + o]] + \
458  b[Y + d16[1 + o]];
459 
460  LOADCHROMA(0);
461  PUTRGB12(dst_1, py_1, 0, 0);
462  PUTRGB12(dst_2, py_2, 0, 0 + 8);
463 
464  LOADCHROMA(1);
465  PUTRGB12(dst_2, py_2, 1, 2 + 8);
466  PUTRGB12(dst_1, py_1, 1, 2);
467 
468  LOADCHROMA(2);
469  PUTRGB12(dst_1, py_1, 2, 4);
470  PUTRGB12(dst_2, py_2, 2, 4 + 8);
471 
472  LOADCHROMA(3);
473  PUTRGB12(dst_2, py_2, 3, 6 + 8);
474  PUTRGB12(dst_1, py_1, 3, 6);
476 
477 // r, g, b, dst_1, dst_2
478 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
479  const uint8_t *d32 = ff_dither_8x8_32[y & 7];
480  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
481 
482 #define PUTRGB8(dst, src, i, o) \
483  Y = src[2 * i]; \
484  dst[2 * i] = r[Y + d32[0 + o]] + \
485  g[Y + d32[0 + o]] + \
486  b[Y + d64[0 + o]]; \
487  Y = src[2 * i + 1]; \
488  dst[2 * i + 1] = r[Y + d32[1 + o]] + \
489  g[Y + d32[1 + o]] + \
490  b[Y + d64[1 + o]];
491 
492  LOADCHROMA(0);
493  PUTRGB8(dst_1, py_1, 0, 0);
494  PUTRGB8(dst_2, py_2, 0, 0 + 8);
495 
496  LOADCHROMA(1);
497  PUTRGB8(dst_2, py_2, 1, 2 + 8);
498  PUTRGB8(dst_1, py_1, 1, 2);
499 
500  LOADCHROMA(2);
501  PUTRGB8(dst_1, py_1, 2, 4);
502  PUTRGB8(dst_2, py_2, 2, 4 + 8);
503 
504  LOADCHROMA(3);
505  PUTRGB8(dst_2, py_2, 3, 6 + 8);
506  PUTRGB8(dst_1, py_1, 3, 6);
507 
508 ENDYUV2RGBLINE(8, 0)
509  const uint8_t *d32 = ff_dither_8x8_32[y & 7];
510  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
511  LOADCHROMA(0);
512  PUTRGB8(dst_1, py_1, 0, 0);
513  PUTRGB8(dst_2, py_2, 0, 0 + 8);
514 
515  LOADCHROMA(1);
516  PUTRGB8(dst_2, py_2, 1, 2 + 8);
517  PUTRGB8(dst_1, py_1, 1, 2);
518 
519 ENDYUV2RGBLINE(8, 1)
520  const uint8_t *d32 = ff_dither_8x8_32[y & 7];
521  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
522  LOADCHROMA(0);
523  PUTRGB8(dst_1, py_1, 0, 0);
524  PUTRGB8(dst_2, py_2, 0, 0 + 8);
525 
527 
528 
529 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
530  const uint8_t * d64 = ff_dither_8x8_73[y & 7];
531  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
532  int acc;
533 
534 #define PUTRGB4D(dst, src, i, o) \
535  Y = src[2 * i]; \
536  acc = r[Y + d128[0 + o]] + \
537  g[Y + d64[0 + o]] + \
538  b[Y + d128[0 + o]]; \
539  Y = src[2 * i + 1]; \
540  acc |= (r[Y + d128[1 + o]] + \
541  g[Y + d64[1 + o]] + \
542  b[Y + d128[1 + o]]) << 4; \
543  dst[i] = acc;
544 
545  LOADCHROMA(0);
546  PUTRGB4D(dst_1, py_1, 0, 0);
547  PUTRGB4D(dst_2, py_2, 0, 0 + 8);
548 
549  LOADCHROMA(1);
550  PUTRGB4D(dst_2, py_2, 1, 2 + 8);
551  PUTRGB4D(dst_1, py_1, 1, 2);
552 
553  LOADCHROMA(2);
554  PUTRGB4D(dst_1, py_1, 2, 4);
555  PUTRGB4D(dst_2, py_2, 2, 4 + 8);
556 
557  LOADCHROMA(3);
558  PUTRGB4D(dst_2, py_2, 3, 6 + 8);
559  PUTRGB4D(dst_1, py_1, 3, 6);
560 
561 ENDYUV2RGBLINE(4, 0)
562  const uint8_t * d64 = ff_dither_8x8_73[y & 7];
563  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
564  int acc;
565  LOADCHROMA(0);
566  PUTRGB4D(dst_1, py_1, 0, 0);
567  PUTRGB4D(dst_2, py_2, 0, 0 + 8);
568 
569  LOADCHROMA(1);
570  PUTRGB4D(dst_2, py_2, 1, 2 + 8);
571  PUTRGB4D(dst_1, py_1, 1, 2);
572 
573 ENDYUV2RGBLINE(4, 1)
574  const uint8_t * d64 = ff_dither_8x8_73[y & 7];
575  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
576  int acc;
577  LOADCHROMA(0);
578  PUTRGB4D(dst_1, py_1, 0, 0);
579  PUTRGB4D(dst_2, py_2, 0, 0 + 8);
581 
582 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
583  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
584  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
585 
586 #define PUTRGB4DB(dst, src, i, o) \
587  Y = src[2 * i]; \
588  dst[2 * i] = r[Y + d128[0 + o]] + \
589  g[Y + d64[0 + o]] + \
590  b[Y + d128[0 + o]]; \
591  Y = src[2 * i + 1]; \
592  dst[2 * i + 1] = r[Y + d128[1 + o]] + \
593  g[Y + d64[1 + o]] + \
594  b[Y + d128[1 + o]];
595 
596  LOADCHROMA(0);
597  PUTRGB4DB(dst_1, py_1, 0, 0);
598  PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
599 
600  LOADCHROMA(1);
601  PUTRGB4DB(dst_2, py_2, 1, 2 + 8);
602  PUTRGB4DB(dst_1, py_1, 1, 2);
603 
604  LOADCHROMA(2);
605  PUTRGB4DB(dst_1, py_1, 2, 4);
606  PUTRGB4DB(dst_2, py_2, 2, 4 + 8);
607 
608  LOADCHROMA(3);
609  PUTRGB4DB(dst_2, py_2, 3, 6 + 8);
610  PUTRGB4DB(dst_1, py_1, 3, 6);
611 ENDYUV2RGBLINE(8, 0)
612  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
613  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
614  LOADCHROMA(0);
615  PUTRGB4DB(dst_1, py_1, 0, 0);
616  PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
617 
618  LOADCHROMA(1);
619  PUTRGB4DB(dst_2, py_2, 1, 2 + 8);
620  PUTRGB4DB(dst_1, py_1, 1, 2);
621 ENDYUV2RGBLINE(8, 1)
622  const uint8_t *d64 = ff_dither_8x8_73[y & 7];
623  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
624  LOADCHROMA(0);
625  PUTRGB4DB(dst_1, py_1, 0, 0);
626  PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
628 
629 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
630  const uint8_t *d128 = ff_dither_8x8_220[y & 7];
631  char out_1 = 0, out_2 = 0;
633 
634 #define PUTRGB1(out, src, i, o) \
635  Y = src[2 * i]; \
636  out += out + g[Y + d128[0 + o]]; \
637  Y = src[2 * i + 1]; \
638  out += out + g[Y + d128[1 + o]];
639 
640  PUTRGB1(out_1, py_1, 0, 0);
641  PUTRGB1(out_2, py_2, 0, 0 + 8);
642 
643  PUTRGB1(out_2, py_2, 1, 2 + 8);
644  PUTRGB1(out_1, py_1, 1, 2);
645 
646  PUTRGB1(out_1, py_1, 2, 4);
647  PUTRGB1(out_2, py_2, 2, 4 + 8);
648 
649  PUTRGB1(out_2, py_2, 3, 6 + 8);
650  PUTRGB1(out_1, py_1, 3, 6);
651 
652  dst_1[0] = out_1;
653  dst_2[0] = out_2;
655 
657 {
658  SwsFunc t = NULL;
659 
660  if (ARCH_PPC)
661  t = ff_yuv2rgb_init_ppc(c);
662  if (ARCH_X86)
663  t = ff_yuv2rgb_init_x86(c);
664 
665  if (t)
666  return t;
667 
669  "No accelerated colorspace conversion found from %s to %s.\n",
670  av_get_pix_fmt_name(c->srcFormat), av_get_pix_fmt_name(c->dstFormat));
671 
672  switch (c->dstFormat) {
673  case AV_PIX_FMT_BGR48BE:
674  case AV_PIX_FMT_BGR48LE:
675  return yuv2rgb_c_bgr48;
676  case AV_PIX_FMT_RGB48BE:
677  case AV_PIX_FMT_RGB48LE:
678  return yuv2rgb_c_48;
679  case AV_PIX_FMT_ARGB:
680  case AV_PIX_FMT_ABGR:
681  if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat))
682  return yuva2argb_c;
683  case AV_PIX_FMT_RGBA:
684  case AV_PIX_FMT_BGRA:
685  return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32;
686  case AV_PIX_FMT_RGB24:
687  return yuv2rgb_c_24_rgb;
688  case AV_PIX_FMT_BGR24:
689  return yuv2rgb_c_24_bgr;
690  case AV_PIX_FMT_RGB565:
691  case AV_PIX_FMT_BGR565:
692  return yuv2rgb_c_16_ordered_dither;
693  case AV_PIX_FMT_RGB555:
694  case AV_PIX_FMT_BGR555:
695  return yuv2rgb_c_15_ordered_dither;
696  case AV_PIX_FMT_RGB444:
697  case AV_PIX_FMT_BGR444:
698  return yuv2rgb_c_12_ordered_dither;
699  case AV_PIX_FMT_RGB8:
700  case AV_PIX_FMT_BGR8:
701  return yuv2rgb_c_8_ordered_dither;
702  case AV_PIX_FMT_RGB4:
703  case AV_PIX_FMT_BGR4:
704  return yuv2rgb_c_4_ordered_dither;
707  return yuv2rgb_c_4b_ordered_dither;
709  return yuv2rgb_c_1_ordered_dither;
710  }
711  return NULL;
712 }
713 
714 static void fill_table(uint8_t* table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize,
715  const int64_t inc, void *y_tab)
716 {
717  int i;
718  uint8_t *y_table = y_tab;
719 
720  y_table -= elemsize * (inc >> 9);
721 
722  for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
723  int64_t cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc;
724  table[i] = y_table + elemsize * (cb >> 16);
725  }
726 }
727 
728 static void fill_gv_table(int table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc)
729 {
730  int i;
731  int off = -(inc >> 9);
732 
733  for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
734  int64_t cb = av_clip_uint8(i-YUVRGB_TABLE_HEADROOM)*inc;
735  table[i] = elemsize * (off + (cb >> 16));
736  }
737 }
738 
739 static uint16_t roundToInt16(int64_t f)
740 {
741  int r = (f + (1 << 15)) >> 16;
742 
743  if (r < -0x7FFF)
744  return 0x8000;
745  else if (r > 0x7FFF)
746  return 0x7FFF;
747  else
748  return r;
749 }
750 
751 av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
752  int fullRange, int brightness,
753  int contrast, int saturation)
754 {
755  const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
757  c->dstFormat == AV_PIX_FMT_BGR24 ||
764  c->dstFormat == AV_PIX_FMT_RGB8 ||
765  c->dstFormat == AV_PIX_FMT_RGB4 ||
768  const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
769  c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
770  c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
771  c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
772  c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
773  c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
774  const int bpp = c->dstFormatBpp;
775  uint8_t *y_table;
776  uint16_t *y_table16;
777  uint32_t *y_table32;
778  int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha;
779  const int yoffs = fullRange ? 384 : 326;
780 
781  int64_t crv = inv_table[0];
782  int64_t cbu = inv_table[1];
783  int64_t cgu = -inv_table[2];
784  int64_t cgv = -inv_table[3];
785  int64_t cy = 1 << 16;
786  int64_t oy = 0;
787  int64_t yb = 0;
788 
789  if (!fullRange) {
790  cy = (cy * 255) / 219;
791  oy = 16 << 16;
792  } else {
793  crv = (crv * 224) / 255;
794  cbu = (cbu * 224) / 255;
795  cgu = (cgu * 224) / 255;
796  cgv = (cgv * 224) / 255;
797  }
798 
799  cy = (cy * contrast) >> 16;
800  crv = (crv * contrast * saturation) >> 32;
801  cbu = (cbu * contrast * saturation) >> 32;
802  cgu = (cgu * contrast * saturation) >> 32;
803  cgv = (cgv * contrast * saturation) >> 32;
804  oy -= 256 * brightness;
805 
806  c->uOffset = 0x0400040004000400LL;
807  c->vOffset = 0x0400040004000400LL;
808  c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
809  c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
810  c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
811  c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
812  c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
813  c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
814 
815  c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
816  c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
817  c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
818  c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
819  c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
820  c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
821 
822  //scale coefficients by cy
823  crv = ((crv << 16) + 0x8000) / FFMAX(cy, 1);
824  cbu = ((cbu << 16) + 0x8000) / FFMAX(cy, 1);
825  cgu = ((cgu << 16) + 0x8000) / FFMAX(cy, 1);
826  cgv = ((cgv << 16) + 0x8000) / FFMAX(cy, 1);
827 
828  av_freep(&c->yuvTable);
829 
830 #define ALLOC_YUV_TABLE(x) \
831  c->yuvTable = av_malloc(x); \
832  if (!c->yuvTable) \
833  return AVERROR(ENOMEM);
834  switch (bpp) {
835  case 1:
836  ALLOC_YUV_TABLE(1024);
837  y_table = c->yuvTable;
838  yb = -(384 << 16) - oy;
839  for (i = 0; i < 1024 - 110; i++) {
840  y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
841  yb += cy;
842  }
843  fill_table(c->table_gU, 1, cgu, y_table + yoffs);
844  fill_gv_table(c->table_gV, 1, cgv);
845  break;
846  case 4:
847  case 4 | 128:
848  rbase = isRgb ? 3 : 0;
849  gbase = 1;
850  bbase = isRgb ? 0 : 3;
851  ALLOC_YUV_TABLE(1024 * 3);
852  y_table = c->yuvTable;
853  yb = -(384 << 16) - oy;
854  for (i = 0; i < 1024 - 110; i++) {
855  int yval = av_clip_uint8((yb + 0x8000) >> 16);
856  y_table[i + 110] = (yval >> 7) << rbase;
857  y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
858  y_table[i + 110 + 2048] = (yval >> 7) << bbase;
859  yb += cy;
860  }
861  fill_table(c->table_rV, 1, crv, y_table + yoffs);
862  fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
863  fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
864  fill_gv_table(c->table_gV, 1, cgv);
865  break;
866  case 8:
867  rbase = isRgb ? 5 : 0;
868  gbase = isRgb ? 2 : 3;
869  bbase = isRgb ? 0 : 6;
870  ALLOC_YUV_TABLE(1024 * 3);
871  y_table = c->yuvTable;
872  yb = -(384 << 16) - oy;
873  for (i = 0; i < 1024 - 38; i++) {
874  int yval = av_clip_uint8((yb + 0x8000) >> 16);
875  y_table[i + 16] = ((yval + 18) / 36) << rbase;
876  y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
877  y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
878  yb += cy;
879  }
880  fill_table(c->table_rV, 1, crv, y_table + yoffs);
881  fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
882  fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
883  fill_gv_table(c->table_gV, 1, cgv);
884  break;
885  case 12:
886  rbase = isRgb ? 8 : 0;
887  gbase = 4;
888  bbase = isRgb ? 0 : 8;
889  ALLOC_YUV_TABLE(1024 * 3 * 2);
890  y_table16 = c->yuvTable;
891  yb = -(384 << 16) - oy;
892  for (i = 0; i < 1024; i++) {
893  uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
894  y_table16[i] = (yval >> 4) << rbase;
895  y_table16[i + 1024] = (yval >> 4) << gbase;
896  y_table16[i + 2048] = (yval >> 4) << bbase;
897  yb += cy;
898  }
899  if (isNotNe)
900  for (i = 0; i < 1024 * 3; i++)
901  y_table16[i] = av_bswap16(y_table16[i]);
902  fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
903  fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
904  fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
905  fill_gv_table(c->table_gV, 2, cgv);
906  break;
907  case 15:
908  case 16:
909  rbase = isRgb ? bpp - 5 : 0;
910  gbase = 5;
911  bbase = isRgb ? 0 : (bpp - 5);
912  ALLOC_YUV_TABLE(1024 * 3 * 2);
913  y_table16 = c->yuvTable;
914  yb = -(384 << 16) - oy;
915  for (i = 0; i < 1024; i++) {
916  uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
917  y_table16[i] = (yval >> 3) << rbase;
918  y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
919  y_table16[i + 2048] = (yval >> 3) << bbase;
920  yb += cy;
921  }
922  if (isNotNe)
923  for (i = 0; i < 1024 * 3; i++)
924  y_table16[i] = av_bswap16(y_table16[i]);
925  fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
926  fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
927  fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
928  fill_gv_table(c->table_gV, 2, cgv);
929  break;
930  case 24:
931  case 48:
932  ALLOC_YUV_TABLE(1024);
933  y_table = c->yuvTable;
934  yb = -(384 << 16) - oy;
935  for (i = 0; i < 1024; i++) {
936  y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
937  yb += cy;
938  }
939  fill_table(c->table_rV, 1, crv, y_table + yoffs);
940  fill_table(c->table_gU, 1, cgu, y_table + yoffs);
941  fill_table(c->table_bU, 1, cbu, y_table + yoffs);
942  fill_gv_table(c->table_gV, 1, cgv);
943  break;
944  case 32:
945  case 64:
946  base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
947  c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
948  rbase = base + (isRgb ? 16 : 0);
949  gbase = base + 8;
950  bbase = base + (isRgb ? 0 : 16);
951  needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
952  if (!needAlpha)
953  abase = (base + 24) & 31;
954  ALLOC_YUV_TABLE(1024 * 3 * 4);
955  y_table32 = c->yuvTable;
956  yb = -(384 << 16) - oy;
957  for (i = 0; i < 1024; i++) {
958  unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
959  y_table32[i] = (yval << rbase) +
960  (needAlpha ? 0 : (255u << abase));
961  y_table32[i + 1024] = yval << gbase;
962  y_table32[i + 2048] = yval << bbase;
963  yb += cy;
964  }
965  fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
966  fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
967  fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
968  fill_gv_table(c->table_gV, 4, cgv);
969  break;
970  default:
971  if(!isPlanar(c->dstFormat) || bpp <= 24)
972  av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
973  return -1;
974  }
975  return 0;
976 }
uint64_t vrCoeff
dst_1[0]
Definition: yuv2rgb.c:652
#define NULL
Definition: coverity.c:32
char out_2
Definition: yuv2rgb.c:631
const int32_t ff_yuv2rgb_coeffs[8][4]
Definition: yuv2rgb.c:38
#define YUVRGB_TABLE_HEADROOM
pa_1
Definition: yuv2rgb.c:272
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:65
packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:86
const uint8_t * e16
Definition: yuv2rgb.c:387
int acc
Definition: yuv2rgb.c:532
const uint8_t ff_dither_2x2_8[][8]
Definition: output.c:45
av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c)
Definition: yuv2rgb.c:72
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:117
uint8_t * table_bU[256+2 *YUVRGB_TABLE_HEADROOM]
#define av_bswap16
Definition: bswap.h:31
int dstFormatBpp
Number of bits per pixel of the destination pixel format.
#define ALLOC_YUV_TABLE(x)
#define PUTRGB15(dst, src, i, o)
Definition: yuv2rgb.c:420
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
Definition: pixfmt.h:140
#define PUTBGR24(dst, src, i)
Definition: yuv2rgb.c:79
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:353
const uint8_t ff_dither_8x8_220[][8]
Definition: output.c:84
packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in ...
Definition: pixfmt.h:89
uint64_t ubCoeff
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:714
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:87
const uint8_t ff_dither_8x8_32[][8]
Definition: output.c:59
#define PUTRGB(dst, src, i)
Definition: yuv2rgb.c:63
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:96
const uint8_t ff_dither_2x2_4[][8]
Definition: output.c:39
uint8_t
#define av_cold
Definition: attributes.h:74
const uint8_t ff_dither_4x4_16[][8]
Definition: output.c:51
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:728
packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:139
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:96
#define PUTRGB16(dst, src, i, o)
Definition: yuv2rgb.c:390
uint64_t yOffset
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:89
#define isALPHA(x)
Definition: swscale-test.c:49
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:344
#define AV_PIX_FMT_NE(be, le)
Definition: pixfmt.h:338
#define PUTBGR48(dst, src, i)
Definition: yuv2rgb.c:105
const uint8_t * d64
Definition: yuv2rgb.c:480
static const struct endianess table[]
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:97
const char * r
Definition: vf_curves.c:107
g
Definition: yuv2rgb.c:632
#define ENDYUV2RGBFUNC()
Definition: yuv2rgb.c:156
uint64_t ugCoeff
#define SWS_CS_DEFAULT
Definition: swscale.h:109
#define FFMAX(a, b)
Definition: common.h:64
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:94
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
Definition: pixfmt.h:149
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:95
#define YUV2RGBFUNC(func_name, dst_type, alpha)
Definition: yuv2rgb.c:115
static uint16_t roundToInt16(int64_t f)
Definition: yuv2rgb.c:739
float y
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
Definition: pixfmt.h:90
uint64_t vgCoeff
uint64_t uOffset
int32_t
int table_gV[256+2 *YUVRGB_TABLE_HEADROOM]
const int * sws_getCoefficients(int colorspace)
Return a pointer to yuv<->rgb coefficients for the given colorspace suitable for sws_setColorspaceDet...
Definition: yuv2rgb.c:49
float u
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:66
uint8_t * table_rV[256+2 *YUVRGB_TABLE_HEADROOM]
#define PUTRGB4D(dst, src, i, o)
Definition: yuv2rgb.c:534
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
Definition: pixfmt.h:148
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:751
const uint8_t * d16
Definition: yuv2rgb.c:386
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:357
const uint8_t * f16
Definition: yuv2rgb.c:388
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:85
#define CLOSEYUV2RGBFUNC(dst_delta)
Definition: yuv2rgb.c:162
SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
Definition: yuv2rgb.c:656
static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
#define PUTRGB12(dst, src, i, o)
Definition: yuv2rgb.c:450
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:341
const uint8_t ff_dither_8x8_73[][8]
Definition: output.c:71
int(* SwsFunc)(struct SwsContext *context, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
byte swapping routines
const uint8_t * d32
Definition: yuv2rgb.c:479
#define ENDYUV2RGBLINE(dst_delta, ss)
Definition: yuv2rgb.c:145
pa_2
Definition: yuv2rgb.c:273
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:356
av_cold SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:116
#define PUTRGB48(dst, src, i)
Definition: yuv2rgb.c:95
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
Definition: pixfmt.h:73
#define PUTRGB4DB(dst, src, i, o)
Definition: yuv2rgb.c:586
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:482
#define AV_PIX_FMT_BGR444
Definition: pixfmt.h:358
enum AVPixelFormat srcFormat
Source pixel format.
const uint8_t * d128
Definition: yuv2rgb.c:531
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:88
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:352
#define PUTRGB1(out, src, i, o)
Definition: yuv2rgb.c:634
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:342
char out_1
Definition: yuv2rgb.c:631
uint64_t yCoeff
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:351
#define LOADCHROMA(i)
Definition: yuv2rgb.c:56
#define av_uninit(x)
Definition: attributes.h:141
#define av_freep(p)
dst_2[0]
Definition: yuv2rgb.c:653
enum AVColorSpace colorspace
Definition: dirac.c:102
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:2011
uint64_t vOffset
#define PUTRGB24(dst, src, i)
Definition: yuv2rgb.c:69