| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 FX_DWORD CONTEXT; | 73 FX_DWORD CONTEXT; |
| 74 CJBig2_Image* GBREG; | 74 CJBig2_Image* GBREG; |
| 75 FX_DWORD line1, line2; | 75 FX_DWORD line1, line2; |
| 76 uint8_t *pLine, *pLine1, *pLine2, cVal; | 76 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 77 int32_t nStride, nStride2, k; | 77 int32_t nStride, nStride2, k; |
| 78 int32_t nLineBytes, nBitsLeft, cc; | 78 int32_t nLineBytes, nBitsLeft, cc; |
| 79 LTP = 0; | 79 LTP = 0; |
| 80 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); | 80 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); |
| 81 if (GBREG->m_pData == NULL) { | 81 if (GBREG->m_pData == NULL) { |
| 82 delete GBREG; | 82 delete GBREG; |
| 83 m_pModule->JBig2_Error( | |
| 84 "Generic region decoding procedure: Create Image Failed with width = " | |
| 85 "%d, height = %d\n", | |
| 86 GBW, GBH); | |
| 87 return NULL; | 83 return NULL; |
| 88 } | 84 } |
| 89 pLine = GBREG->m_pData; | 85 pLine = GBREG->m_pData; |
| 90 nStride = GBREG->m_nStride; | 86 nStride = GBREG->m_nStride; |
| 91 nStride2 = nStride << 1; | 87 nStride2 = nStride << 1; |
| 92 nLineBytes = ((GBW + 7) >> 3) - 1; | 88 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 93 nBitsLeft = GBW - (nLineBytes << 3); | 89 nBitsLeft = GBW - (nLineBytes << 3); |
| 94 FX_DWORD height = GBH & 0x7fffffff; | 90 FX_DWORD height = GBH & 0x7fffffff; |
| 95 for (FX_DWORD h = 0; h < height; h++) { | 91 for (FX_DWORD h = 0; h < height; h++) { |
| 96 if (TPGDON) { | 92 if (TPGDON) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 FX_DWORD CONTEXT; | 212 FX_DWORD CONTEXT; |
| 217 CJBig2_Image* GBREG; | 213 CJBig2_Image* GBREG; |
| 218 FX_DWORD line1, line2; | 214 FX_DWORD line1, line2; |
| 219 uint8_t *pLine, *pLine1, *pLine2, cVal; | 215 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 220 int32_t nStride, nStride2, k; | 216 int32_t nStride, nStride2, k; |
| 221 int32_t nLineBytes, nBitsLeft, cc; | 217 int32_t nLineBytes, nBitsLeft, cc; |
| 222 LTP = 0; | 218 LTP = 0; |
| 223 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); | 219 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); |
| 224 if (GBREG->m_pData == NULL) { | 220 if (GBREG->m_pData == NULL) { |
| 225 delete GBREG; | 221 delete GBREG; |
| 226 m_pModule->JBig2_Error( | |
| 227 "Generic region decoding procedure: Create Image Failed with width = " | |
| 228 "%d, height = %d\n", | |
| 229 GBW, GBH); | |
| 230 return NULL; | 222 return NULL; |
| 231 } | 223 } |
| 232 pLine = GBREG->m_pData; | 224 pLine = GBREG->m_pData; |
| 233 nStride = GBREG->m_nStride; | 225 nStride = GBREG->m_nStride; |
| 234 nStride2 = nStride << 1; | 226 nStride2 = nStride << 1; |
| 235 nLineBytes = ((GBW + 7) >> 3) - 1; | 227 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 236 nBitsLeft = GBW - (nLineBytes << 3); | 228 nBitsLeft = GBW - (nLineBytes << 3); |
| 237 for (FX_DWORD h = 0; h < GBH; h++) { | 229 for (FX_DWORD h = 0; h < GBH; h++) { |
| 238 if (TPGDON) { | 230 if (TPGDON) { |
| 239 SLTP = pArithDecoder->DECODE(&gbContext[0x0795]); | 231 SLTP = pArithDecoder->DECODE(&gbContext[0x0795]); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 FX_DWORD CONTEXT; | 348 FX_DWORD CONTEXT; |
| 357 CJBig2_Image* GBREG; | 349 CJBig2_Image* GBREG; |
| 358 FX_DWORD line1, line2; | 350 FX_DWORD line1, line2; |
| 359 uint8_t *pLine, *pLine1, *pLine2, cVal; | 351 uint8_t *pLine, *pLine1, *pLine2, cVal; |
| 360 int32_t nStride, nStride2, k; | 352 int32_t nStride, nStride2, k; |
| 361 int32_t nLineBytes, nBitsLeft, cc; | 353 int32_t nLineBytes, nBitsLeft, cc; |
| 362 LTP = 0; | 354 LTP = 0; |
| 363 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); | 355 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); |
| 364 if (GBREG->m_pData == NULL) { | 356 if (GBREG->m_pData == NULL) { |
| 365 delete GBREG; | 357 delete GBREG; |
| 366 m_pModule->JBig2_Error( | |
| 367 "Generic region decoding procedure: Create Image Failed with width = " | |
| 368 "%d, height = %d\n", | |
| 369 GBW, GBH); | |
| 370 return NULL; | 358 return NULL; |
| 371 } | 359 } |
| 372 pLine = GBREG->m_pData; | 360 pLine = GBREG->m_pData; |
| 373 nStride = GBREG->m_nStride; | 361 nStride = GBREG->m_nStride; |
| 374 nStride2 = nStride << 1; | 362 nStride2 = nStride << 1; |
| 375 nLineBytes = ((GBW + 7) >> 3) - 1; | 363 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 376 nBitsLeft = GBW - (nLineBytes << 3); | 364 nBitsLeft = GBW - (nLineBytes << 3); |
| 377 for (FX_DWORD h = 0; h < GBH; h++) { | 365 for (FX_DWORD h = 0; h < GBH; h++) { |
| 378 if (TPGDON) { | 366 if (TPGDON) { |
| 379 SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]); | 367 SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 FX_DWORD CONTEXT; | 482 FX_DWORD CONTEXT; |
| 495 CJBig2_Image* GBREG; | 483 CJBig2_Image* GBREG; |
| 496 FX_DWORD line1; | 484 FX_DWORD line1; |
| 497 uint8_t *pLine, *pLine1, cVal; | 485 uint8_t *pLine, *pLine1, cVal; |
| 498 int32_t nStride, k; | 486 int32_t nStride, k; |
| 499 int32_t nLineBytes, nBitsLeft, cc; | 487 int32_t nLineBytes, nBitsLeft, cc; |
| 500 LTP = 0; | 488 LTP = 0; |
| 501 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); | 489 JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); |
| 502 if (GBREG->m_pData == NULL) { | 490 if (GBREG->m_pData == NULL) { |
| 503 delete GBREG; | 491 delete GBREG; |
| 504 m_pModule->JBig2_Error( | |
| 505 "Generic region decoding procedure: Create Image Failed with width = " | |
| 506 "%d, height = %d\n", | |
| 507 GBW, GBH); | |
| 508 return NULL; | 492 return NULL; |
| 509 } | 493 } |
| 510 pLine = GBREG->m_pData; | 494 pLine = GBREG->m_pData; |
| 511 nStride = GBREG->m_nStride; | 495 nStride = GBREG->m_nStride; |
| 512 nLineBytes = ((GBW + 7) >> 3) - 1; | 496 nLineBytes = ((GBW + 7) >> 3) - 1; |
| 513 nBitsLeft = GBW - (nLineBytes << 3); | 497 nBitsLeft = GBW - (nLineBytes << 3); |
| 514 for (FX_DWORD h = 0; h < GBH; h++) { | 498 for (FX_DWORD h = 0; h < GBH; h++) { |
| 515 if (TPGDON) { | 499 if (TPGDON) { |
| 516 SLTP = pArithDecoder->DECODE(&gbContext[0x0195]); | 500 SLTP = pArithDecoder->DECODE(&gbContext[0x0195]); |
| 517 LTP = LTP ^ SLTP; | 501 LTP = LTP ^ SLTP; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 intptr_t nStride, nStrideR, nOffset; | 740 intptr_t nStride, nStrideR, nOffset; |
| 757 int32_t k, nBits; | 741 int32_t k, nBits; |
| 758 int32_t GRWR, GRHR; | 742 int32_t GRWR, GRHR; |
| 759 int32_t GRW, GRH; | 743 int32_t GRW, GRH; |
| 760 GRW = (int32_t)CJBig2_GRRDProc::GRW; | 744 GRW = (int32_t)CJBig2_GRRDProc::GRW; |
| 761 GRH = (int32_t)CJBig2_GRRDProc::GRH; | 745 GRH = (int32_t)CJBig2_GRRDProc::GRH; |
| 762 LTP = 0; | 746 LTP = 0; |
| 763 JBIG2_ALLOC(GRREG, CJBig2_Image(GRW, GRH)); | 747 JBIG2_ALLOC(GRREG, CJBig2_Image(GRW, GRH)); |
| 764 if (GRREG->m_pData == NULL) { | 748 if (GRREG->m_pData == NULL) { |
| 765 delete GRREG; | 749 delete GRREG; |
| 766 m_pModule->JBig2_Error( | |
| 767 "Generic refinement region decoding procedure: Create Image Failed " | |
| 768 "with width = %d, height = %d\n", | |
| 769 GRW, GRH); | |
| 770 return NULL; | 750 return NULL; |
| 771 } | 751 } |
| 772 pLine = GRREG->m_pData; | 752 pLine = GRREG->m_pData; |
| 773 pLineR = GRREFERENCE->m_pData; | 753 pLineR = GRREFERENCE->m_pData; |
| 774 nStride = GRREG->m_nStride; | 754 nStride = GRREG->m_nStride; |
| 775 nStrideR = GRREFERENCE->m_nStride; | 755 nStrideR = GRREFERENCE->m_nStride; |
| 776 GRWR = (int32_t)GRREFERENCE->m_nWidth; | 756 GRWR = (int32_t)GRREFERENCE->m_nWidth; |
| 777 GRHR = (int32_t)GRREFERENCE->m_nHeight; | 757 GRHR = (int32_t)GRREFERENCE->m_nHeight; |
| 778 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { | 758 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { |
| 779 GRREFERENCEDY = 0; | 759 GRREFERENCEDY = 0; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 intptr_t nStride, nStrideR, nOffset; | 976 intptr_t nStride, nStrideR, nOffset; |
| 997 int32_t k, nBits; | 977 int32_t k, nBits; |
| 998 int32_t GRWR, GRHR; | 978 int32_t GRWR, GRHR; |
| 999 int32_t GRW, GRH; | 979 int32_t GRW, GRH; |
| 1000 GRW = (int32_t)CJBig2_GRRDProc::GRW; | 980 GRW = (int32_t)CJBig2_GRRDProc::GRW; |
| 1001 GRH = (int32_t)CJBig2_GRRDProc::GRH; | 981 GRH = (int32_t)CJBig2_GRRDProc::GRH; |
| 1002 LTP = 0; | 982 LTP = 0; |
| 1003 JBIG2_ALLOC(GRREG, CJBig2_Image(GRW, GRH)); | 983 JBIG2_ALLOC(GRREG, CJBig2_Image(GRW, GRH)); |
| 1004 if (GRREG->m_pData == NULL) { | 984 if (GRREG->m_pData == NULL) { |
| 1005 delete GRREG; | 985 delete GRREG; |
| 1006 m_pModule->JBig2_Error( | |
| 1007 "Generic refinement region decoding procedure: Create Image Failed " | |
| 1008 "with width = %d, height = %d\n", | |
| 1009 GRW, GRH); | |
| 1010 return NULL; | 986 return NULL; |
| 1011 } | 987 } |
| 1012 pLine = GRREG->m_pData; | 988 pLine = GRREG->m_pData; |
| 1013 pLineR = GRREFERENCE->m_pData; | 989 pLineR = GRREFERENCE->m_pData; |
| 1014 nStride = GRREG->m_nStride; | 990 nStride = GRREG->m_nStride; |
| 1015 nStrideR = GRREFERENCE->m_nStride; | 991 nStrideR = GRREFERENCE->m_nStride; |
| 1016 GRWR = (int32_t)GRREFERENCE->m_nWidth; | 992 GRWR = (int32_t)GRREFERENCE->m_nWidth; |
| 1017 GRHR = (int32_t)GRREFERENCE->m_nHeight; | 993 GRHR = (int32_t)GRREFERENCE->m_nHeight; |
| 1018 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { | 994 if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) { |
| 1019 GRREFERENCEDY = 0; | 995 GRREFERENCEDY = 0; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 CJBig2_Image* SBREG; | 1113 CJBig2_Image* SBREG; |
| 1138 FX_BOOL bFirst; | 1114 FX_BOOL bFirst; |
| 1139 FX_DWORD nTmp; | 1115 FX_DWORD nTmp; |
| 1140 int32_t nVal, nBits; | 1116 int32_t nVal, nBits; |
| 1141 CJBig2_GRRDProc* pGRRD; | 1117 CJBig2_GRRDProc* pGRRD; |
| 1142 CJBig2_ArithDecoder* pArithDecoder; | 1118 CJBig2_ArithDecoder* pArithDecoder; |
| 1143 CJBig2_HuffmanDecoder* pHuffmanDecoder = new CJBig2_HuffmanDecoder(pStream); | 1119 CJBig2_HuffmanDecoder* pHuffmanDecoder = new CJBig2_HuffmanDecoder(pStream); |
| 1144 JBIG2_ALLOC(SBREG, CJBig2_Image(SBW, SBH)); | 1120 JBIG2_ALLOC(SBREG, CJBig2_Image(SBW, SBH)); |
| 1145 SBREG->fill(SBDEFPIXEL); | 1121 SBREG->fill(SBDEFPIXEL); |
| 1146 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) { | 1122 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) { |
| 1147 m_pModule->JBig2_Error( | |
| 1148 "text region decoding procedure (huffman): too short."); | |
| 1149 goto failed; | 1123 goto failed; |
| 1150 } | 1124 } |
| 1151 STRIPT *= SBSTRIPS; | 1125 STRIPT *= SBSTRIPS; |
| 1152 STRIPT = -STRIPT; | 1126 STRIPT = -STRIPT; |
| 1153 FIRSTS = 0; | 1127 FIRSTS = 0; |
| 1154 NINSTANCES = 0; | 1128 NINSTANCES = 0; |
| 1155 while (NINSTANCES < SBNUMINSTANCES) { | 1129 while (NINSTANCES < SBNUMINSTANCES) { |
| 1156 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &DT) != 0) { | 1130 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &DT) != 0) { |
| 1157 m_pModule->JBig2_Error( | |
| 1158 "text region decoding procedure (huffman): too short."); | |
| 1159 goto failed; | 1131 goto failed; |
| 1160 } | 1132 } |
| 1161 DT *= SBSTRIPS; | 1133 DT *= SBSTRIPS; |
| 1162 STRIPT = STRIPT + DT; | 1134 STRIPT = STRIPT + DT; |
| 1163 bFirst = TRUE; | 1135 bFirst = TRUE; |
| 1164 for (;;) { | 1136 for (;;) { |
| 1165 if (bFirst) { | 1137 if (bFirst) { |
| 1166 if (pHuffmanDecoder->decodeAValue(SBHUFFFS, &DFS) != 0) { | 1138 if (pHuffmanDecoder->decodeAValue(SBHUFFFS, &DFS) != 0) { |
| 1167 m_pModule->JBig2_Error( | |
| 1168 "text region decoding procedure (huffman): too short."); | |
| 1169 goto failed; | 1139 goto failed; |
| 1170 } | 1140 } |
| 1171 FIRSTS = FIRSTS + DFS; | 1141 FIRSTS = FIRSTS + DFS; |
| 1172 CURS = FIRSTS; | 1142 CURS = FIRSTS; |
| 1173 bFirst = FALSE; | 1143 bFirst = FALSE; |
| 1174 } else { | 1144 } else { |
| 1175 nVal = pHuffmanDecoder->decodeAValue(SBHUFFDS, &IDS); | 1145 nVal = pHuffmanDecoder->decodeAValue(SBHUFFDS, &IDS); |
| 1176 if (nVal == JBIG2_OOB) { | 1146 if (nVal == JBIG2_OOB) { |
| 1177 break; | 1147 break; |
| 1178 } else if (nVal != 0) { | 1148 } else if (nVal != 0) { |
| 1179 m_pModule->JBig2_Error( | |
| 1180 "text region decoding procedure (huffman): too short."); | |
| 1181 goto failed; | 1149 goto failed; |
| 1182 } else { | 1150 } else { |
| 1183 CURS = CURS + IDS + SBDSOFFSET; | 1151 CURS = CURS + IDS + SBDSOFFSET; |
| 1184 } | 1152 } |
| 1185 } | 1153 } |
| 1186 if (SBSTRIPS == 1) { | 1154 if (SBSTRIPS == 1) { |
| 1187 CURT = 0; | 1155 CURT = 0; |
| 1188 } else { | 1156 } else { |
| 1189 nTmp = 1; | 1157 nTmp = 1; |
| 1190 while ((FX_DWORD)(1 << nTmp) < SBSTRIPS) { | 1158 while ((FX_DWORD)(1 << nTmp) < SBSTRIPS) { |
| 1191 nTmp++; | 1159 nTmp++; |
| 1192 } | 1160 } |
| 1193 if (pStream->readNBits(nTmp, &nVal) != 0) { | 1161 if (pStream->readNBits(nTmp, &nVal) != 0) { |
| 1194 m_pModule->JBig2_Error( | |
| 1195 "text region decoding procedure (huffman): too short."); | |
| 1196 goto failed; | 1162 goto failed; |
| 1197 } | 1163 } |
| 1198 CURT = nVal; | 1164 CURT = nVal; |
| 1199 } | 1165 } |
| 1200 TI = STRIPT + CURT; | 1166 TI = STRIPT + CURT; |
| 1201 nVal = 0; | 1167 nVal = 0; |
| 1202 nBits = 0; | 1168 nBits = 0; |
| 1203 for (;;) { | 1169 for (;;) { |
| 1204 if (pStream->read1Bit(&nTmp) != 0) { | 1170 if (pStream->read1Bit(&nTmp) != 0) { |
| 1205 m_pModule->JBig2_Error( | |
| 1206 "text region decoding procedure (huffman): too short."); | |
| 1207 goto failed; | 1171 goto failed; |
| 1208 } | 1172 } |
| 1209 nVal = (nVal << 1) | nTmp; | 1173 nVal = (nVal << 1) | nTmp; |
| 1210 nBits++; | 1174 nBits++; |
| 1211 for (IDI = 0; IDI < SBNUMSYMS; IDI++) { | 1175 for (IDI = 0; IDI < SBNUMSYMS; IDI++) { |
| 1212 if ((nBits == SBSYMCODES[IDI].codelen) && | 1176 if ((nBits == SBSYMCODES[IDI].codelen) && |
| 1213 (nVal == SBSYMCODES[IDI].code)) { | 1177 (nVal == SBSYMCODES[IDI].code)) { |
| 1214 break; | 1178 break; |
| 1215 } | 1179 } |
| 1216 } | 1180 } |
| 1217 if (IDI < SBNUMSYMS) { | 1181 if (IDI < SBNUMSYMS) { |
| 1218 break; | 1182 break; |
| 1219 } | 1183 } |
| 1220 } | 1184 } |
| 1221 if (SBREFINE == 0) { | 1185 if (SBREFINE == 0) { |
| 1222 RI = 0; | 1186 RI = 0; |
| 1223 } else { | 1187 } else { |
| 1224 if (pStream->read1Bit(&RI) != 0) { | 1188 if (pStream->read1Bit(&RI) != 0) { |
| 1225 m_pModule->JBig2_Error( | |
| 1226 "text region decoding procedure (huffman): too short."); | |
| 1227 goto failed; | 1189 goto failed; |
| 1228 } | 1190 } |
| 1229 } | 1191 } |
| 1230 if (RI == 0) { | 1192 if (RI == 0) { |
| 1231 IBI = SBSYMS[IDI]; | 1193 IBI = SBSYMS[IDI]; |
| 1232 } else { | 1194 } else { |
| 1233 if ((pHuffmanDecoder->decodeAValue(SBHUFFRDW, &RDWI) != 0) || | 1195 if ((pHuffmanDecoder->decodeAValue(SBHUFFRDW, &RDWI) != 0) || |
| 1234 (pHuffmanDecoder->decodeAValue(SBHUFFRDH, &RDHI) != 0) || | 1196 (pHuffmanDecoder->decodeAValue(SBHUFFRDH, &RDHI) != 0) || |
| 1235 (pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDXI) != 0) || | 1197 (pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDXI) != 0) || |
| 1236 (pHuffmanDecoder->decodeAValue(SBHUFFRDY, &RDYI) != 0) || | 1198 (pHuffmanDecoder->decodeAValue(SBHUFFRDY, &RDYI) != 0) || |
| 1237 (pHuffmanDecoder->decodeAValue(SBHUFFRSIZE, &nVal) != 0)) { | 1199 (pHuffmanDecoder->decodeAValue(SBHUFFRSIZE, &nVal) != 0)) { |
| 1238 m_pModule->JBig2_Error( | |
| 1239 "text region decoding procedure (huffman): too short."); | |
| 1240 goto failed; | 1200 goto failed; |
| 1241 } | 1201 } |
| 1242 pStream->alignByte(); | 1202 pStream->alignByte(); |
| 1243 nTmp = pStream->getOffset(); | 1203 nTmp = pStream->getOffset(); |
| 1244 IBOI = SBSYMS[IDI]; | 1204 IBOI = SBSYMS[IDI]; |
| 1245 if (!IBOI) { | 1205 if (!IBOI) { |
| 1246 goto failed; | 1206 goto failed; |
| 1247 } | 1207 } |
| 1248 WOI = IBOI->m_nWidth; | 1208 WOI = IBOI->m_nWidth; |
| 1249 HOI = IBOI->m_nHeight; | 1209 HOI = IBOI->m_nHeight; |
| 1250 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { | 1210 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { |
| 1251 m_pModule->JBig2_Error( | |
| 1252 "text region decoding procedure (huffman): Invalid RDWI or RDHI " | |
| 1253 "value."); | |
| 1254 goto failed; | 1211 goto failed; |
| 1255 } | 1212 } |
| 1256 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); | 1213 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); |
| 1257 pGRRD->GRW = WOI + RDWI; | 1214 pGRRD->GRW = WOI + RDWI; |
| 1258 pGRRD->GRH = HOI + RDHI; | 1215 pGRRD->GRH = HOI + RDHI; |
| 1259 pGRRD->GRTEMPLATE = SBRTEMPLATE; | 1216 pGRRD->GRTEMPLATE = SBRTEMPLATE; |
| 1260 pGRRD->GRREFERENCE = IBOI; | 1217 pGRRD->GRREFERENCE = IBOI; |
| 1261 pGRRD->GRREFERENCEDX = (RDWI >> 2) + RDXI; | 1218 pGRRD->GRREFERENCEDX = (RDWI >> 2) + RDXI; |
| 1262 pGRRD->GRREFERENCEDY = (RDHI >> 2) + RDYI; | 1219 pGRRD->GRREFERENCEDY = (RDHI >> 2) + RDYI; |
| 1263 pGRRD->TPGRON = 0; | 1220 pGRRD->TPGRON = 0; |
| 1264 pGRRD->GRAT[0] = SBRAT[0]; | 1221 pGRRD->GRAT[0] = SBRAT[0]; |
| 1265 pGRRD->GRAT[1] = SBRAT[1]; | 1222 pGRRD->GRAT[1] = SBRAT[1]; |
| 1266 pGRRD->GRAT[2] = SBRAT[2]; | 1223 pGRRD->GRAT[2] = SBRAT[2]; |
| 1267 pGRRD->GRAT[3] = SBRAT[3]; | 1224 pGRRD->GRAT[3] = SBRAT[3]; |
| 1268 pArithDecoder = new CJBig2_ArithDecoder(pStream); | 1225 pArithDecoder = new CJBig2_ArithDecoder(pStream); |
| 1269 IBI = pGRRD->decode(pArithDecoder, grContext); | 1226 IBI = pGRRD->decode(pArithDecoder, grContext); |
| 1270 if (IBI == NULL) { | 1227 if (IBI == NULL) { |
| 1271 delete pGRRD; | 1228 delete pGRRD; |
| 1272 delete pArithDecoder; | 1229 delete pArithDecoder; |
| 1273 goto failed; | 1230 goto failed; |
| 1274 } | 1231 } |
| 1275 delete pArithDecoder; | 1232 delete pArithDecoder; |
| 1276 pStream->alignByte(); | 1233 pStream->alignByte(); |
| 1277 pStream->offset(2); | 1234 pStream->offset(2); |
| 1278 if ((FX_DWORD)nVal != (pStream->getOffset() - nTmp)) { | 1235 if ((FX_DWORD)nVal != (pStream->getOffset() - nTmp)) { |
| 1279 delete IBI; | 1236 delete IBI; |
| 1280 delete pGRRD; | 1237 delete pGRRD; |
| 1281 m_pModule->JBig2_Error( | |
| 1282 "text region decoding procedure (huffman):" | |
| 1283 "bytes processed by generic refinement region decoding procedure " | |
| 1284 "doesn't equal SBHUFFRSIZE."); | |
| 1285 goto failed; | 1238 goto failed; |
| 1286 } | 1239 } |
| 1287 delete pGRRD; | 1240 delete pGRRD; |
| 1288 } | 1241 } |
| 1289 if (!IBI) { | 1242 if (!IBI) { |
| 1290 continue; | 1243 continue; |
| 1291 } | 1244 } |
| 1292 WI = IBI->m_nWidth; | 1245 WI = IBI->m_nWidth; |
| 1293 HI = IBI->m_nHeight; | 1246 HI = IBI->m_nHeight; |
| 1294 if (TRANSPOSED == 0 && ((REFCORNER == JBIG2_CORNER_TOPRIGHT) || | 1247 if (TRANSPOSED == 0 && ((REFCORNER == JBIG2_CORNER_TOPRIGHT) || |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 IARDW = new CJBig2_ArithIntDecoder(); | 1348 IARDW = new CJBig2_ArithIntDecoder(); |
| 1396 IARDH = new CJBig2_ArithIntDecoder(); | 1349 IARDH = new CJBig2_ArithIntDecoder(); |
| 1397 IARDX = new CJBig2_ArithIntDecoder(); | 1350 IARDX = new CJBig2_ArithIntDecoder(); |
| 1398 IARDY = new CJBig2_ArithIntDecoder(); | 1351 IARDY = new CJBig2_ArithIntDecoder(); |
| 1399 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); | 1352 IAID = new CJBig2_ArithIaidDecoder(SBSYMCODELEN); |
| 1400 bRetained = FALSE; | 1353 bRetained = FALSE; |
| 1401 } | 1354 } |
| 1402 JBIG2_ALLOC(SBREG, CJBig2_Image(SBW, SBH)); | 1355 JBIG2_ALLOC(SBREG, CJBig2_Image(SBW, SBH)); |
| 1403 SBREG->fill(SBDEFPIXEL); | 1356 SBREG->fill(SBDEFPIXEL); |
| 1404 if (IADT->decode(pArithDecoder, &STRIPT) == -1) { | 1357 if (IADT->decode(pArithDecoder, &STRIPT) == -1) { |
| 1405 m_pModule->JBig2_Error( | |
| 1406 "text region decoding procedure (arith): too short."); | |
| 1407 goto failed; | 1358 goto failed; |
| 1408 } | 1359 } |
| 1409 STRIPT *= SBSTRIPS; | 1360 STRIPT *= SBSTRIPS; |
| 1410 STRIPT = -STRIPT; | 1361 STRIPT = -STRIPT; |
| 1411 FIRSTS = 0; | 1362 FIRSTS = 0; |
| 1412 NINSTANCES = 0; | 1363 NINSTANCES = 0; |
| 1413 while (NINSTANCES < SBNUMINSTANCES) { | 1364 while (NINSTANCES < SBNUMINSTANCES) { |
| 1414 if (IADT->decode(pArithDecoder, &DT) == -1) { | 1365 if (IADT->decode(pArithDecoder, &DT) == -1) { |
| 1415 m_pModule->JBig2_Error( | |
| 1416 "text region decoding procedure (arith): too short."); | |
| 1417 goto failed; | 1366 goto failed; |
| 1418 } | 1367 } |
| 1419 DT *= SBSTRIPS; | 1368 DT *= SBSTRIPS; |
| 1420 STRIPT = STRIPT + DT; | 1369 STRIPT = STRIPT + DT; |
| 1421 bFirst = TRUE; | 1370 bFirst = TRUE; |
| 1422 for (;;) { | 1371 for (;;) { |
| 1423 if (bFirst) { | 1372 if (bFirst) { |
| 1424 if (IAFS->decode(pArithDecoder, &DFS) == -1) { | 1373 if (IAFS->decode(pArithDecoder, &DFS) == -1) { |
| 1425 m_pModule->JBig2_Error( | |
| 1426 "text region decoding procedure (arith): too short."); | |
| 1427 goto failed; | 1374 goto failed; |
| 1428 } | 1375 } |
| 1429 FIRSTS = FIRSTS + DFS; | 1376 FIRSTS = FIRSTS + DFS; |
| 1430 CURS = FIRSTS; | 1377 CURS = FIRSTS; |
| 1431 bFirst = FALSE; | 1378 bFirst = FALSE; |
| 1432 } else { | 1379 } else { |
| 1433 nRet = IADS->decode(pArithDecoder, &IDS); | 1380 nRet = IADS->decode(pArithDecoder, &IDS); |
| 1434 if (nRet == JBIG2_OOB) { | 1381 if (nRet == JBIG2_OOB) { |
| 1435 break; | 1382 break; |
| 1436 } else if (nRet != 0) { | 1383 } else if (nRet != 0) { |
| 1437 m_pModule->JBig2_Error( | |
| 1438 "text region decoding procedure (arith): too short."); | |
| 1439 goto failed; | 1384 goto failed; |
| 1440 } else { | 1385 } else { |
| 1441 CURS = CURS + IDS + SBDSOFFSET; | 1386 CURS = CURS + IDS + SBDSOFFSET; |
| 1442 } | 1387 } |
| 1443 } | 1388 } |
| 1444 if (NINSTANCES >= SBNUMINSTANCES) { | 1389 if (NINSTANCES >= SBNUMINSTANCES) { |
| 1445 break; | 1390 break; |
| 1446 } | 1391 } |
| 1447 if (SBSTRIPS == 1) { | 1392 if (SBSTRIPS == 1) { |
| 1448 CURT = 0; | 1393 CURT = 0; |
| 1449 } else { | 1394 } else { |
| 1450 if (IAIT->decode(pArithDecoder, &nVal) == -1) { | 1395 if (IAIT->decode(pArithDecoder, &nVal) == -1) { |
| 1451 m_pModule->JBig2_Error( | |
| 1452 "text region decoding procedure (arith): too short."); | |
| 1453 goto failed; | 1396 goto failed; |
| 1454 } | 1397 } |
| 1455 CURT = nVal; | 1398 CURT = nVal; |
| 1456 } | 1399 } |
| 1457 TI = STRIPT + CURT; | 1400 TI = STRIPT + CURT; |
| 1458 if (IAID->decode(pArithDecoder, &nVal) == -1) { | 1401 if (IAID->decode(pArithDecoder, &nVal) == -1) { |
| 1459 m_pModule->JBig2_Error( | |
| 1460 "text region decoding procedure (arith): too short."); | |
| 1461 goto failed; | 1402 goto failed; |
| 1462 } | 1403 } |
| 1463 IDI = nVal; | 1404 IDI = nVal; |
| 1464 if (IDI >= SBNUMSYMS) { | 1405 if (IDI >= SBNUMSYMS) { |
| 1465 m_pModule->JBig2_Error( | |
| 1466 "text region decoding procedure (arith): symbol id out of " | |
| 1467 "range.(%d/%d)", | |
| 1468 IDI, SBNUMSYMS); | |
| 1469 goto failed; | 1406 goto failed; |
| 1470 } | 1407 } |
| 1471 if (SBREFINE == 0) { | 1408 if (SBREFINE == 0) { |
| 1472 RI = 0; | 1409 RI = 0; |
| 1473 } else { | 1410 } else { |
| 1474 if (IARI->decode(pArithDecoder, &RI) == -1) { | 1411 if (IARI->decode(pArithDecoder, &RI) == -1) { |
| 1475 m_pModule->JBig2_Error( | |
| 1476 "text region decoding procedure (arith): too short."); | |
| 1477 goto failed; | 1412 goto failed; |
| 1478 } | 1413 } |
| 1479 } | 1414 } |
| 1480 if (!SBSYMS[IDI]) { | 1415 if (!SBSYMS[IDI]) { |
| 1481 goto failed; | 1416 goto failed; |
| 1482 } | 1417 } |
| 1483 if (RI == 0) { | 1418 if (RI == 0) { |
| 1484 IBI = SBSYMS[IDI]; | 1419 IBI = SBSYMS[IDI]; |
| 1485 } else { | 1420 } else { |
| 1486 if ((IARDW->decode(pArithDecoder, &RDWI) == -1) || | 1421 if ((IARDW->decode(pArithDecoder, &RDWI) == -1) || |
| 1487 (IARDH->decode(pArithDecoder, &RDHI) == -1) || | 1422 (IARDH->decode(pArithDecoder, &RDHI) == -1) || |
| 1488 (IARDX->decode(pArithDecoder, &RDXI) == -1) || | 1423 (IARDX->decode(pArithDecoder, &RDXI) == -1) || |
| 1489 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { | 1424 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { |
| 1490 m_pModule->JBig2_Error( | |
| 1491 "text region decoding procedure (arith): too short."); | |
| 1492 goto failed; | 1425 goto failed; |
| 1493 } | 1426 } |
| 1494 IBOI = SBSYMS[IDI]; | 1427 IBOI = SBSYMS[IDI]; |
| 1495 WOI = IBOI->m_nWidth; | 1428 WOI = IBOI->m_nWidth; |
| 1496 HOI = IBOI->m_nHeight; | 1429 HOI = IBOI->m_nHeight; |
| 1497 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { | 1430 if ((int)(WOI + RDWI) < 0 || (int)(HOI + RDHI) < 0) { |
| 1498 m_pModule->JBig2_Error( | |
| 1499 "text region decoding procedure (arith): Invalid RDWI or RDHI " | |
| 1500 "value."); | |
| 1501 goto failed; | 1431 goto failed; |
| 1502 } | 1432 } |
| 1503 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); | 1433 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); |
| 1504 pGRRD->GRW = WOI + RDWI; | 1434 pGRRD->GRW = WOI + RDWI; |
| 1505 pGRRD->GRH = HOI + RDHI; | 1435 pGRRD->GRH = HOI + RDHI; |
| 1506 pGRRD->GRTEMPLATE = SBRTEMPLATE; | 1436 pGRRD->GRTEMPLATE = SBRTEMPLATE; |
| 1507 pGRRD->GRREFERENCE = IBOI; | 1437 pGRRD->GRREFERENCE = IBOI; |
| 1508 pGRRD->GRREFERENCEDX = (RDWI >> 1) + RDXI; | 1438 pGRRD->GRREFERENCEDX = (RDWI >> 1) + RDXI; |
| 1509 pGRRD->GRREFERENCEDY = (RDHI >> 1) + RDYI; | 1439 pGRRD->GRREFERENCEDY = (RDHI >> 1) + RDYI; |
| 1510 pGRRD->TPGRON = 0; | 1440 pGRRD->TPGRON = 0; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 } | 1581 } |
| 1652 IAID = new CJBig2_ArithIaidDecoder((uint8_t)nTmp); | 1582 IAID = new CJBig2_ArithIaidDecoder((uint8_t)nTmp); |
| 1653 SDNEWSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2(SDNUMNEWSYMS, | 1583 SDNEWSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2(SDNUMNEWSYMS, |
| 1654 sizeof(CJBig2_Image*)); | 1584 sizeof(CJBig2_Image*)); |
| 1655 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); | 1585 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); |
| 1656 HCHEIGHT = 0; | 1586 HCHEIGHT = 0; |
| 1657 NSYMSDECODED = 0; | 1587 NSYMSDECODED = 0; |
| 1658 while (NSYMSDECODED < SDNUMNEWSYMS) { | 1588 while (NSYMSDECODED < SDNUMNEWSYMS) { |
| 1659 BS = NULL; | 1589 BS = NULL; |
| 1660 if (IADH->decode(pArithDecoder, &HCDH) == -1) { | 1590 if (IADH->decode(pArithDecoder, &HCDH) == -1) { |
| 1661 m_pModule->JBig2_Error( | |
| 1662 "symbol dictionary decoding procedure (arith): too short."); | |
| 1663 goto failed; | 1591 goto failed; |
| 1664 } | 1592 } |
| 1665 HCHEIGHT = HCHEIGHT + HCDH; | 1593 HCHEIGHT = HCHEIGHT + HCDH; |
| 1666 if ((int)HCHEIGHT < 0 || (int)HCHEIGHT > JBIG2_MAX_IMAGE_SIZE) { | 1594 if ((int)HCHEIGHT < 0 || (int)HCHEIGHT > JBIG2_MAX_IMAGE_SIZE) { |
| 1667 m_pModule->JBig2_Error( | |
| 1668 "symbol dictionary decoding procedure (arith): invalid HCHEIGHT " | |
| 1669 "value."); | |
| 1670 goto failed; | 1595 goto failed; |
| 1671 } | 1596 } |
| 1672 SYMWIDTH = 0; | 1597 SYMWIDTH = 0; |
| 1673 TOTWIDTH = 0; | 1598 TOTWIDTH = 0; |
| 1674 for (;;) { | 1599 for (;;) { |
| 1675 nVal = IADW->decode(pArithDecoder, &DW); | 1600 nVal = IADW->decode(pArithDecoder, &DW); |
| 1676 if (nVal == JBIG2_OOB) { | 1601 if (nVal == JBIG2_OOB) { |
| 1677 break; | 1602 break; |
| 1678 } else if (nVal != 0) { | 1603 } else if (nVal != 0) { |
| 1679 m_pModule->JBig2_Error( | |
| 1680 "symbol dictionary decoding procedure (arith): too short."); | |
| 1681 goto failed; | 1604 goto failed; |
| 1682 } else { | 1605 } else { |
| 1683 if (NSYMSDECODED >= SDNUMNEWSYMS) { | 1606 if (NSYMSDECODED >= SDNUMNEWSYMS) { |
| 1684 m_pModule->JBig2_Error( | |
| 1685 "symbol dictionary decoding procedure (arith): NSYMSDECODED >= " | |
| 1686 "SDNUMNEWSYMS."); | |
| 1687 goto failed; | 1607 goto failed; |
| 1688 } | 1608 } |
| 1689 SYMWIDTH = SYMWIDTH + DW; | 1609 SYMWIDTH = SYMWIDTH + DW; |
| 1690 if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) { | 1610 if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) { |
| 1691 m_pModule->JBig2_Error( | |
| 1692 "symbol dictionary decoding procedure (arith): invalid SYMWIDTH " | |
| 1693 "value."); | |
| 1694 goto failed; | 1611 goto failed; |
| 1695 } else if (HCHEIGHT == 0 || SYMWIDTH == 0) { | 1612 } else if (HCHEIGHT == 0 || SYMWIDTH == 0) { |
| 1696 TOTWIDTH = TOTWIDTH + SYMWIDTH; | 1613 TOTWIDTH = TOTWIDTH + SYMWIDTH; |
| 1697 SDNEWSYMS[NSYMSDECODED] = NULL; | 1614 SDNEWSYMS[NSYMSDECODED] = NULL; |
| 1698 NSYMSDECODED = NSYMSDECODED + 1; | 1615 NSYMSDECODED = NSYMSDECODED + 1; |
| 1699 continue; | 1616 continue; |
| 1700 } | 1617 } |
| 1701 TOTWIDTH = TOTWIDTH + SYMWIDTH; | 1618 TOTWIDTH = TOTWIDTH + SYMWIDTH; |
| 1702 } | 1619 } |
| 1703 if (SDREFAGG == 0) { | 1620 if (SDREFAGG == 0) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1717 pGRD->GBAT[6] = SDAT[6]; | 1634 pGRD->GBAT[6] = SDAT[6]; |
| 1718 pGRD->GBAT[7] = SDAT[7]; | 1635 pGRD->GBAT[7] = SDAT[7]; |
| 1719 BS = pGRD->decode_Arith(pArithDecoder, gbContext); | 1636 BS = pGRD->decode_Arith(pArithDecoder, gbContext); |
| 1720 if (BS == NULL) { | 1637 if (BS == NULL) { |
| 1721 delete pGRD; | 1638 delete pGRD; |
| 1722 goto failed; | 1639 goto failed; |
| 1723 } | 1640 } |
| 1724 delete pGRD; | 1641 delete pGRD; |
| 1725 } else { | 1642 } else { |
| 1726 if (IAAI->decode(pArithDecoder, (int*)&REFAGGNINST) == -1) { | 1643 if (IAAI->decode(pArithDecoder, (int*)&REFAGGNINST) == -1) { |
| 1727 m_pModule->JBig2_Error( | |
| 1728 "symbol dictionary decoding procedure (arith): too short."); | |
| 1729 goto failed; | 1644 goto failed; |
| 1730 } | 1645 } |
| 1731 if (REFAGGNINST > 1) { | 1646 if (REFAGGNINST > 1) { |
| 1732 CJBig2_TRDProc* pDecoder; | 1647 CJBig2_TRDProc* pDecoder; |
| 1733 JBIG2_ALLOC(pDecoder, CJBig2_TRDProc()); | 1648 JBIG2_ALLOC(pDecoder, CJBig2_TRDProc()); |
| 1734 pDecoder->SBHUFF = SDHUFF; | 1649 pDecoder->SBHUFF = SDHUFF; |
| 1735 pDecoder->SBREFINE = 1; | 1650 pDecoder->SBREFINE = 1; |
| 1736 pDecoder->SBW = SYMWIDTH; | 1651 pDecoder->SBW = SYMWIDTH; |
| 1737 pDecoder->SBH = HCHEIGHT; | 1652 pDecoder->SBH = HCHEIGHT; |
| 1738 pDecoder->SBNUMINSTANCES = REFAGGNINST; | 1653 pDecoder->SBNUMINSTANCES = REFAGGNINST; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 delete SBHUFFDT; | 1739 delete SBHUFFDT; |
| 1825 delete SBHUFFRDW; | 1740 delete SBHUFFRDW; |
| 1826 delete SBHUFFRDH; | 1741 delete SBHUFFRDH; |
| 1827 delete SBHUFFRDX; | 1742 delete SBHUFFRDX; |
| 1828 delete SBHUFFRDY; | 1743 delete SBHUFFRDY; |
| 1829 delete SBHUFFRSIZE; | 1744 delete SBHUFFRSIZE; |
| 1830 delete pDecoder; | 1745 delete pDecoder; |
| 1831 } else if (REFAGGNINST == 1) { | 1746 } else if (REFAGGNINST == 1) { |
| 1832 SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; | 1747 SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; |
| 1833 if (IAID->decode(pArithDecoder, (int*)&IDI) == -1) { | 1748 if (IAID->decode(pArithDecoder, (int*)&IDI) == -1) { |
| 1834 m_pModule->JBig2_Error( | |
| 1835 "symbol dictionary decoding procedure (arith): too short."); | |
| 1836 goto failed; | 1749 goto failed; |
| 1837 } | 1750 } |
| 1838 if ((IARDX->decode(pArithDecoder, &RDXI) == -1) || | 1751 if ((IARDX->decode(pArithDecoder, &RDXI) == -1) || |
| 1839 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { | 1752 (IARDY->decode(pArithDecoder, &RDYI) == -1)) { |
| 1840 m_pModule->JBig2_Error( | |
| 1841 "symbol dictionary decoding procedure (arith): too short."); | |
| 1842 goto failed; | 1753 goto failed; |
| 1843 } | 1754 } |
| 1844 if (IDI >= SBNUMSYMS) { | 1755 if (IDI >= SBNUMSYMS) { |
| 1845 m_pModule->JBig2_Error( | |
| 1846 "symbol dictionary decoding procedure (arith):" | |
| 1847 " refinement references unknown symbol %d", | |
| 1848 IDI); | |
| 1849 goto failed; | 1756 goto failed; |
| 1850 } | 1757 } |
| 1851 SBSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( | 1758 SBSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( |
| 1852 SBNUMSYMS, sizeof(CJBig2_Image*)); | 1759 SBNUMSYMS, sizeof(CJBig2_Image*)); |
| 1853 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); | 1760 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); |
| 1854 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, | 1761 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, |
| 1855 NSYMSDECODED * sizeof(CJBig2_Image*)); | 1762 NSYMSDECODED * sizeof(CJBig2_Image*)); |
| 1856 if (!SBSYMS[IDI]) { | 1763 if (!SBSYMS[IDI]) { |
| 1857 m_pModule->JBig2_Free(SBSYMS); | 1764 m_pModule->JBig2_Free(SBSYMS); |
| 1858 goto failed; | 1765 goto failed; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1884 NSYMSDECODED = NSYMSDECODED + 1; | 1791 NSYMSDECODED = NSYMSDECODED + 1; |
| 1885 } | 1792 } |
| 1886 } | 1793 } |
| 1887 EXINDEX = 0; | 1794 EXINDEX = 0; |
| 1888 CUREXFLAG = 0; | 1795 CUREXFLAG = 0; |
| 1889 EXFLAGS = (FX_BOOL*)m_pModule->JBig2_Malloc2(sizeof(FX_BOOL), | 1796 EXFLAGS = (FX_BOOL*)m_pModule->JBig2_Malloc2(sizeof(FX_BOOL), |
| 1890 (SDNUMINSYMS + SDNUMNEWSYMS)); | 1797 (SDNUMINSYMS + SDNUMNEWSYMS)); |
| 1891 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { | 1798 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { |
| 1892 if (IAEX->decode(pArithDecoder, (int*)&EXRUNLENGTH) == -1) { | 1799 if (IAEX->decode(pArithDecoder, (int*)&EXRUNLENGTH) == -1) { |
| 1893 m_pModule->JBig2_Free(EXFLAGS); | 1800 m_pModule->JBig2_Free(EXFLAGS); |
| 1894 m_pModule->JBig2_Error( | |
| 1895 "symbol dictionary decoding procedure (arith): too short."); | |
| 1896 goto failed; | 1801 goto failed; |
| 1897 } | 1802 } |
| 1898 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { | 1803 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { |
| 1899 m_pModule->JBig2_Free(EXFLAGS); | 1804 m_pModule->JBig2_Free(EXFLAGS); |
| 1900 m_pModule->JBig2_Error( | |
| 1901 "symbol dictionary decoding procedure (arith): Invalid EXRUNLENGTH " | |
| 1902 "value."); | |
| 1903 goto failed; | 1805 goto failed; |
| 1904 } | 1806 } |
| 1905 if (EXRUNLENGTH != 0) { | 1807 if (EXRUNLENGTH != 0) { |
| 1906 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { | 1808 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { |
| 1907 EXFLAGS[I] = CUREXFLAG; | 1809 EXFLAGS[I] = CUREXFLAG; |
| 1908 } | 1810 } |
| 1909 } | 1811 } |
| 1910 EXINDEX = EXINDEX + EXRUNLENGTH; | 1812 EXINDEX = EXINDEX + EXRUNLENGTH; |
| 1911 CUREXFLAG = !CUREXFLAG; | 1813 CUREXFLAG = !CUREXFLAG; |
| 1912 } | 1814 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 if (SDREFAGG == 0) { | 1915 if (SDREFAGG == 0) { |
| 2014 SDNEWSYMWIDTHS = | 1916 SDNEWSYMWIDTHS = |
| 2015 (FX_DWORD*)m_pModule->JBig2_Malloc2(SDNUMNEWSYMS, sizeof(FX_DWORD)); | 1917 (FX_DWORD*)m_pModule->JBig2_Malloc2(SDNUMNEWSYMS, sizeof(FX_DWORD)); |
| 2016 FXSYS_memset(SDNEWSYMWIDTHS, 0, SDNUMNEWSYMS * sizeof(FX_DWORD)); | 1918 FXSYS_memset(SDNEWSYMWIDTHS, 0, SDNUMNEWSYMS * sizeof(FX_DWORD)); |
| 2017 } | 1919 } |
| 2018 HCHEIGHT = 0; | 1920 HCHEIGHT = 0; |
| 2019 NSYMSDECODED = 0; | 1921 NSYMSDECODED = 0; |
| 2020 BS = NULL; | 1922 BS = NULL; |
| 2021 while (NSYMSDECODED < SDNUMNEWSYMS) { | 1923 while (NSYMSDECODED < SDNUMNEWSYMS) { |
| 2022 if (pHuffmanDecoder->decodeAValue(SDHUFFDH, &HCDH) != 0) { | 1924 if (pHuffmanDecoder->decodeAValue(SDHUFFDH, &HCDH) != 0) { |
| 2023 m_pModule->JBig2_Error( | |
| 2024 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2025 goto failed; | 1925 goto failed; |
| 2026 } | 1926 } |
| 2027 HCHEIGHT = HCHEIGHT + HCDH; | 1927 HCHEIGHT = HCHEIGHT + HCDH; |
| 2028 if ((int)HCHEIGHT < 0 || (int)HCHEIGHT > JBIG2_MAX_IMAGE_SIZE) { | 1928 if ((int)HCHEIGHT < 0 || (int)HCHEIGHT > JBIG2_MAX_IMAGE_SIZE) { |
| 2029 m_pModule->JBig2_Error( | |
| 2030 "symbol dictionary decoding procedure (huffman): invalid HCHEIGHT " | |
| 2031 "value."); | |
| 2032 goto failed; | 1929 goto failed; |
| 2033 } | 1930 } |
| 2034 SYMWIDTH = 0; | 1931 SYMWIDTH = 0; |
| 2035 TOTWIDTH = 0; | 1932 TOTWIDTH = 0; |
| 2036 HCFIRSTSYM = NSYMSDECODED; | 1933 HCFIRSTSYM = NSYMSDECODED; |
| 2037 for (;;) { | 1934 for (;;) { |
| 2038 nVal = pHuffmanDecoder->decodeAValue(SDHUFFDW, &DW); | 1935 nVal = pHuffmanDecoder->decodeAValue(SDHUFFDW, &DW); |
| 2039 if (nVal == JBIG2_OOB) { | 1936 if (nVal == JBIG2_OOB) { |
| 2040 break; | 1937 break; |
| 2041 } else if (nVal != 0) { | 1938 } else if (nVal != 0) { |
| 2042 m_pModule->JBig2_Error( | |
| 2043 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2044 goto failed; | 1939 goto failed; |
| 2045 } else { | 1940 } else { |
| 2046 if (NSYMSDECODED >= SDNUMNEWSYMS) { | 1941 if (NSYMSDECODED >= SDNUMNEWSYMS) { |
| 2047 m_pModule->JBig2_Error( | |
| 2048 "symbol dictionary decoding procedure (huffman): NSYMSDECODED >= " | |
| 2049 "SDNUMNEWSYMS."); | |
| 2050 goto failed; | 1942 goto failed; |
| 2051 } | 1943 } |
| 2052 SYMWIDTH = SYMWIDTH + DW; | 1944 SYMWIDTH = SYMWIDTH + DW; |
| 2053 if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) { | 1945 if ((int)SYMWIDTH < 0 || (int)SYMWIDTH > JBIG2_MAX_IMAGE_SIZE) { |
| 2054 m_pModule->JBig2_Error( | |
| 2055 "symbol dictionary decoding procedure (huffman): invalid " | |
| 2056 "SYMWIDTH value."); | |
| 2057 goto failed; | 1946 goto failed; |
| 2058 } else if (HCHEIGHT == 0 || SYMWIDTH == 0) { | 1947 } else if (HCHEIGHT == 0 || SYMWIDTH == 0) { |
| 2059 TOTWIDTH = TOTWIDTH + SYMWIDTH; | 1948 TOTWIDTH = TOTWIDTH + SYMWIDTH; |
| 2060 SDNEWSYMS[NSYMSDECODED] = NULL; | 1949 SDNEWSYMS[NSYMSDECODED] = NULL; |
| 2061 NSYMSDECODED = NSYMSDECODED + 1; | 1950 NSYMSDECODED = NSYMSDECODED + 1; |
| 2062 continue; | 1951 continue; |
| 2063 } | 1952 } |
| 2064 TOTWIDTH = TOTWIDTH + SYMWIDTH; | 1953 TOTWIDTH = TOTWIDTH + SYMWIDTH; |
| 2065 } | 1954 } |
| 2066 if (SDREFAGG == 1) { | 1955 if (SDREFAGG == 1) { |
| 2067 if (pHuffmanDecoder->decodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) != | 1956 if (pHuffmanDecoder->decodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) != |
| 2068 0) { | 1957 0) { |
| 2069 m_pModule->JBig2_Error( | |
| 2070 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2071 goto failed; | 1958 goto failed; |
| 2072 } | 1959 } |
| 2073 BS = NULL; | 1960 BS = NULL; |
| 2074 if (REFAGGNINST > 1) { | 1961 if (REFAGGNINST > 1) { |
| 2075 CJBig2_TRDProc* pDecoder; | 1962 CJBig2_TRDProc* pDecoder; |
| 2076 JBIG2_ALLOC(pDecoder, CJBig2_TRDProc()); | 1963 JBIG2_ALLOC(pDecoder, CJBig2_TRDProc()); |
| 2077 pDecoder->SBHUFF = SDHUFF; | 1964 pDecoder->SBHUFF = SDHUFF; |
| 2078 pDecoder->SBREFINE = 1; | 1965 pDecoder->SBREFINE = 1; |
| 2079 pDecoder->SBW = SYMWIDTH; | 1966 pDecoder->SBW = SYMWIDTH; |
| 2080 pDecoder->SBH = HCHEIGHT; | 1967 pDecoder->SBH = HCHEIGHT; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2178 SBNUMSYMS, sizeof(JBig2HuffmanCode)); | 2065 SBNUMSYMS, sizeof(JBig2HuffmanCode)); |
| 2179 for (I = 0; I < SBNUMSYMS; I++) { | 2066 for (I = 0; I < SBNUMSYMS; I++) { |
| 2180 SBSYMCODES[I].codelen = SBSYMCODELEN; | 2067 SBSYMCODES[I].codelen = SBSYMCODELEN; |
| 2181 SBSYMCODES[I].code = I; | 2068 SBSYMCODES[I].code = I; |
| 2182 } | 2069 } |
| 2183 nVal = 0; | 2070 nVal = 0; |
| 2184 nBits = 0; | 2071 nBits = 0; |
| 2185 for (;;) { | 2072 for (;;) { |
| 2186 if (pStream->read1Bit(&nTmp) != 0) { | 2073 if (pStream->read1Bit(&nTmp) != 0) { |
| 2187 m_pModule->JBig2_Free(SBSYMCODES); | 2074 m_pModule->JBig2_Free(SBSYMCODES); |
| 2188 m_pModule->JBig2_Error( | |
| 2189 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2190 goto failed; | 2075 goto failed; |
| 2191 } | 2076 } |
| 2192 nVal = (nVal << 1) | nTmp; | 2077 nVal = (nVal << 1) | nTmp; |
| 2193 for (IDI = 0; IDI < SBNUMSYMS; IDI++) { | 2078 for (IDI = 0; IDI < SBNUMSYMS; IDI++) { |
| 2194 if ((nVal == SBSYMCODES[IDI].code) && | 2079 if ((nVal == SBSYMCODES[IDI].code) && |
| 2195 (nBits == SBSYMCODES[IDI].codelen)) { | 2080 (nBits == SBSYMCODES[IDI].codelen)) { |
| 2196 break; | 2081 break; |
| 2197 } | 2082 } |
| 2198 } | 2083 } |
| 2199 if (IDI < SBNUMSYMS) { | 2084 if (IDI < SBNUMSYMS) { |
| 2200 break; | 2085 break; |
| 2201 } | 2086 } |
| 2202 } | 2087 } |
| 2203 m_pModule->JBig2_Free(SBSYMCODES); | 2088 m_pModule->JBig2_Free(SBSYMCODES); |
| 2204 SBHUFFRDX = new CJBig2_HuffmanTable(HuffmanTable_B15, | 2089 SBHUFFRDX = new CJBig2_HuffmanTable(HuffmanTable_B15, |
| 2205 FX_ArraySize(HuffmanTable_B15), | 2090 FX_ArraySize(HuffmanTable_B15), |
| 2206 HuffmanTable_HTOOB_B15); | 2091 HuffmanTable_HTOOB_B15); |
| 2207 SBHUFFRSIZE = new CJBig2_HuffmanTable(HuffmanTable_B1, | 2092 SBHUFFRSIZE = new CJBig2_HuffmanTable(HuffmanTable_B1, |
| 2208 FX_ArraySize(HuffmanTable_B1), | 2093 FX_ArraySize(HuffmanTable_B1), |
| 2209 HuffmanTable_HTOOB_B1); | 2094 HuffmanTable_HTOOB_B1); |
| 2210 if ((pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDXI) != 0) || | 2095 if ((pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDXI) != 0) || |
| 2211 (pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDYI) != 0) || | 2096 (pHuffmanDecoder->decodeAValue(SBHUFFRDX, &RDYI) != 0) || |
| 2212 (pHuffmanDecoder->decodeAValue(SBHUFFRSIZE, &nVal) != 0)) { | 2097 (pHuffmanDecoder->decodeAValue(SBHUFFRSIZE, &nVal) != 0)) { |
| 2213 delete SBHUFFRDX; | 2098 delete SBHUFFRDX; |
| 2214 delete SBHUFFRSIZE; | 2099 delete SBHUFFRSIZE; |
| 2215 m_pModule->JBig2_Error( | |
| 2216 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2217 goto failed; | 2100 goto failed; |
| 2218 } | 2101 } |
| 2219 delete SBHUFFRDX; | 2102 delete SBHUFFRDX; |
| 2220 delete SBHUFFRSIZE; | 2103 delete SBHUFFRSIZE; |
| 2221 pStream->alignByte(); | 2104 pStream->alignByte(); |
| 2222 nTmp = pStream->getOffset(); | 2105 nTmp = pStream->getOffset(); |
| 2223 SBSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( | 2106 SBSYMS = (CJBig2_Image**)m_pModule->JBig2_Malloc2( |
| 2224 SBNUMSYMS, sizeof(CJBig2_Image*)); | 2107 SBNUMSYMS, sizeof(CJBig2_Image*)); |
| 2225 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); | 2108 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); |
| 2226 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, | 2109 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2245 delete pArithDecoder; | 2128 delete pArithDecoder; |
| 2246 goto failed; | 2129 goto failed; |
| 2247 } | 2130 } |
| 2248 pStream->alignByte(); | 2131 pStream->alignByte(); |
| 2249 pStream->offset(2); | 2132 pStream->offset(2); |
| 2250 if ((FX_DWORD)nVal != (pStream->getOffset() - nTmp)) { | 2133 if ((FX_DWORD)nVal != (pStream->getOffset() - nTmp)) { |
| 2251 delete BS; | 2134 delete BS; |
| 2252 m_pModule->JBig2_Free(SBSYMS); | 2135 m_pModule->JBig2_Free(SBSYMS); |
| 2253 delete pGRRD; | 2136 delete pGRRD; |
| 2254 delete pArithDecoder; | 2137 delete pArithDecoder; |
| 2255 m_pModule->JBig2_Error( | |
| 2256 "symbol dictionary decoding procedure (huffman):" | |
| 2257 "bytes processed by generic refinement region decoding " | |
| 2258 "procedure doesn't equal SBHUFFRSIZE."); | |
| 2259 goto failed; | 2138 goto failed; |
| 2260 } | 2139 } |
| 2261 m_pModule->JBig2_Free(SBSYMS); | 2140 m_pModule->JBig2_Free(SBSYMS); |
| 2262 delete pGRRD; | 2141 delete pGRRD; |
| 2263 delete pArithDecoder; | 2142 delete pArithDecoder; |
| 2264 } | 2143 } |
| 2265 SDNEWSYMS[NSYMSDECODED] = BS; | 2144 SDNEWSYMS[NSYMSDECODED] = BS; |
| 2266 } | 2145 } |
| 2267 if (SDREFAGG == 0) { | 2146 if (SDREFAGG == 0) { |
| 2268 SDNEWSYMWIDTHS[NSYMSDECODED] = SYMWIDTH; | 2147 SDNEWSYMWIDTHS[NSYMSDECODED] = SYMWIDTH; |
| 2269 } | 2148 } |
| 2270 NSYMSDECODED = NSYMSDECODED + 1; | 2149 NSYMSDECODED = NSYMSDECODED + 1; |
| 2271 } | 2150 } |
| 2272 if (SDREFAGG == 0) { | 2151 if (SDREFAGG == 0) { |
| 2273 if (pHuffmanDecoder->decodeAValue(SDHUFFBMSIZE, (int32_t*)&BMSIZE) != 0) { | 2152 if (pHuffmanDecoder->decodeAValue(SDHUFFBMSIZE, (int32_t*)&BMSIZE) != 0) { |
| 2274 m_pModule->JBig2_Error( | |
| 2275 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2276 goto failed; | 2153 goto failed; |
| 2277 } | 2154 } |
| 2278 pStream->alignByte(); | 2155 pStream->alignByte(); |
| 2279 if (BMSIZE == 0) { | 2156 if (BMSIZE == 0) { |
| 2280 stride = (TOTWIDTH + 7) >> 3; | 2157 stride = (TOTWIDTH + 7) >> 3; |
| 2281 if (pStream->getByteLeft() >= stride * HCHEIGHT) { | 2158 if (pStream->getByteLeft() >= stride * HCHEIGHT) { |
| 2282 JBIG2_ALLOC(BHC, CJBig2_Image(TOTWIDTH, HCHEIGHT)); | 2159 JBIG2_ALLOC(BHC, CJBig2_Image(TOTWIDTH, HCHEIGHT)); |
| 2283 for (I = 0; I < HCHEIGHT; I++) { | 2160 for (I = 0; I < HCHEIGHT; I++) { |
| 2284 JBIG2_memcpy(BHC->m_pData + I * BHC->m_nStride, | 2161 JBIG2_memcpy(BHC->m_pData + I * BHC->m_nStride, |
| 2285 pStream->getPointer(), stride); | 2162 pStream->getPointer(), stride); |
| 2286 pStream->offset(stride); | 2163 pStream->offset(stride); |
| 2287 } | 2164 } |
| 2288 } else { | 2165 } else { |
| 2289 m_pModule->JBig2_Error( | |
| 2290 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2291 goto failed; | 2166 goto failed; |
| 2292 } | 2167 } |
| 2293 } else { | 2168 } else { |
| 2294 JBIG2_ALLOC(pGRD, CJBig2_GRDProc()); | 2169 JBIG2_ALLOC(pGRD, CJBig2_GRDProc()); |
| 2295 pGRD->MMR = 1; | 2170 pGRD->MMR = 1; |
| 2296 pGRD->GBW = TOTWIDTH; | 2171 pGRD->GBW = TOTWIDTH; |
| 2297 pGRD->GBH = HCHEIGHT; | 2172 pGRD->GBH = HCHEIGHT; |
| 2298 FXCODEC_STATUS status = pGRD->Start_decode_MMR(&BHC, pStream); | 2173 FXCODEC_STATUS status = pGRD->Start_decode_MMR(&BHC, pStream); |
| 2299 while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) { | 2174 while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) { |
| 2300 pGRD->Continue_decode(pPause); | 2175 pGRD->Continue_decode(pPause); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2317 EXINDEX = 0; | 2192 EXINDEX = 0; |
| 2318 CUREXFLAG = 0; | 2193 CUREXFLAG = 0; |
| 2319 pTable = new CJBig2_HuffmanTable( | 2194 pTable = new CJBig2_HuffmanTable( |
| 2320 HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1); | 2195 HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1); |
| 2321 EXFLAGS = (FX_BOOL*)m_pModule->JBig2_Malloc2(sizeof(FX_BOOL), | 2196 EXFLAGS = (FX_BOOL*)m_pModule->JBig2_Malloc2(sizeof(FX_BOOL), |
| 2322 (SDNUMINSYMS + SDNUMNEWSYMS)); | 2197 (SDNUMINSYMS + SDNUMNEWSYMS)); |
| 2323 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { | 2198 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { |
| 2324 if (pHuffmanDecoder->decodeAValue(pTable, (int*)&EXRUNLENGTH) != 0) { | 2199 if (pHuffmanDecoder->decodeAValue(pTable, (int*)&EXRUNLENGTH) != 0) { |
| 2325 delete pTable; | 2200 delete pTable; |
| 2326 m_pModule->JBig2_Free(EXFLAGS); | 2201 m_pModule->JBig2_Free(EXFLAGS); |
| 2327 m_pModule->JBig2_Error( | |
| 2328 "symbol dictionary decoding procedure (huffman): too short."); | |
| 2329 goto failed; | 2202 goto failed; |
| 2330 } | 2203 } |
| 2331 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { | 2204 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { |
| 2332 delete pTable; | 2205 delete pTable; |
| 2333 m_pModule->JBig2_Free(EXFLAGS); | 2206 m_pModule->JBig2_Free(EXFLAGS); |
| 2334 m_pModule->JBig2_Error( | |
| 2335 "symbol dictionary decoding procedure (arith): Invalid EXRUNLENGTH " | |
| 2336 "value."); | |
| 2337 goto failed; | 2207 goto failed; |
| 2338 } | 2208 } |
| 2339 if (EXRUNLENGTH != 0) { | 2209 if (EXRUNLENGTH != 0) { |
| 2340 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { | 2210 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { |
| 2341 EXFLAGS[I] = CUREXFLAG; | 2211 EXFLAGS[I] = CUREXFLAG; |
| 2342 } | 2212 } |
| 2343 } | 2213 } |
| 2344 EXINDEX = EXINDEX + EXRUNLENGTH; | 2214 EXINDEX = EXINDEX + EXRUNLENGTH; |
| 2345 CUREXFLAG = !CUREXFLAG; | 2215 CUREXFLAG = !CUREXFLAG; |
| 2346 } | 2216 } |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 return FXCODEC_STATUS_DECODE_FINISH; | 2612 return FXCODEC_STATUS_DECODE_FINISH; |
| 2743 } | 2613 } |
| 2744 m_ProssiveStatus = FXCODEC_STATUS_DECODE_READY; | 2614 m_ProssiveStatus = FXCODEC_STATUS_DECODE_READY; |
| 2745 m_pPause = pPause; | 2615 m_pPause = pPause; |
| 2746 if (*pImage == NULL) { | 2616 if (*pImage == NULL) { |
| 2747 JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); | 2617 JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); |
| 2748 } | 2618 } |
| 2749 if ((*pImage)->m_pData == NULL) { | 2619 if ((*pImage)->m_pData == NULL) { |
| 2750 delete *pImage; | 2620 delete *pImage; |
| 2751 *pImage = NULL; | 2621 *pImage = NULL; |
| 2752 m_pModule->JBig2_Error( | |
| 2753 "Generic region decoding procedure: Create Image Failed with width = " | |
| 2754 "%d, height = %d\n", | |
| 2755 GBW, GBH); | |
| 2756 m_ProssiveStatus = FXCODEC_STATUS_ERROR; | 2622 m_ProssiveStatus = FXCODEC_STATUS_ERROR; |
| 2757 return FXCODEC_STATUS_ERROR; | 2623 return FXCODEC_STATUS_ERROR; |
| 2758 } | 2624 } |
| 2759 m_DecodeType = 1; | 2625 m_DecodeType = 1; |
| 2760 m_pImage = pImage; | 2626 m_pImage = pImage; |
| 2761 (*m_pImage)->fill(0); | 2627 (*m_pImage)->fill(0); |
| 2762 m_pArithDecoder = pArithDecoder; | 2628 m_pArithDecoder = pArithDecoder; |
| 2763 m_gbContext = gbContext; | 2629 m_gbContext = gbContext; |
| 2764 LTP = 0; | 2630 LTP = 0; |
| 2765 m_pLine = NULL; | 2631 m_pLine = NULL; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 return m_ProssiveStatus; | 2680 return m_ProssiveStatus; |
| 2815 } | 2681 } |
| 2816 FXCODEC_STATUS CJBig2_GRDProc::Start_decode_MMR(CJBig2_Image** pImage, | 2682 FXCODEC_STATUS CJBig2_GRDProc::Start_decode_MMR(CJBig2_Image** pImage, |
| 2817 CJBig2_BitStream* pStream, | 2683 CJBig2_BitStream* pStream, |
| 2818 IFX_Pause* pPause) { | 2684 IFX_Pause* pPause) { |
| 2819 int bitpos, i; | 2685 int bitpos, i; |
| 2820 JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); | 2686 JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); |
| 2821 if ((*pImage)->m_pData == NULL) { | 2687 if ((*pImage)->m_pData == NULL) { |
| 2822 delete (*pImage); | 2688 delete (*pImage); |
| 2823 (*pImage) = NULL; | 2689 (*pImage) = NULL; |
| 2824 m_pModule->JBig2_Error( | |
| 2825 "Generic region decoding procedure: Create Image Failed with width = " | |
| 2826 "%d, height = %d\n", | |
| 2827 GBW, GBH); | |
| 2828 m_ProssiveStatus = FXCODEC_STATUS_ERROR; | 2690 m_ProssiveStatus = FXCODEC_STATUS_ERROR; |
| 2829 return m_ProssiveStatus; | 2691 return m_ProssiveStatus; |
| 2830 } | 2692 } |
| 2831 bitpos = (int)pStream->getBitPos(); | 2693 bitpos = (int)pStream->getBitPos(); |
| 2832 _FaxG4Decode(m_pModule, pStream->getBuf(), pStream->getLength(), &bitpos, | 2694 _FaxG4Decode(m_pModule, pStream->getBuf(), pStream->getLength(), &bitpos, |
| 2833 (*pImage)->m_pData, GBW, GBH, (*pImage)->m_nStride); | 2695 (*pImage)->m_pData, GBW, GBH, (*pImage)->m_nStride); |
| 2834 pStream->setBitPos(bitpos); | 2696 pStream->setBitPos(bitpos); |
| 2835 for (i = 0; (FX_DWORD)i < (*pImage)->m_nStride * GBH; i++) { | 2697 for (i = 0; (FX_DWORD)i < (*pImage)->m_nStride * GBH; i++) { |
| 2836 (*pImage)->m_pData[i] = ~(*pImage)->m_pData[i]; | 2698 (*pImage)->m_pData[i] = ~(*pImage)->m_pData[i]; |
| 2837 } | 2699 } |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 } | 3264 } |
| 3403 if (pPause && pPause->NeedToPauseNow()) { | 3265 if (pPause && pPause->NeedToPauseNow()) { |
| 3404 m_loopIndex++; | 3266 m_loopIndex++; |
| 3405 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; | 3267 m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 3406 return FXCODEC_STATUS_DECODE_TOBECONTINUE; | 3268 return FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 3407 } | 3269 } |
| 3408 } | 3270 } |
| 3409 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; | 3271 m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; |
| 3410 return FXCODEC_STATUS_DECODE_FINISH; | 3272 return FXCODEC_STATUS_DECODE_FINISH; |
| 3411 } | 3273 } |
| OLD | NEW |