Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_BitStream.cpp

Issue 1380243004: Various changes to JBig2 cache: (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "JBig2_BitStream.h" 7 #include "JBig2_BitStream.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 CJBig2_BitStream::CJBig2_BitStream(const uint8_t* pBuffer, FX_DWORD dwLength) 11 CJBig2_BitStream::CJBig2_BitStream(CPDF_StreamAcc* pSrcStream)
12 : m_pBuf(pBuffer), m_dwLength(dwLength), m_dwByteIdx(0), m_dwBitIdx(0) { 12 : m_pBuf(pSrcStream->GetData()),
13 m_dwLength(pSrcStream->GetSize()),
14 m_dwByteIdx(0),
15 m_dwBitIdx(0),
16 m_dwObjNum(pSrcStream->GetStream()->GetObjNum()) {
Lei Zhang 2015/10/08 03:22:44 Do we need to handle GetStream() returning NULL? I
David Lattimore 2015/10/08 03:44:39 I'm not sure. To err on the side of caution, I put
Lei Zhang 2015/10/08 03:56:04 Well, the PDF spec says positive for object number
13 if (m_dwLength > 256 * 1024 * 1024) { 17 if (m_dwLength > 256 * 1024 * 1024) {
14 m_dwLength = 0; 18 m_dwLength = 0;
15 m_pBuf = nullptr; 19 m_pBuf = nullptr;
16 } 20 }
17 } 21 }
18 22
19 CJBig2_BitStream::~CJBig2_BitStream() { 23 CJBig2_BitStream::~CJBig2_BitStream() {
20 } 24 }
21 25
22 int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, FX_DWORD* dwResult) { 26 int32_t CJBig2_BitStream::readNBits(FX_DWORD dwBits, FX_DWORD* dwResult) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 173 }
170 } 174 }
171 175
172 bool CJBig2_BitStream::IsInBound() const { 176 bool CJBig2_BitStream::IsInBound() const {
173 return m_dwByteIdx < m_dwLength; 177 return m_dwByteIdx < m_dwLength;
174 } 178 }
175 179
176 FX_DWORD CJBig2_BitStream::LengthInBits() const { 180 FX_DWORD CJBig2_BitStream::LengthInBits() const {
177 return m_dwLength << 3; 181 return m_dwLength << 3;
178 } 182 }
183
184 FX_DWORD CJBig2_BitStream::getObjNum() const {
185 return m_dwObjNum;
186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698