| OLD | NEW |
| 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 "../../../include/fxcrt/fx_coordinates.h" | 9 #include "../../../include/fxcrt/fx_coordinates.h" |
| 10 #include "../../../include/fxcrt/fx_safe_types.h" | 10 #include "../../../include/fxcrt/fx_safe_types.h" |
| 11 #include "JBig2_Image.h" | 11 #include "JBig2_Image.h" |
| 12 | 12 |
| 13 CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) | 13 CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) |
| 14 { | 14 { |
| 15 m_nWidth = w; | 15 m_nWidth = w; |
| 16 m_nHeight = h; | 16 m_nHeight = h; |
| 17 if (m_nWidth <= 0 || m_nHeight <= 0 || m_nWidth > INT_MAX - 31) { | 17 if (m_nWidth <= 0 || m_nHeight <= 0 || m_nWidth > INT_MAX - 31) { |
| 18 m_pData = NULL; | 18 m_pData = NULL; |
| 19 m_bNeedFree = FALSE; | 19 m_bNeedFree = false; |
| 20 return; | 20 return; |
| 21 } | 21 } |
| 22 m_nStride = ((w + 31) >> 5) << 2; | 22 m_nStride = ((w + 31) >> 5) << 2; |
| 23 if (m_nStride * m_nHeight > 0 && 104857600 / (int)m_nStride > m_nHeight) { | 23 if (m_nStride * m_nHeight > 0 && 104857600 / (int)m_nStride > m_nHeight) { |
| 24 m_pData = (uint8_t *)m_pModule->JBig2_Malloc2(m_nStride, m_nHeight); | 24 m_pData = (uint8_t *)m_pModule->JBig2_Malloc2(m_nStride, m_nHeight); |
| 25 } else { | 25 } else { |
| 26 m_pData = NULL; | 26 m_pData = NULL; |
| 27 } | 27 } |
| 28 m_bNeedFree = TRUE; | 28 m_bNeedFree = true; |
| 29 } | 29 } |
| 30 CJBig2_Image::CJBig2_Image(int32_t w, int32_t h, int32_t stride, uint8_t*pBuf) | 30 CJBig2_Image::CJBig2_Image(int32_t w, int32_t h, int32_t stride, uint8_t*pBuf) |
| 31 { | 31 { |
| 32 m_nWidth = w; | 32 m_nWidth = w; |
| 33 m_nHeight = h; | 33 m_nHeight = h; |
| 34 m_nStride = stride; | 34 m_nStride = stride; |
| 35 m_pData = pBuf; | 35 m_pData = pBuf; |
| 36 m_bNeedFree = FALSE; | 36 m_bNeedFree = false; |
| 37 } | 37 } |
| 38 CJBig2_Image::CJBig2_Image(CJBig2_Image &im) | 38 CJBig2_Image::CJBig2_Image(CJBig2_Image &im) |
| 39 { | 39 { |
| 40 m_pModule = im.m_pModule; | 40 m_pModule = im.m_pModule; |
| 41 m_nWidth = im.m_nWidth; | 41 m_nWidth = im.m_nWidth; |
| 42 m_nHeight = im.m_nHeight; | 42 m_nHeight = im.m_nHeight; |
| 43 m_nStride = im.m_nStride; | 43 m_nStride = im.m_nStride; |
| 44 if (im.m_pData) { | 44 if (im.m_pData) { |
| 45 m_pData = (uint8_t*)m_pModule->JBig2_Malloc2(m_nStride, m_nHeight); | 45 m_pData = (uint8_t*)m_pModule->JBig2_Malloc2(m_nStride, m_nHeight); |
| 46 JBIG2_memcpy(m_pData, im.m_pData, m_nStride * m_nHeight); | 46 JBIG2_memcpy(m_pData, im.m_pData, m_nStride * m_nHeight); |
| 47 } else { | 47 } else { |
| 48 m_pData = NULL; | 48 m_pData = NULL; |
| 49 } | 49 } |
| 50 m_bNeedFree = TRUE; | 50 m_bNeedFree = true; |
| 51 } | 51 } |
| 52 CJBig2_Image::~CJBig2_Image() | 52 CJBig2_Image::~CJBig2_Image() |
| 53 { | 53 { |
| 54 if(m_bNeedFree && m_pData) { | 54 if(m_bNeedFree && m_pData) { |
| 55 m_pModule->JBig2_Free(m_pData); | 55 m_pModule->JBig2_Free(m_pData); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 FX_BOOL CJBig2_Image::getPixel(int32_t x, int32_t y) | 58 bool CJBig2_Image::getPixel(int32_t x, int32_t y) |
| 59 { | 59 { |
| 60 if (!m_pData) { | 60 if (!m_pData) { |
| 61 return 0; | 61 return 0; |
| 62 } | 62 } |
| 63 int32_t m, n; | 63 int32_t m, n; |
| 64 if(x < 0 || x >= m_nWidth) { | 64 if(x < 0 || x >= m_nWidth) { |
| 65 return 0; | 65 return 0; |
| 66 } | 66 } |
| 67 if(y < 0 || y >= m_nHeight) { | 67 if(y < 0 || y >= m_nHeight) { |
| 68 return 0; | 68 return 0; |
| 69 } | 69 } |
| 70 m = y * m_nStride + (x >> 3); | 70 m = y * m_nStride + (x >> 3); |
| 71 n = x & 7; | 71 n = x & 7; |
| 72 return ((m_pData[m] >> (7 - n)) & 1); | 72 return ((m_pData[m] >> (7 - n)) & 1); |
| 73 } | 73 } |
| 74 | 74 |
| 75 int32_t CJBig2_Image::setPixel(int32_t x, int32_t y, FX_BOOL v) | 75 int32_t CJBig2_Image::setPixel(int32_t x, int32_t y, bool v) |
| 76 { | 76 { |
| 77 if (!m_pData) { | 77 if (!m_pData) { |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 int32_t m, n; | 80 int32_t m, n; |
| 81 if(x < 0 || x >= m_nWidth) { | 81 if(x < 0 || x >= m_nWidth) { |
| 82 return 0; | 82 return 0; |
| 83 } | 83 } |
| 84 if(y < 0 || y >= m_nHeight) { | 84 if(y < 0 || y >= m_nHeight) { |
| 85 return 0; | 85 return 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 { | 97 { |
| 98 if (!m_pData) { | 98 if (!m_pData) { |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 if(hFrom < 0 || hFrom >= m_nHeight) { | 101 if(hFrom < 0 || hFrom >= m_nHeight) { |
| 102 JBIG2_memset(m_pData + hTo * m_nStride, 0, m_nStride); | 102 JBIG2_memset(m_pData + hTo * m_nStride, 0, m_nStride); |
| 103 } else { | 103 } else { |
| 104 JBIG2_memcpy(m_pData + hTo * m_nStride, m_pData + hFrom * m_nStride, m_n
Stride); | 104 JBIG2_memcpy(m_pData + hTo * m_nStride, m_pData + hFrom * m_nStride, m_n
Stride); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 void CJBig2_Image::fill(FX_BOOL v) | 107 void CJBig2_Image::fill(bool v) |
| 108 { | 108 { |
| 109 if (!m_pData) { | 109 if (!m_pData) { |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 JBIG2_memset(m_pData, v ? 0xff : 0, m_nStride * m_nHeight); | 112 JBIG2_memset(m_pData, v ? 0xff : 0, m_nStride * m_nHeight); |
| 113 } | 113 } |
| 114 FX_BOOL CJBig2_Image::composeTo(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2C
omposeOp op) | 114 bool CJBig2_Image::composeTo(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2Comp
oseOp op) |
| 115 { | 115 { |
| 116 if (!m_pData) { | 116 if (!m_pData) { |
| 117 return FALSE; | 117 return false; |
| 118 } | 118 } |
| 119 return composeTo_opt2(pDst, x, y, op); | 119 return composeTo_opt2(pDst, x, y, op); |
| 120 } | 120 } |
| 121 FX_BOOL CJBig2_Image::composeTo(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2C
omposeOp op, const FX_RECT* pSrcRect) | 121 bool CJBig2_Image::composeTo(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2Comp
oseOp op, const FX_RECT* pSrcRect) |
| 122 { | 122 { |
| 123 if (!m_pData) { | 123 if (!m_pData) { |
| 124 return FALSE; | 124 return false; |
| 125 } | 125 } |
| 126 if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) { | 126 if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) { |
| 127 return composeTo_opt2(pDst, x, y, op); | 127 return composeTo_opt2(pDst, x, y, op); |
| 128 } | 128 } |
| 129 return composeTo_opt2(pDst, x, y, op, pSrcRect); | 129 return composeTo_opt2(pDst, x, y, op, pSrcRect); |
| 130 } | 130 } |
| 131 FX_BOOL CJBig2_Image::composeTo_unopt(CJBig2_Image *pDst, int32_t x, int32_t y,
JBig2ComposeOp op) | 131 bool CJBig2_Image::composeTo_unopt(CJBig2_Image *pDst, int32_t x, int32_t y, JBi
g2ComposeOp op) |
| 132 { | 132 { |
| 133 int32_t w, h, dx, dy; | 133 int32_t w, h, dx, dy; |
| 134 int32_t i, j; | 134 int32_t i, j; |
| 135 w = m_nWidth; | 135 w = m_nWidth; |
| 136 h = m_nHeight; | 136 h = m_nHeight; |
| 137 dx = dy = 0; | 137 dx = dy = 0; |
| 138 if(x < 0) { | 138 if(x < 0) { |
| 139 dx += -x; | 139 dx += -x; |
| 140 w -= -x; | 140 w -= -x; |
| 141 x = 0; | 141 x = 0; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 break; | 186 break; |
| 187 case JBIG2_COMPOSE_REPLACE: | 187 case JBIG2_COMPOSE_REPLACE: |
| 188 for(j = 0; j < h; j++) { | 188 for(j = 0; j < h; j++) { |
| 189 for(i = 0; i < w; i++) { | 189 for(i = 0; i < w; i++) { |
| 190 pDst->setPixel(x + i, y + j, getPixel(i + dx, j + dy)); | 190 pDst->setPixel(x + i, y + j, getPixel(i + dx, j + dy)); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 break; | 193 break; |
| 194 } | 194 } |
| 195 return TRUE; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 FX_BOOL CJBig2_Image::composeTo_opt(CJBig2_Image *pDst, int32_t x, int32_t y, JB
ig2ComposeOp op) | 198 bool CJBig2_Image::composeTo_opt(CJBig2_Image *pDst, int32_t x, int32_t y, JBig2
ComposeOp op) |
| 199 { | 199 { |
| 200 int32_t x0, x1, y0, y1, xx, yy; | 200 int32_t x0, x1, y0, y1, xx, yy; |
| 201 uint8_t *pLineSrc, *pLineDst, *srcPtr, *destPtr; | 201 uint8_t *pLineSrc, *pLineDst, *srcPtr, *destPtr; |
| 202 FX_DWORD src0, src1, src, dest, s1, s2, m1, m2, m3; | 202 FX_DWORD src0, src1, src, dest, s1, s2, m1, m2, m3; |
| 203 FX_BOOL oneByte; | 203 bool oneByte; |
| 204 if (!m_pData) { | 204 if (!m_pData) { |
| 205 return FALSE; | 205 return false; |
| 206 } | 206 } |
| 207 if (y < 0) { | 207 if (y < 0) { |
| 208 y0 = -y; | 208 y0 = -y; |
| 209 } else { | 209 } else { |
| 210 y0 = 0; | 210 y0 = 0; |
| 211 } | 211 } |
| 212 if (y + m_nHeight > pDst->m_nHeight) { | 212 if (y + m_nHeight > pDst->m_nHeight) { |
| 213 y1 = pDst->m_nHeight - y; | 213 y1 = pDst->m_nHeight - y; |
| 214 } else { | 214 } else { |
| 215 y1 = m_nHeight; | 215 y1 = m_nHeight; |
| 216 } | 216 } |
| 217 if (y0 >= y1) { | 217 if (y0 >= y1) { |
| 218 return FALSE; | 218 return false; |
| 219 } | 219 } |
| 220 if (x >= 0) { | 220 if (x >= 0) { |
| 221 x0 = x & ~7; | 221 x0 = x & ~7; |
| 222 } else { | 222 } else { |
| 223 x0 = 0; | 223 x0 = 0; |
| 224 } | 224 } |
| 225 x1 = x + m_nWidth; | 225 x1 = x + m_nWidth; |
| 226 if (x1 > pDst->m_nWidth) { | 226 if (x1 > pDst->m_nWidth) { |
| 227 x1 = pDst->m_nWidth; | 227 x1 = pDst->m_nWidth; |
| 228 } | 228 } |
| 229 if (x0 >= x1) { | 229 if (x0 >= x1) { |
| 230 return FALSE; | 230 return false; |
| 231 } | 231 } |
| 232 s1 = x & 7; | 232 s1 = x & 7; |
| 233 s2 = 8 - s1; | 233 s2 = 8 - s1; |
| 234 m1 = 0xff >> (x1 & 7); | 234 m1 = 0xff >> (x1 & 7); |
| 235 m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); | 235 m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); |
| 236 m3 = (0xff >> s1) & m2; | 236 m3 = (0xff >> s1) & m2; |
| 237 oneByte = x0 == ((x1 - 1) & ~7); | 237 oneByte = x0 == ((x1 - 1) & ~7); |
| 238 pLineDst = pDst->m_pData + y * pDst->m_nStride; | 238 pLineDst = pDst->m_pData + y * pDst->m_nStride; |
| 239 pLineSrc = m_pData + y0 * m_nStride; | 239 pLineSrc = m_pData + y0 * m_nStride; |
| 240 if(oneByte) { | 240 if(oneByte) { |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 dest = (src & m2) | (dest & m1); | 672 dest = (src & m2) | (dest & m1); |
| 673 *destPtr = (uint8_t)dest; | 673 *destPtr = (uint8_t)dest; |
| 674 pLineDst += pDst->m_nStride; | 674 pLineDst += pDst->m_nStride; |
| 675 pLineSrc += m_nStride; | 675 pLineSrc += m_nStride; |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 break; | 678 break; |
| 679 } | 679 } |
| 680 } | 680 } |
| 681 } | 681 } |
| 682 return TRUE; | 682 return true; |
| 683 } | 683 } |
| 684 FX_BOOL CJBig2_Image::composeFrom(int32_t x, int32_t y, CJBig2_Image *pSrc, JBig
2ComposeOp op) | 684 bool CJBig2_Image::composeFrom(int32_t x, int32_t y, CJBig2_Image *pSrc, JBig2Co
mposeOp op) |
| 685 { | 685 { |
| 686 if (!m_pData) { | 686 if (!m_pData) { |
| 687 return FALSE; | 687 return false; |
| 688 } | 688 } |
| 689 return pSrc->composeTo(this, x, y, op); | 689 return pSrc->composeTo(this, x, y, op); |
| 690 } | 690 } |
| 691 FX_BOOL CJBig2_Image::composeFrom(int32_t x, int32_t y, CJBig2_Image *pSrc, JBig
2ComposeOp op, const FX_RECT* pSrcRect) | 691 bool CJBig2_Image::composeFrom(int32_t x, int32_t y, CJBig2_Image *pSrc, JBig2Co
mposeOp op, const FX_RECT* pSrcRect) |
| 692 { | 692 { |
| 693 if (!m_pData) { | 693 if (!m_pData) { |
| 694 return FALSE; | 694 return false; |
| 695 } | 695 } |
| 696 return pSrc->composeTo(this, x, y, op, pSrcRect); | 696 return pSrc->composeTo(this, x, y, op, pSrcRect); |
| 697 } | 697 } |
| 698 CJBig2_Image *CJBig2_Image::subImage_unopt(int32_t x, int32_t y, int32_t w, int3
2_t h) | 698 CJBig2_Image *CJBig2_Image::subImage_unopt(int32_t x, int32_t y, int32_t w, int3
2_t h) |
| 699 { | 699 { |
| 700 CJBig2_Image *pImage; | 700 CJBig2_Image *pImage; |
| 701 int32_t i, j; | 701 int32_t i, j; |
| 702 JBIG2_ALLOC(pImage, CJBig2_Image(w, h)); | 702 JBIG2_ALLOC(pImage, CJBig2_Image(w, h)); |
| 703 for(j = 0; j < h; j++) { | 703 for(j = 0; j < h; j++) { |
| 704 for(i = 0; i < w; i++) { | 704 for(i = 0; i < w; i++) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 pDst[1] = (uint8_t)(wTmp >> 16); | 758 pDst[1] = (uint8_t)(wTmp >> 16); |
| 759 pDst[2] = (uint8_t)(wTmp >> 8); | 759 pDst[2] = (uint8_t)(wTmp >> 8); |
| 760 pDst[3] = (uint8_t)wTmp; | 760 pDst[3] = (uint8_t)wTmp; |
| 761 } | 761 } |
| 762 pLineSrc += m_nStride; | 762 pLineSrc += m_nStride; |
| 763 pLineDst += pImage->m_nStride; | 763 pLineDst += pImage->m_nStride; |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 return pImage; | 766 return pImage; |
| 767 } | 767 } |
| 768 void CJBig2_Image::expand(int32_t h, FX_BOOL v) | 768 void CJBig2_Image::expand(int32_t h, bool v) |
| 769 { | 769 { |
| 770 if (!m_pData || h <= m_nHeight) { | 770 if (!m_pData || h <= m_nHeight) { |
| 771 return; | 771 return; |
| 772 } | 772 } |
| 773 FX_DWORD dwH = pdfium::base::checked_cast<FX_DWORD>(h); | 773 FX_DWORD dwH = pdfium::base::checked_cast<FX_DWORD>(h); |
| 774 FX_DWORD dwStride = pdfium::base::checked_cast<FX_DWORD>(m_nStride); | 774 FX_DWORD dwStride = pdfium::base::checked_cast<FX_DWORD>(m_nStride); |
| 775 FX_DWORD dwHeight = pdfium::base::checked_cast<FX_DWORD>(m_nHeight); | 775 FX_DWORD dwHeight = pdfium::base::checked_cast<FX_DWORD>(m_nHeight); |
| 776 FX_SAFE_DWORD safeMemSize = dwH; | 776 FX_SAFE_DWORD safeMemSize = dwH; |
| 777 safeMemSize *= dwStride; | 777 safeMemSize *= dwStride; |
| 778 if (!safeMemSize.IsValid()) { | 778 if (!safeMemSize.IsValid()) { |
| 779 return; | 779 return; |
| 780 } | 780 } |
| 781 //The guaranteed reallocated memory is to be < 4GB (unsigned int). | 781 //The guaranteed reallocated memory is to be < 4GB (unsigned int). |
| 782 m_pData = (uint8_t*)m_pModule->JBig2_Realloc(m_pData, safeMemSize.ValueOrDie
()); | 782 m_pData = (uint8_t*)m_pModule->JBig2_Realloc(m_pData, safeMemSize.ValueOrDie
()); |
| 783 //The result of dwHeight * dwStride doesn't overflow after the | 783 //The result of dwHeight * dwStride doesn't overflow after the |
| 784 //checking of safeMemSize. | 784 //checking of safeMemSize. |
| 785 //The same as the result of (dwH - dwHeight) * dwStride) because | 785 //The same as the result of (dwH - dwHeight) * dwStride) because |
| 786 //dwH - dwHeight is always less than dwH(h) which is checked in | 786 //dwH - dwHeight is always less than dwH(h) which is checked in |
| 787 //the calculation of dwH * dwStride. | 787 //the calculation of dwH * dwStride. |
| 788 JBIG2_memset(m_pData + dwHeight * dwStride, v ? 0xff : 0, (dwH - dwHeight) *
dwStride); | 788 JBIG2_memset(m_pData + dwHeight * dwStride, v ? 0xff : 0, (dwH - dwHeight) *
dwStride); |
| 789 m_nHeight = h; | 789 m_nHeight = h; |
| 790 } | 790 } |
| 791 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image *pDst, int32_t x, int32_t y, J
Big2ComposeOp op) | 791 bool CJBig2_Image::composeTo_opt2(CJBig2_Image *pDst, int32_t x, int32_t y, JBig
2ComposeOp op) |
| 792 { | 792 { |
| 793 int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0, xd0 = 0, yd0 = 0
, xd1 = 0, | 793 int32_t xs0 = 0, ys0 = 0, xs1 = 0, ys1 = 0, xd0 = 0, yd0 = 0
, xd1 = 0, |
| 794 yd1 = 0, xx = 0, yy = 0, w = 0, h = 0, middleDwords =
0, lineLeft = 0; | 794 yd1 = 0, xx = 0, yy = 0, w = 0, h = 0, middleDwords =
0, lineLeft = 0; |
| 795 | 795 |
| 796 FX_DWORD s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 =
0, | 796 FX_DWORD s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 =
0, |
| 797 tmp = 0, tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM =
0; | 797 tmp = 0, tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM =
0; |
| 798 | 798 |
| 799 uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL; | 799 uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL; |
| 800 | 800 |
| 801 if (!m_pData) { | 801 if (!m_pData) { |
| 802 return FALSE; | 802 return false; |
| 803 } | 803 } |
| 804 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { | 804 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { |
| 805 return FALSE; | 805 return false; |
| 806 } | 806 } |
| 807 if(y < 0) { | 807 if(y < 0) { |
| 808 ys0 = -y; | 808 ys0 = -y; |
| 809 } | 809 } |
| 810 if(y + m_nHeight > pDst->m_nHeight) { | 810 if(y + m_nHeight > pDst->m_nHeight) { |
| 811 ys1 = pDst->m_nHeight - y; | 811 ys1 = pDst->m_nHeight - y; |
| 812 } else { | 812 } else { |
| 813 ys1 = m_nHeight; | 813 ys1 = m_nHeight; |
| 814 } | 814 } |
| 815 if(x < 0) { | 815 if(x < 0) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 dp[2] = (uint8_t)(tmp >> 8); | 1198 dp[2] = (uint8_t)(tmp >> 8); |
| 1199 dp[3] = (uint8_t)tmp; | 1199 dp[3] = (uint8_t)tmp; |
| 1200 } | 1200 } |
| 1201 lineSrc += m_nStride; | 1201 lineSrc += m_nStride; |
| 1202 lineDst += pDst->m_nStride; | 1202 lineDst += pDst->m_nStride; |
| 1203 } | 1203 } |
| 1204 } | 1204 } |
| 1205 } | 1205 } |
| 1206 return 1; | 1206 return 1; |
| 1207 } | 1207 } |
| 1208 FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image *pDst, int32_t x, int32_t y, J
Big2ComposeOp op, const FX_RECT* pSrcRect) | 1208 bool CJBig2_Image::composeTo_opt2(CJBig2_Image *pDst, int32_t x, int32_t y, JBig
2ComposeOp op, const FX_RECT* pSrcRect) |
| 1209 { | 1209 { |
| 1210 int32_t xs0, ys0, xs1, ys1, xd0, yd0, xd1, yd1, xx, yy, w, h, middleDwords,
lineLeft; | 1210 int32_t xs0, ys0, xs1, ys1, xd0, yd0, xd1, yd1, xx, yy, w, h, middleDwords,
lineLeft; |
| 1211 FX_DWORD s1, d1, d2, shift, shift1, shift2, tmp, tmp1, tmp2, maskL, maskR, m
askM; | 1211 FX_DWORD s1, d1, d2, shift, shift1, shift2, tmp, tmp1, tmp2, maskL, maskR, m
askM; |
| 1212 uint8_t *lineSrc, *lineDst, *sp, *dp; | 1212 uint8_t *lineSrc, *lineDst, *sp, *dp; |
| 1213 int32_t sw, sh; | 1213 int32_t sw, sh; |
| 1214 if (!m_pData) { | 1214 if (!m_pData) { |
| 1215 return FALSE; | 1215 return false; |
| 1216 } | 1216 } |
| 1217 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { | 1217 if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) { |
| 1218 return FALSE; | 1218 return false; |
| 1219 } | 1219 } |
| 1220 sw = pSrcRect->Width(); | 1220 sw = pSrcRect->Width(); |
| 1221 sh = pSrcRect->Height(); | 1221 sh = pSrcRect->Height(); |
| 1222 if(y < 0) { | 1222 if(y < 0) { |
| 1223 ys0 = -y; | 1223 ys0 = -y; |
| 1224 } else { | 1224 } else { |
| 1225 ys0 = 0; | 1225 ys0 = 0; |
| 1226 } | 1226 } |
| 1227 if(y + sh > pDst->m_nHeight) { | 1227 if(y + sh > pDst->m_nHeight) { |
| 1228 ys1 = pDst->m_nHeight - y; | 1228 ys1 = pDst->m_nHeight - y; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 dp[2] = (uint8_t)(tmp >> 8); | 1621 dp[2] = (uint8_t)(tmp >> 8); |
| 1622 dp[3] = (uint8_t)tmp; | 1622 dp[3] = (uint8_t)tmp; |
| 1623 } | 1623 } |
| 1624 lineSrc += m_nStride; | 1624 lineSrc += m_nStride; |
| 1625 lineDst += pDst->m_nStride; | 1625 lineDst += pDst->m_nStride; |
| 1626 } | 1626 } |
| 1627 } | 1627 } |
| 1628 } | 1628 } |
| 1629 return 1; | 1629 return 1; |
| 1630 } | 1630 } |
| OLD | NEW |