From 1599b465904a312f0d0455cd26cdc9b0fe7b7d0c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 1 May 2018 14:37:54 +0000 Subject: Add struct CJBig2_GRDProc::ProgressiveArithDecodeState. Track the decode state in one data structure. Also grab pointers to data structure members before tight loops when decoding. It turns out referring to this->foo in tight loops can actually slow down decoding. Change-Id: I6a09b08ca06ef05968966055b5ad20f8c89896af Reviewed-on: https://pdfium-review.googlesource.com/31790 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- core/fxcodec/jbig2/JBig2_Context.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'core/fxcodec/jbig2/JBig2_Context.cpp') diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index 76dff1d592..1763144b49 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -1094,15 +1094,19 @@ int32_t CJBig2_Context::ParseGenericRegion(CJBig2_Segment* pSegment, if (m_pGRD->MMR == 0) { if (m_gbContext.empty()) m_gbContext.resize(GetHuffContextSize(m_pGRD->GBTEMPLATE)); - if (!m_pArithDecoder) { + + bool bStart = !m_pArithDecoder; + if (bStart) { m_pArithDecoder = pdfium::MakeUnique(m_pStream.get()); - m_ProcessingStatus = m_pGRD->StartDecodeArith( - &pSegment->m_Image, m_pArithDecoder.get(), &m_gbContext[0], pPause); - } else { - m_ProcessingStatus = - m_pGRD->ContinueDecode(pPause, m_pArithDecoder.get()); } + CJBig2_GRDProc::ProgressiveArithDecodeState state; + state.pImage = &pSegment->m_Image; + state.pArithDecoder = m_pArithDecoder.get(); + state.gbContext = m_gbContext.data(); + state.pPause = pPause; + m_ProcessingStatus = bStart ? m_pGRD->StartDecodeArith(&state) + : m_pGRD->ContinueDecode(&state); if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { if (pSegment->m_cFlags.s.type != 36) { if (!m_bBufSpecified) { -- cgit v1.2.3