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/fxcodec/jbig2/JBig2_SddProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_SddProc.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 12 matching lines...) Expand all Loading... |
23 CJBig2_ArithDecoder* pArithDecoder, | 23 CJBig2_ArithDecoder* pArithDecoder, |
24 std::vector<JBig2ArithCtx>* gbContext, | 24 std::vector<JBig2ArithCtx>* gbContext, |
25 std::vector<JBig2ArithCtx>* grContext) { | 25 std::vector<JBig2ArithCtx>* grContext) { |
26 CJBig2_Image** SDNEWSYMS; | 26 CJBig2_Image** SDNEWSYMS; |
27 uint32_t HCHEIGHT, NSYMSDECODED; | 27 uint32_t HCHEIGHT, NSYMSDECODED; |
28 int32_t HCDH; | 28 int32_t HCDH; |
29 uint32_t SYMWIDTH, TOTWIDTH; | 29 uint32_t SYMWIDTH, TOTWIDTH; |
30 int32_t DW; | 30 int32_t DW; |
31 CJBig2_Image* BS; | 31 CJBig2_Image* BS; |
32 uint32_t I, J, REFAGGNINST; | 32 uint32_t I, J, REFAGGNINST; |
33 FX_BOOL* EXFLAGS; | 33 bool* EXFLAGS; |
34 uint32_t EXINDEX; | 34 uint32_t EXINDEX; |
35 FX_BOOL CUREXFLAG; | 35 bool CUREXFLAG; |
36 uint32_t EXRUNLENGTH; | 36 uint32_t EXRUNLENGTH; |
37 uint32_t nTmp; | 37 uint32_t nTmp; |
38 uint32_t SBNUMSYMS; | 38 uint32_t SBNUMSYMS; |
39 uint8_t SBSYMCODELEN; | 39 uint8_t SBSYMCODELEN; |
40 int32_t RDXI, RDYI; | 40 int32_t RDXI, RDYI; |
41 uint32_t num_ex_syms; | 41 uint32_t num_ex_syms; |
42 CJBig2_Image** SBSYMS; | 42 CJBig2_Image** SBSYMS; |
43 std::unique_ptr<CJBig2_ArithIaidDecoder> IAID; | 43 std::unique_ptr<CJBig2_ArithIaidDecoder> IAID; |
44 std::unique_ptr<CJBig2_SymbolDict> pDict; | 44 std::unique_ptr<CJBig2_SymbolDict> pDict; |
45 std::unique_ptr<CJBig2_ArithIntDecoder> IADH(new CJBig2_ArithIntDecoder); | 45 std::unique_ptr<CJBig2_ArithIntDecoder> IADH(new CJBig2_ArithIntDecoder); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 FX_Free(SBSYMS); | 228 FX_Free(SBSYMS); |
229 } | 229 } |
230 } | 230 } |
231 SDNEWSYMS[NSYMSDECODED] = BS; | 231 SDNEWSYMS[NSYMSDECODED] = BS; |
232 BS = nullptr; | 232 BS = nullptr; |
233 NSYMSDECODED = NSYMSDECODED + 1; | 233 NSYMSDECODED = NSYMSDECODED + 1; |
234 } | 234 } |
235 } | 235 } |
236 EXINDEX = 0; | 236 EXINDEX = 0; |
237 CUREXFLAG = 0; | 237 CUREXFLAG = 0; |
238 EXFLAGS = FX_Alloc(FX_BOOL, SDNUMINSYMS + SDNUMNEWSYMS); | 238 EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS); |
239 num_ex_syms = 0; | 239 num_ex_syms = 0; |
240 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { | 240 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { |
241 IAEX->decode(pArithDecoder, (int*)&EXRUNLENGTH); | 241 IAEX->decode(pArithDecoder, (int*)&EXRUNLENGTH); |
242 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { | 242 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { |
243 FX_Free(EXFLAGS); | 243 FX_Free(EXFLAGS); |
244 goto failed; | 244 goto failed; |
245 } | 245 } |
246 if (EXRUNLENGTH != 0) { | 246 if (EXRUNLENGTH != 0) { |
247 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { | 247 for (I = EXINDEX; I < EXINDEX + EXRUNLENGTH; I++) { |
248 if (CUREXFLAG) | 248 if (CUREXFLAG) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 std::vector<JBig2ArithCtx>* grContext, | 292 std::vector<JBig2ArithCtx>* grContext, |
293 IFX_Pause* pPause) { | 293 IFX_Pause* pPause) { |
294 CJBig2_Image** SDNEWSYMS; | 294 CJBig2_Image** SDNEWSYMS; |
295 uint32_t* SDNEWSYMWIDTHS; | 295 uint32_t* SDNEWSYMWIDTHS; |
296 uint32_t HCHEIGHT, NSYMSDECODED; | 296 uint32_t HCHEIGHT, NSYMSDECODED; |
297 int32_t HCDH; | 297 int32_t HCDH; |
298 uint32_t SYMWIDTH, TOTWIDTH, HCFIRSTSYM; | 298 uint32_t SYMWIDTH, TOTWIDTH, HCFIRSTSYM; |
299 int32_t DW; | 299 int32_t DW; |
300 CJBig2_Image *BS, *BHC; | 300 CJBig2_Image *BS, *BHC; |
301 uint32_t I, J, REFAGGNINST; | 301 uint32_t I, J, REFAGGNINST; |
302 FX_BOOL* EXFLAGS; | 302 bool* EXFLAGS; |
303 uint32_t EXINDEX; | 303 uint32_t EXINDEX; |
304 FX_BOOL CUREXFLAG; | 304 bool CUREXFLAG; |
305 uint32_t EXRUNLENGTH; | 305 uint32_t EXRUNLENGTH; |
306 int32_t nVal, nBits; | 306 int32_t nVal, nBits; |
307 uint32_t nTmp; | 307 uint32_t nTmp; |
308 uint32_t SBNUMSYMS; | 308 uint32_t SBNUMSYMS; |
309 uint8_t SBSYMCODELEN; | 309 uint8_t SBSYMCODELEN; |
310 JBig2HuffmanCode* SBSYMCODES; | 310 JBig2HuffmanCode* SBSYMCODES; |
311 uint32_t IDI; | 311 uint32_t IDI; |
312 int32_t RDXI, RDYI; | 312 int32_t RDXI, RDYI; |
313 uint32_t BMSIZE; | 313 uint32_t BMSIZE; |
314 uint32_t stride; | 314 uint32_t stride; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 nTmp += SDNEWSYMWIDTHS[I]; | 557 nTmp += SDNEWSYMWIDTHS[I]; |
558 } | 558 } |
559 delete BHC; | 559 delete BHC; |
560 BHC = nullptr; | 560 BHC = nullptr; |
561 } | 561 } |
562 } | 562 } |
563 EXINDEX = 0; | 563 EXINDEX = 0; |
564 CUREXFLAG = 0; | 564 CUREXFLAG = 0; |
565 pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size, | 565 pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size, |
566 HuffmanTable_HTOOB_B1)); | 566 HuffmanTable_HTOOB_B1)); |
567 EXFLAGS = FX_Alloc(FX_BOOL, SDNUMINSYMS + SDNUMNEWSYMS); | 567 EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS); |
568 num_ex_syms = 0; | 568 num_ex_syms = 0; |
569 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { | 569 while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) { |
570 if (pHuffmanDecoder->decodeAValue(pTable.get(), (int*)&EXRUNLENGTH) != 0) { | 570 if (pHuffmanDecoder->decodeAValue(pTable.get(), (int*)&EXRUNLENGTH) != 0) { |
571 FX_Free(EXFLAGS); | 571 FX_Free(EXFLAGS); |
572 goto failed; | 572 goto failed; |
573 } | 573 } |
574 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { | 574 if (EXINDEX + EXRUNLENGTH > SDNUMINSYMS + SDNUMNEWSYMS) { |
575 FX_Free(EXFLAGS); | 575 FX_Free(EXFLAGS); |
576 goto failed; | 576 goto failed; |
577 } | 577 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 failed: | 613 failed: |
614 for (I = 0; I < NSYMSDECODED; I++) { | 614 for (I = 0; I < NSYMSDECODED; I++) { |
615 delete SDNEWSYMS[I]; | 615 delete SDNEWSYMS[I]; |
616 } | 616 } |
617 FX_Free(SDNEWSYMS); | 617 FX_Free(SDNEWSYMS); |
618 if (SDREFAGG == 0) { | 618 if (SDREFAGG == 0) { |
619 FX_Free(SDNEWSYMWIDTHS); | 619 FX_Free(SDNEWSYMWIDTHS); |
620 } | 620 } |
621 return nullptr; | 621 return nullptr; |
622 } | 622 } |
OLD | NEW |