| 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 #ifndef _JBIG2_ARITHMETIC_DECODER_H_ | 7 #ifndef _JBIG2_ARITHMETIC_DECODER_H_ |
| 8 #define _JBIG2_ARITHMETIC_DECODER_H_ | 8 #define _JBIG2_ARITHMETIC_DECODER_H_ |
| 9 #include "JBig2_Define.h" | 9 #include "JBig2_Define.h" |
| 10 #include "JBig2_BitStream.h" | 10 #include "JBig2_BitStream.h" |
| 11 #include "JBig2_ArithQe.h" | 11 #include "JBig2_ArithQe.h" |
| 12 typedef struct { | 12 |
| 13 struct JBig2ArithCtx { |
| 13 unsigned int MPS; | 14 unsigned int MPS; |
| 14 unsigned int I; | 15 unsigned int I; |
| 15 } JBig2ArithCtx; | 16 }; |
| 16 class CJBig2_ArithDecoder : public CJBig2_Object { | 17 |
| 18 class CJBig2_ArithDecoder { |
| 17 public: | 19 public: |
| 18 CJBig2_ArithDecoder(CJBig2_BitStream* pStream); | 20 explicit CJBig2_ArithDecoder(CJBig2_BitStream* pStream); |
| 19 | 21 |
| 20 ~CJBig2_ArithDecoder(); | 22 ~CJBig2_ArithDecoder(); |
| 21 | 23 |
| 22 int DECODE(JBig2ArithCtx* pCX); | 24 int DECODE(JBig2ArithCtx* pCX); |
| 23 | 25 |
| 24 private: | 26 private: |
| 25 void INITDEC(); | 27 void INITDEC(); |
| 28 void BYTEIN(); |
| 26 | 29 |
| 27 void BYTEIN(); | |
| 28 unsigned char B; | 30 unsigned char B; |
| 29 unsigned int C; | 31 unsigned int C; |
| 30 unsigned int A; | 32 unsigned int A; |
| 31 unsigned int CT; | 33 unsigned int CT; |
| 32 CJBig2_BitStream* m_pStream; | 34 CJBig2_BitStream* m_pStream; |
| 33 }; | 35 }; |
| 36 |
| 34 inline CJBig2_ArithDecoder::CJBig2_ArithDecoder(CJBig2_BitStream* pStream) { | 37 inline CJBig2_ArithDecoder::CJBig2_ArithDecoder(CJBig2_BitStream* pStream) { |
| 35 m_pStream = pStream; | 38 m_pStream = pStream; |
| 36 INITDEC(); | 39 INITDEC(); |
| 37 } | 40 } |
| 38 inline CJBig2_ArithDecoder::~CJBig2_ArithDecoder() {} | 41 inline CJBig2_ArithDecoder::~CJBig2_ArithDecoder() {} |
| 39 inline void CJBig2_ArithDecoder::INITDEC() { | 42 inline void CJBig2_ArithDecoder::INITDEC() { |
| 40 B = m_pStream->getCurByte_arith(); | 43 B = m_pStream->getCurByte_arith(); |
| 41 C = (B ^ 0xff) << 16; | 44 C = (B ^ 0xff) << 16; |
| 42 ; | 45 ; |
| 43 BYTEIN(); | 46 BYTEIN(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 BYTEIN(); | 117 BYTEIN(); |
| 115 } | 118 } |
| 116 A <<= 1; | 119 A <<= 1; |
| 117 C <<= 1; | 120 C <<= 1; |
| 118 CT--; | 121 CT--; |
| 119 } while ((A & 0x8000) == 0); | 122 } while ((A & 0x8000) == 0); |
| 120 } | 123 } |
| 121 return D; | 124 return D; |
| 122 } | 125 } |
| 123 #endif | 126 #endif |
| OLD | NEW |