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

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

Issue 1800523005: Move core/src/ up to core/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h"
8
9 #include "core/src/fxcodec/jbig2/JBig2_Define.h"
10
11 CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream)
12 : m_pStream(pStream) {
13 }
14
15 CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {}
16
17 int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
18 int* nResult) {
19 int nVal = 0;
20 int nBits = 0;
21 while (1) {
22 FX_DWORD nTmp;
23 if (m_pStream->read1Bit(&nTmp) == -1)
24 break;
25
26 nVal = (nVal << 1) | nTmp;
27 ++nBits;
28 for (FX_DWORD i = 0; i < pTable->Size(); ++i) {
29 if (pTable->GetPREFLEN()[i] == nBits && pTable->GetCODES()[i] == nVal) {
30 if (pTable->IsHTOOB() && i == pTable->Size() - 1)
31 return JBIG2_OOB;
32
33 if (m_pStream->readNBits(pTable->GetRANGELEN()[i], &nTmp) == -1)
34 return -1;
35
36 FX_DWORD offset = pTable->IsHTOOB() ? 3 : 2;
37 if (i == pTable->Size() - offset)
38 *nResult = pTable->GetRANGELOW()[i] - nTmp;
39 else
40 *nResult = pTable->GetRANGELOW()[i] + nTmp;
41 return 0;
42 }
43 }
44 }
45 return -1;
46 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h ('k') | core/src/fxcodec/jbig2/JBig2_HuffmanTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698