Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: core/fxcodec/jbig2/JBig2_Image.cpp

Issue 1801383002: Re-enable several MSVC warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address more comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "core/fxcodec/jbig2/JBig2_Image.h" 9 #include "core/fxcodec/jbig2/JBig2_Image.h"
10 #include "core/include/fxcrt/fx_coordinates.h" 10 #include "core/include/fxcrt/fx_coordinates.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } 658 }
659 } 659 }
660 } 660 }
661 return 1; 661 return 1;
662 } 662 }
663 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, 663 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
664 int32_t x, 664 int32_t x,
665 int32_t y, 665 int32_t y,
666 JBig2ComposeOp op, 666 JBig2ComposeOp op,
667 const FX_RECT* pSrcRect) { 667 const FX_RECT* pSrcRect) {
668 int32_t xs0, ys0, xs1, ys1, xd0, yd0, xd1, yd1, xx, yy, w, h, middleDwords,
669 lineLeft;
670 FX_DWORD s1, d1, d2, shift, shift1, shift2, tmp, tmp1, tmp2, maskL, maskR,
671 maskM;
672 uint8_t *lineSrc, *lineDst, *sp, *dp;
673 int32_t sw, sh;
674 if (!m_pData) { 668 if (!m_pData) {
675 return FALSE; 669 return FALSE;
676 } 670 }
677 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { 671 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) {
Tom Sepez 2016/03/17 16:40:05 Ok, let's add a TODO here to check on 1048576 vs 1
Wei Li 2016/03/18 17:42:39 Done.
678 return FALSE; 672 return FALSE;
679 } 673 }
680 sw = pSrcRect->Width(); 674 int32_t sw = pSrcRect->Width();
681 sh = pSrcRect->Height(); 675 int32_t sh = pSrcRect->Height();
682 if (y < 0) { 676 int32_t ys0 = y < 0 ? -y : 0;
683 ys0 = -y; 677 int32_t ys1 = y + sh > pDst->m_nHeight ? pDst->m_nHeight - y : sh;
684 } else { 678 int32_t xs0 = x < 0 ? -x : 0;
685 ys0 = 0; 679 int32_t xs1 = x + sw > pDst->m_nWidth ? pDst->m_nWidth - x : sw;
686 }
687 if (y + sh > pDst->m_nHeight) {
688 ys1 = pDst->m_nHeight - y;
689 } else {
690 ys1 = sh;
691 }
692 if (x < 0) {
693 xs0 = -x;
694 } else {
695 xs0 = 0;
696 }
697 if (x + sw > pDst->m_nWidth) {
698 xs1 = pDst->m_nWidth - x;
699 } else {
700 xs1 = sw;
701 }
702 if ((ys0 >= ys1) || (xs0 >= xs1)) { 680 if ((ys0 >= ys1) || (xs0 >= xs1)) {
703 return 0; 681 return 0;
704 } 682 }
705 w = xs1 - xs0; 683 int32_t w = xs1 - xs0;
706 h = ys1 - ys0; 684 int32_t h = ys1 - ys0;
707 if (y < 0) { 685 int32_t yd0 = y < 0 ? 0 : y;
708 yd0 = 0; 686 int32_t xd0 = x < 0 ? 0 : x;
709 } else { 687 int32_t xd1 = xd0 + w;
710 yd0 = y; 688 int32_t yd1 = yd0 + h;
711 } 689 int32_t d1 = xd0 & 31;
712 if (x < 0) { 690 int32_t d2 = xd1 & 31;
713 xd0 = 0; 691 int32_t s1 = xs0 & 31;
714 } else { 692 int32_t maskL = 0xffffffff >> d1;
715 xd0 = x; 693 int32_t maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
716 } 694 int32_t maskM = maskL & maskR;
717 xd1 = xd0 + w; 695 uint8_t* lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride +
718 yd1 = yd0 + h; 696 (((xs0 + pSrcRect->left) >> 5) << 2);
719 d1 = xd0 & 31; 697 int32_t lineLeft = m_nStride - ((xs0 >> 5) << 2);
720 d2 = xd1 & 31; 698 uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
721 s1 = xs0 & 31;
722 maskL = 0xffffffff >> d1;
723 maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
724 maskM = maskL & maskR;
725 lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride +
726 (((xs0 + pSrcRect->left) >> 5) << 2);
727 lineLeft = m_nStride - ((xs0 >> 5) << 2);
728 lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
729 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) { 699 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) {
730 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) { 700 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) {
731 if (s1 > d1) { 701 if (s1 > d1) {
732 shift = s1 - d1; 702 FX_DWORD shift = s1 - d1;
733 for (yy = yd0; yy < yd1; yy++) { 703 for (int32_t yy = yd0; yy < yd1; yy++) {
734 tmp1 = JBIG2_GETDWORD(lineSrc) << shift; 704 FX_DWORD tmp1 = JBIG2_GETDWORD(lineSrc) << shift;
735 tmp2 = JBIG2_GETDWORD(lineDst); 705 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst);
706 FX_DWORD tmp = 0;
736 switch (op) { 707 switch (op) {
737 case JBIG2_COMPOSE_OR: 708 case JBIG2_COMPOSE_OR:
738 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 709 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
739 break; 710 break;
740 case JBIG2_COMPOSE_AND: 711 case JBIG2_COMPOSE_AND:
741 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 712 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
742 break; 713 break;
743 case JBIG2_COMPOSE_XOR: 714 case JBIG2_COMPOSE_XOR:
744 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 715 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
745 break; 716 break;
746 case JBIG2_COMPOSE_XNOR: 717 case JBIG2_COMPOSE_XNOR:
747 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 718 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
748 break; 719 break;
749 case JBIG2_COMPOSE_REPLACE: 720 case JBIG2_COMPOSE_REPLACE:
750 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 721 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
751 break; 722 break;
752 } 723 }
753 lineDst[0] = (uint8_t)(tmp >> 24); 724 lineDst[0] = (uint8_t)(tmp >> 24);
754 lineDst[1] = (uint8_t)(tmp >> 16); 725 lineDst[1] = (uint8_t)(tmp >> 16);
755 lineDst[2] = (uint8_t)(tmp >> 8); 726 lineDst[2] = (uint8_t)(tmp >> 8);
756 lineDst[3] = (uint8_t)tmp; 727 lineDst[3] = (uint8_t)tmp;
757 lineSrc += m_nStride; 728 lineSrc += m_nStride;
758 lineDst += pDst->m_nStride; 729 lineDst += pDst->m_nStride;
759 } 730 }
760 } else { 731 } else {
761 shift = d1 - s1; 732 FX_DWORD shift = d1 - s1;
762 for (yy = yd0; yy < yd1; yy++) { 733 for (int32_t yy = yd0; yy < yd1; yy++) {
763 tmp1 = JBIG2_GETDWORD(lineSrc) >> shift; 734 FX_DWORD tmp1 = JBIG2_GETDWORD(lineSrc) >> shift;
764 tmp2 = JBIG2_GETDWORD(lineDst); 735 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst);
736 FX_DWORD tmp = 0;
765 switch (op) { 737 switch (op) {
766 case JBIG2_COMPOSE_OR: 738 case JBIG2_COMPOSE_OR:
767 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 739 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
768 break; 740 break;
769 case JBIG2_COMPOSE_AND: 741 case JBIG2_COMPOSE_AND:
770 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 742 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
771 break; 743 break;
772 case JBIG2_COMPOSE_XOR: 744 case JBIG2_COMPOSE_XOR:
773 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 745 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
774 break; 746 break;
775 case JBIG2_COMPOSE_XNOR: 747 case JBIG2_COMPOSE_XNOR:
776 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 748 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
777 break; 749 break;
778 case JBIG2_COMPOSE_REPLACE: 750 case JBIG2_COMPOSE_REPLACE:
779 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 751 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
780 break; 752 break;
781 } 753 }
782 lineDst[0] = (uint8_t)(tmp >> 24); 754 lineDst[0] = (uint8_t)(tmp >> 24);
783 lineDst[1] = (uint8_t)(tmp >> 16); 755 lineDst[1] = (uint8_t)(tmp >> 16);
784 lineDst[2] = (uint8_t)(tmp >> 8); 756 lineDst[2] = (uint8_t)(tmp >> 8);
785 lineDst[3] = (uint8_t)tmp; 757 lineDst[3] = (uint8_t)tmp;
786 lineSrc += m_nStride; 758 lineSrc += m_nStride;
787 lineDst += pDst->m_nStride; 759 lineDst += pDst->m_nStride;
788 } 760 }
789 } 761 }
790 } else { 762 } else {
791 shift1 = s1 - d1; 763 FX_DWORD shift1 = s1 - d1;
792 shift2 = 32 - shift1; 764 FX_DWORD shift2 = 32 - shift1;
793 for (yy = yd0; yy < yd1; yy++) { 765 for (int32_t yy = yd0; yy < yd1; yy++) {
794 tmp1 = (JBIG2_GETDWORD(lineSrc) << shift1) | 766 FX_DWORD tmp1 = (JBIG2_GETDWORD(lineSrc) << shift1) |
795 (JBIG2_GETDWORD(lineSrc + 4) >> shift2); 767 (JBIG2_GETDWORD(lineSrc + 4) >> shift2);
796 tmp2 = JBIG2_GETDWORD(lineDst); 768 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst);
769 FX_DWORD tmp = 0;
797 switch (op) { 770 switch (op) {
798 case JBIG2_COMPOSE_OR: 771 case JBIG2_COMPOSE_OR:
799 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 772 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
800 break; 773 break;
801 case JBIG2_COMPOSE_AND: 774 case JBIG2_COMPOSE_AND:
802 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 775 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
803 break; 776 break;
804 case JBIG2_COMPOSE_XOR: 777 case JBIG2_COMPOSE_XOR:
805 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 778 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
806 break; 779 break;
807 case JBIG2_COMPOSE_XNOR: 780 case JBIG2_COMPOSE_XNOR:
808 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 781 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
809 break; 782 break;
810 case JBIG2_COMPOSE_REPLACE: 783 case JBIG2_COMPOSE_REPLACE:
811 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 784 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
812 break; 785 break;
813 } 786 }
814 lineDst[0] = (uint8_t)(tmp >> 24); 787 lineDst[0] = (uint8_t)(tmp >> 24);
815 lineDst[1] = (uint8_t)(tmp >> 16); 788 lineDst[1] = (uint8_t)(tmp >> 16);
816 lineDst[2] = (uint8_t)(tmp >> 8); 789 lineDst[2] = (uint8_t)(tmp >> 8);
817 lineDst[3] = (uint8_t)tmp; 790 lineDst[3] = (uint8_t)tmp;
818 lineSrc += m_nStride; 791 lineSrc += m_nStride;
819 lineDst += pDst->m_nStride; 792 lineDst += pDst->m_nStride;
820 } 793 }
821 } 794 }
822 } else { 795 } else {
823 if (s1 > d1) { 796 if (s1 > d1) {
824 shift1 = s1 - d1; 797 FX_DWORD shift1 = s1 - d1;
825 shift2 = 32 - shift1; 798 FX_DWORD shift2 = 32 - shift1;
826 middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 799 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
827 for (yy = yd0; yy < yd1; yy++) { 800 for (int32_t yy = yd0; yy < yd1; yy++) {
828 sp = lineSrc; 801 uint8_t* sp = lineSrc;
829 dp = lineDst; 802 uint8_t* dp = lineDst;
830 if (d1 != 0) { 803 if (d1 != 0) {
831 tmp1 = (JBIG2_GETDWORD(sp) << shift1) | 804 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift1) |
832 (JBIG2_GETDWORD(sp + 4) >> shift2); 805 (JBIG2_GETDWORD(sp + 4) >> shift2);
833 tmp2 = JBIG2_GETDWORD(dp); 806 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
807 FX_DWORD tmp = 0;
834 switch (op) { 808 switch (op) {
835 case JBIG2_COMPOSE_OR: 809 case JBIG2_COMPOSE_OR:
836 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 810 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
837 break; 811 break;
838 case JBIG2_COMPOSE_AND: 812 case JBIG2_COMPOSE_AND:
839 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 813 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
840 break; 814 break;
841 case JBIG2_COMPOSE_XOR: 815 case JBIG2_COMPOSE_XOR:
842 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 816 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
843 break; 817 break;
844 case JBIG2_COMPOSE_XNOR: 818 case JBIG2_COMPOSE_XNOR:
845 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 819 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
846 break; 820 break;
847 case JBIG2_COMPOSE_REPLACE: 821 case JBIG2_COMPOSE_REPLACE:
848 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 822 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
849 break; 823 break;
850 } 824 }
851 dp[0] = (uint8_t)(tmp >> 24); 825 dp[0] = (uint8_t)(tmp >> 24);
852 dp[1] = (uint8_t)(tmp >> 16); 826 dp[1] = (uint8_t)(tmp >> 16);
853 dp[2] = (uint8_t)(tmp >> 8); 827 dp[2] = (uint8_t)(tmp >> 8);
854 dp[3] = (uint8_t)tmp; 828 dp[3] = (uint8_t)tmp;
855 sp += 4; 829 sp += 4;
856 dp += 4; 830 dp += 4;
857 } 831 }
858 for (xx = 0; xx < middleDwords; xx++) { 832 for (int32_t xx = 0; xx < middleDwords; xx++) {
859 tmp1 = (JBIG2_GETDWORD(sp) << shift1) | 833 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift1) |
860 (JBIG2_GETDWORD(sp + 4) >> shift2); 834 (JBIG2_GETDWORD(sp + 4) >> shift2);
861 tmp2 = JBIG2_GETDWORD(dp); 835 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
836 FX_DWORD tmp = 0;
862 switch (op) { 837 switch (op) {
863 case JBIG2_COMPOSE_OR: 838 case JBIG2_COMPOSE_OR:
864 tmp = tmp1 | tmp2; 839 tmp = tmp1 | tmp2;
865 break; 840 break;
866 case JBIG2_COMPOSE_AND: 841 case JBIG2_COMPOSE_AND:
867 tmp = tmp1 & tmp2; 842 tmp = tmp1 & tmp2;
868 break; 843 break;
869 case JBIG2_COMPOSE_XOR: 844 case JBIG2_COMPOSE_XOR:
870 tmp = tmp1 ^ tmp2; 845 tmp = tmp1 ^ tmp2;
871 break; 846 break;
872 case JBIG2_COMPOSE_XNOR: 847 case JBIG2_COMPOSE_XNOR:
873 tmp = ~(tmp1 ^ tmp2); 848 tmp = ~(tmp1 ^ tmp2);
874 break; 849 break;
875 case JBIG2_COMPOSE_REPLACE: 850 case JBIG2_COMPOSE_REPLACE:
876 tmp = tmp1; 851 tmp = tmp1;
877 break; 852 break;
878 } 853 }
879 dp[0] = (uint8_t)(tmp >> 24); 854 dp[0] = (uint8_t)(tmp >> 24);
880 dp[1] = (uint8_t)(tmp >> 16); 855 dp[1] = (uint8_t)(tmp >> 16);
881 dp[2] = (uint8_t)(tmp >> 8); 856 dp[2] = (uint8_t)(tmp >> 8);
882 dp[3] = (uint8_t)tmp; 857 dp[3] = (uint8_t)tmp;
883 sp += 4; 858 sp += 4;
884 dp += 4; 859 dp += 4;
885 } 860 }
886 if (d2 != 0) { 861 if (d2 != 0) {
887 tmp1 = 862 FX_DWORD tmp1 =
888 (JBIG2_GETDWORD(sp) << shift1) | 863 (JBIG2_GETDWORD(sp) << shift1) |
889 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >> 864 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >>
890 shift2); 865 shift2);
891 tmp2 = JBIG2_GETDWORD(dp); 866 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
867 FX_DWORD tmp = 0;
892 switch (op) { 868 switch (op) {
893 case JBIG2_COMPOSE_OR: 869 case JBIG2_COMPOSE_OR:
894 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 870 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
895 break; 871 break;
896 case JBIG2_COMPOSE_AND: 872 case JBIG2_COMPOSE_AND:
897 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 873 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
898 break; 874 break;
899 case JBIG2_COMPOSE_XOR: 875 case JBIG2_COMPOSE_XOR:
900 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 876 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
901 break; 877 break;
902 case JBIG2_COMPOSE_XNOR: 878 case JBIG2_COMPOSE_XNOR:
903 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR); 879 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR);
904 break; 880 break;
905 case JBIG2_COMPOSE_REPLACE: 881 case JBIG2_COMPOSE_REPLACE:
906 tmp = (tmp2 & ~maskR) | (tmp1 & maskR); 882 tmp = (tmp2 & ~maskR) | (tmp1 & maskR);
907 break; 883 break;
908 } 884 }
909 dp[0] = (uint8_t)(tmp >> 24); 885 dp[0] = (uint8_t)(tmp >> 24);
910 dp[1] = (uint8_t)(tmp >> 16); 886 dp[1] = (uint8_t)(tmp >> 16);
911 dp[2] = (uint8_t)(tmp >> 8); 887 dp[2] = (uint8_t)(tmp >> 8);
912 dp[3] = (uint8_t)tmp; 888 dp[3] = (uint8_t)tmp;
913 } 889 }
914 lineSrc += m_nStride; 890 lineSrc += m_nStride;
915 lineDst += pDst->m_nStride; 891 lineDst += pDst->m_nStride;
916 } 892 }
917 } else if (s1 == d1) { 893 } else if (s1 == d1) {
918 middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 894 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
919 for (yy = yd0; yy < yd1; yy++) { 895 for (int32_t yy = yd0; yy < yd1; yy++) {
920 sp = lineSrc; 896 uint8_t* sp = lineSrc;
921 dp = lineDst; 897 uint8_t* dp = lineDst;
922 if (d1 != 0) { 898 if (d1 != 0) {
923 tmp1 = JBIG2_GETDWORD(sp); 899 FX_DWORD tmp1 = JBIG2_GETDWORD(sp);
924 tmp2 = JBIG2_GETDWORD(dp); 900 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
901 FX_DWORD tmp = 0;
925 switch (op) { 902 switch (op) {
926 case JBIG2_COMPOSE_OR: 903 case JBIG2_COMPOSE_OR:
927 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 904 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
928 break; 905 break;
929 case JBIG2_COMPOSE_AND: 906 case JBIG2_COMPOSE_AND:
930 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 907 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
931 break; 908 break;
932 case JBIG2_COMPOSE_XOR: 909 case JBIG2_COMPOSE_XOR:
933 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 910 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
934 break; 911 break;
935 case JBIG2_COMPOSE_XNOR: 912 case JBIG2_COMPOSE_XNOR:
936 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 913 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
937 break; 914 break;
938 case JBIG2_COMPOSE_REPLACE: 915 case JBIG2_COMPOSE_REPLACE:
939 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 916 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
940 break; 917 break;
941 } 918 }
942 dp[0] = (uint8_t)(tmp >> 24); 919 dp[0] = (uint8_t)(tmp >> 24);
943 dp[1] = (uint8_t)(tmp >> 16); 920 dp[1] = (uint8_t)(tmp >> 16);
944 dp[2] = (uint8_t)(tmp >> 8); 921 dp[2] = (uint8_t)(tmp >> 8);
945 dp[3] = (uint8_t)tmp; 922 dp[3] = (uint8_t)tmp;
946 sp += 4; 923 sp += 4;
947 dp += 4; 924 dp += 4;
948 } 925 }
949 for (xx = 0; xx < middleDwords; xx++) { 926 for (int32_t xx = 0; xx < middleDwords; xx++) {
950 tmp1 = JBIG2_GETDWORD(sp); 927 FX_DWORD tmp1 = JBIG2_GETDWORD(sp);
951 tmp2 = JBIG2_GETDWORD(dp); 928 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
929 FX_DWORD tmp = 0;
952 switch (op) { 930 switch (op) {
953 case JBIG2_COMPOSE_OR: 931 case JBIG2_COMPOSE_OR:
954 tmp = tmp1 | tmp2; 932 tmp = tmp1 | tmp2;
955 break; 933 break;
956 case JBIG2_COMPOSE_AND: 934 case JBIG2_COMPOSE_AND:
957 tmp = tmp1 & tmp2; 935 tmp = tmp1 & tmp2;
958 break; 936 break;
959 case JBIG2_COMPOSE_XOR: 937 case JBIG2_COMPOSE_XOR:
960 tmp = tmp1 ^ tmp2; 938 tmp = tmp1 ^ tmp2;
961 break; 939 break;
962 case JBIG2_COMPOSE_XNOR: 940 case JBIG2_COMPOSE_XNOR:
963 tmp = ~(tmp1 ^ tmp2); 941 tmp = ~(tmp1 ^ tmp2);
964 break; 942 break;
965 case JBIG2_COMPOSE_REPLACE: 943 case JBIG2_COMPOSE_REPLACE:
966 tmp = tmp1; 944 tmp = tmp1;
967 break; 945 break;
968 } 946 }
969 dp[0] = (uint8_t)(tmp >> 24); 947 dp[0] = (uint8_t)(tmp >> 24);
970 dp[1] = (uint8_t)(tmp >> 16); 948 dp[1] = (uint8_t)(tmp >> 16);
971 dp[2] = (uint8_t)(tmp >> 8); 949 dp[2] = (uint8_t)(tmp >> 8);
972 dp[3] = (uint8_t)tmp; 950 dp[3] = (uint8_t)tmp;
973 sp += 4; 951 sp += 4;
974 dp += 4; 952 dp += 4;
975 } 953 }
976 if (d2 != 0) { 954 if (d2 != 0) {
977 tmp1 = JBIG2_GETDWORD(sp); 955 FX_DWORD tmp1 = JBIG2_GETDWORD(sp);
978 tmp2 = JBIG2_GETDWORD(dp); 956 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
957 FX_DWORD tmp = 0;
979 switch (op) { 958 switch (op) {
980 case JBIG2_COMPOSE_OR: 959 case JBIG2_COMPOSE_OR:
981 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 960 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
982 break; 961 break;
983 case JBIG2_COMPOSE_AND: 962 case JBIG2_COMPOSE_AND:
984 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 963 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
985 break; 964 break;
986 case JBIG2_COMPOSE_XOR: 965 case JBIG2_COMPOSE_XOR:
987 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 966 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
988 break; 967 break;
989 case JBIG2_COMPOSE_XNOR: 968 case JBIG2_COMPOSE_XNOR:
990 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR); 969 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR);
991 break; 970 break;
992 case JBIG2_COMPOSE_REPLACE: 971 case JBIG2_COMPOSE_REPLACE:
993 tmp = (tmp2 & ~maskR) | (tmp1 & maskR); 972 tmp = (tmp2 & ~maskR) | (tmp1 & maskR);
994 break; 973 break;
995 } 974 }
996 dp[0] = (uint8_t)(tmp >> 24); 975 dp[0] = (uint8_t)(tmp >> 24);
997 dp[1] = (uint8_t)(tmp >> 16); 976 dp[1] = (uint8_t)(tmp >> 16);
998 dp[2] = (uint8_t)(tmp >> 8); 977 dp[2] = (uint8_t)(tmp >> 8);
999 dp[3] = (uint8_t)tmp; 978 dp[3] = (uint8_t)tmp;
1000 } 979 }
1001 lineSrc += m_nStride; 980 lineSrc += m_nStride;
1002 lineDst += pDst->m_nStride; 981 lineDst += pDst->m_nStride;
1003 } 982 }
1004 } else { 983 } else {
1005 shift1 = d1 - s1; 984 FX_DWORD shift1 = d1 - s1;
1006 shift2 = 32 - shift1; 985 FX_DWORD shift2 = 32 - shift1;
1007 middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 986 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
1008 for (yy = yd0; yy < yd1; yy++) { 987 for (int32_t yy = yd0; yy < yd1; yy++) {
1009 sp = lineSrc; 988 uint8_t* sp = lineSrc;
1010 dp = lineDst; 989 uint8_t* dp = lineDst;
1011 if (d1 != 0) { 990 if (d1 != 0) {
1012 tmp1 = JBIG2_GETDWORD(sp) >> shift1; 991 FX_DWORD tmp1 = JBIG2_GETDWORD(sp) >> shift1;
1013 tmp2 = JBIG2_GETDWORD(dp); 992 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
993 FX_DWORD tmp = 0;
1014 switch (op) { 994 switch (op) {
1015 case JBIG2_COMPOSE_OR: 995 case JBIG2_COMPOSE_OR:
1016 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 996 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
1017 break; 997 break;
1018 case JBIG2_COMPOSE_AND: 998 case JBIG2_COMPOSE_AND:
1019 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 999 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
1020 break; 1000 break;
1021 case JBIG2_COMPOSE_XOR: 1001 case JBIG2_COMPOSE_XOR:
1022 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 1002 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
1023 break; 1003 break;
1024 case JBIG2_COMPOSE_XNOR: 1004 case JBIG2_COMPOSE_XNOR:
1025 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 1005 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
1026 break; 1006 break;
1027 case JBIG2_COMPOSE_REPLACE: 1007 case JBIG2_COMPOSE_REPLACE:
1028 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 1008 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
1029 break; 1009 break;
1030 } 1010 }
1031 dp[0] = (uint8_t)(tmp >> 24); 1011 dp[0] = (uint8_t)(tmp >> 24);
1032 dp[1] = (uint8_t)(tmp >> 16); 1012 dp[1] = (uint8_t)(tmp >> 16);
1033 dp[2] = (uint8_t)(tmp >> 8); 1013 dp[2] = (uint8_t)(tmp >> 8);
1034 dp[3] = (uint8_t)tmp; 1014 dp[3] = (uint8_t)tmp;
1035 dp += 4; 1015 dp += 4;
1036 } 1016 }
1037 for (xx = 0; xx < middleDwords; xx++) { 1017 for (int32_t xx = 0; xx < middleDwords; xx++) {
1038 tmp1 = (JBIG2_GETDWORD(sp) << shift2) | 1018 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift2) |
1039 ((JBIG2_GETDWORD(sp + 4)) >> shift1); 1019 ((JBIG2_GETDWORD(sp + 4)) >> shift1);
1040 tmp2 = JBIG2_GETDWORD(dp); 1020 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
1021 FX_DWORD tmp = 0;
1041 switch (op) { 1022 switch (op) {
1042 case JBIG2_COMPOSE_OR: 1023 case JBIG2_COMPOSE_OR:
1043 tmp = tmp1 | tmp2; 1024 tmp = tmp1 | tmp2;
1044 break; 1025 break;
1045 case JBIG2_COMPOSE_AND: 1026 case JBIG2_COMPOSE_AND:
1046 tmp = tmp1 & tmp2; 1027 tmp = tmp1 & tmp2;
1047 break; 1028 break;
1048 case JBIG2_COMPOSE_XOR: 1029 case JBIG2_COMPOSE_XOR:
1049 tmp = tmp1 ^ tmp2; 1030 tmp = tmp1 ^ tmp2;
1050 break; 1031 break;
1051 case JBIG2_COMPOSE_XNOR: 1032 case JBIG2_COMPOSE_XNOR:
1052 tmp = ~(tmp1 ^ tmp2); 1033 tmp = ~(tmp1 ^ tmp2);
1053 break; 1034 break;
1054 case JBIG2_COMPOSE_REPLACE: 1035 case JBIG2_COMPOSE_REPLACE:
1055 tmp = tmp1; 1036 tmp = tmp1;
1056 break; 1037 break;
1057 } 1038 }
1058 dp[0] = (uint8_t)(tmp >> 24); 1039 dp[0] = (uint8_t)(tmp >> 24);
1059 dp[1] = (uint8_t)(tmp >> 16); 1040 dp[1] = (uint8_t)(tmp >> 16);
1060 dp[2] = (uint8_t)(tmp >> 8); 1041 dp[2] = (uint8_t)(tmp >> 8);
1061 dp[3] = (uint8_t)tmp; 1042 dp[3] = (uint8_t)tmp;
1062 sp += 4; 1043 sp += 4;
1063 dp += 4; 1044 dp += 4;
1064 } 1045 }
1065 if (d2 != 0) { 1046 if (d2 != 0) {
1066 tmp1 = 1047 FX_DWORD tmp1 =
1067 (JBIG2_GETDWORD(sp) << shift2) | 1048 (JBIG2_GETDWORD(sp) << shift2) |
1068 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >> 1049 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >>
1069 shift1); 1050 shift1);
1070 tmp2 = JBIG2_GETDWORD(dp); 1051 FX_DWORD tmp2 = JBIG2_GETDWORD(dp);
1052 FX_DWORD tmp = 0;
1071 switch (op) { 1053 switch (op) {
1072 case JBIG2_COMPOSE_OR: 1054 case JBIG2_COMPOSE_OR:
1073 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 1055 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
1074 break; 1056 break;
1075 case JBIG2_COMPOSE_AND: 1057 case JBIG2_COMPOSE_AND:
1076 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 1058 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
1077 break; 1059 break;
1078 case JBIG2_COMPOSE_XOR: 1060 case JBIG2_COMPOSE_XOR:
1079 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 1061 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
1080 break; 1062 break;
1081 case JBIG2_COMPOSE_XNOR: 1063 case JBIG2_COMPOSE_XNOR:
1082 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR); 1064 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR);
1083 break; 1065 break;
1084 case JBIG2_COMPOSE_REPLACE: 1066 case JBIG2_COMPOSE_REPLACE:
1085 tmp = (tmp2 & ~maskR) | (tmp1 & maskR); 1067 tmp = (tmp2 & ~maskR) | (tmp1 & maskR);
1086 break; 1068 break;
1087 } 1069 }
1088 dp[0] = (uint8_t)(tmp >> 24); 1070 dp[0] = (uint8_t)(tmp >> 24);
1089 dp[1] = (uint8_t)(tmp >> 16); 1071 dp[1] = (uint8_t)(tmp >> 16);
1090 dp[2] = (uint8_t)(tmp >> 8); 1072 dp[2] = (uint8_t)(tmp >> 8);
1091 dp[3] = (uint8_t)tmp; 1073 dp[3] = (uint8_t)tmp;
1092 } 1074 }
1093 lineSrc += m_nStride; 1075 lineSrc += m_nStride;
1094 lineDst += pDst->m_nStride; 1076 lineDst += pDst->m_nStride;
1095 } 1077 }
1096 } 1078 }
1097 } 1079 }
1098 return 1; 1080 return 1;
1099 } 1081 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698