comparison postproc/yuv2rgb.c @ 9171:898e5270a46e

fixing rgb4 & bgr4 (2 pixels per byte) adding bg4b & rg4b (1 pixel per byte)
author michael
date Thu, 30 Jan 2003 09:15:09 +0000
parents 96bc9b4a0287
children eff727517e6b
comparison
equal deleted inserted replaced
9170:bcf4bf10f9c7 9171:898e5270a46e
607 h_size >>= 3; 607 h_size >>= 3;
608 dst_1 = _dst_1; 608 dst_1 = _dst_1;
609 dst_2 = _dst_2; 609 dst_2 = _dst_2;
610 610
611 while (h_size--) { 611 while (h_size--) {
612 int acc;
613 #define DST1_4(i) \
614 Y = py_1[2*i]; \
615 acc = r[Y] + g[Y] + b[Y]; \
616 Y = py_1[2*i+1]; \
617 acc |= (r[Y] + g[Y] + b[Y])<<4;\
618 dst_1[i] = acc;
619
620 #define DST2_4(i) \
621 Y = py_2[2*i]; \
622 acc = r[Y] + g[Y] + b[Y]; \
623 Y = py_2[2*i+1]; \
624 acc |= (r[Y] + g[Y] + b[Y])<<4;\
625 dst_2[i] = acc;
626
627 RGB(0);
628 DST1_4(0);
629 DST2_4(0);
630
631 RGB(1);
632 DST2_4(1);
633 DST1_4(1);
634
635 RGB(2);
636 DST1_4(2);
637 DST2_4(2);
638
639 RGB(3);
640 DST2_4(3);
641 DST1_4(3);
642
643 pu += 4;
644 pv += 4;
645 py_1 += 8;
646 py_2 += 8;
647 dst_1 += 4;
648 dst_2 += 4;
649 }
650 }
651
652 static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2,
653 uint8_t * pu, uint8_t * pv,
654 void * _dst_1, void * _dst_2, int h_size, int v_pos)
655 {
656 int U, V, Y;
657 uint8_t * r, * g, * b;
658 uint8_t * dst_1, * dst_2;
659
660 h_size >>= 3;
661 dst_1 = _dst_1;
662 dst_2 = _dst_2;
663
664 while (h_size--) {
665 const uint8_t *d64= dither_8x8_73[v_pos&7];
666 const uint8_t *d128=dither_8x8_220[v_pos&7];
667 int acc;
668
669 #define DST1bpp4(i,o) \
670 Y = py_1[2*i]; \
671 acc = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
672 Y = py_1[2*i+1]; \
673 acc |= (r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]])<<4;\
674 dst_1[i]= acc;
675
676 #define DST2bpp4(i,o) \
677 Y = py_2[2*i]; \
678 acc = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \
679 Y = py_2[2*i+1]; \
680 acc |= (r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]])<<4;\
681 dst_2[i]= acc;
682
683
684 RGB(0);
685 DST1bpp4(0,0);
686 DST2bpp4(0,0);
687
688 RGB(1);
689 DST2bpp4(1,2);
690 DST1bpp4(1,2);
691
692 RGB(2);
693 DST1bpp4(2,4);
694 DST2bpp4(2,4);
695
696 RGB(3);
697 DST2bpp4(3,6);
698 DST1bpp4(3,6);
699
700 pu += 4;
701 pv += 4;
702 py_1 += 8;
703 py_2 += 8;
704 dst_1 += 4;
705 dst_2 += 4;
706 }
707 }
708
709 // This is exactly the same code as yuv2rgb_c_32 except for the types of
710 // r, g, b, dst_1, dst_2
711 static void yuv2rgb_c_4b (uint8_t * py_1, uint8_t * py_2,
712 uint8_t * pu, uint8_t * pv,
713 void * _dst_1, void * _dst_2, int h_size, int v_pos)
714 {
715 int U, V, Y;
716 uint8_t * r, * g, * b;
717 uint8_t * dst_1, * dst_2;
718
719 h_size >>= 3;
720 dst_1 = _dst_1;
721 dst_2 = _dst_2;
722
723 while (h_size--) {
612 RGB(0); 724 RGB(0);
613 DST1(0); 725 DST1(0);
614 DST2(0); 726 DST2(0);
615 727
616 RGB(1); 728 RGB(1);
632 dst_1 += 8; 744 dst_1 += 8;
633 dst_2 += 8; 745 dst_2 += 8;
634 } 746 }
635 } 747 }
636 748
637 static void yuv2rgb_c_4_ordered_dither (uint8_t * py_1, uint8_t * py_2, 749 static void yuv2rgb_c_4b_ordered_dither (uint8_t * py_1, uint8_t * py_2,
638 uint8_t * pu, uint8_t * pv, 750 uint8_t * pu, uint8_t * pv,
639 void * _dst_1, void * _dst_2, int h_size, int v_pos) 751 void * _dst_1, void * _dst_2, int h_size, int v_pos)
640 { 752 {
641 int U, V, Y; 753 int U, V, Y;
642 uint8_t * r, * g, * b; 754 uint8_t * r, * g, * b;
648 760
649 while (h_size--) { 761 while (h_size--) {
650 const uint8_t *d64= dither_8x8_73[v_pos&7]; 762 const uint8_t *d64= dither_8x8_73[v_pos&7];
651 const uint8_t *d128=dither_8x8_220[v_pos&7]; 763 const uint8_t *d128=dither_8x8_220[v_pos&7];
652 764
653 #define DST1bpp4(i,o) \ 765 #define DST1bpp4b(i,o) \
654 Y = py_1[2*i]; \ 766 Y = py_1[2*i]; \
655 dst_1[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \ 767 dst_1[2*i] = r[Y+d128[0+o]] + g[Y+d64[0+o]] + b[Y+d128[0+o]]; \
656 Y = py_1[2*i+1]; \ 768 Y = py_1[2*i+1]; \
657 dst_1[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]]; 769 dst_1[2*i+1] = r[Y+d128[1+o]] + g[Y+d64[1+o]] + b[Y+d128[1+o]];
658 770
659 #define DST2bpp4(i,o) \ 771 #define DST2bpp4b(i,o) \
660 Y = py_2[2*i]; \ 772 Y = py_2[2*i]; \
661 dst_2[2*i] = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \ 773 dst_2[2*i] = r[Y+d128[8+o]] + g[Y+d64[8+o]] + b[Y+d128[8+o]]; \
662 Y = py_2[2*i+1]; \ 774 Y = py_2[2*i+1]; \
663 dst_2[2*i+1] = r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]]; 775 dst_2[2*i+1] = r[Y+d128[9+o]] + g[Y+d64[9+o]] + b[Y+d128[9+o]];
664 776
665 777
666 RGB(0); 778 RGB(0);
667 DST1bpp4(0,0); 779 DST1bpp4b(0,0);
668 DST2bpp4(0,0); 780 DST2bpp4b(0,0);
669 781
670 RGB(1); 782 RGB(1);
671 DST2bpp4(1,2); 783 DST2bpp4b(1,2);
672 DST1bpp4(1,2); 784 DST1bpp4b(1,2);
673 785
674 RGB(2); 786 RGB(2);
675 DST1bpp4(2,4); 787 DST1bpp4b(2,4);
676 DST2bpp4(2,4); 788 DST2bpp4b(2,4);
677 789
678 RGB(3); 790 RGB(3);
679 DST2bpp4(3,6); 791 DST2bpp4b(3,6);
680 DST1bpp4(3,6); 792 DST1bpp4b(3,6);
681 793
682 pu += 4; 794 pu += 4;
683 pv += 4; 795 pv += 4;
684 py_1 += 8; 796 py_1 += 8;
685 py_2 += 8; 797 py_2 += 8;
877 989
878 ((uint8_t *)table_b)[i] = j; 990 ((uint8_t *)table_b)[i] = j;
879 } 991 }
880 break; 992 break;
881 case 4: 993 case 4:
882 yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4; 994 case 4|128:
995 if(bpp==4)
996 yuv2rgb_c_internal = yuv2rgb_c_4_ordered_dither; //yuv2rgb_c_4;
997 else
998 yuv2rgb_c_internal = yuv2rgb_c_4b_ordered_dither; //yuv2rgb_c_4;
883 999
884 table_start= table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); 1000 table_start= table_121 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
885 1001
886 entry_size = sizeof (uint8_t); 1002 entry_size = sizeof (uint8_t);
887 table_r = table_121 + 197; 1003 table_r = table_121 + 197;