Chromium Code Reviews| Index: core/fxcodec/jbig2/JBig2_Context.cpp |
| diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp |
| index 8dde290be6df11c362579eb35424f198156fa573..6eceeb2d3ba77f8b530c77ec0fa732a73b21ad31 100644 |
| --- a/core/fxcodec/jbig2/JBig2_Context.cpp |
| +++ b/core/fxcodec/jbig2/JBig2_Context.cpp |
| @@ -45,19 +45,6 @@ size_t GetRefAggContextSize(FX_BOOL val) { |
| // difference for typical JBIG2 documents. |
| static const int kSymbolDictCacheMaxSize = 2; |
| -CJBig2_Context* CJBig2_Context::CreateContext( |
| - CPDF_StreamAcc* pGlobalStream, |
| - CPDF_StreamAcc* pSrcStream, |
| - std::list<CJBig2_CachePair>* pSymbolDictCache, |
| - IFX_Pause* pPause) { |
| - return new CJBig2_Context(pGlobalStream, pSrcStream, pSymbolDictCache, pPause, |
| - false); |
| -} |
| - |
| -void CJBig2_Context::DestroyContext(CJBig2_Context* pContext) { |
| - delete pContext; |
| -} |
| - |
| CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, |
| CPDF_StreamAcc* pSrcStream, |
| std::list<CJBig2_CachePair>* pSymbolDictCache, |
| @@ -69,26 +56,17 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream, |
| m_PauseStep(10), |
| m_pPause(pPause), |
| m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY), |
| - m_gbContext(nullptr), |
| m_dwOffset(0), |
| m_pSymbolDictCache(pSymbolDictCache), |
| m_bIsGlobal(bIsGlobal) { |
| if (pGlobalStream && (pGlobalStream->GetSize() > 0)) { |
| - m_pGlobalContext = new CJBig2_Context(nullptr, pGlobalStream, |
| - pSymbolDictCache, pPause, true); |
| - } else { |
| - m_pGlobalContext = nullptr; |
| + m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream, |
| + pSymbolDictCache, pPause, true)); |
| } |
| - |
| m_pStream.reset(new CJBig2_BitStream(pSrcStream)); |
| } |
| -CJBig2_Context::~CJBig2_Context() { |
| - FX_Free(m_gbContext); |
| - m_gbContext = nullptr; |
| - delete m_pGlobalContext; |
| - m_pGlobalContext = nullptr; |
| -} |
| +CJBig2_Context::~CJBig2_Context() {} |
| int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) { |
| int32_t nRet; |
| @@ -1106,15 +1084,15 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, |
| } |
| pSegment->m_nResultType = JBIG2_IMAGE_POINTER; |
| if (m_pGRD->MMR == 0) { |
| - if (!m_gbContext) { |
| + if (!m_gbContext.size()) { |
|
Lei Zhang
2016/07/18 23:55:10
if (m_gbContext.empty())
Wei Li
2016/07/19 21:21:29
Done.
|
| const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE); |
| - m_gbContext = FX_Alloc(JBig2ArithCtx, size); |
| - JBIG2_memset(m_gbContext, 0, sizeof(JBig2ArithCtx) * size); |
| + m_gbContext.resize(size); |
| } |
| if (!m_pArithDecoder) { |
| m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get())); |
| - m_ProcessingStatus = m_pGRD->Start_decode_Arith( |
| - &pSegment->m_Result.im, m_pArithDecoder.get(), m_gbContext, pPause); |
| + m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im, |
| + m_pArithDecoder.get(), |
| + &m_gbContext[0], pPause); |
| } else { |
| m_ProcessingStatus = m_pGRD->Continue_decode(pPause); |
| } |
| @@ -1136,8 +1114,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, |
| return JBIG2_SUCCESS; |
| } else { |
| m_pArithDecoder.reset(); |
| - FX_Free(m_gbContext); |
| - m_gbContext = nullptr; |
| + m_gbContext.clear(); |
| if (!pSegment->m_Result.im) { |
| m_ProcessingStatus = FXCODEC_STATUS_ERROR; |
| m_pGRD.reset(); |