| 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" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 } else { | 66 } else { |
| 67 m_pStream->incByteIdx(); | 67 m_pStream->incByteIdx(); |
| 68 B = m_pStream->getCurByte_arith(); | 68 B = m_pStream->getCurByte_arith(); |
| 69 C = C + 0xff00 - (B << 8); | 69 C = C + 0xff00 - (B << 8); |
| 70 CT = 8; | 70 CT = 8; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 inline int CJBig2_ArithDecoder::DECODE(JBig2ArithCtx *pCX) | 73 inline int CJBig2_ArithDecoder::DECODE(JBig2ArithCtx *pCX) |
| 74 { | 74 { |
| 75 if (!pCX || pCX->I >= JBIG2_QE_NUM) { |
| 76 return 0; |
| 77 } |
| 78 |
| 75 int D; | 79 int D; |
| 76 const JBig2ArithQe * qe = &QeTable[pCX->I]; | 80 const JBig2ArithQe * qe = &QeTable[pCX->I]; |
| 77 A = A - qe->Qe; | 81 A = A - qe->Qe; |
| 78 if((C >> 16) < A) { | 82 if((C >> 16) < A) { |
| 79 if(A & 0x8000) { | 83 if(A & 0x8000) { |
| 80 D = pCX->MPS; | 84 D = pCX->MPS; |
| 81 } else { | 85 } else { |
| 82 if(A < qe->Qe) { | 86 if(A < qe->Qe) { |
| 83 D = 1 - pCX->MPS; | 87 D = 1 - pCX->MPS; |
| 84 if(qe->nSwitch == 1) { | 88 if(qe->nSwitch == 1) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 BYTEIN(); | 121 BYTEIN(); |
| 118 } | 122 } |
| 119 A <<= 1; | 123 A <<= 1; |
| 120 C <<= 1; | 124 C <<= 1; |
| 121 CT--; | 125 CT--; |
| 122 } while ((A & 0x8000) == 0); | 126 } while ((A & 0x8000) == 0); |
| 123 } | 127 } |
| 124 return D; | 128 return D; |
| 125 } | 129 } |
| 126 #endif | 130 #endif |
| OLD | NEW |