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 CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ | 7 #ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ |
8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ | 8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ |
9 | 9 |
10 #include "../../../include/fxcrt/fx_basic.h" | 10 #include "../../../include/fxcrt/fx_basic.h" |
11 | 11 |
| 12 class CPDF_StreamAcc; |
| 13 |
12 class CJBig2_BitStream { | 14 class CJBig2_BitStream { |
13 public: | 15 public: |
14 CJBig2_BitStream(const uint8_t* pBuffer, FX_DWORD dwLength); | 16 explicit CJBig2_BitStream(CPDF_StreamAcc* pSrcStream); |
15 ~CJBig2_BitStream(); | 17 ~CJBig2_BitStream(); |
16 | 18 |
17 // TODO(thestig): readFoo() should return bool. | 19 // TODO(thestig): readFoo() should return bool. |
18 int32_t readNBits(FX_DWORD nBits, FX_DWORD* dwResult); | 20 int32_t readNBits(FX_DWORD nBits, FX_DWORD* dwResult); |
19 int32_t readNBits(FX_DWORD nBits, int32_t* nResult); | 21 int32_t readNBits(FX_DWORD nBits, int32_t* nResult); |
20 int32_t read1Bit(FX_DWORD* dwResult); | 22 int32_t read1Bit(FX_DWORD* dwResult); |
21 int32_t read1Bit(FX_BOOL* bResult); | 23 int32_t read1Bit(FX_BOOL* bResult); |
22 int32_t read1Byte(uint8_t* cResult); | 24 int32_t read1Byte(uint8_t* cResult); |
23 int32_t readInteger(FX_DWORD* dwResult); | 25 int32_t readInteger(FX_DWORD* dwResult); |
24 int32_t readShortInteger(FX_WORD* wResult); | 26 int32_t readShortInteger(FX_WORD* wResult); |
25 void alignByte(); | 27 void alignByte(); |
26 uint8_t getCurByte() const; | 28 uint8_t getCurByte() const; |
27 void incByteIdx(); | 29 void incByteIdx(); |
28 uint8_t getCurByte_arith() const; | 30 uint8_t getCurByte_arith() const; |
29 uint8_t getNextByte_arith() const; | 31 uint8_t getNextByte_arith() const; |
30 FX_DWORD getOffset() const; | 32 FX_DWORD getOffset() const; |
31 void setOffset(FX_DWORD dwOffset); | 33 void setOffset(FX_DWORD dwOffset); |
32 FX_DWORD getBitPos() const; | 34 FX_DWORD getBitPos() const; |
33 void setBitPos(FX_DWORD dwBitPos); | 35 void setBitPos(FX_DWORD dwBitPos); |
34 const uint8_t* getBuf() const; | 36 const uint8_t* getBuf() const; |
35 FX_DWORD getLength() const { return m_dwLength; } | 37 FX_DWORD getLength() const { return m_dwLength; } |
36 const uint8_t* getPointer() const; | 38 const uint8_t* getPointer() const; |
37 void offset(FX_DWORD dwOffset); | 39 void offset(FX_DWORD dwOffset); |
38 FX_DWORD getByteLeft() const; | 40 FX_DWORD getByteLeft() const; |
| 41 FX_DWORD getObjNum() const; |
39 | 42 |
40 private: | 43 private: |
41 void AdvanceBit(); | 44 void AdvanceBit(); |
42 bool IsInBound() const; | 45 bool IsInBound() const; |
43 FX_DWORD LengthInBits() const; | 46 FX_DWORD LengthInBits() const; |
44 | 47 |
45 const uint8_t* m_pBuf; | 48 const uint8_t* m_pBuf; |
46 FX_DWORD m_dwLength; | 49 FX_DWORD m_dwLength; |
47 FX_DWORD m_dwByteIdx; | 50 FX_DWORD m_dwByteIdx; |
48 FX_DWORD m_dwBitIdx; | 51 FX_DWORD m_dwBitIdx; |
| 52 const FX_DWORD m_dwObjNum; |
49 | 53 |
50 CJBig2_BitStream(const CJBig2_BitStream&) = delete; | 54 CJBig2_BitStream(const CJBig2_BitStream&) = delete; |
51 void operator=(const CJBig2_BitStream&) = delete; | 55 void operator=(const CJBig2_BitStream&) = delete; |
52 }; | 56 }; |
53 | 57 |
54 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ | 58 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_BITSTREAM_H_ |
OLD | NEW |