summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-06-29 14:37:09 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-29 14:37:09 +0000
commit55f82fcc12972bdf405a28c3c428e11e889e8ce1 (patch)
treedc83a7f212749505140c99c1f28429ddc568c2fc /core/fxcodec
parentc4642d4ffe8e6d315663119b5317d3a889e59f1a (diff)
downloadpdfium-55f82fcc12972bdf405a28c3c428e11e889e8ce1.tar.xz
Clean up CJBig2_PDDProc.
Change-Id: Ia83ac5dae0dedf55f1b0f0cf2a728c64474f72db Reviewed-on: https://pdfium-review.googlesource.com/36450 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/jbig2/JBig2_PddProc.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/core/fxcodec/jbig2/JBig2_PddProc.cpp b/core/fxcodec/jbig2/JBig2_PddProc.cpp
index bb61088886..82364b6ae2 100644
--- a/core/fxcodec/jbig2/JBig2_PddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_PddProc.cpp
@@ -17,10 +17,6 @@ std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeArith(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
PauseIndicatorIface* pPause) {
- uint32_t GRAY;
- std::unique_ptr<CJBig2_Image> BHDC;
- auto pDict = pdfium::MakeUnique<CJBig2_PatternDict>(GRAYMAX + 1);
-
auto pGRD = pdfium::MakeUnique<CJBig2_GRDProc>();
pGRD->MMR = HDMMR;
pGRD->GBW = (GRAYMAX + 1) * HDPW;
@@ -28,7 +24,7 @@ std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeArith(
pGRD->GBTEMPLATE = HDTEMPLATE;
pGRD->TPGDON = 0;
pGRD->USESKIP = 0;
- pGRD->GBAT[0] = -(int32_t)HDPW;
+ pGRD->GBAT[0] = -1 * static_cast<int32_t>(HDPW);
pGRD->GBAT[1] = 0;
if (pGRD->GBTEMPLATE == 0) {
pGRD->GBAT[2] = -3;
@@ -38,6 +34,8 @@ std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeArith(
pGRD->GBAT[6] = -2;
pGRD->GBAT[7] = -2;
}
+
+ std::unique_ptr<CJBig2_Image> BHDC;
CJBig2_GRDProc::ProgressiveArithDecodeState state;
state.pImage = &BHDC;
state.pArithDecoder = pArithDecoder;
@@ -51,20 +49,15 @@ std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeArith(
if (!BHDC)
return nullptr;
- GRAY = 0;
- while (GRAY <= GRAYMAX) {
+ auto pDict = pdfium::MakeUnique<CJBig2_PatternDict>(GRAYMAX + 1);
+ for (uint32_t GRAY = 0; GRAY <= GRAYMAX; ++GRAY)
pDict->HDPATS[GRAY] = BHDC->SubImage(HDPW * GRAY, 0, HDPW, HDPH);
- GRAY = GRAY + 1;
- }
return pDict;
}
std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeMMR(
CJBig2_BitStream* pStream) {
- uint32_t GRAY;
std::unique_ptr<CJBig2_Image> BHDC;
- auto pDict = pdfium::MakeUnique<CJBig2_PatternDict>(GRAYMAX + 1);
-
auto pGRD = pdfium::MakeUnique<CJBig2_GRDProc>();
pGRD->MMR = HDMMR;
pGRD->GBW = (GRAYMAX + 1) * HDPW;
@@ -73,10 +66,8 @@ std::unique_ptr<CJBig2_PatternDict> CJBig2_PDDProc::DecodeMMR(
if (!BHDC)
return nullptr;
- GRAY = 0;
- while (GRAY <= GRAYMAX) {
+ auto pDict = pdfium::MakeUnique<CJBig2_PatternDict>(GRAYMAX + 1);
+ for (uint32_t GRAY = 0; GRAY <= GRAYMAX; ++GRAY)
pDict->HDPATS[GRAY] = BHDC->SubImage(HDPW * GRAY, 0, HDPW, HDPH);
- GRAY = GRAY + 1;
- }
return pDict;
}