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

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

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
« no previous file with comments | « core/fxcodec/jbig2/JBig2_HuffmanTable.cpp ('k') | core/fxcodec/jbig2/JBig2_Page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fxcrt/include/fx_coordinates.h" 10 #include "core/fxcrt/include/fx_coordinates.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 int32_t y, 142 int32_t y,
143 CJBig2_Image* pSrc, 143 CJBig2_Image* pSrc,
144 JBig2ComposeOp op, 144 JBig2ComposeOp op,
145 const FX_RECT* pSrcRect) { 145 const FX_RECT* pSrcRect) {
146 if (!m_pData) { 146 if (!m_pData) {
147 return FALSE; 147 return FALSE;
148 } 148 }
149 return pSrc->composeTo(this, x, y, op, pSrcRect); 149 return pSrc->composeTo(this, x, y, op, pSrcRect);
150 } 150 }
151 #define JBIG2_GETDWORD(buf) \ 151 #define JBIG2_GETDWORD(buf) \
152 ((FX_DWORD)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3])) 152 ((uint32_t)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3]))
153 CJBig2_Image* CJBig2_Image::subImage(int32_t x, 153 CJBig2_Image* CJBig2_Image::subImage(int32_t x,
154 int32_t y, 154 int32_t y,
155 int32_t w, 155 int32_t w,
156 int32_t h) { 156 int32_t h) {
157 int32_t m, n, j; 157 int32_t m, n, j;
158 uint8_t *pLineSrc, *pLineDst; 158 uint8_t *pLineSrc, *pLineDst;
159 FX_DWORD wTmp; 159 uint32_t wTmp;
160 uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd; 160 uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd;
161 if (w == 0 || h == 0) { 161 if (w == 0 || h == 0) {
162 return NULL; 162 return NULL;
163 } 163 }
164 CJBig2_Image* pImage = new CJBig2_Image(w, h); 164 CJBig2_Image* pImage = new CJBig2_Image(w, h);
165 if (!m_pData) { 165 if (!m_pData) {
166 pImage->fill(0); 166 pImage->fill(0);
167 return pImage; 167 return pImage;
168 } 168 }
169 if (!pImage->m_pData) { 169 if (!pImage->m_pData) {
170 return pImage; 170 return pImage;
171 } 171 }
172 pLineSrc = m_pData + m_nStride * y; 172 pLineSrc = m_pData + m_nStride * y;
173 pLineDst = pImage->m_pData; 173 pLineDst = pImage->m_pData;
174 m = (x >> 5) << 2; 174 m = (x >> 5) << 2;
175 n = x & 31; 175 n = x & 31;
176 if (n == 0) { 176 if (n == 0) {
177 for (j = 0; j < h; j++) { 177 for (j = 0; j < h; j++) {
178 pSrc = pLineSrc + m; 178 pSrc = pLineSrc + m;
179 pSrcEnd = pLineSrc + m_nStride; 179 pSrcEnd = pLineSrc + m_nStride;
180 pDst = pLineDst; 180 pDst = pLineDst;
181 pDstEnd = pLineDst + pImage->m_nStride; 181 pDstEnd = pLineDst + pImage->m_nStride;
182 for (; pDst < pDstEnd; pSrc += 4, pDst += 4) { 182 for (; pDst < pDstEnd; pSrc += 4, pDst += 4) {
183 *((FX_DWORD*)pDst) = *((FX_DWORD*)pSrc); 183 *((uint32_t*)pDst) = *((uint32_t*)pSrc);
184 } 184 }
185 pLineSrc += m_nStride; 185 pLineSrc += m_nStride;
186 pLineDst += pImage->m_nStride; 186 pLineDst += pImage->m_nStride;
187 } 187 }
188 } else { 188 } else {
189 for (j = 0; j < h; j++) { 189 for (j = 0; j < h; j++) {
190 pSrc = pLineSrc + m; 190 pSrc = pLineSrc + m;
191 pSrcEnd = pLineSrc + m_nStride; 191 pSrcEnd = pLineSrc + m_nStride;
192 pDst = pLineDst; 192 pDst = pLineDst;
193 pDstEnd = pLineDst + pImage->m_nStride; 193 pDstEnd = pLineDst + pImage->m_nStride;
(...skipping 12 matching lines...) Expand all
206 pLineSrc += m_nStride; 206 pLineSrc += m_nStride;
207 pLineDst += pImage->m_nStride; 207 pLineDst += pImage->m_nStride;
208 } 208 }
209 } 209 }
210 return pImage; 210 return pImage;
211 } 211 }
212 void CJBig2_Image::expand(int32_t h, FX_BOOL v) { 212 void CJBig2_Image::expand(int32_t h, FX_BOOL v) {
213 if (!m_pData || h <= m_nHeight) { 213 if (!m_pData || h <= m_nHeight) {
214 return; 214 return;
215 } 215 }
216 FX_DWORD dwH = pdfium::base::checked_cast<FX_DWORD>(h); 216 uint32_t dwH = pdfium::base::checked_cast<uint32_t>(h);
217 FX_DWORD dwStride = pdfium::base::checked_cast<FX_DWORD>(m_nStride); 217 uint32_t dwStride = pdfium::base::checked_cast<uint32_t>(m_nStride);
218 FX_DWORD dwHeight = pdfium::base::checked_cast<FX_DWORD>(m_nHeight); 218 uint32_t dwHeight = pdfium::base::checked_cast<uint32_t>(m_nHeight);
219 FX_SAFE_DWORD safeMemSize = dwH; 219 FX_SAFE_DWORD safeMemSize = dwH;
220 safeMemSize *= dwStride; 220 safeMemSize *= dwStride;
221 if (!safeMemSize.IsValid()) { 221 if (!safeMemSize.IsValid()) {
222 return; 222 return;
223 } 223 }
224 // The guaranteed reallocated memory is to be < 4GB (unsigned int). 224 // The guaranteed reallocated memory is to be < 4GB (unsigned int).
225 m_pData = FX_Realloc(uint8_t, m_pData, safeMemSize.ValueOrDie()); 225 m_pData = FX_Realloc(uint8_t, m_pData, safeMemSize.ValueOrDie());
226 226
227 // The result of dwHeight * dwStride doesn't overflow after the 227 // The result of dwHeight * dwStride doesn't overflow after the
228 // checking of safeMemSize. 228 // checking of safeMemSize.
229 // The same as the result of (dwH - dwHeight) * dwStride) because 229 // The same as the result of (dwH - dwHeight) * dwStride) because
230 // dwH - dwHeight is always less than dwH(h) which is checked in 230 // dwH - dwHeight is always less than dwH(h) which is checked in
231 // the calculation of dwH * dwStride. 231 // the calculation of dwH * dwStride.
232 JBIG2_memset(m_pData + dwHeight * dwStride, v ? 0xff : 0, 232 JBIG2_memset(m_pData + dwHeight * dwStride, v ? 0xff : 0,
233 (dwH - dwHeight) * dwStride); 233 (dwH - dwHeight) * dwStride);
234 m_nHeight = h; 234 m_nHeight = h;
235 } 235 }
236 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst, 236 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
237 int32_t x, 237 int32_t x,
238 int32_t y, 238 int32_t y,
239 JBig2ComposeOp op) { 239 JBig2ComposeOp op) {
240 int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0, xd0 = 0, yd0 = 0, xd1 = 0, 240 int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0, xd0 = 0, yd0 = 0, xd1 = 0,
241 yd1 = 0, xx = 0, yy = 0, w = 0, h = 0, middleDwords = 0, lineLeft = 0; 241 yd1 = 0, xx = 0, yy = 0, w = 0, h = 0, middleDwords = 0, lineLeft = 0;
242 242
243 FX_DWORD s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 = 0, tmp = 0, 243 uint32_t s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 = 0, tmp = 0,
244 tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0; 244 tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0;
245 245
246 uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL; 246 uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL;
247 247
248 if (!m_pData) { 248 if (!m_pData) {
249 return FALSE; 249 return FALSE;
250 } 250 }
251 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { 251 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) {
252 return FALSE; 252 return FALSE;
253 } 253 }
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 int32_t maskL = 0xffffffff >> d1; 693 int32_t maskL = 0xffffffff >> d1;
694 int32_t maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32); 694 int32_t maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
695 int32_t maskM = maskL & maskR; 695 int32_t maskM = maskL & maskR;
696 uint8_t* lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride + 696 uint8_t* lineSrc = m_pData + (pSrcRect->top + ys0) * m_nStride +
697 (((xs0 + pSrcRect->left) >> 5) << 2); 697 (((xs0 + pSrcRect->left) >> 5) << 2);
698 int32_t lineLeft = m_nStride - ((xs0 >> 5) << 2); 698 int32_t lineLeft = m_nStride - ((xs0 >> 5) << 2);
699 uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2); 699 uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
700 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) { 700 if ((xd0 & ~31) == ((xd1 - 1) & ~31)) {
701 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) { 701 if ((xs0 & ~31) == ((xs1 - 1) & ~31)) {
702 if (s1 > d1) { 702 if (s1 > d1) {
703 FX_DWORD shift = s1 - d1; 703 uint32_t shift = s1 - d1;
704 for (int32_t yy = yd0; yy < yd1; yy++) { 704 for (int32_t yy = yd0; yy < yd1; yy++) {
705 FX_DWORD tmp1 = JBIG2_GETDWORD(lineSrc) << shift; 705 uint32_t tmp1 = JBIG2_GETDWORD(lineSrc) << shift;
706 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst); 706 uint32_t tmp2 = JBIG2_GETDWORD(lineDst);
707 FX_DWORD tmp = 0; 707 uint32_t tmp = 0;
708 switch (op) { 708 switch (op) {
709 case JBIG2_COMPOSE_OR: 709 case JBIG2_COMPOSE_OR:
710 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 710 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
711 break; 711 break;
712 case JBIG2_COMPOSE_AND: 712 case JBIG2_COMPOSE_AND:
713 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 713 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
714 break; 714 break;
715 case JBIG2_COMPOSE_XOR: 715 case JBIG2_COMPOSE_XOR:
716 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 716 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
717 break; 717 break;
718 case JBIG2_COMPOSE_XNOR: 718 case JBIG2_COMPOSE_XNOR:
719 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 719 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
720 break; 720 break;
721 case JBIG2_COMPOSE_REPLACE: 721 case JBIG2_COMPOSE_REPLACE:
722 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 722 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
723 break; 723 break;
724 } 724 }
725 lineDst[0] = (uint8_t)(tmp >> 24); 725 lineDst[0] = (uint8_t)(tmp >> 24);
726 lineDst[1] = (uint8_t)(tmp >> 16); 726 lineDst[1] = (uint8_t)(tmp >> 16);
727 lineDst[2] = (uint8_t)(tmp >> 8); 727 lineDst[2] = (uint8_t)(tmp >> 8);
728 lineDst[3] = (uint8_t)tmp; 728 lineDst[3] = (uint8_t)tmp;
729 lineSrc += m_nStride; 729 lineSrc += m_nStride;
730 lineDst += pDst->m_nStride; 730 lineDst += pDst->m_nStride;
731 } 731 }
732 } else { 732 } else {
733 FX_DWORD shift = d1 - s1; 733 uint32_t shift = d1 - s1;
734 for (int32_t yy = yd0; yy < yd1; yy++) { 734 for (int32_t yy = yd0; yy < yd1; yy++) {
735 FX_DWORD tmp1 = JBIG2_GETDWORD(lineSrc) >> shift; 735 uint32_t tmp1 = JBIG2_GETDWORD(lineSrc) >> shift;
736 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst); 736 uint32_t tmp2 = JBIG2_GETDWORD(lineDst);
737 FX_DWORD tmp = 0; 737 uint32_t tmp = 0;
738 switch (op) { 738 switch (op) {
739 case JBIG2_COMPOSE_OR: 739 case JBIG2_COMPOSE_OR:
740 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 740 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
741 break; 741 break;
742 case JBIG2_COMPOSE_AND: 742 case JBIG2_COMPOSE_AND:
743 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 743 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
744 break; 744 break;
745 case JBIG2_COMPOSE_XOR: 745 case JBIG2_COMPOSE_XOR:
746 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 746 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
747 break; 747 break;
748 case JBIG2_COMPOSE_XNOR: 748 case JBIG2_COMPOSE_XNOR:
749 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 749 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
750 break; 750 break;
751 case JBIG2_COMPOSE_REPLACE: 751 case JBIG2_COMPOSE_REPLACE:
752 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 752 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
753 break; 753 break;
754 } 754 }
755 lineDst[0] = (uint8_t)(tmp >> 24); 755 lineDst[0] = (uint8_t)(tmp >> 24);
756 lineDst[1] = (uint8_t)(tmp >> 16); 756 lineDst[1] = (uint8_t)(tmp >> 16);
757 lineDst[2] = (uint8_t)(tmp >> 8); 757 lineDst[2] = (uint8_t)(tmp >> 8);
758 lineDst[3] = (uint8_t)tmp; 758 lineDst[3] = (uint8_t)tmp;
759 lineSrc += m_nStride; 759 lineSrc += m_nStride;
760 lineDst += pDst->m_nStride; 760 lineDst += pDst->m_nStride;
761 } 761 }
762 } 762 }
763 } else { 763 } else {
764 FX_DWORD shift1 = s1 - d1; 764 uint32_t shift1 = s1 - d1;
765 FX_DWORD shift2 = 32 - shift1; 765 uint32_t shift2 = 32 - shift1;
766 for (int32_t yy = yd0; yy < yd1; yy++) { 766 for (int32_t yy = yd0; yy < yd1; yy++) {
767 FX_DWORD tmp1 = (JBIG2_GETDWORD(lineSrc) << shift1) | 767 uint32_t tmp1 = (JBIG2_GETDWORD(lineSrc) << shift1) |
768 (JBIG2_GETDWORD(lineSrc + 4) >> shift2); 768 (JBIG2_GETDWORD(lineSrc + 4) >> shift2);
769 FX_DWORD tmp2 = JBIG2_GETDWORD(lineDst); 769 uint32_t tmp2 = JBIG2_GETDWORD(lineDst);
770 FX_DWORD tmp = 0; 770 uint32_t tmp = 0;
771 switch (op) { 771 switch (op) {
772 case JBIG2_COMPOSE_OR: 772 case JBIG2_COMPOSE_OR:
773 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM); 773 tmp = (tmp2 & ~maskM) | ((tmp1 | tmp2) & maskM);
774 break; 774 break;
775 case JBIG2_COMPOSE_AND: 775 case JBIG2_COMPOSE_AND:
776 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM); 776 tmp = (tmp2 & ~maskM) | ((tmp1 & tmp2) & maskM);
777 break; 777 break;
778 case JBIG2_COMPOSE_XOR: 778 case JBIG2_COMPOSE_XOR:
779 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM); 779 tmp = (tmp2 & ~maskM) | ((tmp1 ^ tmp2) & maskM);
780 break; 780 break;
781 case JBIG2_COMPOSE_XNOR: 781 case JBIG2_COMPOSE_XNOR:
782 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM); 782 tmp = (tmp2 & ~maskM) | ((~(tmp1 ^ tmp2)) & maskM);
783 break; 783 break;
784 case JBIG2_COMPOSE_REPLACE: 784 case JBIG2_COMPOSE_REPLACE:
785 tmp = (tmp2 & ~maskM) | (tmp1 & maskM); 785 tmp = (tmp2 & ~maskM) | (tmp1 & maskM);
786 break; 786 break;
787 } 787 }
788 lineDst[0] = (uint8_t)(tmp >> 24); 788 lineDst[0] = (uint8_t)(tmp >> 24);
789 lineDst[1] = (uint8_t)(tmp >> 16); 789 lineDst[1] = (uint8_t)(tmp >> 16);
790 lineDst[2] = (uint8_t)(tmp >> 8); 790 lineDst[2] = (uint8_t)(tmp >> 8);
791 lineDst[3] = (uint8_t)tmp; 791 lineDst[3] = (uint8_t)tmp;
792 lineSrc += m_nStride; 792 lineSrc += m_nStride;
793 lineDst += pDst->m_nStride; 793 lineDst += pDst->m_nStride;
794 } 794 }
795 } 795 }
796 } else { 796 } else {
797 if (s1 > d1) { 797 if (s1 > d1) {
798 FX_DWORD shift1 = s1 - d1; 798 uint32_t shift1 = s1 - d1;
799 FX_DWORD shift2 = 32 - shift1; 799 uint32_t shift2 = 32 - shift1;
800 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 800 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
801 for (int32_t yy = yd0; yy < yd1; yy++) { 801 for (int32_t yy = yd0; yy < yd1; yy++) {
802 uint8_t* sp = lineSrc; 802 uint8_t* sp = lineSrc;
803 uint8_t* dp = lineDst; 803 uint8_t* dp = lineDst;
804 if (d1 != 0) { 804 if (d1 != 0) {
805 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift1) | 805 uint32_t tmp1 = (JBIG2_GETDWORD(sp) << shift1) |
806 (JBIG2_GETDWORD(sp + 4) >> shift2); 806 (JBIG2_GETDWORD(sp + 4) >> shift2);
807 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 807 uint32_t tmp2 = JBIG2_GETDWORD(dp);
808 FX_DWORD tmp = 0; 808 uint32_t tmp = 0;
809 switch (op) { 809 switch (op) {
810 case JBIG2_COMPOSE_OR: 810 case JBIG2_COMPOSE_OR:
811 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 811 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
812 break; 812 break;
813 case JBIG2_COMPOSE_AND: 813 case JBIG2_COMPOSE_AND:
814 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 814 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
815 break; 815 break;
816 case JBIG2_COMPOSE_XOR: 816 case JBIG2_COMPOSE_XOR:
817 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 817 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
818 break; 818 break;
819 case JBIG2_COMPOSE_XNOR: 819 case JBIG2_COMPOSE_XNOR:
820 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 820 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
821 break; 821 break;
822 case JBIG2_COMPOSE_REPLACE: 822 case JBIG2_COMPOSE_REPLACE:
823 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 823 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
824 break; 824 break;
825 } 825 }
826 dp[0] = (uint8_t)(tmp >> 24); 826 dp[0] = (uint8_t)(tmp >> 24);
827 dp[1] = (uint8_t)(tmp >> 16); 827 dp[1] = (uint8_t)(tmp >> 16);
828 dp[2] = (uint8_t)(tmp >> 8); 828 dp[2] = (uint8_t)(tmp >> 8);
829 dp[3] = (uint8_t)tmp; 829 dp[3] = (uint8_t)tmp;
830 sp += 4; 830 sp += 4;
831 dp += 4; 831 dp += 4;
832 } 832 }
833 for (int32_t xx = 0; xx < middleDwords; xx++) { 833 for (int32_t xx = 0; xx < middleDwords; xx++) {
834 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift1) | 834 uint32_t tmp1 = (JBIG2_GETDWORD(sp) << shift1) |
835 (JBIG2_GETDWORD(sp + 4) >> shift2); 835 (JBIG2_GETDWORD(sp + 4) >> shift2);
836 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 836 uint32_t tmp2 = JBIG2_GETDWORD(dp);
837 FX_DWORD tmp = 0; 837 uint32_t tmp = 0;
838 switch (op) { 838 switch (op) {
839 case JBIG2_COMPOSE_OR: 839 case JBIG2_COMPOSE_OR:
840 tmp = tmp1 | tmp2; 840 tmp = tmp1 | tmp2;
841 break; 841 break;
842 case JBIG2_COMPOSE_AND: 842 case JBIG2_COMPOSE_AND:
843 tmp = tmp1 & tmp2; 843 tmp = tmp1 & tmp2;
844 break; 844 break;
845 case JBIG2_COMPOSE_XOR: 845 case JBIG2_COMPOSE_XOR:
846 tmp = tmp1 ^ tmp2; 846 tmp = tmp1 ^ tmp2;
847 break; 847 break;
848 case JBIG2_COMPOSE_XNOR: 848 case JBIG2_COMPOSE_XNOR:
849 tmp = ~(tmp1 ^ tmp2); 849 tmp = ~(tmp1 ^ tmp2);
850 break; 850 break;
851 case JBIG2_COMPOSE_REPLACE: 851 case JBIG2_COMPOSE_REPLACE:
852 tmp = tmp1; 852 tmp = tmp1;
853 break; 853 break;
854 } 854 }
855 dp[0] = (uint8_t)(tmp >> 24); 855 dp[0] = (uint8_t)(tmp >> 24);
856 dp[1] = (uint8_t)(tmp >> 16); 856 dp[1] = (uint8_t)(tmp >> 16);
857 dp[2] = (uint8_t)(tmp >> 8); 857 dp[2] = (uint8_t)(tmp >> 8);
858 dp[3] = (uint8_t)tmp; 858 dp[3] = (uint8_t)tmp;
859 sp += 4; 859 sp += 4;
860 dp += 4; 860 dp += 4;
861 } 861 }
862 if (d2 != 0) { 862 if (d2 != 0) {
863 FX_DWORD tmp1 = 863 uint32_t tmp1 =
864 (JBIG2_GETDWORD(sp) << shift1) | 864 (JBIG2_GETDWORD(sp) << shift1) |
865 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >> 865 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >>
866 shift2); 866 shift2);
867 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 867 uint32_t tmp2 = JBIG2_GETDWORD(dp);
868 FX_DWORD tmp = 0; 868 uint32_t tmp = 0;
869 switch (op) { 869 switch (op) {
870 case JBIG2_COMPOSE_OR: 870 case JBIG2_COMPOSE_OR:
871 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 871 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
872 break; 872 break;
873 case JBIG2_COMPOSE_AND: 873 case JBIG2_COMPOSE_AND:
874 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 874 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
875 break; 875 break;
876 case JBIG2_COMPOSE_XOR: 876 case JBIG2_COMPOSE_XOR:
877 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 877 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
878 break; 878 break;
(...skipping 11 matching lines...) Expand all
890 } 890 }
891 lineSrc += m_nStride; 891 lineSrc += m_nStride;
892 lineDst += pDst->m_nStride; 892 lineDst += pDst->m_nStride;
893 } 893 }
894 } else if (s1 == d1) { 894 } else if (s1 == d1) {
895 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 895 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
896 for (int32_t yy = yd0; yy < yd1; yy++) { 896 for (int32_t yy = yd0; yy < yd1; yy++) {
897 uint8_t* sp = lineSrc; 897 uint8_t* sp = lineSrc;
898 uint8_t* dp = lineDst; 898 uint8_t* dp = lineDst;
899 if (d1 != 0) { 899 if (d1 != 0) {
900 FX_DWORD tmp1 = JBIG2_GETDWORD(sp); 900 uint32_t tmp1 = JBIG2_GETDWORD(sp);
901 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 901 uint32_t tmp2 = JBIG2_GETDWORD(dp);
902 FX_DWORD tmp = 0; 902 uint32_t tmp = 0;
903 switch (op) { 903 switch (op) {
904 case JBIG2_COMPOSE_OR: 904 case JBIG2_COMPOSE_OR:
905 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 905 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
906 break; 906 break;
907 case JBIG2_COMPOSE_AND: 907 case JBIG2_COMPOSE_AND:
908 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 908 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
909 break; 909 break;
910 case JBIG2_COMPOSE_XOR: 910 case JBIG2_COMPOSE_XOR:
911 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 911 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
912 break; 912 break;
913 case JBIG2_COMPOSE_XNOR: 913 case JBIG2_COMPOSE_XNOR:
914 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 914 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
915 break; 915 break;
916 case JBIG2_COMPOSE_REPLACE: 916 case JBIG2_COMPOSE_REPLACE:
917 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 917 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
918 break; 918 break;
919 } 919 }
920 dp[0] = (uint8_t)(tmp >> 24); 920 dp[0] = (uint8_t)(tmp >> 24);
921 dp[1] = (uint8_t)(tmp >> 16); 921 dp[1] = (uint8_t)(tmp >> 16);
922 dp[2] = (uint8_t)(tmp >> 8); 922 dp[2] = (uint8_t)(tmp >> 8);
923 dp[3] = (uint8_t)tmp; 923 dp[3] = (uint8_t)tmp;
924 sp += 4; 924 sp += 4;
925 dp += 4; 925 dp += 4;
926 } 926 }
927 for (int32_t xx = 0; xx < middleDwords; xx++) { 927 for (int32_t xx = 0; xx < middleDwords; xx++) {
928 FX_DWORD tmp1 = JBIG2_GETDWORD(sp); 928 uint32_t tmp1 = JBIG2_GETDWORD(sp);
929 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 929 uint32_t tmp2 = JBIG2_GETDWORD(dp);
930 FX_DWORD tmp = 0; 930 uint32_t tmp = 0;
931 switch (op) { 931 switch (op) {
932 case JBIG2_COMPOSE_OR: 932 case JBIG2_COMPOSE_OR:
933 tmp = tmp1 | tmp2; 933 tmp = tmp1 | tmp2;
934 break; 934 break;
935 case JBIG2_COMPOSE_AND: 935 case JBIG2_COMPOSE_AND:
936 tmp = tmp1 & tmp2; 936 tmp = tmp1 & tmp2;
937 break; 937 break;
938 case JBIG2_COMPOSE_XOR: 938 case JBIG2_COMPOSE_XOR:
939 tmp = tmp1 ^ tmp2; 939 tmp = tmp1 ^ tmp2;
940 break; 940 break;
941 case JBIG2_COMPOSE_XNOR: 941 case JBIG2_COMPOSE_XNOR:
942 tmp = ~(tmp1 ^ tmp2); 942 tmp = ~(tmp1 ^ tmp2);
943 break; 943 break;
944 case JBIG2_COMPOSE_REPLACE: 944 case JBIG2_COMPOSE_REPLACE:
945 tmp = tmp1; 945 tmp = tmp1;
946 break; 946 break;
947 } 947 }
948 dp[0] = (uint8_t)(tmp >> 24); 948 dp[0] = (uint8_t)(tmp >> 24);
949 dp[1] = (uint8_t)(tmp >> 16); 949 dp[1] = (uint8_t)(tmp >> 16);
950 dp[2] = (uint8_t)(tmp >> 8); 950 dp[2] = (uint8_t)(tmp >> 8);
951 dp[3] = (uint8_t)tmp; 951 dp[3] = (uint8_t)tmp;
952 sp += 4; 952 sp += 4;
953 dp += 4; 953 dp += 4;
954 } 954 }
955 if (d2 != 0) { 955 if (d2 != 0) {
956 FX_DWORD tmp1 = JBIG2_GETDWORD(sp); 956 uint32_t tmp1 = JBIG2_GETDWORD(sp);
957 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 957 uint32_t tmp2 = JBIG2_GETDWORD(dp);
958 FX_DWORD tmp = 0; 958 uint32_t tmp = 0;
959 switch (op) { 959 switch (op) {
960 case JBIG2_COMPOSE_OR: 960 case JBIG2_COMPOSE_OR:
961 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 961 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
962 break; 962 break;
963 case JBIG2_COMPOSE_AND: 963 case JBIG2_COMPOSE_AND:
964 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 964 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
965 break; 965 break;
966 case JBIG2_COMPOSE_XOR: 966 case JBIG2_COMPOSE_XOR:
967 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 967 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
968 break; 968 break;
969 case JBIG2_COMPOSE_XNOR: 969 case JBIG2_COMPOSE_XNOR:
970 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR); 970 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR);
971 break; 971 break;
972 case JBIG2_COMPOSE_REPLACE: 972 case JBIG2_COMPOSE_REPLACE:
973 tmp = (tmp2 & ~maskR) | (tmp1 & maskR); 973 tmp = (tmp2 & ~maskR) | (tmp1 & maskR);
974 break; 974 break;
975 } 975 }
976 dp[0] = (uint8_t)(tmp >> 24); 976 dp[0] = (uint8_t)(tmp >> 24);
977 dp[1] = (uint8_t)(tmp >> 16); 977 dp[1] = (uint8_t)(tmp >> 16);
978 dp[2] = (uint8_t)(tmp >> 8); 978 dp[2] = (uint8_t)(tmp >> 8);
979 dp[3] = (uint8_t)tmp; 979 dp[3] = (uint8_t)tmp;
980 } 980 }
981 lineSrc += m_nStride; 981 lineSrc += m_nStride;
982 lineDst += pDst->m_nStride; 982 lineDst += pDst->m_nStride;
983 } 983 }
984 } else { 984 } else {
985 FX_DWORD shift1 = d1 - s1; 985 uint32_t shift1 = d1 - s1;
986 FX_DWORD shift2 = 32 - shift1; 986 uint32_t shift2 = 32 - shift1;
987 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5); 987 int32_t middleDwords = (xd1 >> 5) - ((xd0 + 31) >> 5);
988 for (int32_t yy = yd0; yy < yd1; yy++) { 988 for (int32_t yy = yd0; yy < yd1; yy++) {
989 uint8_t* sp = lineSrc; 989 uint8_t* sp = lineSrc;
990 uint8_t* dp = lineDst; 990 uint8_t* dp = lineDst;
991 if (d1 != 0) { 991 if (d1 != 0) {
992 FX_DWORD tmp1 = JBIG2_GETDWORD(sp) >> shift1; 992 uint32_t tmp1 = JBIG2_GETDWORD(sp) >> shift1;
993 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 993 uint32_t tmp2 = JBIG2_GETDWORD(dp);
994 FX_DWORD tmp = 0; 994 uint32_t tmp = 0;
995 switch (op) { 995 switch (op) {
996 case JBIG2_COMPOSE_OR: 996 case JBIG2_COMPOSE_OR:
997 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL); 997 tmp = (tmp2 & ~maskL) | ((tmp1 | tmp2) & maskL);
998 break; 998 break;
999 case JBIG2_COMPOSE_AND: 999 case JBIG2_COMPOSE_AND:
1000 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL); 1000 tmp = (tmp2 & ~maskL) | ((tmp1 & tmp2) & maskL);
1001 break; 1001 break;
1002 case JBIG2_COMPOSE_XOR: 1002 case JBIG2_COMPOSE_XOR:
1003 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL); 1003 tmp = (tmp2 & ~maskL) | ((tmp1 ^ tmp2) & maskL);
1004 break; 1004 break;
1005 case JBIG2_COMPOSE_XNOR: 1005 case JBIG2_COMPOSE_XNOR:
1006 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL); 1006 tmp = (tmp2 & ~maskL) | ((~(tmp1 ^ tmp2)) & maskL);
1007 break; 1007 break;
1008 case JBIG2_COMPOSE_REPLACE: 1008 case JBIG2_COMPOSE_REPLACE:
1009 tmp = (tmp2 & ~maskL) | (tmp1 & maskL); 1009 tmp = (tmp2 & ~maskL) | (tmp1 & maskL);
1010 break; 1010 break;
1011 } 1011 }
1012 dp[0] = (uint8_t)(tmp >> 24); 1012 dp[0] = (uint8_t)(tmp >> 24);
1013 dp[1] = (uint8_t)(tmp >> 16); 1013 dp[1] = (uint8_t)(tmp >> 16);
1014 dp[2] = (uint8_t)(tmp >> 8); 1014 dp[2] = (uint8_t)(tmp >> 8);
1015 dp[3] = (uint8_t)tmp; 1015 dp[3] = (uint8_t)tmp;
1016 dp += 4; 1016 dp += 4;
1017 } 1017 }
1018 for (int32_t xx = 0; xx < middleDwords; xx++) { 1018 for (int32_t xx = 0; xx < middleDwords; xx++) {
1019 FX_DWORD tmp1 = (JBIG2_GETDWORD(sp) << shift2) | 1019 uint32_t tmp1 = (JBIG2_GETDWORD(sp) << shift2) |
1020 ((JBIG2_GETDWORD(sp + 4)) >> shift1); 1020 ((JBIG2_GETDWORD(sp + 4)) >> shift1);
1021 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 1021 uint32_t tmp2 = JBIG2_GETDWORD(dp);
1022 FX_DWORD tmp = 0; 1022 uint32_t tmp = 0;
1023 switch (op) { 1023 switch (op) {
1024 case JBIG2_COMPOSE_OR: 1024 case JBIG2_COMPOSE_OR:
1025 tmp = tmp1 | tmp2; 1025 tmp = tmp1 | tmp2;
1026 break; 1026 break;
1027 case JBIG2_COMPOSE_AND: 1027 case JBIG2_COMPOSE_AND:
1028 tmp = tmp1 & tmp2; 1028 tmp = tmp1 & tmp2;
1029 break; 1029 break;
1030 case JBIG2_COMPOSE_XOR: 1030 case JBIG2_COMPOSE_XOR:
1031 tmp = tmp1 ^ tmp2; 1031 tmp = tmp1 ^ tmp2;
1032 break; 1032 break;
1033 case JBIG2_COMPOSE_XNOR: 1033 case JBIG2_COMPOSE_XNOR:
1034 tmp = ~(tmp1 ^ tmp2); 1034 tmp = ~(tmp1 ^ tmp2);
1035 break; 1035 break;
1036 case JBIG2_COMPOSE_REPLACE: 1036 case JBIG2_COMPOSE_REPLACE:
1037 tmp = tmp1; 1037 tmp = tmp1;
1038 break; 1038 break;
1039 } 1039 }
1040 dp[0] = (uint8_t)(tmp >> 24); 1040 dp[0] = (uint8_t)(tmp >> 24);
1041 dp[1] = (uint8_t)(tmp >> 16); 1041 dp[1] = (uint8_t)(tmp >> 16);
1042 dp[2] = (uint8_t)(tmp >> 8); 1042 dp[2] = (uint8_t)(tmp >> 8);
1043 dp[3] = (uint8_t)tmp; 1043 dp[3] = (uint8_t)tmp;
1044 sp += 4; 1044 sp += 4;
1045 dp += 4; 1045 dp += 4;
1046 } 1046 }
1047 if (d2 != 0) { 1047 if (d2 != 0) {
1048 FX_DWORD tmp1 = 1048 uint32_t tmp1 =
1049 (JBIG2_GETDWORD(sp) << shift2) | 1049 (JBIG2_GETDWORD(sp) << shift2) |
1050 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >> 1050 (((sp + 4) < lineSrc + lineLeft ? JBIG2_GETDWORD(sp + 4) : 0) >>
1051 shift1); 1051 shift1);
1052 FX_DWORD tmp2 = JBIG2_GETDWORD(dp); 1052 uint32_t tmp2 = JBIG2_GETDWORD(dp);
1053 FX_DWORD tmp = 0; 1053 uint32_t tmp = 0;
1054 switch (op) { 1054 switch (op) {
1055 case JBIG2_COMPOSE_OR: 1055 case JBIG2_COMPOSE_OR:
1056 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR); 1056 tmp = (tmp2 & ~maskR) | ((tmp1 | tmp2) & maskR);
1057 break; 1057 break;
1058 case JBIG2_COMPOSE_AND: 1058 case JBIG2_COMPOSE_AND:
1059 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR); 1059 tmp = (tmp2 & ~maskR) | ((tmp1 & tmp2) & maskR);
1060 break; 1060 break;
1061 case JBIG2_COMPOSE_XOR: 1061 case JBIG2_COMPOSE_XOR:
1062 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR); 1062 tmp = (tmp2 & ~maskR) | ((tmp1 ^ tmp2) & maskR);
1063 break; 1063 break;
1064 case JBIG2_COMPOSE_XNOR: 1064 case JBIG2_COMPOSE_XNOR:
1065 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR); 1065 tmp = (tmp2 & ~maskR) | ((~(tmp1 ^ tmp2)) & maskR);
1066 break; 1066 break;
1067 case JBIG2_COMPOSE_REPLACE: 1067 case JBIG2_COMPOSE_REPLACE:
1068 tmp = (tmp2 & ~maskR) | (tmp1 & maskR); 1068 tmp = (tmp2 & ~maskR) | (tmp1 & maskR);
1069 break; 1069 break;
1070 } 1070 }
1071 dp[0] = (uint8_t)(tmp >> 24); 1071 dp[0] = (uint8_t)(tmp >> 24);
1072 dp[1] = (uint8_t)(tmp >> 16); 1072 dp[1] = (uint8_t)(tmp >> 16);
1073 dp[2] = (uint8_t)(tmp >> 8); 1073 dp[2] = (uint8_t)(tmp >> 8);
1074 dp[3] = (uint8_t)tmp; 1074 dp[3] = (uint8_t)tmp;
1075 } 1075 }
1076 lineSrc += m_nStride; 1076 lineSrc += m_nStride;
1077 lineDst += pDst->m_nStride; 1077 lineDst += pDst->m_nStride;
1078 } 1078 }
1079 } 1079 }
1080 } 1080 }
1081 return 1; 1081 return 1;
1082 } 1082 }
OLDNEW
« no previous file with comments | « core/fxcodec/jbig2/JBig2_HuffmanTable.cpp ('k') | core/fxcodec/jbig2/JBig2_Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698