From 43927ad2f498a388b0fd4840b861a8bf01c790b1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 21 Aug 2018 21:11:31 +0000 Subject: Use UnownedPtr<> in JBIG2_SDDProc. Pack a little tighter while at it. Change-Id: If7cbb324ebf828a4bb60eb364fc3e0f31625e57f Reviewed-on: https://pdfium-review.googlesource.com/40913 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxcodec/jbig2/JBig2_SddProc.cpp | 17 +++++++++++------ core/fxcodec/jbig2/JBig2_SddProc.h | 18 +++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'core/fxcodec') diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp index 29c604f1c7..7bdcf5c5f9 100644 --- a/core/fxcodec/jbig2/JBig2_SddProc.cpp +++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp @@ -22,6 +22,10 @@ #include "core/fxcodec/jbig2/JBig2_TrdProc.h" #include "third_party/base/ptr_util.h" +CJBig2_SDDProc::CJBig2_SDDProc() = default; + +CJBig2_SDDProc::~CJBig2_SDDProc() = default; + std::unique_ptr CJBig2_SDDProc::DecodeArith( CJBig2_ArithDecoder* pArithDecoder, std::vector* gbContext, @@ -289,7 +293,7 @@ std::unique_ptr CJBig2_SDDProc::DecodeHuffman( NSYMSDECODED = 0; std::unique_ptr BS; while (NSYMSDECODED < SDNUMNEWSYMS) { - if (pHuffmanDecoder->DecodeAValue(SDHUFFDH, &HCDH) != 0) + if (pHuffmanDecoder->DecodeAValue(SDHUFFDH.Get(), &HCDH) != 0) return nullptr; HCHEIGHT = HCHEIGHT + HCDH; @@ -300,7 +304,7 @@ std::unique_ptr CJBig2_SDDProc::DecodeHuffman( TOTWIDTH = 0; HCFIRSTSYM = NSYMSDECODED; for (;;) { - nVal = pHuffmanDecoder->DecodeAValue(SDHUFFDW, &DW); + nVal = pHuffmanDecoder->DecodeAValue(SDHUFFDW.Get(), &DW); if (nVal == JBIG2_OOB) break; if (nVal != 0) @@ -319,8 +323,8 @@ std::unique_ptr CJBig2_SDDProc::DecodeHuffman( } TOTWIDTH = TOTWIDTH + SYMWIDTH; if (SDREFAGG == 1) { - if (pHuffmanDecoder->DecodeAValue(SDHUFFAGGINST, (int*)&REFAGGNINST) != - 0) { + if (pHuffmanDecoder->DecodeAValue(SDHUFFAGGINST.Get(), + (int*)&REFAGGNINST) != 0) { return nullptr; } BS = nullptr; @@ -440,9 +444,10 @@ std::unique_ptr CJBig2_SDDProc::DecodeHuffman( NSYMSDECODED = NSYMSDECODED + 1; } if (SDREFAGG == 0) { - if (pHuffmanDecoder->DecodeAValue(SDHUFFBMSIZE, (int32_t*)&BMSIZE) != 0) + if (pHuffmanDecoder->DecodeAValue(SDHUFFBMSIZE.Get(), + (int32_t*)&BMSIZE) != 0) { return nullptr; - + } pStream->alignByte(); std::unique_ptr BHC; if (BMSIZE == 0) { diff --git a/core/fxcodec/jbig2/JBig2_SddProc.h b/core/fxcodec/jbig2/JBig2_SddProc.h index a6fb039cac..abef010868 100644 --- a/core/fxcodec/jbig2/JBig2_SddProc.h +++ b/core/fxcodec/jbig2/JBig2_SddProc.h @@ -12,6 +12,7 @@ #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" #include "core/fxcrt/fx_system.h" +#include "core/fxcrt/unowned_ptr.h" class CJBig2_BitStream; class CJBig2_HuffmanTable; @@ -20,6 +21,9 @@ class CJBig2_SymbolDict; class CJBig2_SDDProc { public: + CJBig2_SDDProc(); + ~CJBig2_SDDProc(); + std::unique_ptr DecodeArith( CJBig2_ArithDecoder* pArithDecoder, std::vector* gbContext, @@ -32,17 +36,17 @@ class CJBig2_SDDProc { bool SDHUFF; bool SDREFAGG; + bool SDRTEMPLATE; + uint8_t SDTEMPLATE; uint32_t SDNUMINSYMS; - CJBig2_Image** SDINSYMS; uint32_t SDNUMNEWSYMS; uint32_t SDNUMEXSYMS; - const CJBig2_HuffmanTable* SDHUFFDH; - const CJBig2_HuffmanTable* SDHUFFDW; - const CJBig2_HuffmanTable* SDHUFFBMSIZE; - const CJBig2_HuffmanTable* SDHUFFAGGINST; - uint8_t SDTEMPLATE; + CJBig2_Image** SDINSYMS; + UnownedPtr SDHUFFDH; + UnownedPtr SDHUFFDW; + UnownedPtr SDHUFFBMSIZE; + UnownedPtr SDHUFFAGGINST; int8_t SDAT[8]; - bool SDRTEMPLATE; int8_t SDRAT[4]; }; -- cgit v1.2.3