From 764ec513eecbebd12781bcc96ce81ed5e736ee92 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 Mar 2016 13:35:12 -0400 Subject: Move core/src/ up to core/. This CL moves the core/src/ files up to core/ and fixes up the include guards, includes and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1800523005 . --- core/fxcodec/jbig2/JBig2_Context.h | 134 +++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 core/fxcodec/jbig2/JBig2_Context.h (limited to 'core/fxcodec/jbig2/JBig2_Context.h') diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h new file mode 100644 index 0000000000..f09b8fc1ab --- /dev/null +++ b/core/fxcodec/jbig2/JBig2_Context.h @@ -0,0 +1,134 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ +#define CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ + +#include +#include +#include + +#include "core/fxcodec/jbig2/JBig2_List.h" +#include "core/fxcodec/jbig2/JBig2_Page.h" +#include "core/fxcodec/jbig2/JBig2_Segment.h" +#include "core/include/fpdfapi/cpdf_object.h" +#include "core/include/fxcodec/fx_codec_def.h" + +class CJBig2_ArithDecoder; +class CJBig2_GRDProc; +class CPDF_StreamAcc; +class IFX_Pause; + +// Cache is keyed by the ObjNum of a stream and an index within the stream. +using CJBig2_CacheKey = std::pair; +// NB: CJBig2_SymbolDict* is owned. +using CJBig2_CachePair = std::pair; + +#define JBIG2_SUCCESS 0 +#define JBIG2_FAILED -1 +#define JBIG2_ERROR_TOO_SHORT -2 +#define JBIG2_ERROR_FATAL -3 +#define JBIG2_END_OF_PAGE 2 +#define JBIG2_END_OF_FILE 3 +#define JBIG2_ERROR_FILE_FORMAT -4 +#define JBIG2_ERROR_STREAM_TYPE -5 +#define JBIG2_ERROR_LIMIT -6 +#define JBIG2_MIN_SEGMENT_SIZE 11 + +class CJBig2_Context { + public: + static CJBig2_Context* CreateContext( + CPDF_StreamAcc* pGlobalStream, + CPDF_StreamAcc* pSrcStream, + std::list* pSymbolDictCache, + IFX_Pause* pPause = NULL); + + static void DestroyContext(CJBig2_Context* pContext); + + int32_t getFirstPage(uint8_t* pBuf, + int32_t width, + int32_t height, + int32_t stride, + IFX_Pause* pPause); + + int32_t Continue(IFX_Pause* pPause); + FXCODEC_STATUS GetProcessingStatus() { return m_ProcessingStatus; } + + private: + CJBig2_Context(CPDF_StreamAcc* pGlobalStream, + CPDF_StreamAcc* pSrcStream, + std::list* pSymbolDictCache, + IFX_Pause* pPause, + bool bIsGlobal); + + ~CJBig2_Context(); + + int32_t decode_SquentialOrgnazation(IFX_Pause* pPause); + + int32_t decode_EmbedOrgnazation(IFX_Pause* pPause); + + int32_t decode_RandomOrgnazation_FirstPage(IFX_Pause* pPause); + + int32_t decode_RandomOrgnazation(IFX_Pause* pPause); + + CJBig2_Segment* findSegmentByNumber(FX_DWORD dwNumber); + + CJBig2_Segment* findReferredSegmentByTypeAndIndex(CJBig2_Segment* pSegment, + uint8_t cType, + int32_t nIndex); + + int32_t parseSegmentHeader(CJBig2_Segment* pSegment); + + int32_t parseSegmentData(CJBig2_Segment* pSegment, IFX_Pause* pPause); + int32_t ProcessingParseSegmentData(CJBig2_Segment* pSegment, + IFX_Pause* pPause); + + int32_t parseSymbolDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); + + int32_t parseTextRegion(CJBig2_Segment* pSegment); + + int32_t parsePatternDict(CJBig2_Segment* pSegment, IFX_Pause* pPause); + + int32_t parseHalftoneRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); + + int32_t parseGenericRegion(CJBig2_Segment* pSegment, IFX_Pause* pPause); + + int32_t parseGenericRefinementRegion(CJBig2_Segment* pSegment); + + int32_t parseTable(CJBig2_Segment* pSegment); + + int32_t parseRegionInfo(JBig2RegionInfo* pRI); + + JBig2HuffmanCode* decodeSymbolIDHuffmanTable(CJBig2_BitStream* pStream, + FX_DWORD SBNUMSYMS); + + void huffman_assign_code(int* CODES, int* PREFLEN, int NTEMP); + + void huffman_assign_code(JBig2HuffmanCode* SBSYMCODES, int NTEMP); + + private: + CJBig2_Context* m_pGlobalContext; + std::unique_ptr m_pStream; + CJBig2_List m_SegmentList; + CJBig2_List m_PageInfoList; + std::unique_ptr m_pPage; + size_t m_nSegmentDecoded; + bool m_bInPage; + bool m_bBufSpecified; + int32_t m_PauseStep; + IFX_Pause* m_pPause; + FXCODEC_STATUS m_ProcessingStatus; + std::unique_ptr m_pArithDecoder; + std::unique_ptr m_pGRD; + JBig2ArithCtx* m_gbContext; + std::unique_ptr m_pSegment; + FX_DWORD m_dwOffset; + JBig2RegionInfo m_ri; + std::list* const m_pSymbolDictCache; + bool m_bIsGlobal; +}; + +#endif // CORE_FXCODEC_JBIG2_JBIG2_CONTEXT_H_ -- cgit v1.2.3