Chromium Code Reviews| 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_BIT_STREAM_H_ | 7 #ifndef _JBIG2_BIT_STREAM_H_ |
| 8 #define _JBIG2_BIT_STREAM_H_ | 8 #define _JBIG2_BIT_STREAM_H_ |
| 9 | 9 |
| 10 #include "../../../include/fpdfapi/fpdf_objects.h" | |
| 10 #include "JBig2_Define.h" | 11 #include "JBig2_Define.h" |
| 11 | 12 |
| 12 class CJBig2_BitStream { | 13 class CJBig2_BitStream { |
| 13 public: | 14 public: |
| 14 CJBig2_BitStream(const uint8_t* pBuffer, FX_DWORD dwLength); | 15 CJBig2_BitStream(CPDF_StreamAcc* pSrcStream); |
|
Lei Zhang
2015/10/06 22:40:24
add the explicit keyword
David Lattimore
2015/10/07 22:41:53
Done.
| |
| 15 | 16 |
| 16 CJBig2_BitStream(CJBig2_BitStream& bs); | 17 CJBig2_BitStream(CJBig2_BitStream& bs); |
| 17 | 18 |
| 18 ~CJBig2_BitStream(); | 19 ~CJBig2_BitStream(); |
| 19 | 20 |
| 20 int32_t readNBits(FX_DWORD nBits, FX_DWORD* dwResult); | 21 int32_t readNBits(FX_DWORD nBits, FX_DWORD* dwResult); |
| 21 | 22 |
| 22 int32_t readNBits(FX_DWORD nBits, int32_t* nResult); | 23 int32_t readNBits(FX_DWORD nBits, int32_t* nResult); |
| 23 | 24 |
| 24 int32_t read1Bit(FX_DWORD* dwResult); | 25 int32_t read1Bit(FX_DWORD* dwResult); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 const uint8_t* getBuf(); | 59 const uint8_t* getBuf(); |
| 59 | 60 |
| 60 FX_DWORD getLength() { return m_dwLength; } | 61 FX_DWORD getLength() { return m_dwLength; } |
| 61 | 62 |
| 62 const uint8_t* getPointer(); | 63 const uint8_t* getPointer(); |
| 63 | 64 |
| 64 void offset(FX_DWORD dwOffset); | 65 void offset(FX_DWORD dwOffset); |
| 65 | 66 |
| 66 FX_DWORD getByteLeft(); | 67 FX_DWORD getByteLeft(); |
| 67 | 68 |
| 69 FX_DWORD getObjNum(); | |
|
Lei Zhang
2015/10/06 22:40:24
This can be a const method.
David Lattimore
2015/10/07 22:41:53
Done.
| |
| 70 | |
| 68 private: | 71 private: |
| 69 const uint8_t* m_pBuf; | 72 const uint8_t* m_pBuf; |
| 70 | 73 |
| 71 FX_DWORD m_dwLength; | 74 FX_DWORD m_dwLength; |
| 72 | 75 |
| 73 FX_DWORD m_dwByteIdx; | 76 FX_DWORD m_dwByteIdx; |
| 74 | 77 |
| 75 FX_DWORD m_dwBitIdx; | 78 FX_DWORD m_dwBitIdx; |
| 79 | |
| 80 FX_DWORD m_dwObjNum; | |
|
Lei Zhang
2015/10/06 22:40:24
If you move the initialization in the ctors to the
David Lattimore
2015/10/07 22:41:53
Done.
| |
| 76 }; | 81 }; |
| 77 inline CJBig2_BitStream::CJBig2_BitStream(const uint8_t* pBuffer, | 82 inline CJBig2_BitStream::CJBig2_BitStream(CPDF_StreamAcc* pSrcStream) { |
|
Lei Zhang
2015/10/06 22:40:24
Oh geez, I need to fix more of these silly inlinin
| |
| 78 FX_DWORD dwLength) { | 83 m_pBuf = pSrcStream->GetData(); |
| 79 m_pBuf = pBuffer; | 84 m_dwLength = pSrcStream->GetSize(); |
| 80 m_dwLength = dwLength; | 85 m_dwObjNum = pSrcStream->GetStream()->GetObjNum(); |
| 81 m_dwByteIdx = 0; | 86 m_dwByteIdx = 0; |
| 82 m_dwBitIdx = 0; | 87 m_dwBitIdx = 0; |
| 83 if (m_dwLength > 256 * 1024 * 1024) { | 88 if (m_dwLength > 256 * 1024 * 1024) { |
| 84 m_dwLength = 0; | 89 m_dwLength = 0; |
| 85 m_pBuf = NULL; | 90 m_pBuf = NULL; |
| 86 } | 91 } |
| 87 } | 92 } |
| 88 inline CJBig2_BitStream::CJBig2_BitStream(CJBig2_BitStream& bs) { | 93 inline CJBig2_BitStream::CJBig2_BitStream(CJBig2_BitStream& bs) { |
| 89 m_pBuf = bs.m_pBuf; | 94 m_pBuf = bs.m_pBuf; |
| 90 m_dwLength = bs.m_dwLength; | 95 m_dwLength = bs.m_dwLength; |
| 91 m_dwByteIdx = bs.m_dwByteIdx; | 96 m_dwByteIdx = bs.m_dwByteIdx; |
| 92 m_dwBitIdx = bs.m_dwBitIdx; | 97 m_dwBitIdx = bs.m_dwBitIdx; |
| 98 m_dwObjNum = bs.m_dwObjNum; | |
| 93 } | 99 } |
| 94 inline CJBig2_BitStream::~CJBig2_BitStream() {} | 100 inline CJBig2_BitStream::~CJBig2_BitStream() {} |
| 95 inline int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, | 101 inline int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, |
| 96 FX_DWORD* dwResult) { | 102 FX_DWORD* dwResult) { |
| 97 FX_DWORD dwTemp = (m_dwByteIdx << 3) + m_dwBitIdx; | 103 FX_DWORD dwTemp = (m_dwByteIdx << 3) + m_dwBitIdx; |
| 98 if (dwTemp <= (m_dwLength << 3)) { | 104 if (dwTemp <= (m_dwLength << 3)) { |
| 99 *dwResult = 0; | 105 *dwResult = 0; |
| 100 if (dwTemp + dwBits <= (m_dwLength << 3)) { | 106 if (dwTemp + dwBits <= (m_dwLength << 3)) { |
| 101 dwTemp = dwBits; | 107 dwTemp = dwBits; |
| 102 } else { | 108 } else { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 } | 286 } |
| 281 inline const uint8_t* CJBig2_BitStream::getPointer() { | 287 inline const uint8_t* CJBig2_BitStream::getPointer() { |
| 282 return m_pBuf + m_dwByteIdx; | 288 return m_pBuf + m_dwByteIdx; |
| 283 } | 289 } |
| 284 inline void CJBig2_BitStream::offset(FX_DWORD dwOffset) { | 290 inline void CJBig2_BitStream::offset(FX_DWORD dwOffset) { |
| 285 m_dwByteIdx += dwOffset; | 291 m_dwByteIdx += dwOffset; |
| 286 } | 292 } |
| 287 inline FX_DWORD CJBig2_BitStream::getByteLeft() { | 293 inline FX_DWORD CJBig2_BitStream::getByteLeft() { |
| 288 return m_dwLength - m_dwByteIdx; | 294 return m_dwLength - m_dwByteIdx; |
| 289 } | 295 } |
| 296 inline FX_DWORD CJBig2_BitStream::getObjNum() { | |
| 297 return m_dwObjNum; | |
| 298 } | |
| 290 #endif | 299 #endif |
| OLD | NEW |