summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-04-27 19:39:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-27 19:39:27 +0000
commita8b4400e27c1d7be05b06f71d8bd1d6314fa4adf (patch)
treeae6859a40e24200fd9ff3871aad8b144e1ae8ab7 /core/fxcodec/jbig2
parent862cbe46b7d7040e35733f5ed63839ee34223387 (diff)
downloadpdfium-a8b4400e27c1d7be05b06f71d8bd1d6314fa4adf.tar.xz
Simplify CJBig2_Context::FindReferredSegmentByTypeAndIndex().
It only looks for a single segment type. Change-Id: I83457c6f74c210299caec79a563e7876f4d1d9ea Reviewed-on: https://pdfium-review.googlesource.com/31534 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp30
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.h5
2 files changed, 17 insertions, 18 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index ce18375d88..9b866d75d0 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -223,15 +223,15 @@ CJBig2_Segment* CJBig2_Context::FindSegmentByNumber(uint32_t dwNumber) {
return nullptr;
}
-CJBig2_Segment* CJBig2_Context::FindReferredSegmentByTypeAndIndex(
+CJBig2_Segment* CJBig2_Context::FindReferredTableSegmentByIndex(
CJBig2_Segment* pSegment,
- uint8_t cType,
int32_t nIndex) {
+ static const uint8_t kTableType = 53;
int32_t count = 0;
for (int32_t i = 0; i < pSegment->m_nReferred_to_segment_count; ++i) {
CJBig2_Segment* pSeg =
FindSegmentByNumber(pSegment->m_Referred_to_segment_numbers[i]);
- if (pSeg && pSeg->m_cFlags.s.type == cType) {
+ if (pSeg && pSeg->m_cFlags.s.type == kTableType) {
if (count == nIndex)
return pSeg;
++count;
@@ -501,7 +501,7 @@ int32_t CJBig2_Context::ParseSymbolDict(CJBig2_Segment* pSegment) {
pSymbolDictDecoder->SDHUFFDH = Table_B5.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pSymbolDictDecoder->SDHUFFDH = pSeg->m_HuffmanTable.get();
@@ -516,7 +516,7 @@ int32_t CJBig2_Context::ParseSymbolDict(CJBig2_Segment* pSegment) {
pSymbolDictDecoder->SDHUFFDW = Table_B3.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pSymbolDictDecoder->SDHUFFDW = pSeg->m_HuffmanTable.get();
@@ -527,7 +527,7 @@ int32_t CJBig2_Context::ParseSymbolDict(CJBig2_Segment* pSegment) {
pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_HuffmanTable.get();
@@ -541,7 +541,7 @@ int32_t CJBig2_Context::ParseSymbolDict(CJBig2_Segment* pSegment) {
pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_HuffmanTable.get();
@@ -773,7 +773,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFFS = Table_B7.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFFS = pSeg->m_HuffmanTable.get();
@@ -792,7 +792,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDS = Table_B10.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFDS = pSeg->m_HuffmanTable.get();
@@ -811,7 +811,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDT = Table_B13.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFDT = pSeg->m_HuffmanTable.get();
@@ -826,7 +826,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDW = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFRDW = pSeg->m_HuffmanTable.get();
@@ -845,7 +845,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDH = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFRDH = pSeg->m_HuffmanTable.get();
@@ -864,7 +864,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDX = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFRDX = pSeg->m_HuffmanTable.get();
@@ -883,7 +883,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDY = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFRDY = pSeg->m_HuffmanTable.get();
@@ -894,7 +894,7 @@ int32_t CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
- FindReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
+ FindReferredTableSegmentByIndex(pSegment, nIndex++);
if (!pSeg)
return JBIG2_ERROR_FATAL;
pTRD->SBHUFFRSIZE = pSeg->m_HuffmanTable.get();
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index 117999eb00..d5dbbd22a6 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -60,9 +60,8 @@ class CJBig2_Context {
int32_t DecodeRandom(PauseIndicatorIface* pPause);
CJBig2_Segment* FindSegmentByNumber(uint32_t dwNumber);
- CJBig2_Segment* FindReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment,
- uint8_t cType,
- int32_t nIndex);
+ CJBig2_Segment* FindReferredTableSegmentByIndex(CJBig2_Segment* pSegment,
+ int32_t nIndex);
int32_t ParseSegmentHeader(CJBig2_Segment* pSegment);
int32_t ParseSegmentData(CJBig2_Segment* pSegment,