2 * software YUV to RGB converter
4 * Copyright (C) 2009 Konstantin Shishkov
6 * 1,4,8bpp support and context / deglobalize stuff
7 * by Michael Niedermayer (michaelni@gmx.at)
9 * This file is part of FFmpeg.
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.
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.
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
34 #include "swscale_internal.h"
35 #include "libavutil/x86_cpu.h"
37 extern const uint8_t dither_8x8_32[8][8];
38 extern const uint8_t dither_8x8_73[8][8];
39 extern const uint8_t dither_8x8_220[8][8];
41 const int32_t ff_yuv2rgb_coeffs[8][4] = {
42 {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
43 {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
44 {104597, 132201, 25675, 53279}, /* unspecified */
45 {104597, 132201, 25675, 53279}, /* reserved */
46 {104448, 132798, 24759, 53109}, /* FCC */
47 {104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
48 {104597, 132201, 25675, 53279}, /* SMPTE 170M */
49 {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
52 #define LOADCHROMA(i) \
55 r = (void *)c->table_rV[V]; \
56 g = (void *)(c->table_gU[U] + c->table_gV[V]); \
57 b = (void *)c->table_bU[U];
59 #define PUTRGB(dst,src,i,o) \
61 dst[2*i ] = r[Y] + g[Y] + b[Y]; \
63 dst[2*i+1] = r[Y] + g[Y] + b[Y];
65 #define PUTRGB24(dst,src,i) \
67 dst[6*i+0] = r[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = b[Y]; \
69 dst[6*i+3] = r[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = b[Y];
71 #define PUTBGR24(dst,src,i) \
73 dst[6*i+0] = b[Y]; dst[6*i+1] = g[Y]; dst[6*i+2] = r[Y]; \
75 dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y];
77 #define PUTRGBA(dst,ysrc,asrc,i,o,s) \
79 dst[2*i ] = r[Y] + g[Y] + b[Y] + (asrc[2*i ]<<s); \
81 dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s);
83 #define YUV2RGBFUNC(func_name, dst_type, alpha) \
84 static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, \
85 int srcSliceH, uint8_t* dst[], int dstStride[]){\
88 if (!alpha && c->srcFormat == PIX_FMT_YUV422P) {\
92 for (y=0; y<srcSliceH; y+=2) {\
93 dst_type *dst_1 = (dst_type*)(dst[0] + (y+srcSliceY )*dstStride[0]);\
94 dst_type *dst_2 = (dst_type*)(dst[0] + (y+srcSliceY+1)*dstStride[0]);\
95 dst_type av_unused *r, *b;\
97 uint8_t *py_1 = src[0] + y*srcStride[0];\
98 uint8_t *py_2 = py_1 + srcStride[0];\
99 uint8_t *pu = src[1] + (y>>1)*srcStride[1];\
100 uint8_t *pv = src[2] + (y>>1)*srcStride[2];\
101 uint8_t av_unused *pa_1, *pa_2;\
102 unsigned int h_size = c->dstW>>3;\
104 pa_1 = src[3] + y*srcStride[3];\
105 pa_2 = pa_1 + srcStride[3];\
111 #define ENDYUV2RGBLINE(dst_delta)\
120 int av_unused Y, U, V;\
122 #define ENDYUV2RGBFUNC()\
128 #define CLOSEYUV2RGBFUNC(dst_delta)\
129 ENDYUV2RGBLINE(dst_delta)\
132 YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
134 PUTRGB(dst_1,py_1,0,0);
135 PUTRGB(dst_2,py_2,0,1);
138 PUTRGB(dst_2,py_2,1,1);
139 PUTRGB(dst_1,py_1,1,0);
141 PUTRGB(dst_2,py_2,1,1);
142 PUTRGB(dst_1,py_1,1,0);
145 PUTRGB(dst_1,py_1,2,0);
146 PUTRGB(dst_2,py_2,2,1);
149 PUTRGB(dst_2,py_2,3,1);
150 PUTRGB(dst_1,py_1,3,0);
153 PUTRGB(dst_1,py_1,0,0);
154 PUTRGB(dst_2,py_2,0,1);
157 PUTRGB(dst_2,py_2,1,1);
158 PUTRGB(dst_1,py_1,1,0);
161 YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
163 PUTRGBA(dst_1,py_1,pa_1,0,0,24);
164 PUTRGBA(dst_2,py_2,pa_2,0,1,24);
167 PUTRGBA(dst_2,py_2,pa_1,1,1,24);
168 PUTRGBA(dst_1,py_1,pa_2,1,0,24);
170 PUTRGBA(dst_2,py_2,pa_1,1,1,24);
171 PUTRGBA(dst_1,py_1,pa_2,1,0,24);
174 PUTRGBA(dst_1,py_1,pa_1,2,0,24);
175 PUTRGBA(dst_2,py_2,pa_2,2,1,24);
178 PUTRGBA(dst_2,py_2,pa_1,3,1,24);
179 PUTRGBA(dst_1,py_1,pa_2,3,0,24);
184 PUTRGBA(dst_1,py_1,pa_1,0,0,24);
185 PUTRGBA(dst_2,py_2,pa_2,0,1,24);
188 PUTRGBA(dst_2,py_2,pa_1,1,1,24);
189 PUTRGBA(dst_1,py_1,pa_2,1,0,24);
192 YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
194 PUTRGBA(dst_1,py_1,pa_1,0,0,0);
195 PUTRGBA(dst_2,py_2,pa_2,0,1,0);
198 PUTRGBA(dst_2,py_2,pa_2,1,1,0);
199 PUTRGBA(dst_1,py_1,pa_1,1,0,0);
201 PUTRGBA(dst_2,py_2,pa_2,1,1,0);
202 PUTRGBA(dst_1,py_1,pa_1,1,0,0);
205 PUTRGBA(dst_1,py_1,pa_1,2,0,0);
206 PUTRGBA(dst_2,py_2,pa_2,2,1,0);
209 PUTRGBA(dst_2,py_2,pa_2,3,1,0);
210 PUTRGBA(dst_1,py_1,pa_1,3,0,0);
215 PUTRGBA(dst_1,py_1,pa_1,0,0,0);
216 PUTRGBA(dst_2,py_2,pa_2,0,1,0);
219 PUTRGBA(dst_2,py_2,pa_2,1,1,0);
220 PUTRGBA(dst_1,py_1,pa_1,1,0,0);
223 YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
225 PUTRGB24(dst_1,py_1,0);
226 PUTRGB24(dst_2,py_2,0);
229 PUTRGB24(dst_2,py_2,1);
230 PUTRGB24(dst_1,py_1,1);
233 PUTRGB24(dst_1,py_1,2);
234 PUTRGB24(dst_2,py_2,2);
237 PUTRGB24(dst_2,py_2,3);
238 PUTRGB24(dst_1,py_1,3);
241 PUTRGB24(dst_1,py_1,0);
242 PUTRGB24(dst_2,py_2,0);
245 PUTRGB24(dst_2,py_2,1);
246 PUTRGB24(dst_1,py_1,1);
249 // only trivial mods from yuv2rgb_c_24_rgb
250 YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)
252 PUTBGR24(dst_1,py_1,0);
253 PUTBGR24(dst_2,py_2,0);
256 PUTBGR24(dst_2,py_2,1);
257 PUTBGR24(dst_1,py_1,1);
260 PUTBGR24(dst_1,py_1,2);
261 PUTBGR24(dst_2,py_2,2);
264 PUTBGR24(dst_2,py_2,3);
265 PUTBGR24(dst_1,py_1,3);
268 PUTBGR24(dst_1,py_1,0);
269 PUTBGR24(dst_2,py_2,0);
272 PUTBGR24(dst_2,py_2,1);
273 PUTBGR24(dst_1,py_1,1);
276 // This is exactly the same code as yuv2rgb_c_32 except for the types of
277 // r, g, b, dst_1, dst_2
278 YUV2RGBFUNC(yuv2rgb_c_16, uint16_t, 0)
280 PUTRGB(dst_1,py_1,0,0);
281 PUTRGB(dst_2,py_2,0,1);
284 PUTRGB(dst_2,py_2,1,1);
285 PUTRGB(dst_1,py_1,1,0);
288 PUTRGB(dst_1,py_1,2,0);
289 PUTRGB(dst_2,py_2,2,1);
292 PUTRGB(dst_2,py_2,3,1);
293 PUTRGB(dst_1,py_1,3,0);
296 // This is exactly the same code as yuv2rgb_c_32 except for the types of
297 // r, g, b, dst_1, dst_2
298 YUV2RGBFUNC(yuv2rgb_c_8, uint8_t, 0)
300 PUTRGB(dst_1,py_1,0,0);
301 PUTRGB(dst_2,py_2,0,1);
304 PUTRGB(dst_2,py_2,1,1);
305 PUTRGB(dst_1,py_1,1,0);
308 PUTRGB(dst_1,py_1,2,0);
309 PUTRGB(dst_2,py_2,2,1);
312 PUTRGB(dst_2,py_2,3,1);
313 PUTRGB(dst_1,py_1,3,0);
316 // r, g, b, dst_1, dst_2
317 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
318 const uint8_t *d32 = dither_8x8_32[y&7];
319 const uint8_t *d64 = dither_8x8_73[y&7];
320 #define PUTRGB8(dst,src,i,o) \
322 dst[2*i] = r[Y+d32[0+o]] + g[Y+d32[0+o]] + b[Y+d64[0+o]]; \
324 dst[2*i+1] = r[Y+d32[1+o]] + g[Y+d32[1+o]] + b[Y+d64[1+o]];
327 PUTRGB8(dst_1,py_1,0,0);
328 PUTRGB8(dst_2,py_2,0,0+8);
331 PUTRGB8(dst_2,py_2,1,2+8);
332 PUTRGB8(dst_1,py_1,1,2);
335 PUTRGB8(dst_1,py_1,2,4);
336 PUTRGB8(dst_2,py_2,2,4+8);
339 PUTRGB8(dst_2,py_2,3,6+8);
340 PUTRGB8(dst_1,py_1,3,6);
344 // This is exactly the same code as yuv2rgb_c_32 except for the types of
345 // r, g, b, dst_1, dst_2
346 YUV2RGBFUNC(yuv2rgb_c_4, uint8_t, 0)
348 #define PUTRGB4(dst,src,i) \
350 acc = r[Y] + g[Y] + b[Y]; \
352 acc |= (r[Y] + g[Y] + b[Y])<<4; \
356 PUTRGB4(dst_1,py_1,0);
357 PUTRGB4(dst_2,py_2,0);
360 PUTRGB4(dst_2,py_2,1);
361 PUTRGB4(dst_1,py_1,1);
364 PUTRGB4(dst_1,py_1,2);
365 PUTRGB4(dst_2,py_2,2);
368 PUTRGB4(dst_2,py_2,3);
369 PUTRGB4(dst_1,py_1,3);
372 YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
373 const uint8_t *d64 = dither_8x8_73[y&7];
374 const uint8_t *d128 = dither_8x8_220[y&7];
377 #define PUTRGB4D(dst,src,i,o) \
379 acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
381 acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4; \
385 PUTRGB4D(dst_1,py_1,0,0);
386 PUTRGB4D(dst_2,py_2,0,0+8);
389 PUTRGB4D(dst_2,py_2,1,2+8);
390 PUTRGB4D(dst_1,py_1,1,2);
393 PUTRGB4D(dst_1,py_1,2,4);
394 PUTRGB4D(dst_2,py_2,2,4+8);
397 PUTRGB4D(dst_2,py_2,3,6+8);
398 PUTRGB4D(dst_1,py_1,3,6);
401 // This is exactly the same code as yuv2rgb_c_32 except for the types of
402 // r, g, b, dst_1, dst_2
403 YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t, 0)
405 PUTRGB(dst_1,py_1,0,0);
406 PUTRGB(dst_2,py_2,0,1);
409 PUTRGB(dst_2,py_2,1,1);
410 PUTRGB(dst_1,py_1,1,0);
413 PUTRGB(dst_1,py_1,2,0);
414 PUTRGB(dst_2,py_2,2,1);
417 PUTRGB(dst_2,py_2,3,1);
418 PUTRGB(dst_1,py_1,3,0);
421 YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
422 const uint8_t *d64 = dither_8x8_73[y&7];
423 const uint8_t *d128 = dither_8x8_220[y&7];
425 #define PUTRGB4DB(dst,src,i,o) \
427 dst[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
429 dst[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
432 PUTRGB4DB(dst_1,py_1,0,0);
433 PUTRGB4DB(dst_2,py_2,0,0+8);
436 PUTRGB4DB(dst_2,py_2,1,2+8);
437 PUTRGB4DB(dst_1,py_1,1,2);
440 PUTRGB4DB(dst_1,py_1,2,4);
441 PUTRGB4DB(dst_2,py_2,2,4+8);
444 PUTRGB4DB(dst_2,py_2,3,6+8);
445 PUTRGB4DB(dst_1,py_1,3,6);
448 YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
449 const uint8_t *d128 = dither_8x8_220[y&7];
450 char out_1 = 0, out_2 = 0;
451 g= c->table_gU[128] + c->table_gV[128];
453 #define PUTRGB1(out,src,i,o) \
455 out+= out + g[Y+d128[0+o]]; \
457 out+= out + g[Y+d128[1+o]];
459 PUTRGB1(out_1,py_1,0,0);
460 PUTRGB1(out_2,py_2,0,0+8);
462 PUTRGB1(out_2,py_2,1,2+8);
463 PUTRGB1(out_1,py_1,1,2);
465 PUTRGB1(out_1,py_1,2,4);
466 PUTRGB1(out_2,py_2,2,4+8);
468 PUTRGB1(out_2,py_2,3,6+8);
469 PUTRGB1(out_1,py_1,3,6);
475 SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
478 #if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL
479 t = ff_yuv2rgb_init_mmx(c);
482 t = ff_yuv2rgb_init_vis(c);
485 t = ff_yuv2rgb_init_mlib(c);
487 #if HAVE_ALTIVEC && CONFIG_GPL
488 if (c->flags & SWS_CPU_CAPS_ALTIVEC)
489 t = ff_yuv2rgb_init_altivec(c);
493 if (c->flags & SWS_CPU_CAPS_BFIN)
494 t = ff_yuv2rgb_get_func_ptr_bfin(c);
500 av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
502 switch (c->dstFormat) {
504 case PIX_FMT_ABGR: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
506 case PIX_FMT_BGRA: return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
507 case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
508 case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
512 case PIX_FMT_BGR555: return yuv2rgb_c_16;
514 case PIX_FMT_BGR8: return yuv2rgb_c_8_ordered_dither;
516 case PIX_FMT_BGR4: return yuv2rgb_c_4_ordered_dither;
517 case PIX_FMT_RGB4_BYTE:
518 case PIX_FMT_BGR4_BYTE: return yuv2rgb_c_4b_ordered_dither;
519 case PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither;
526 static void fill_table(uint8_t* table[256], const int elemsize, const int inc, uint8_t *y_table)
531 y_table -= elemsize * (inc >> 9);
533 for (i = 0; i < 256; i++) {
534 table[i] = y_table + elemsize * (cb >> 16);
539 static void fill_gv_table(int table[256], const int elemsize, const int inc)
543 int off = -(inc >> 9);
545 for (i = 0; i < 256; i++) {
546 table[i] = elemsize * (off + (cb >> 16));
551 av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
552 int brightness, int contrast, int saturation)
554 const int isRgb = c->dstFormat==PIX_FMT_RGB32
555 || c->dstFormat==PIX_FMT_RGB32_1
556 || c->dstFormat==PIX_FMT_BGR24
557 || c->dstFormat==PIX_FMT_RGB565
558 || c->dstFormat==PIX_FMT_RGB555
559 || c->dstFormat==PIX_FMT_RGB8
560 || c->dstFormat==PIX_FMT_RGB4
561 || c->dstFormat==PIX_FMT_RGB4_BYTE
562 || c->dstFormat==PIX_FMT_MONOBLACK;
563 const int bpp = fmt_depth(c->dstFormat);
567 int i, base, rbase, gbase, bbase, abase, needAlpha;
568 const int yoffs = fullRange ? 384 : 326;
570 int64_t crv = inv_table[0];
571 int64_t cbu = inv_table[1];
572 int64_t cgu = -inv_table[2];
573 int64_t cgv = -inv_table[3];
583 crv = (crv*224) / 255;
584 cbu = (cbu*224) / 255;
585 cgu = (cgu*224) / 255;
586 cgv = (cgv*224) / 255;
589 cy = (cy *contrast ) >> 16;
590 crv = (crv*contrast * saturation) >> 32;
591 cbu = (cbu*contrast * saturation) >> 32;
592 cgu = (cgu*contrast * saturation) >> 32;
593 cgv = (cgv*contrast * saturation) >> 32;
594 oy -= 256*brightness;
596 //scale coefficients by cy
597 crv = ((crv << 16) + 0x8000) / cy;
598 cbu = ((cbu << 16) + 0x8000) / cy;
599 cgu = ((cgu << 16) + 0x8000) / cy;
600 cgv = ((cgv << 16) + 0x8000) / cy;
602 av_free(c->yuvTable);
606 c->yuvTable = av_malloc(1024);
607 y_table = c->yuvTable;
608 yb = -(384<<16) - oy;
609 for (i = 0; i < 1024-110; i++) {
610 y_table[i+110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
613 fill_table(c->table_gU, 1, cgu, y_table + yoffs);
614 fill_gv_table(c->table_gV, 1, cgv);
618 rbase = isRgb ? 3 : 0;
620 bbase = isRgb ? 0 : 3;
621 c->yuvTable = av_malloc(1024*3);
622 y_table = c->yuvTable;
623 yb = -(384<<16) - oy;
624 for (i = 0; i < 1024-110; i++) {
625 int yval = av_clip_uint8((yb + 0x8000) >> 16);
626 y_table[i+110 ] = (yval >> 7) << rbase;
627 y_table[i+ 37+1024] = ((yval + 43) / 85) << gbase;
628 y_table[i+110+2048] = (yval >> 7) << bbase;
631 fill_table(c->table_rV, 1, crv, y_table + yoffs);
632 fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
633 fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
634 fill_gv_table(c->table_gV, 1, cgv);
637 rbase = isRgb ? 5 : 0;
638 gbase = isRgb ? 2 : 3;
639 bbase = isRgb ? 0 : 6;
640 c->yuvTable = av_malloc(1024*3);
641 y_table = c->yuvTable;
642 yb = -(384<<16) - oy;
643 for (i = 0; i < 1024-38; i++) {
644 int yval = av_clip_uint8((yb + 0x8000) >> 16);
645 y_table[i+16 ] = ((yval + 18) / 36) << rbase;
646 y_table[i+16+1024] = ((yval + 18) / 36) << gbase;
647 y_table[i+37+2048] = ((yval + 43) / 85) << bbase;
650 fill_table(c->table_rV, 1, crv, y_table + yoffs);
651 fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
652 fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
653 fill_gv_table(c->table_gV, 1, cgv);
657 rbase = isRgb ? bpp - 5 : 0;
659 bbase = isRgb ? 0 : (bpp - 5);
660 c->yuvTable = av_malloc(1024*3*2);
661 y_table16 = c->yuvTable;
662 yb = -(384<<16) - oy;
663 for (i = 0; i < 1024; i++) {
664 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
665 y_table16[i ] = (yval >> 3) << rbase;
666 y_table16[i+1024] = (yval >> (18 - bpp)) << gbase;
667 y_table16[i+2048] = (yval >> 3) << bbase;
670 fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
671 fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
672 fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
673 fill_gv_table(c->table_gV, 2, cgv);
676 c->yuvTable = av_malloc(1024);
677 y_table = c->yuvTable;
678 yb = -(384<<16) - oy;
679 for (i = 0; i < 1024; i++) {
680 y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
683 fill_table(c->table_rV, 1, crv, y_table + yoffs);
684 fill_table(c->table_gU, 1, cgu, y_table + yoffs);
685 fill_table(c->table_bU, 1, cbu, y_table + yoffs);
686 fill_gv_table(c->table_gV, 1, cgv);
689 base = (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
690 rbase = base + (isRgb ? 16 : 0);
692 bbase = base + (isRgb ? 0 : 16);
693 needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
695 abase = (base + 24) & 31;
696 c->yuvTable = av_malloc(1024*3*4);
697 y_table32 = c->yuvTable;
698 yb = -(384<<16) - oy;
699 for (i = 0; i < 1024; i++) {
700 uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
701 y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255 << abase));
702 y_table32[i+1024] = yval << gbase;
703 y_table32[i+2048] = yval << bbase;
706 fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
707 fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
708 fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
709 fill_gv_table(c->table_gV, 4, cgv);
713 av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);