1 // Copyright 2016 The PDFium Authors 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_JBIG2_DECODER_H_ 8 #define CORE_FXCODEC_JBIG2_JBIG2_DECODER_H_ 9 10 #include <memory> 11 12 #include "core/fxcodec/fx_codec_def.h" 13 #include "core/fxcrt/unowned_ptr_exclusion.h" 14 #include "third_party/base/containers/span.h" 15 16 class CJBig2_Context; 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 uint64_t m_nGlobalKey = 0; 30 uint64_t m_nSrcKey = 0; 31 pdfium::span<const uint8_t> m_pGlobalSpan; 32 pdfium::span<const uint8_t> m_pSrcSpan; 33 UNOWNED_PTR_EXCLUSION 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 Jbig2Decoder { 39 public: 40 static FXCODEC_STATUS StartDecode( 41 Jbig2Context* pJbig2Context, 42 JBig2_DocumentContext* pJbig2DocumentContext, 43 uint32_t width, 44 uint32_t height, 45 pdfium::span<const uint8_t> src_span, 46 uint64_t src_key, 47 pdfium::span<const uint8_t> global_span, 48 uint64_t global_key, 49 pdfium::span<uint8_t> dest_buf, 50 uint32_t dest_pitch, 51 PauseIndicatorIface* pPause); 52 53 static FXCODEC_STATUS ContinueDecode(Jbig2Context* pJbig2Context, 54 PauseIndicatorIface* pPause); 55 56 Jbig2Decoder() = delete; 57 Jbig2Decoder(const Jbig2Decoder&) = delete; 58 Jbig2Decoder& operator=(const Jbig2Decoder&) = delete; 59 }; 60 61 } // namespace fxcodec 62 63 using Jbig2Context = fxcodec::Jbig2Context; 64 using Jbig2Decoder = fxcodec::Jbig2Decoder; 65 66 #endif // CORE_FXCODEC_JBIG2_JBIG2_DECODER_H_ 67