• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "third_party/base/span.h"
14 
15 class CJBig2_Context;
16 class JBig2_DocumentContext;
17 class PauseIndicatorIface;
18 
19 namespace fxcodec {
20 
21 class Jbig2Context {
22  public:
23   Jbig2Context();
24   ~Jbig2Context();
25 
26   uint32_t m_width = 0;
27   uint32_t m_height = 0;
28   uint64_t m_nGlobalKey = 0;
29   uint64_t m_nSrcKey = 0;
30   pdfium::span<const uint8_t> m_pGlobalSpan;
31   pdfium::span<const uint8_t> m_pSrcSpan;
32   uint8_t* m_dest_buf = nullptr;
33   uint32_t m_dest_pitch = 0;
34   std::unique_ptr<CJBig2_Context> m_pContext;
35 };
36 
37 class Jbig2Decoder {
38  public:
39   static FXCODEC_STATUS StartDecode(
40       Jbig2Context* pJbig2Context,
41       JBig2_DocumentContext* pJbig2DocumentContext,
42       uint32_t width,
43       uint32_t height,
44       pdfium::span<const uint8_t> src_span,
45       uint64_t src_key,
46       pdfium::span<const uint8_t> global_span,
47       uint64_t global_key,
48       pdfium::span<uint8_t> dest_buf,
49       uint32_t dest_pitch,
50       PauseIndicatorIface* pPause);
51 
52   static FXCODEC_STATUS ContinueDecode(Jbig2Context* pJbig2Context,
53                                        PauseIndicatorIface* pPause);
54 
55   Jbig2Decoder() = delete;
56   Jbig2Decoder(const Jbig2Decoder&) = delete;
57   Jbig2Decoder& operator=(const Jbig2Decoder&) = delete;
58 };
59 
60 }  // namespace fxcodec
61 
62 using Jbig2Context = fxcodec::Jbig2Context;
63 using Jbig2Decoder = fxcodec::Jbig2Decoder;
64 
65 #endif  // CORE_FXCODEC_JBIG2_JBIG2_DECODER_H_
66