comparison libswscale/yuv2rgb.c @ 30798:91f90077acf6

Support BGR555, BGR565, RGB555 and RGB565 foreign endian output in libswscale. Patch by Alexis Ballier, alexis D ballier A gmail
author cehoyos
date Thu, 04 Mar 2010 16:57:04 +0000
parents 6cef34c73074
children 76f3878f34fd
comparison
equal deleted inserted replaced
30797:5c32244c0ae1 30798:91f90077acf6
31 #include "config.h" 31 #include "config.h"
32 #include "rgb2rgb.h" 32 #include "rgb2rgb.h"
33 #include "swscale.h" 33 #include "swscale.h"
34 #include "swscale_internal.h" 34 #include "swscale_internal.h"
35 #include "libavutil/x86_cpu.h" 35 #include "libavutil/x86_cpu.h"
36 #include "libavutil/bswap.h"
36 37
37 extern const uint8_t dither_8x8_32[8][8]; 38 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_73[8][8];
39 extern const uint8_t dither_8x8_220[8][8]; 40 extern const uint8_t dither_8x8_220[8][8];
40 41
594 int brightness, int contrast, int saturation) 595 int brightness, int contrast, int saturation)
595 { 596 {
596 const int isRgb = c->dstFormat==PIX_FMT_RGB32 597 const int isRgb = c->dstFormat==PIX_FMT_RGB32
597 || c->dstFormat==PIX_FMT_RGB32_1 598 || c->dstFormat==PIX_FMT_RGB32_1
598 || c->dstFormat==PIX_FMT_BGR24 599 || c->dstFormat==PIX_FMT_BGR24
599 || c->dstFormat==PIX_FMT_RGB565 600 || c->dstFormat==PIX_FMT_RGB565BE
600 || c->dstFormat==PIX_FMT_RGB555 601 || c->dstFormat==PIX_FMT_RGB565LE
602 || c->dstFormat==PIX_FMT_RGB555BE
603 || c->dstFormat==PIX_FMT_RGB555LE
601 || c->dstFormat==PIX_FMT_RGB8 604 || c->dstFormat==PIX_FMT_RGB8
602 || c->dstFormat==PIX_FMT_RGB4 605 || c->dstFormat==PIX_FMT_RGB4
603 || c->dstFormat==PIX_FMT_RGB4_BYTE 606 || c->dstFormat==PIX_FMT_RGB4_BYTE
604 || c->dstFormat==PIX_FMT_MONOBLACK; 607 || c->dstFormat==PIX_FMT_MONOBLACK;
608 const int isNotNe = c->dstFormat==PIX_FMT_NE(RGB565LE,RGB565BE)
609 || c->dstFormat==PIX_FMT_NE(RGB555LE,RGB555BE)
610 || c->dstFormat==PIX_FMT_NE(BGR565LE,BGR565BE)
611 || c->dstFormat==PIX_FMT_NE(BGR555LE,BGR555BE);
605 const int bpp = c->dstFormatBpp; 612 const int bpp = c->dstFormatBpp;
606 uint8_t *y_table; 613 uint8_t *y_table;
607 uint16_t *y_table16; 614 uint16_t *y_table16;
608 uint32_t *y_table32; 615 uint32_t *y_table32;
609 int i, base, rbase, gbase, bbase, abase, needAlpha; 616 int i, base, rbase, gbase, bbase, abase, needAlpha;
707 y_table16[i ] = (yval >> 3) << rbase; 714 y_table16[i ] = (yval >> 3) << rbase;
708 y_table16[i+1024] = (yval >> (18 - bpp)) << gbase; 715 y_table16[i+1024] = (yval >> (18 - bpp)) << gbase;
709 y_table16[i+2048] = (yval >> 3) << bbase; 716 y_table16[i+2048] = (yval >> 3) << bbase;
710 yb += cy; 717 yb += cy;
711 } 718 }
719 if(isNotNe)
720 for (i = 0; i < 1024*3; i++)
721 y_table16[i] = bswap_16(y_table16[i]);
712 fill_table(c->table_rV, 2, crv, y_table16 + yoffs); 722 fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
713 fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); 723 fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
714 fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); 724 fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
715 fill_gv_table(c->table_gV, 2, cgv); 725 fill_gv_table(c->table_gV, 2, cgv);
716 break; 726 break;