| 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> |
| 11 | 11 |
| 12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" | 12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" |
| 13 #include "core/fxcodec/jbig2/JBig2_GrdProc.h" | 13 #include "core/fxcodec/jbig2/JBig2_GrdProc.h" |
| 14 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" | 14 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" |
| 15 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" | 15 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" |
| 16 #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h" | 16 #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h" |
| 17 #include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" | 17 #include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" |
| 18 #include "core/fxcodec/jbig2/JBig2_SymbolDict.h" | 18 #include "core/fxcodec/jbig2/JBig2_SymbolDict.h" |
| 19 #include "core/fxcodec/jbig2/JBig2_TrdProc.h" | 19 #include "core/fxcodec/jbig2/JBig2_TrdProc.h" |
| 20 #include "core/fxcrt/include/fx_basic.h" | 20 #include "core/fxcrt/include/fx_basic.h" |
| 21 | 21 |
| 22 CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( | 22 CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith( |
| 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 FX_DWORD HCHEIGHT, NSYMSDECODED; | 27 uint32_t HCHEIGHT, NSYMSDECODED; |
| 28 int32_t HCDH; | 28 int32_t HCDH; |
| 29 FX_DWORD SYMWIDTH, TOTWIDTH; | 29 uint32_t SYMWIDTH, TOTWIDTH; |
| 30 int32_t DW; | 30 int32_t DW; |
| 31 CJBig2_Image* BS; | 31 CJBig2_Image* BS; |
| 32 FX_DWORD I, J, REFAGGNINST; | 32 uint32_t I, J, REFAGGNINST; |
| 33 FX_BOOL* EXFLAGS; | 33 FX_BOOL* EXFLAGS; |
| 34 FX_DWORD EXINDEX; | 34 uint32_t EXINDEX; |
| 35 FX_BOOL CUREXFLAG; | 35 FX_BOOL CUREXFLAG; |
| 36 FX_DWORD EXRUNLENGTH; | 36 uint32_t EXRUNLENGTH; |
| 37 FX_DWORD nTmp; | 37 uint32_t nTmp; |
| 38 FX_DWORD SBNUMSYMS; | 38 uint32_t SBNUMSYMS; |
| 39 uint8_t SBSYMCODELEN; | 39 uint8_t SBSYMCODELEN; |
| 40 int32_t RDXI, RDYI; | 40 int32_t RDXI, RDYI; |
| 41 CJBig2_Image** SBSYMS; | 41 CJBig2_Image** SBSYMS; |
| 42 std::unique_ptr<CJBig2_ArithIaidDecoder> IAID; | 42 std::unique_ptr<CJBig2_ArithIaidDecoder> IAID; |
| 43 std::unique_ptr<CJBig2_SymbolDict> pDict; | 43 std::unique_ptr<CJBig2_SymbolDict> pDict; |
| 44 std::unique_ptr<CJBig2_ArithIntDecoder> IADH(new CJBig2_ArithIntDecoder); | 44 std::unique_ptr<CJBig2_ArithIntDecoder> IADH(new CJBig2_ArithIntDecoder); |
| 45 std::unique_ptr<CJBig2_ArithIntDecoder> IADW(new CJBig2_ArithIntDecoder); | 45 std::unique_ptr<CJBig2_ArithIntDecoder> IADW(new CJBig2_ArithIntDecoder); |
| 46 std::unique_ptr<CJBig2_ArithIntDecoder> IAAI(new CJBig2_ArithIntDecoder); | 46 std::unique_ptr<CJBig2_ArithIntDecoder> IAAI(new CJBig2_ArithIntDecoder); |
| 47 std::unique_ptr<CJBig2_ArithIntDecoder> IARDX(new CJBig2_ArithIntDecoder); | 47 std::unique_ptr<CJBig2_ArithIntDecoder> IARDX(new CJBig2_ArithIntDecoder); |
| 48 std::unique_ptr<CJBig2_ArithIntDecoder> IARDY(new CJBig2_ArithIntDecoder); | 48 std::unique_ptr<CJBig2_ArithIntDecoder> IARDY(new CJBig2_ArithIntDecoder); |
| 49 std::unique_ptr<CJBig2_ArithIntDecoder> IAEX(new CJBig2_ArithIntDecoder); | 49 std::unique_ptr<CJBig2_ArithIntDecoder> IAEX(new CJBig2_ArithIntDecoder); |
| 50 std::unique_ptr<CJBig2_ArithIntDecoder> IADT(new CJBig2_ArithIntDecoder); | 50 std::unique_ptr<CJBig2_ArithIntDecoder> IADT(new CJBig2_ArithIntDecoder); |
| 51 std::unique_ptr<CJBig2_ArithIntDecoder> IAFS(new CJBig2_ArithIntDecoder); | 51 std::unique_ptr<CJBig2_ArithIntDecoder> IAFS(new CJBig2_ArithIntDecoder); |
| 52 std::unique_ptr<CJBig2_ArithIntDecoder> IADS(new CJBig2_ArithIntDecoder); | 52 std::unique_ptr<CJBig2_ArithIntDecoder> IADS(new CJBig2_ArithIntDecoder); |
| 53 std::unique_ptr<CJBig2_ArithIntDecoder> IAIT(new CJBig2_ArithIntDecoder); | 53 std::unique_ptr<CJBig2_ArithIntDecoder> IAIT(new CJBig2_ArithIntDecoder); |
| 54 std::unique_ptr<CJBig2_ArithIntDecoder> IARI(new CJBig2_ArithIntDecoder); | 54 std::unique_ptr<CJBig2_ArithIntDecoder> IARI(new CJBig2_ArithIntDecoder); |
| 55 std::unique_ptr<CJBig2_ArithIntDecoder> IARDW(new CJBig2_ArithIntDecoder); | 55 std::unique_ptr<CJBig2_ArithIntDecoder> IARDW(new CJBig2_ArithIntDecoder); |
| 56 std::unique_ptr<CJBig2_ArithIntDecoder> IARDH(new CJBig2_ArithIntDecoder); | 56 std::unique_ptr<CJBig2_ArithIntDecoder> IARDH(new CJBig2_ArithIntDecoder); |
| 57 nTmp = 0; | 57 nTmp = 0; |
| 58 while ((FX_DWORD)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) { | 58 while ((uint32_t)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) { |
| 59 nTmp++; | 59 nTmp++; |
| 60 } | 60 } |
| 61 IAID.reset(new CJBig2_ArithIaidDecoder((uint8_t)nTmp)); | 61 IAID.reset(new CJBig2_ArithIaidDecoder((uint8_t)nTmp)); |
| 62 SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS); | 62 SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS); |
| 63 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); | 63 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); |
| 64 | 64 |
| 65 HCHEIGHT = 0; | 65 HCHEIGHT = 0; |
| 66 NSYMSDECODED = 0; | 66 NSYMSDECODED = 0; |
| 67 while (NSYMSDECODED < SDNUMNEWSYMS) { | 67 while (NSYMSDECODED < SDNUMNEWSYMS) { |
| 68 BS = nullptr; | 68 BS = nullptr; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 std::unique_ptr<CJBig2_TRDProc> pDecoder(new CJBig2_TRDProc()); | 117 std::unique_ptr<CJBig2_TRDProc> pDecoder(new CJBig2_TRDProc()); |
| 118 pDecoder->SBHUFF = SDHUFF; | 118 pDecoder->SBHUFF = SDHUFF; |
| 119 pDecoder->SBREFINE = 1; | 119 pDecoder->SBREFINE = 1; |
| 120 pDecoder->SBW = SYMWIDTH; | 120 pDecoder->SBW = SYMWIDTH; |
| 121 pDecoder->SBH = HCHEIGHT; | 121 pDecoder->SBH = HCHEIGHT; |
| 122 pDecoder->SBNUMINSTANCES = REFAGGNINST; | 122 pDecoder->SBNUMINSTANCES = REFAGGNINST; |
| 123 pDecoder->SBSTRIPS = 1; | 123 pDecoder->SBSTRIPS = 1; |
| 124 pDecoder->SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; | 124 pDecoder->SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; |
| 125 SBNUMSYMS = pDecoder->SBNUMSYMS; | 125 SBNUMSYMS = pDecoder->SBNUMSYMS; |
| 126 nTmp = 0; | 126 nTmp = 0; |
| 127 while ((FX_DWORD)(1 << nTmp) < SBNUMSYMS) { | 127 while ((uint32_t)(1 << nTmp) < SBNUMSYMS) { |
| 128 nTmp++; | 128 nTmp++; |
| 129 } | 129 } |
| 130 SBSYMCODELEN = (uint8_t)nTmp; | 130 SBSYMCODELEN = (uint8_t)nTmp; |
| 131 pDecoder->SBSYMCODELEN = SBSYMCODELEN; | 131 pDecoder->SBSYMCODELEN = SBSYMCODELEN; |
| 132 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); | 132 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); |
| 133 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); | 133 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); |
| 134 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, | 134 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, |
| 135 NSYMSDECODED * sizeof(CJBig2_Image*)); | 135 NSYMSDECODED * sizeof(CJBig2_Image*)); |
| 136 pDecoder->SBSYMS = SBSYMS; | 136 pDecoder->SBSYMS = SBSYMS; |
| 137 pDecoder->SBDEFPIXEL = 0; | 137 pDecoder->SBDEFPIXEL = 0; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ids.IARDY = IARDY.get(); | 185 ids.IARDY = IARDY.get(); |
| 186 ids.IAID = IAID.get(); | 186 ids.IAID = IAID.get(); |
| 187 BS = pDecoder->decode_Arith(pArithDecoder, grContext->data(), &ids); | 187 BS = pDecoder->decode_Arith(pArithDecoder, grContext->data(), &ids); |
| 188 if (!BS) { | 188 if (!BS) { |
| 189 FX_Free(SBSYMS); | 189 FX_Free(SBSYMS); |
| 190 goto failed; | 190 goto failed; |
| 191 } | 191 } |
| 192 FX_Free(SBSYMS); | 192 FX_Free(SBSYMS); |
| 193 } else if (REFAGGNINST == 1) { | 193 } else if (REFAGGNINST == 1) { |
| 194 SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; | 194 SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; |
| 195 FX_DWORD IDI; | 195 uint32_t IDI; |
| 196 IAID->decode(pArithDecoder, &IDI); | 196 IAID->decode(pArithDecoder, &IDI); |
| 197 IARDX->decode(pArithDecoder, &RDXI); | 197 IARDX->decode(pArithDecoder, &RDXI); |
| 198 IARDY->decode(pArithDecoder, &RDYI); | 198 IARDY->decode(pArithDecoder, &RDYI); |
| 199 if (IDI >= SBNUMSYMS) { | 199 if (IDI >= SBNUMSYMS) { |
| 200 goto failed; | 200 goto failed; |
| 201 } | 201 } |
| 202 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); | 202 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); |
| 203 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); | 203 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); |
| 204 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, | 204 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, |
| 205 NSYMSDECODED * sizeof(CJBig2_Image*)); | 205 NSYMSDECODED * sizeof(CJBig2_Image*)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 FX_Free(SDNEWSYMS); | 276 FX_Free(SDNEWSYMS); |
| 277 return nullptr; | 277 return nullptr; |
| 278 } | 278 } |
| 279 | 279 |
| 280 CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( | 280 CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman( |
| 281 CJBig2_BitStream* pStream, | 281 CJBig2_BitStream* pStream, |
| 282 std::vector<JBig2ArithCtx>* gbContext, | 282 std::vector<JBig2ArithCtx>* gbContext, |
| 283 std::vector<JBig2ArithCtx>* grContext, | 283 std::vector<JBig2ArithCtx>* grContext, |
| 284 IFX_Pause* pPause) { | 284 IFX_Pause* pPause) { |
| 285 CJBig2_Image** SDNEWSYMS; | 285 CJBig2_Image** SDNEWSYMS; |
| 286 FX_DWORD* SDNEWSYMWIDTHS; | 286 uint32_t* SDNEWSYMWIDTHS; |
| 287 FX_DWORD HCHEIGHT, NSYMSDECODED; | 287 uint32_t HCHEIGHT, NSYMSDECODED; |
| 288 int32_t HCDH; | 288 int32_t HCDH; |
| 289 FX_DWORD SYMWIDTH, TOTWIDTH, HCFIRSTSYM; | 289 uint32_t SYMWIDTH, TOTWIDTH, HCFIRSTSYM; |
| 290 int32_t DW; | 290 int32_t DW; |
| 291 CJBig2_Image *BS, *BHC; | 291 CJBig2_Image *BS, *BHC; |
| 292 FX_DWORD I, J, REFAGGNINST; | 292 uint32_t I, J, REFAGGNINST; |
| 293 FX_BOOL* EXFLAGS; | 293 FX_BOOL* EXFLAGS; |
| 294 FX_DWORD EXINDEX; | 294 uint32_t EXINDEX; |
| 295 FX_BOOL CUREXFLAG; | 295 FX_BOOL CUREXFLAG; |
| 296 FX_DWORD EXRUNLENGTH; | 296 uint32_t EXRUNLENGTH; |
| 297 int32_t nVal, nBits; | 297 int32_t nVal, nBits; |
| 298 FX_DWORD nTmp; | 298 uint32_t nTmp; |
| 299 FX_DWORD SBNUMSYMS; | 299 uint32_t SBNUMSYMS; |
| 300 uint8_t SBSYMCODELEN; | 300 uint8_t SBSYMCODELEN; |
| 301 JBig2HuffmanCode* SBSYMCODES; | 301 JBig2HuffmanCode* SBSYMCODES; |
| 302 FX_DWORD IDI; | 302 uint32_t IDI; |
| 303 int32_t RDXI, RDYI; | 303 int32_t RDXI, RDYI; |
| 304 FX_DWORD BMSIZE; | 304 uint32_t BMSIZE; |
| 305 FX_DWORD stride; | 305 uint32_t stride; |
| 306 CJBig2_Image** SBSYMS; | 306 CJBig2_Image** SBSYMS; |
| 307 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( | 307 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( |
| 308 new CJBig2_HuffmanDecoder(pStream)); | 308 new CJBig2_HuffmanDecoder(pStream)); |
| 309 SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS); | 309 SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS); |
| 310 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); | 310 FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*)); |
| 311 SDNEWSYMWIDTHS = nullptr; | 311 SDNEWSYMWIDTHS = nullptr; |
| 312 BHC = nullptr; | 312 BHC = nullptr; |
| 313 if (SDREFAGG == 0) { | 313 if (SDREFAGG == 0) { |
| 314 SDNEWSYMWIDTHS = FX_Alloc(FX_DWORD, SDNUMNEWSYMS); | 314 SDNEWSYMWIDTHS = FX_Alloc(uint32_t, SDNUMNEWSYMS); |
| 315 FXSYS_memset(SDNEWSYMWIDTHS, 0, SDNUMNEWSYMS * sizeof(FX_DWORD)); | 315 FXSYS_memset(SDNEWSYMWIDTHS, 0, SDNUMNEWSYMS * sizeof(uint32_t)); |
| 316 } | 316 } |
| 317 std::unique_ptr<CJBig2_SymbolDict> pDict(new CJBig2_SymbolDict()); | 317 std::unique_ptr<CJBig2_SymbolDict> pDict(new CJBig2_SymbolDict()); |
| 318 std::unique_ptr<CJBig2_HuffmanTable> pTable; | 318 std::unique_ptr<CJBig2_HuffmanTable> pTable; |
| 319 | 319 |
| 320 HCHEIGHT = 0; | 320 HCHEIGHT = 0; |
| 321 NSYMSDECODED = 0; | 321 NSYMSDECODED = 0; |
| 322 BS = nullptr; | 322 BS = nullptr; |
| 323 while (NSYMSDECODED < SDNUMNEWSYMS) { | 323 while (NSYMSDECODED < SDNUMNEWSYMS) { |
| 324 if (pHuffmanDecoder->decodeAValue(SDHUFFDH, &HCDH) != 0) { | 324 if (pHuffmanDecoder->decodeAValue(SDHUFFDH, &HCDH) != 0) { |
| 325 goto failed; | 325 goto failed; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 pDecoder->SBHUFF = SDHUFF; | 363 pDecoder->SBHUFF = SDHUFF; |
| 364 pDecoder->SBREFINE = 1; | 364 pDecoder->SBREFINE = 1; |
| 365 pDecoder->SBW = SYMWIDTH; | 365 pDecoder->SBW = SYMWIDTH; |
| 366 pDecoder->SBH = HCHEIGHT; | 366 pDecoder->SBH = HCHEIGHT; |
| 367 pDecoder->SBNUMINSTANCES = REFAGGNINST; | 367 pDecoder->SBNUMINSTANCES = REFAGGNINST; |
| 368 pDecoder->SBSTRIPS = 1; | 368 pDecoder->SBSTRIPS = 1; |
| 369 pDecoder->SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; | 369 pDecoder->SBNUMSYMS = SDNUMINSYMS + NSYMSDECODED; |
| 370 SBNUMSYMS = pDecoder->SBNUMSYMS; | 370 SBNUMSYMS = pDecoder->SBNUMSYMS; |
| 371 SBSYMCODES = FX_Alloc(JBig2HuffmanCode, SBNUMSYMS); | 371 SBSYMCODES = FX_Alloc(JBig2HuffmanCode, SBNUMSYMS); |
| 372 nTmp = 1; | 372 nTmp = 1; |
| 373 while ((FX_DWORD)(1 << nTmp) < SBNUMSYMS) { | 373 while ((uint32_t)(1 << nTmp) < SBNUMSYMS) { |
| 374 nTmp++; | 374 nTmp++; |
| 375 } | 375 } |
| 376 for (I = 0; I < SBNUMSYMS; I++) { | 376 for (I = 0; I < SBNUMSYMS; I++) { |
| 377 SBSYMCODES[I].codelen = nTmp; | 377 SBSYMCODES[I].codelen = nTmp; |
| 378 SBSYMCODES[I].code = I; | 378 SBSYMCODES[I].code = I; |
| 379 } | 379 } |
| 380 pDecoder->SBSYMCODES = SBSYMCODES; | 380 pDecoder->SBSYMCODES = SBSYMCODES; |
| 381 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); | 381 SBSYMS = FX_Alloc(CJBig2_Image*, SBNUMSYMS); |
| 382 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); | 382 JBIG2_memcpy(SBSYMS, SDINSYMS, SDNUMINSYMS * sizeof(CJBig2_Image*)); |
| 383 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, | 383 JBIG2_memcpy(SBSYMS + SDNUMINSYMS, SDNEWSYMS, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (!BS) { | 426 if (!BS) { |
| 427 FX_Free(SBSYMCODES); | 427 FX_Free(SBSYMCODES); |
| 428 FX_Free(SBSYMS); | 428 FX_Free(SBSYMS); |
| 429 goto failed; | 429 goto failed; |
| 430 } | 430 } |
| 431 FX_Free(SBSYMCODES); | 431 FX_Free(SBSYMCODES); |
| 432 FX_Free(SBSYMS); | 432 FX_Free(SBSYMS); |
| 433 } else if (REFAGGNINST == 1) { | 433 } else if (REFAGGNINST == 1) { |
| 434 SBNUMSYMS = SDNUMINSYMS + SDNUMNEWSYMS; | 434 SBNUMSYMS = SDNUMINSYMS + SDNUMNEWSYMS; |
| 435 nTmp = 1; | 435 nTmp = 1; |
| 436 while ((FX_DWORD)(1 << nTmp) < SBNUMSYMS) { | 436 while ((uint32_t)(1 << nTmp) < SBNUMSYMS) { |
| 437 nTmp++; | 437 nTmp++; |
| 438 } | 438 } |
| 439 SBSYMCODELEN = (uint8_t)nTmp; | 439 SBSYMCODELEN = (uint8_t)nTmp; |
| 440 SBSYMCODES = FX_Alloc(JBig2HuffmanCode, SBNUMSYMS); | 440 SBSYMCODES = FX_Alloc(JBig2HuffmanCode, SBNUMSYMS); |
| 441 for (I = 0; I < SBNUMSYMS; I++) { | 441 for (I = 0; I < SBNUMSYMS; I++) { |
| 442 SBSYMCODES[I].codelen = SBSYMCODELEN; | 442 SBSYMCODES[I].codelen = SBSYMCODELEN; |
| 443 SBSYMCODES[I].code = I; | 443 SBSYMCODES[I].code = I; |
| 444 } | 444 } |
| 445 nVal = 0; | 445 nVal = 0; |
| 446 nBits = 0; | 446 nBits = 0; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 pGRRD->GRAT[3] = SDRAT[3]; | 492 pGRRD->GRAT[3] = SDRAT[3]; |
| 493 std::unique_ptr<CJBig2_ArithDecoder> pArithDecoder( | 493 std::unique_ptr<CJBig2_ArithDecoder> pArithDecoder( |
| 494 new CJBig2_ArithDecoder(pStream)); | 494 new CJBig2_ArithDecoder(pStream)); |
| 495 BS = pGRRD->decode(pArithDecoder.get(), grContext->data()); | 495 BS = pGRRD->decode(pArithDecoder.get(), grContext->data()); |
| 496 if (!BS) { | 496 if (!BS) { |
| 497 FX_Free(SBSYMS); | 497 FX_Free(SBSYMS); |
| 498 goto failed; | 498 goto failed; |
| 499 } | 499 } |
| 500 pStream->alignByte(); | 500 pStream->alignByte(); |
| 501 pStream->offset(2); | 501 pStream->offset(2); |
| 502 if ((FX_DWORD)nVal != (pStream->getOffset() - nTmp)) { | 502 if ((uint32_t)nVal != (pStream->getOffset() - nTmp)) { |
| 503 delete BS; | 503 delete BS; |
| 504 FX_Free(SBSYMS); | 504 FX_Free(SBSYMS); |
| 505 goto failed; | 505 goto failed; |
| 506 } | 506 } |
| 507 FX_Free(SBSYMS); | 507 FX_Free(SBSYMS); |
| 508 } | 508 } |
| 509 SDNEWSYMS[NSYMSDECODED] = BS; | 509 SDNEWSYMS[NSYMSDECODED] = BS; |
| 510 } | 510 } |
| 511 if (SDREFAGG == 0) { | 511 if (SDREFAGG == 0) { |
| 512 SDNEWSYMWIDTHS[NSYMSDECODED] = SYMWIDTH; | 512 SDNEWSYMWIDTHS[NSYMSDECODED] = SYMWIDTH; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 failed: | 597 failed: |
| 598 for (I = 0; I < NSYMSDECODED; I++) { | 598 for (I = 0; I < NSYMSDECODED; I++) { |
| 599 delete SDNEWSYMS[I]; | 599 delete SDNEWSYMS[I]; |
| 600 } | 600 } |
| 601 FX_Free(SDNEWSYMS); | 601 FX_Free(SDNEWSYMS); |
| 602 if (SDREFAGG == 0) { | 602 if (SDREFAGG == 0) { |
| 603 FX_Free(SDNEWSYMWIDTHS); | 603 FX_Free(SDNEWSYMWIDTHS); |
| 604 } | 604 } |
| 605 return nullptr; | 605 return nullptr; |
| 606 } | 606 } |
| OLD | NEW |