| 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_TrdProc.h" | 7 #include "core/fxcodec/jbig2/JBig2_TrdProc.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" | 11 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" |
| 12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" | 12 #include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h" |
| 13 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" | 13 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" |
| 14 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" | 14 #include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h" |
| 15 | 15 |
| 16 CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, | 16 CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, |
| 17 JBig2ArithCtx* grContext) { | 17 JBig2ArithCtx* grContext) { |
| 18 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( | 18 std::unique_ptr<CJBig2_HuffmanDecoder> pHuffmanDecoder( |
| 19 new CJBig2_HuffmanDecoder(pStream)); | 19 new CJBig2_HuffmanDecoder(pStream)); |
| 20 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); | 20 std::unique_ptr<CJBig2_Image> SBREG(new CJBig2_Image(SBW, SBH)); |
| 21 SBREG->fill(SBDEFPIXEL); | 21 SBREG->fill(SBDEFPIXEL); |
| 22 int32_t STRIPT; | 22 int32_t STRIPT; |
| 23 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) | 23 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &STRIPT) != 0) |
| 24 return nullptr; | 24 return nullptr; |
| 25 | 25 |
| 26 STRIPT *= SBSTRIPS; | 26 STRIPT *= SBSTRIPS; |
| 27 STRIPT = -STRIPT; | 27 STRIPT = -STRIPT; |
| 28 int32_t FIRSTS = 0; |
| 28 uint32_t NINSTANCES = 0; | 29 uint32_t NINSTANCES = 0; |
| 29 while (NINSTANCES < SBNUMINSTANCES) { | 30 while (NINSTANCES < SBNUMINSTANCES) { |
| 30 int32_t DT; | 31 int32_t DT; |
| 31 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &DT) != 0) | 32 if (pHuffmanDecoder->decodeAValue(SBHUFFDT, &DT) != 0) |
| 32 return nullptr; | 33 return nullptr; |
| 33 | 34 |
| 34 DT *= SBSTRIPS; | 35 DT *= SBSTRIPS; |
| 35 STRIPT = STRIPT + DT; | 36 STRIPT = STRIPT + DT; |
| 36 bool bFirst = true; | 37 bool bFirst = true; |
| 37 int32_t FIRSTS = 0; | |
| 38 int32_t CURS = 0; | 38 int32_t CURS = 0; |
| 39 for (;;) { | 39 for (;;) { |
| 40 if (bFirst) { | 40 if (bFirst) { |
| 41 int32_t DFS; | 41 int32_t DFS; |
| 42 if (pHuffmanDecoder->decodeAValue(SBHUFFFS, &DFS) != 0) | 42 if (pHuffmanDecoder->decodeAValue(SBHUFFFS, &DFS) != 0) |
| 43 return nullptr; | 43 return nullptr; |
| 44 | 44 |
| 45 FIRSTS = FIRSTS + DFS; | 45 FIRSTS = FIRSTS + DFS; |
| 46 CURS = FIRSTS; | 46 CURS = FIRSTS; |
| 47 bFirst = false; | 47 bFirst = false; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 CURS += WI - 1; | 398 CURS += WI - 1; |
| 399 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || | 399 } else if (TRANSPOSED == 1 && ((REFCORNER == JBIG2_CORNER_TOPLEFT) || |
| 400 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { | 400 (REFCORNER == JBIG2_CORNER_TOPRIGHT))) { |
| 401 CURS += HI - 1; | 401 CURS += HI - 1; |
| 402 } | 402 } |
| 403 ++NINSTANCES; | 403 ++NINSTANCES; |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 return SBREG.release(); | 406 return SBREG.release(); |
| 407 } | 407 } |
| OLD | NEW |