summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_Context.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-01 14:37:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 14:37:54 +0000
commit1599b465904a312f0d0455cd26cdc9b0fe7b7d0c (patch)
tree38a7a3c997c642e91fe9a6e00086dfdf34382f73 /core/fxcodec/jbig2/JBig2_Context.cpp
parentea603b9f0baf33462b61fa4ee6364e4f4161f55a (diff)
downloadpdfium-1599b465904a312f0d0455cd26cdc9b0fe7b7d0c.tar.xz
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 <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Context.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp16
1 files changed, 10 insertions, 6 deletions
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<CJBig2_ArithDecoder>(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) {