1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXCODEC_JBIG2_JBIG2MODULE_H_ 8 #define CORE_FXCODEC_JBIG2_JBIG2MODULE_H_ 9 10 #include <memory> 11 12 #include "core/fxcodec/fx_codec_def.h" 13 #include "third_party/base/span.h" 14 15 class CJBig2_Context; 16 class CJBig2_Image; 17 class JBig2_DocumentContext; 18 class PauseIndicatorIface; 19 20 namespace fxcodec { 21 22 class Jbig2Context { 23 public: 24 Jbig2Context(); 25 ~Jbig2Context(); 26 27 uint32_t m_width = 0; 28 uint32_t m_height = 0; 29 uint32_t m_nGlobalObjNum = 0; 30 uint32_t m_nSrcObjNum = 0; 31 pdfium::span<const uint8_t> m_pGlobalSpan; 32 pdfium::span<const uint8_t> m_pSrcSpan; 33 uint8_t* m_dest_buf = nullptr; 34 uint32_t m_dest_pitch = 0; 35 std::unique_ptr<CJBig2_Context> m_pContext; 36 }; 37 38 class Jbig2Module { 39 public: 40 Jbig2Module(); 41 ~Jbig2Module(); 42 43 FXCODEC_STATUS StartDecode( 44 Jbig2Context* pJbig2Context, 45 std::unique_ptr<JBig2_DocumentContext>* pContextHolder, 46 uint32_t width, 47 uint32_t height, 48 pdfium::span<const uint8_t> src_span, 49 uint32_t src_objnum, 50 pdfium::span<const uint8_t> global_span, 51 uint32_t global_objnum, 52 uint8_t* dest_buf, 53 uint32_t dest_pitch, 54 PauseIndicatorIface* pPause); 55 56 FXCODEC_STATUS ContinueDecode(Jbig2Context* pJbig2Context, 57 PauseIndicatorIface* pPause); 58 59 private: 60 FXCODEC_STATUS Decode(Jbig2Context* pJbig2Context, bool decode_success); 61 }; 62 63 } // namespace fxcodec 64 65 using Jbig2Context = fxcodec::Jbig2Context; 66 using Jbig2Module = fxcodec::Jbig2Module; 67 68 #endif // CORE_FXCODEC_JBIG2_JBIG2MODULE_H_ 69