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

Unified Diff: core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp

Issue 1536923002: Cleanup CJBig2_HuffmanTable and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | core/src/fxcodec/jbig2/JBig2_HuffmanTable.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
index cbbe6af70e1bdaee6e5869b7973dd3b0eda1cc0e..4cbecd017a6e3051cc8f69db562e1df12b6807e4 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.cpp
@@ -21,33 +21,26 @@ int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
while (1) {
FX_DWORD nTmp;
if (m_pStream->read1Bit(&nTmp) == -1)
- return -1;
+ break;
nVal = (nVal << 1) | nTmp;
++nBits;
- for (FX_DWORD i = 0; i < pTable->NTEMP; ++i) {
- if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {
- if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1))
+ for (FX_DWORD 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->RANGELEN[i], &nTmp) == -1)
+ if (m_pStream->readNBits(pTable->GetRANGELEN()[i], &nTmp) == -1)
return -1;
- if (pTable->HTOOB) {
- if (i == pTable->NTEMP - 3)
- *nResult = pTable->RANGELOW[i] - nTmp;
- else
- *nResult = pTable->RANGELOW[i] + nTmp;
- return 0;
- }
-
- if (i == pTable->NTEMP - 2)
- *nResult = pTable->RANGELOW[i] - nTmp;
+ FX_DWORD offset = pTable->IsHTOOB() ? 3 : 2;
+ if (i == pTable->Size() - offset)
+ *nResult = pTable->GetRANGELOW()[i] - nTmp;
else
- *nResult = pTable->RANGELOW[i] + nTmp;
+ *nResult = pTable->GetRANGELOW()[i] + nTmp;
return 0;
}
}
}
- return -2;
+ return -1;
}
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | core/src/fxcodec/jbig2/JBig2_HuffmanTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698