From 55f82fcc12972bdf405a28c3c428e11e889e8ce1 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 29 Jun 2018 14:37:09 +0000 Subject: Clean up CJBig2_PDDProc. Change-Id: Ia83ac5dae0dedf55f1b0f0cf2a728c64474f72db Reviewed-on: https://pdfium-review.googlesource.com/36450 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- core/fxcodec/jbig2/JBig2_PddProc.cpp | 23 +++++++---------------- 1 file 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_PDDProc::DecodeArith( CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, PauseIndicatorIface* pPause) { - uint32_t GRAY; - std::unique_ptr BHDC; - auto pDict = pdfium::MakeUnique(GRAYMAX + 1); - auto pGRD = pdfium::MakeUnique(); pGRD->MMR = HDMMR; pGRD->GBW = (GRAYMAX + 1) * HDPW; @@ -28,7 +24,7 @@ std::unique_ptr CJBig2_PDDProc::DecodeArith( pGRD->GBTEMPLATE = HDTEMPLATE; pGRD->TPGDON = 0; pGRD->USESKIP = 0; - pGRD->GBAT[0] = -(int32_t)HDPW; + pGRD->GBAT[0] = -1 * static_cast(HDPW); pGRD->GBAT[1] = 0; if (pGRD->GBTEMPLATE == 0) { pGRD->GBAT[2] = -3; @@ -38,6 +34,8 @@ std::unique_ptr CJBig2_PDDProc::DecodeArith( pGRD->GBAT[6] = -2; pGRD->GBAT[7] = -2; } + + std::unique_ptr BHDC; CJBig2_GRDProc::ProgressiveArithDecodeState state; state.pImage = &BHDC; state.pArithDecoder = pArithDecoder; @@ -51,20 +49,15 @@ std::unique_ptr CJBig2_PDDProc::DecodeArith( if (!BHDC) return nullptr; - GRAY = 0; - while (GRAY <= GRAYMAX) { + auto pDict = pdfium::MakeUnique(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_PDDProc::DecodeMMR( CJBig2_BitStream* pStream) { - uint32_t GRAY; std::unique_ptr BHDC; - auto pDict = pdfium::MakeUnique(GRAYMAX + 1); - auto pGRD = pdfium::MakeUnique(); pGRD->MMR = HDMMR; pGRD->GBW = (GRAYMAX + 1) * HDPW; @@ -73,10 +66,8 @@ std::unique_ptr CJBig2_PDDProc::DecodeMMR( if (!BHDC) return nullptr; - GRAY = 0; - while (GRAY <= GRAYMAX) { + auto pDict = pdfium::MakeUnique(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; } -- cgit v1.2.3