summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-27 20:53:58 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-27 20:53:58 +0000
commit724f61671bec82f521be75b0ace069fb3130902a (patch)
treed96cba59467a28dc08b93d80b4224feb860cb1e9 /core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
parentccd9426e7127373c13986fd4f8a029f744e9dad0 (diff)
downloadpdfium-724f61671bec82f521be75b0ace069fb3130902a.tar.xz
Change CJBig2_HuffmanTable to use struct JBig2HuffmanCode.
Change-Id: I6461f81a3d8005efa75b8141c18c502a63252883 Reviewed-on: https://pdfium-review.googlesource.com/31537 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp b/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
index c6dd3924b8..cdb6fbe752 100644
--- a/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
+++ b/core/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
@@ -25,20 +25,22 @@ int CJBig2_HuffmanDecoder::DecodeAValue(CJBig2_HuffmanTable* pTable,
nVal = (nVal << 1) | nTmp;
++nBits;
for (uint32_t i = 0; i < pTable->Size(); ++i) {
- if (pTable->GetPREFLEN()[i] == nBits && pTable->GetCODES()[i] == nVal) {
- if (pTable->IsHTOOB() && i == pTable->Size() - 1)
- return JBIG2_OOB;
-
- if (m_pStream->readNBits(pTable->GetRANGELEN()[i], &nTmp) == -1)
- return -1;
-
- uint32_t offset = pTable->IsHTOOB() ? 3 : 2;
- if (i == pTable->Size() - offset)
- *nResult = pTable->GetRANGELOW()[i] - nTmp;
- else
- *nResult = pTable->GetRANGELOW()[i] + nTmp;
- return 0;
- }
+ const JBig2HuffmanCode& code = pTable->GetCODES()[i];
+ if (code.codelen != nBits || code.code != nVal)
+ continue;
+
+ if (pTable->IsHTOOB() && i == pTable->Size() - 1)
+ return JBIG2_OOB;
+
+ if (m_pStream->readNBits(pTable->GetRANGELEN()[i], &nTmp) == -1)
+ return -1;
+
+ uint32_t offset = pTable->IsHTOOB() ? 3 : 2;
+ if (i == pTable->Size() - offset)
+ *nResult = pTable->GetRANGELOW()[i] - nTmp;
+ else
+ *nResult = pTable->GetRANGELOW()[i] + nTmp;
+ return 0;
}
}
return -1;