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