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 "JBig2_GeneralDecoder.h" | 7 #include "JBig2_GeneralDecoder.h" |
8 #include "JBig2_ArithDecoder.h" | 8 #include "JBig2_ArithDecoder.h" |
9 #include "JBig2_ArithIntDecoder.h" | 9 #include "JBig2_ArithIntDecoder.h" |
10 #include "JBig2_HuffmanDecoder.h" | 10 #include "JBig2_HuffmanDecoder.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 extern const unsigned int JBIG2_QE_NUM = sizeof(QeTable) / sizeof(JBig2ArithQe); | 32 extern const unsigned int JBIG2_QE_NUM = sizeof(QeTable) / sizeof(JBig2ArithQe); |
33 | 33 |
34 CJBig2_Image* CJBig2_GRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, | 34 CJBig2_Image* CJBig2_GRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder, |
35 JBig2ArithCtx* gbContext) { | 35 JBig2ArithCtx* gbContext) { |
36 if (GBW == 0 || GBH == 0) { | 36 if (GBW == 0 || GBH == 0) { |
37 CJBig2_Image* pImage; | 37 CJBig2_Image* pImage; |
38 JBIG2_ALLOC(pImage, CJBig2_Image(GBW, GBH)); | 38 JBIG2_ALLOC(pImage, CJBig2_Image(GBW, GBH)); |
39 return pImage; | 39 return pImage; |
40 } | 40 } |
41 if (GBTEMPLATE == 0) { | 41 if (GBTEMPLATE == 0) { |
42 if ((GBAT[0] == 3) && (GBAT[1] == (signed char)-1) && | 42 if ((GBAT[0] == 3) && (GBAT[1] == (int8_t)-1) && (GBAT[2] == (int8_t)-3) && |
43 (GBAT[2] == (signed char)-3) && (GBAT[3] == (signed char)-1) && | 43 (GBAT[3] == (int8_t)-1) && (GBAT[4] == 2) && (GBAT[5] == (int8_t)-2) && |
44 (GBAT[4] == 2) && (GBAT[5] == (signed char)-2) && | 44 (GBAT[6] == (int8_t)-2) && (GBAT[7] == (int8_t)-2)) { |
45 (GBAT[6] == (signed char)-2) && (GBAT[7] == (signed char)-2)) { | |
46 return decode_Arith_Template0_opt3(pArithDecoder, gbContext); | 45 return decode_Arith_Template0_opt3(pArithDecoder, gbContext); |
47 } else { | 46 } else { |
48 return decode_Arith_Template0_unopt(pArithDecoder, gbContext); | 47 return decode_Arith_Template0_unopt(pArithDecoder, gbContext); |
49 } | 48 } |
50 } else if (GBTEMPLATE == 1) { | 49 } else if (GBTEMPLATE == 1) { |
51 if ((GBAT[0] == 3) && (GBAT[1] == (signed char)-1)) { | 50 if ((GBAT[0] == 3) && (GBAT[1] == (int8_t)-1)) { |
52 return decode_Arith_Template1_opt3(pArithDecoder, gbContext); | 51 return decode_Arith_Template1_opt3(pArithDecoder, gbContext); |
53 } else { | 52 } else { |
54 return decode_Arith_Template1_unopt(pArithDecoder, gbContext); | 53 return decode_Arith_Template1_unopt(pArithDecoder, gbContext); |
55 } | 54 } |
56 } else if (GBTEMPLATE == 2) { | 55 } else if (GBTEMPLATE == 2) { |
57 if ((GBAT[0] == 2) && (GBAT[1] == (signed char)-1)) { | 56 if ((GBAT[0] == 2) && (GBAT[1] == (int8_t)-1)) { |
58 return decode_Arith_Template2_opt3(pArithDecoder, gbContext); | 57 return decode_Arith_Template2_opt3(pArithDecoder, gbContext); |
59 } else { | 58 } else { |
60 return decode_Arith_Template2_unopt(pArithDecoder, gbContext); | 59 return decode_Arith_Template2_unopt(pArithDecoder, gbContext); |
61 } | 60 } |
62 } else { | 61 } else { |
63 if ((GBAT[0] == 2) && (GBAT[1] == (signed char)-1)) { | 62 if ((GBAT[0] == 2) && (GBAT[1] == (int8_t)-1)) { |
64 return decode_Arith_Template3_opt3(pArithDecoder, gbContext); | 63 return decode_Arith_Template3_opt3(pArithDecoder, gbContext); |
65 } else { | 64 } else { |
66 return decode_Arith_Template3_unopt(pArithDecoder, gbContext); | 65 return decode_Arith_Template3_unopt(pArithDecoder, gbContext); |
67 } | 66 } |
68 } | 67 } |
69 } | 68 } |
70 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt( | 69 CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt( |
71 CJBig2_ArithDecoder* pArithDecoder, | 70 CJBig2_ArithDecoder* pArithDecoder, |
72 JBig2ArithCtx* gbContext) { | 71 JBig2ArithCtx* gbContext) { |
73 FX_BOOL LTP, SLTP, bVal; | 72 FX_BOOL LTP, SLTP, bVal; |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 return GBREG; | 1059 return GBREG; |
1061 } | 1060 } |
1062 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, | 1061 CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, |
1063 JBig2ArithCtx* grContext) { | 1062 JBig2ArithCtx* grContext) { |
1064 if (GRW == 0 || GRH == 0) { | 1063 if (GRW == 0 || GRH == 0) { |
1065 CJBig2_Image* pImage; | 1064 CJBig2_Image* pImage; |
1066 JBIG2_ALLOC(pImage, CJBig2_Image(GRW, GRH)); | 1065 JBIG2_ALLOC(pImage, CJBig2_Image(GRW, GRH)); |
1067 return pImage; | 1066 return pImage; |
1068 } | 1067 } |
1069 if (GRTEMPLATE == 0) { | 1068 if (GRTEMPLATE == 0) { |
1070 if ((GRAT[0] == (signed char)-1) && (GRAT[1] == (signed char)-1) && | 1069 if ((GRAT[0] == (int8_t)-1) && (GRAT[1] == (int8_t)-1) && |
1071 (GRAT[2] == (signed char)-1) && (GRAT[3] == (signed char)-1) && | 1070 (GRAT[2] == (int8_t)-1) && (GRAT[3] == (int8_t)-1) && |
1072 (GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { | 1071 (GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { |
1073 return decode_Template0_opt(pArithDecoder, grContext); | 1072 return decode_Template0_opt(pArithDecoder, grContext); |
1074 } else { | 1073 } else { |
1075 return decode_Template0_unopt(pArithDecoder, grContext); | 1074 return decode_Template0_unopt(pArithDecoder, grContext); |
1076 } | 1075 } |
1077 } else { | 1076 } else { |
1078 if ((GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { | 1077 if ((GRREFERENCEDX == 0) && (GRW == (FX_DWORD)GRREFERENCE->m_nWidth)) { |
1079 return decode_Template1_opt(pArithDecoder, grContext); | 1078 return decode_Template1_opt(pArithDecoder, grContext); |
1080 } else { | 1079 } else { |
1081 return decode_Template1_unopt(pArithDecoder, grContext); | 1080 return decode_Template1_unopt(pArithDecoder, grContext); |
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3240 m_gbContext = gbContext; | 3239 m_gbContext = gbContext; |
3241 LTP = 0; | 3240 LTP = 0; |
3242 m_pLine = NULL; | 3241 m_pLine = NULL; |
3243 m_loopIndex = 0; | 3242 m_loopIndex = 0; |
3244 return decode_Arith(pPause); | 3243 return decode_Arith(pPause); |
3245 } | 3244 } |
3246 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith(IFX_Pause* pPause) { | 3245 FXCODEC_STATUS CJBig2_GRDProc::decode_Arith(IFX_Pause* pPause) { |
3247 int iline = m_loopIndex; | 3246 int iline = m_loopIndex; |
3248 CJBig2_Image* pImage = *m_pImage; | 3247 CJBig2_Image* pImage = *m_pImage; |
3249 if (GBTEMPLATE == 0) { | 3248 if (GBTEMPLATE == 0) { |
3250 if ((GBAT[0] == 3) && (GBAT[1] == (signed char)-1) && | 3249 if ((GBAT[0] == 3) && (GBAT[1] == (int8_t)-1) && (GBAT[2] == (int8_t)-3) && |
3251 (GBAT[2] == (signed char)-3) && (GBAT[3] == (signed char)-1) && | 3250 (GBAT[3] == (int8_t)-1) && (GBAT[4] == 2) && (GBAT[5] == (int8_t)-2) && |
3252 (GBAT[4] == 2) && (GBAT[5] == (signed char)-2) && | 3251 (GBAT[6] == (int8_t)-2) && (GBAT[7] == (int8_t)-2)) { |
3253 (GBAT[6] == (signed char)-2) && (GBAT[7] == (signed char)-2)) { | |
3254 m_ProssiveStatus = decode_Arith_Template0_opt3(pImage, m_pArithDecoder, | 3252 m_ProssiveStatus = decode_Arith_Template0_opt3(pImage, m_pArithDecoder, |
3255 m_gbContext, pPause); | 3253 m_gbContext, pPause); |
3256 } else { | 3254 } else { |
3257 m_ProssiveStatus = decode_Arith_Template0_unopt(pImage, m_pArithDecoder, | 3255 m_ProssiveStatus = decode_Arith_Template0_unopt(pImage, m_pArithDecoder, |
3258 m_gbContext, pPause); | 3256 m_gbContext, pPause); |
3259 } | 3257 } |
3260 } else if (GBTEMPLATE == 1) { | 3258 } else if (GBTEMPLATE == 1) { |
3261 if ((GBAT[0] == 3) && (GBAT[1] == (signed char)-1)) { | 3259 if ((GBAT[0] == 3) && (GBAT[1] == (int8_t)-1)) { |
3262 m_ProssiveStatus = decode_Arith_Template1_opt3(pImage, m_pArithDecoder, | 3260 m_ProssiveStatus = decode_Arith_Template1_opt3(pImage, m_pArithDecoder, |
3263 m_gbContext, pPause); | 3261 m_gbContext, pPause); |
3264 } else { | 3262 } else { |
3265 m_ProssiveStatus = decode_Arith_Template1_unopt(pImage, m_pArithDecoder, | 3263 m_ProssiveStatus = decode_Arith_Template1_unopt(pImage, m_pArithDecoder, |
3266 m_gbContext, pPause); | 3264 m_gbContext, pPause); |
3267 } | 3265 } |
3268 } else if (GBTEMPLATE == 2) { | 3266 } else if (GBTEMPLATE == 2) { |
3269 if ((GBAT[0] == 2) && (GBAT[1] == (signed char)-1)) { | 3267 if ((GBAT[0] == 2) && (GBAT[1] == (int8_t)-1)) { |
3270 m_ProssiveStatus = decode_Arith_Template2_opt3(pImage, m_pArithDecoder, | 3268 m_ProssiveStatus = decode_Arith_Template2_opt3(pImage, m_pArithDecoder, |
3271 m_gbContext, pPause); | 3269 m_gbContext, pPause); |
3272 } else { | 3270 } else { |
3273 m_ProssiveStatus = decode_Arith_Template2_unopt(pImage, m_pArithDecoder, | 3271 m_ProssiveStatus = decode_Arith_Template2_unopt(pImage, m_pArithDecoder, |
3274 m_gbContext, pPause); | 3272 m_gbContext, pPause); |
3275 } | 3273 } |
3276 } else { | 3274 } else { |
3277 if ((GBAT[0] == 2) && (GBAT[1] == (signed char)-1)) { | 3275 if ((GBAT[0] == 2) && (GBAT[1] == (int8_t)-1)) { |
3278 m_ProssiveStatus = decode_Arith_Template3_opt3(pImage, m_pArithDecoder, | 3276 m_ProssiveStatus = decode_Arith_Template3_opt3(pImage, m_pArithDecoder, |
3279 m_gbContext, pPause); | 3277 m_gbContext, pPause); |
3280 } else { | 3278 } else { |
3281 m_ProssiveStatus = decode_Arith_Template3_unopt(pImage, m_pArithDecoder, | 3279 m_ProssiveStatus = decode_Arith_Template3_unopt(pImage, m_pArithDecoder, |
3282 m_gbContext, pPause); | 3280 m_gbContext, pPause); |
3283 } | 3281 } |
3284 } | 3282 } |
3285 m_ReplaceRect.left = 0; | 3283 m_ReplaceRect.left = 0; |
3286 m_ReplaceRect.right = pImage->m_nWidth; | 3284 m_ReplaceRect.right = pImage->m_nWidth; |
3287 m_ReplaceRect.top = iline; | 3285 m_ReplaceRect.top = iline; |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3880 } | 3878 } |
3881 if (pPause && pPause->NeedToPauseNow()) { | 3879 if (pPause && pPause->NeedToPauseNow()) { |
3882 m_loopIndex++; | 3880 m_loopIndex++; |
3883 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 3881 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
3884 return FXCODEC_STATUS_DECODE_TOBECONTINUE; | 3882 return FXCODEC_STATUS_DECODE_TOBECONTINUE; |
3885 } | 3883 } |
3886 } | 3884 } |
3887 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; | 3885 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; |
3888 return FXCODEC_STATUS_DECODE_FINISH; | 3886 return FXCODEC_STATUS_DECODE_FINISH; |
3889 } | 3887 } |
OLD | NEW |