comparison libswscale/yuv2rgb.c @ 27490:651ebfa4b7db

Support PIX_FMT_RGB32_1 and PIX_FMT_BGR32_1. Fixes issue248.
author michael
date Thu, 04 Sep 2008 21:59:15 +0000
parents c550b2157eaa
children e69bd178104a
comparison
equal deleted inserted replaced
27489:1ef12885a1e4 27490:651ebfa4b7db
642 #endif 642 #endif
643 643
644 av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n"); 644 av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
645 645
646 switch(c->dstFormat){ 646 switch(c->dstFormat){
647 case PIX_FMT_BGR32_1:
648 case PIX_FMT_RGB32_1:
647 case PIX_FMT_BGR32: 649 case PIX_FMT_BGR32:
648 case PIX_FMT_RGB32: return yuv2rgb_c_32; 650 case PIX_FMT_RGB32: return yuv2rgb_c_32;
649 case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb; 651 case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb;
650 case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr; 652 case PIX_FMT_BGR24: return yuv2rgb_c_24_bgr;
651 case PIX_FMT_RGB565: 653 case PIX_FMT_RGB565:
674 } 676 }
675 677
676 int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) 678 int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation)
677 { 679 {
678 const int isRgb = c->dstFormat==PIX_FMT_RGB32 680 const int isRgb = c->dstFormat==PIX_FMT_RGB32
681 || c->dstFormat==PIX_FMT_RGB32_1
679 || c->dstFormat==PIX_FMT_BGR24 682 || c->dstFormat==PIX_FMT_BGR24
680 || c->dstFormat==PIX_FMT_RGB565 683 || c->dstFormat==PIX_FMT_RGB565
681 || c->dstFormat==PIX_FMT_RGB555 684 || c->dstFormat==PIX_FMT_RGB555
682 || c->dstFormat==PIX_FMT_RGB8 685 || c->dstFormat==PIX_FMT_RGB8
683 || c->dstFormat==PIX_FMT_RGB4 686 || c->dstFormat==PIX_FMT_RGB4
684 || c->dstFormat==PIX_FMT_RGB4_BYTE 687 || c->dstFormat==PIX_FMT_RGB4_BYTE
685 || c->dstFormat==PIX_FMT_MONOBLACK; 688 || c->dstFormat==PIX_FMT_MONOBLACK;
686 const int bpp = fmt_depth(c->dstFormat); 689 const int bpp = fmt_depth(c->dstFormat);
687 int i; 690 int i, base;
688 uint8_t table_Y[1024]; 691 uint8_t table_Y[1024];
689 uint32_t *table_32 = 0; 692 uint32_t *table_32 = 0;
690 uint16_t *table_16 = 0; 693 uint16_t *table_16 = 0;
691 uint8_t *table_8 = 0; 694 uint8_t *table_8 = 0;
692 uint8_t *table_332 = 0; 695 uint8_t *table_332 = 0;
731 } 734 }
732 735
733 switch (bpp) { 736 switch (bpp) {
734 case 32: 737 case 32:
735 table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); 738 table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
739 base= (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0;
736 740
737 entry_size = sizeof (uint32_t); 741 entry_size = sizeof (uint32_t);
738 table_r = table_32 + 197; 742 table_r = table_32 + 197;
739 table_b = table_32 + 197 + 685; 743 table_b = table_32 + 197 + 685;
740 table_g = table_32 + 197 + 2*682; 744 table_g = table_32 + 197 + 2*682;
741 745
742 for (i = -197; i < 256+197; i++) 746 for (i = -197; i < 256+197; i++)
743 ((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0); 747 ((uint32_t *)table_r)[i] = table_Y[i+384] << ((isRgb ? 16 : 0) + base);
744 for (i = -132; i < 256+132; i++) 748 for (i = -132; i < 256+132; i++)
745 ((uint32_t *)table_g)[i] = table_Y[i+384] << 8; 749 ((uint32_t *)table_g)[i] = table_Y[i+384] << (8 + base);
746 for (i = -232; i < 256+232; i++) 750 for (i = -232; i < 256+232; i++)
747 ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16); 751 ((uint32_t *)table_b)[i] = table_Y[i+384] << ((isRgb ? 0 : 16) + base);
748 break; 752 break;
749 753
750 case 24: 754 case 24:
751 table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t)); 755 table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t));
752 756