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 "../../../include/fpdfapi/fpdf_objects.h" |
7 #include "JBig2_BitStream.h" | 8 #include "JBig2_BitStream.h" |
8 | 9 |
9 #include <algorithm> | 10 #include <algorithm> |
10 | 11 |
11 CJBig2_BitStream::CJBig2_BitStream(const uint8_t* pBuffer, FX_DWORD dwLength) | 12 CJBig2_BitStream::CJBig2_BitStream(CPDF_StreamAcc* pSrcStream) |
12 : m_pBuf(pBuffer), m_dwLength(dwLength), m_dwByteIdx(0), m_dwBitIdx(0) { | 13 : m_pBuf(pSrcStream->GetData()), |
| 14 m_dwLength(pSrcStream->GetSize()), |
| 15 m_dwByteIdx(0), |
| 16 m_dwBitIdx(0), |
| 17 m_dwObjNum(pSrcStream->GetStream() ? pSrcStream->GetStream()->GetObjNum() |
| 18 : 0) { |
13 if (m_dwLength > 256 * 1024 * 1024) { | 19 if (m_dwLength > 256 * 1024 * 1024) { |
14 m_dwLength = 0; | 20 m_dwLength = 0; |
15 m_pBuf = nullptr; | 21 m_pBuf = nullptr; |
16 } | 22 } |
17 } | 23 } |
18 | 24 |
19 CJBig2_BitStream::~CJBig2_BitStream() { | 25 CJBig2_BitStream::~CJBig2_BitStream() { |
20 } | 26 } |
21 | 27 |
22 int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, FX_DWORD* dwResult) { | 28 int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, FX_DWORD* dwResult) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 175 } |
170 } | 176 } |
171 | 177 |
172 bool CJBig2_BitStream::IsInBound() const { | 178 bool CJBig2_BitStream::IsInBound() const { |
173 return m_dwByteIdx < m_dwLength; | 179 return m_dwByteIdx < m_dwLength; |
174 } | 180 } |
175 | 181 |
176 FX_DWORD CJBig2_BitStream::LengthInBits() const { | 182 FX_DWORD CJBig2_BitStream::LengthInBits() const { |
177 return m_dwLength << 3; | 183 return m_dwLength << 3; |
178 } | 184 } |
| 185 |
| 186 FX_DWORD CJBig2_BitStream::getObjNum() const { |
| 187 return m_dwObjNum; |
| 188 } |
OLD | NEW |