| OLD | NEW |
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/src/fxcodec/jbig2/JBig2_GrdProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_GrdProc.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" |
| 12 #include "core/fxcodec/jbig2/JBig2_BitStream.h" |
| 13 #include "core/fxcodec/jbig2/JBig2_Image.h" |
| 11 #include "core/include/fxcodec/fx_codec.h" | 14 #include "core/include/fxcodec/fx_codec.h" |
| 12 #include "core/src/fxcodec/jbig2/JBig2_ArithDecoder.h" | |
| 13 #include "core/src/fxcodec/jbig2/JBig2_BitStream.h" | |
| 14 #include "core/src/fxcodec/jbig2/JBig2_Image.h" | |
| 15 | 15 |
| 16 CJBig2_GRDProc::CJBig2_GRDProc() | 16 CJBig2_GRDProc::CJBig2_GRDProc() |
| 17 : m_loopIndex(0), | 17 : m_loopIndex(0), |
| 18 m_pLine(nullptr), | 18 m_pLine(nullptr), |
| 19 m_pPause(nullptr), | 19 m_pPause(nullptr), |
| 20 m_DecodeType(0), | 20 m_DecodeType(0), |
| 21 LTP(0) { | 21 LTP(0) { |
| 22 m_ReplaceRect.left = 0; | 22 m_ReplaceRect.left = 0; |
| 23 m_ReplaceRect.bottom = 0; | 23 m_ReplaceRect.bottom = 0; |
| 24 m_ReplaceRect.top = 0; | 24 m_ReplaceRect.top = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return decode_Arith_Template3_opt3(pArithDecoder, gbContext); | 61 return decode_Arith_Template3_opt3(pArithDecoder, gbContext); |
| 62 return decode_Arith_Template3_unopt(pArithDecoder, gbContext); | 62 return decode_Arith_Template3_unopt(pArithDecoder, gbContext); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3( | 65 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3( |
| 66 CJBig2_ArithDecoder* pArithDecoder, | 66 CJBig2_ArithDecoder* pArithDecoder, |
| 67 JBig2ArithCtx* gbContext) { | 67 JBig2ArithCtx* gbContext) { |
| 68 FX_BOOL LTP, SLTP, bVal; | 68 FX_BOOL LTP, SLTP, bVal; |
| 69 FX_DWORD CONTEXT; | 69 FX_DWORD CONTEXT; |
| 70 FX_DWORD line1, line2; | 70 FX_DWORD line1, line2; |
| 71 uint8_t* pLine, *pLine1, *pLine2, cVal; | 71 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 72 int32_t nStride, nStride2, k; | 72 int32_t nStride, nStride2, k; |
| 73 int32_t nLineBytes, nBitsLeft, cc; | 73 int32_t nLineBytes, nBitsLeft, cc; |
| 74 LTP = 0; | 74 LTP = 0; |
| 75 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); | 75 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); |
| 76 if (!GBREG->m_pData) | 76 if (!GBREG->m_pData) |
| 77 return nullptr; | 77 return nullptr; |
| 78 | 78 |
| 79 pLine = GBREG->m_pData; | 79 pLine = GBREG->m_pData; |
| 80 nStride = GBREG->m_nStride; | 80 nStride = GBREG->m_nStride; |
| 81 nStride2 = nStride << 1; | 81 nStride2 = nStride << 1; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 199 } |
| 200 return GBREG.release(); | 200 return GBREG.release(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3( | 203 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3( |
| 204 CJBig2_ArithDecoder* pArithDecoder, | 204 CJBig2_ArithDecoder* pArithDecoder, |
| 205 JBig2ArithCtx* gbContext) { | 205 JBig2ArithCtx* gbContext) { |
| 206 FX_BOOL LTP, SLTP, bVal; | 206 FX_BOOL LTP, SLTP, bVal; |
| 207 FX_DWORD CONTEXT; | 207 FX_DWORD CONTEXT; |
| 208 FX_DWORD line1, line2; | 208 FX_DWORD line1, line2; |
| 209 uint8_t* pLine, *pLine1, *pLine2, cVal; | 209 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 210 int32_t nStride, nStride2, k; | 210 int32_t nStride, nStride2, k; |
| 211 int32_t nLineBytes, nBitsLeft, cc; | 211 int32_t nLineBytes, nBitsLeft, cc; |
| 212 LTP = 0; | 212 LTP = 0; |
| 213 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); | 213 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); |
| 214 if (!GBREG->m_pData) | 214 if (!GBREG->m_pData) |
| 215 return nullptr; | 215 return nullptr; |
| 216 | 216 |
| 217 pLine = GBREG->m_pData; | 217 pLine = GBREG->m_pData; |
| 218 nStride = GBREG->m_nStride; | 218 nStride = GBREG->m_nStride; |
| 219 nStride2 = nStride << 1; | 219 nStride2 = nStride << 1; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 return GBREG.release(); | 335 return GBREG.release(); |
| 336 } | 336 } |
| 337 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3( | 337 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3( |
| 338 CJBig2_ArithDecoder* pArithDecoder, | 338 CJBig2_ArithDecoder* pArithDecoder, |
| 339 JBig2ArithCtx* gbContext) { | 339 JBig2ArithCtx* gbContext) { |
| 340 FX_BOOL LTP, SLTP, bVal; | 340 FX_BOOL LTP, SLTP, bVal; |
| 341 FX_DWORD CONTEXT; | 341 FX_DWORD CONTEXT; |
| 342 FX_DWORD line1, line2; | 342 FX_DWORD line1, line2; |
| 343 uint8_t* pLine, *pLine1, *pLine2, cVal; | 343 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 344 int32_t nStride, nStride2, k; | 344 int32_t nStride, nStride2, k; |
| 345 int32_t nLineBytes, nBitsLeft, cc; | 345 int32_t nLineBytes, nBitsLeft, cc; |
| 346 LTP = 0; | 346 LTP = 0; |
| 347 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); | 347 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); |
| 348 if (!GBREG->m_pData) | 348 if (!GBREG->m_pData) |
| 349 return nullptr; | 349 return nullptr; |
| 350 | 350 |
| 351 pLine = GBREG->m_pData; | 351 pLine = GBREG->m_pData; |
| 352 nStride = GBREG->m_nStride; | 352 nStride = GBREG->m_nStride; |
| 353 nStride2 = nStride << 1; | 353 nStride2 = nStride << 1; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 466 } |
| 467 return GBREG.release(); | 467 return GBREG.release(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3( | 470 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3( |
| 471 CJBig2_ArithDecoder* pArithDecoder, | 471 CJBig2_ArithDecoder* pArithDecoder, |
| 472 JBig2ArithCtx* gbContext) { | 472 JBig2ArithCtx* gbContext) { |
| 473 FX_BOOL LTP, SLTP, bVal; | 473 FX_BOOL LTP, SLTP, bVal; |
| 474 FX_DWORD CONTEXT; | 474 FX_DWORD CONTEXT; |
| 475 FX_DWORD line1; | 475 FX_DWORD line1; |
| 476 uint8_t* pLine, *pLine1, cVal; | 476 uint8_t *pLine, *pLine1, cVal; |
| 477 int32_t nStride, k; | 477 int32_t nStride, k; |
| 478 int32_t nLineBytes, nBitsLeft, cc; | 478 int32_t nLineBytes, nBitsLeft, cc; |
| 479 LTP = 0; | 479 LTP = 0; |
| 480 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); | 480 std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH)); |
| 481 if (!GBREG->m_pData) | 481 if (!GBREG->m_pData) |
| 482 return nullptr; | 482 return nullptr; |
| 483 | 483 |
| 484 pLine = GBREG->m_pData; | 484 pLine = GBREG->m_pData; |
| 485 nStride = GBREG->m_nStride; | 485 nStride = GBREG->m_nStride; |
| 486 nLineBytes = ((GBW + 7) >> 3) - 1; | 486 nLineBytes = ((GBW + 7) >> 3) - 1; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 693 } |
| 694 | 694 |
| 695 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3( | 695 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3( |
| 696 CJBig2_Image* pImage, | 696 CJBig2_Image* pImage, |
| 697 CJBig2_ArithDecoder* pArithDecoder, | 697 CJBig2_ArithDecoder* pArithDecoder, |
| 698 JBig2ArithCtx* gbContext, | 698 JBig2ArithCtx* gbContext, |
| 699 IFX_Pause* pPause) { | 699 IFX_Pause* pPause) { |
| 700 FX_BOOL SLTP, bVal; | 700 FX_BOOL SLTP, bVal; |
| 701 FX_DWORD CONTEXT; | 701 FX_DWORD CONTEXT; |
| 702 FX_DWORD line1, line2; | 702 FX_DWORD line1, line2; |
| 703 uint8_t* pLine1, *pLine2, cVal; | 703 uint8_t *pLine1, *pLine2, cVal; |
| 704 int32_t nStride, nStride2, k; | 704 int32_t nStride, nStride2, k; |
| 705 int32_t nLineBytes, nBitsLeft, cc; | 705 int32_t nLineBytes, nBitsLeft, cc; |
| 706 if (!m_pLine) { | 706 if (!m_pLine) { |
| 707 m_pLine = pImage->m_pData; | 707 m_pLine = pImage->m_pData; |
| 708 } | 708 } |
| 709 nStride = pImage->m_nStride; | 709 nStride = pImage->m_nStride; |
| 710 nStride2 = nStride << 1; | 710 nStride2 = nStride << 1; |
| 711 nLineBytes = ((GBW + 7) >> 3) - 1; | 711 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 712 nBitsLeft = GBW - (nLineBytes << 3); | 712 nBitsLeft = GBW - (nLineBytes << 3); |
| 713 FX_DWORD height = GBH & 0x7fffffff; | 713 FX_DWORD height = GBH & 0x7fffffff; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 843 } |
| 844 | 844 |
| 845 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_opt3( | 845 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_opt3( |
| 846 CJBig2_Image* pImage, | 846 CJBig2_Image* pImage, |
| 847 CJBig2_ArithDecoder* pArithDecoder, | 847 CJBig2_ArithDecoder* pArithDecoder, |
| 848 JBig2ArithCtx* gbContext, | 848 JBig2ArithCtx* gbContext, |
| 849 IFX_Pause* pPause) { | 849 IFX_Pause* pPause) { |
| 850 FX_BOOL SLTP, bVal; | 850 FX_BOOL SLTP, bVal; |
| 851 FX_DWORD CONTEXT; | 851 FX_DWORD CONTEXT; |
| 852 FX_DWORD line1, line2; | 852 FX_DWORD line1, line2; |
| 853 uint8_t* pLine1, *pLine2, cVal; | 853 uint8_t *pLine1, *pLine2, cVal; |
| 854 int32_t nStride, nStride2, k; | 854 int32_t nStride, nStride2, k; |
| 855 int32_t nLineBytes, nBitsLeft, cc; | 855 int32_t nLineBytes, nBitsLeft, cc; |
| 856 if (!m_pLine) { | 856 if (!m_pLine) { |
| 857 m_pLine = pImage->m_pData; | 857 m_pLine = pImage->m_pData; |
| 858 } | 858 } |
| 859 nStride = pImage->m_nStride; | 859 nStride = pImage->m_nStride; |
| 860 nStride2 = nStride << 1; | 860 nStride2 = nStride << 1; |
| 861 nLineBytes = ((GBW + 7) >> 3) - 1; | 861 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 862 nBitsLeft = GBW - (nLineBytes << 3); | 862 nBitsLeft = GBW - (nLineBytes << 3); |
| 863 for (; m_loopIndex < GBH; m_loopIndex++) { | 863 for (; m_loopIndex < GBH; m_loopIndex++) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 988 } |
| 989 | 989 |
| 990 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_opt3( | 990 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_opt3( |
| 991 CJBig2_Image* pImage, | 991 CJBig2_Image* pImage, |
| 992 CJBig2_ArithDecoder* pArithDecoder, | 992 CJBig2_ArithDecoder* pArithDecoder, |
| 993 JBig2ArithCtx* gbContext, | 993 JBig2ArithCtx* gbContext, |
| 994 IFX_Pause* pPause) { | 994 IFX_Pause* pPause) { |
| 995 FX_BOOL SLTP, bVal; | 995 FX_BOOL SLTP, bVal; |
| 996 FX_DWORD CONTEXT; | 996 FX_DWORD CONTEXT; |
| 997 FX_DWORD line1, line2; | 997 FX_DWORD line1, line2; |
| 998 uint8_t* pLine1, *pLine2, cVal; | 998 uint8_t *pLine1, *pLine2, cVal; |
| 999 int32_t nStride, nStride2, k; | 999 int32_t nStride, nStride2, k; |
| 1000 int32_t nLineBytes, nBitsLeft, cc; | 1000 int32_t nLineBytes, nBitsLeft, cc; |
| 1001 if (!m_pLine) { | 1001 if (!m_pLine) { |
| 1002 m_pLine = pImage->m_pData; | 1002 m_pLine = pImage->m_pData; |
| 1003 } | 1003 } |
| 1004 nStride = pImage->m_nStride; | 1004 nStride = pImage->m_nStride; |
| 1005 nStride2 = nStride << 1; | 1005 nStride2 = nStride << 1; |
| 1006 nLineBytes = ((GBW + 7) >> 3) - 1; | 1006 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 1007 nBitsLeft = GBW - (nLineBytes << 3); | 1007 nBitsLeft = GBW - (nLineBytes << 3); |
| 1008 for (; m_loopIndex < GBH; m_loopIndex++) { | 1008 for (; m_loopIndex < GBH; m_loopIndex++) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template3_opt3( | 1135 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template3_opt3( |
| 1136 CJBig2_Image* pImage, | 1136 CJBig2_Image* pImage, |
| 1137 CJBig2_ArithDecoder* pArithDecoder, | 1137 CJBig2_ArithDecoder* pArithDecoder, |
| 1138 JBig2ArithCtx* gbContext, | 1138 JBig2ArithCtx* gbContext, |
| 1139 IFX_Pause* pPause) { | 1139 IFX_Pause* pPause) { |
| 1140 FX_BOOL SLTP, bVal; | 1140 FX_BOOL SLTP, bVal; |
| 1141 FX_DWORD CONTEXT; | 1141 FX_DWORD CONTEXT; |
| 1142 FX_DWORD line1; | 1142 FX_DWORD line1; |
| 1143 uint8_t* pLine1, cVal; | 1143 uint8_t *pLine1, cVal; |
| 1144 int32_t nStride, k; | 1144 int32_t nStride, k; |
| 1145 int32_t nLineBytes, nBitsLeft, cc; | 1145 int32_t nLineBytes, nBitsLeft, cc; |
| 1146 if (!m_pLine) { | 1146 if (!m_pLine) { |
| 1147 m_pLine = pImage->m_pData; | 1147 m_pLine = pImage->m_pData; |
| 1148 } | 1148 } |
| 1149 nStride = pImage->m_nStride; | 1149 nStride = pImage->m_nStride; |
| 1150 nLineBytes = ((GBW + 7) >> 3) - 1; | 1150 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 1151 nBitsLeft = GBW - (nLineBytes << 3); | 1151 nBitsLeft = GBW - (nLineBytes << 3); |
| 1152 for (; m_loopIndex < GBH; m_loopIndex++) { | 1152 for (; m_loopIndex < GBH; m_loopIndex++) { |
| 1153 if (TPGDON) { | 1153 if (TPGDON) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 } | 1250 } |
| 1251 if (pPause && pPause->NeedToPauseNow()) { | 1251 if (pPause && pPause->NeedToPauseNow()) { |
| 1252 m_loopIndex++; | 1252 m_loopIndex++; |
| 1253 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 1253 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 1254 return FXCODEC_STATUS_DECODE_TOBECONTINUE; | 1254 return FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 1255 } | 1255 } |
| 1256 } | 1256 } |
| 1257 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; | 1257 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; |
| 1258 return FXCODEC_STATUS_DECODE_FINISH; | 1258 return FXCODEC_STATUS_DECODE_FINISH; |
| 1259 } | 1259 } |
| OLD | NEW |