comparison libswscale/yuv2rgb.c @ 19143:c4dac777b44c

Use libavutil in libswscale, and allow it to be built out of the mplayer tree
author lucabe
date Thu, 20 Jul 2006 12:13:57 +0000
parents 8579acff875e
children c629606a0702
comparison
equal deleted inserted replaced
19142:4c22e1d84ac9 19143:c4dac777b44c
34 #include <stdlib.h> 34 #include <stdlib.h>
35 #include <inttypes.h> 35 #include <inttypes.h>
36 #include <assert.h> 36 #include <assert.h>
37 37
38 #include "config.h" 38 #include "config.h"
39 //#include "video_out.h"
40 #include "rgb2rgb.h" 39 #include "rgb2rgb.h"
41 #include "swscale.h" 40 #include "swscale.h"
42 #include "swscale_internal.h" 41 #include "swscale_internal.h"
43 #include "mangle.h" 42 #include "img_format.h" //FIXME try to reduce dependency of such stuff
44 #include "libvo/img_format.h" //FIXME try to reduce dependency of such stuff
45 43
46 #ifdef HAVE_MLIB 44 #ifdef HAVE_MLIB
47 #include "yuv2rgb_mlib.c" 45 #include "yuv2rgb_mlib.c"
48 #endif 46 #endif
49 47
690 table_Y[i] = j; 688 table_Y[i] = j;
691 } 689 }
692 690
693 switch (bpp) { 691 switch (bpp) {
694 case 32: 692 case 32:
695 table_start= table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); 693 table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
696 694
697 entry_size = sizeof (uint32_t); 695 entry_size = sizeof (uint32_t);
698 table_r = table_32 + 197; 696 table_r = table_32 + 197;
699 table_b = table_32 + 197 + 685; 697 table_b = table_32 + 197 + 685;
700 table_g = table_32 + 197 + 2*682; 698 table_g = table_32 + 197 + 2*682;
706 for (i = -232; i < 256+232; i++) 704 for (i = -232; i < 256+232; i++)
707 ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16); 705 ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16);
708 break; 706 break;
709 707
710 case 24: 708 case 24:
711 table_start= table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); 709 table_start= table_8 = av_malloc ((256 + 2*232) * sizeof (uint8_t));
712 710
713 entry_size = sizeof (uint8_t); 711 entry_size = sizeof (uint8_t);
714 table_r = table_g = table_b = table_8 + 232; 712 table_r = table_g = table_b = table_8 + 232;
715 713
716 for (i = -232; i < 256+232; i++) 714 for (i = -232; i < 256+232; i++)
717 ((uint8_t * )table_b)[i] = table_Y[i+384]; 715 ((uint8_t * )table_b)[i] = table_Y[i+384];
718 break; 716 break;
719 717
720 case 15: 718 case 15:
721 case 16: 719 case 16:
722 table_start= table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); 720 table_start= table_16 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
723 721
724 entry_size = sizeof (uint16_t); 722 entry_size = sizeof (uint16_t);
725 table_r = table_16 + 197; 723 table_r = table_16 + 197;
726 table_b = table_16 + 197 + 685; 724 table_b = table_16 + 197 + 685;
727 table_g = table_16 + 197 + 2*682; 725 table_g = table_16 + 197 + 2*682;
748 ((uint16_t *)table_b)[i] = j; 746 ((uint16_t *)table_b)[i] = j;
749 } 747 }
750 break; 748 break;
751 749
752 case 8: 750 case 8:
753 table_start= table_332 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); 751 table_start= table_332 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
754 752
755 entry_size = sizeof (uint8_t); 753 entry_size = sizeof (uint8_t);
756 table_r = table_332 + 197; 754 table_r = table_332 + 197;
757 table_b = table_332 + 197 + 685; 755 table_b = table_332 + 197 + 685;
758 table_g = table_332 + 197 + 2*682; 756 table_g = table_332 + 197 + 2*682;
782 ((uint8_t *)table_b)[i] = j; 780 ((uint8_t *)table_b)[i] = j;
783 } 781 }
784 break; 782 break;
785 case 4: 783 case 4:
786 case 4|128: 784 case 4|128:
787 table_start= table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); 785 table_start= table_121 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
788 786
789 entry_size = sizeof (uint8_t); 787 entry_size = sizeof (uint8_t);
790 table_r = table_121 + 197; 788 table_r = table_121 + 197;
791 table_b = table_121 + 197 + 685; 789 table_b = table_121 + 197 + 685;
792 table_g = table_121 + 197 + 2*682; 790 table_g = table_121 + 197 + 2*682;
813 ((uint8_t *)table_b)[i] = j; 811 ((uint8_t *)table_b)[i] = j;
814 } 812 }
815 break; 813 break;
816 814
817 case 1: 815 case 1:
818 table_start= table_1 = malloc (256*2 * sizeof (uint8_t)); 816 table_start= table_1 = av_malloc (256*2 * sizeof (uint8_t));
819 817
820 entry_size = sizeof (uint8_t); 818 entry_size = sizeof (uint8_t);
821 table_g = table_1; 819 table_g = table_1;
822 table_r = table_b = NULL; 820 table_r = table_b = NULL;
823 821
840 c->table_gU[i] = table_g + entry_size * div_round (cgu * (i-128), 76309); 838 c->table_gU[i] = table_g + entry_size * div_round (cgu * (i-128), 76309);
841 c->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); 839 c->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
842 c->table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309); 840 c->table_bU[i] = table_b + entry_size * div_round (cbu * (i-128), 76309);
843 } 841 }
844 842
845 if(c->yuvTable) free(c->yuvTable); 843 av_free(c->yuvTable);
846 c->yuvTable= table_start; 844 c->yuvTable= table_start;
847 return 0; 845 return 0;
848 } 846 }