1 // Copyright 2014 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_JBIG2_SEGMENT_H_
8 #define CORE_FXCODEC_JBIG2_JBIG2_SEGMENT_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "core/fxcodec/jbig2/JBig2_Define.h"
14 #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h"
15 #include "core/fxcodec/jbig2/JBig2_PatternDict.h"
16 #include "core/fxcodec/jbig2/JBig2_SymbolDict.h"
17 
18 enum JBig2_SegmentState {
19   JBIG2_SEGMENT_HEADER_UNPARSED,
20   JBIG2_SEGMENT_DATA_UNPARSED,
21   JBIG2_SEGMENT_PARSE_COMPLETE,
22   JBIG2_SEGMENT_PAUSED,
23   JBIG2_SEGMENT_ERROR
24 };
25 
26 enum JBig2_ResultType {
27   JBIG2_VOID_POINTER = 0,
28   JBIG2_IMAGE_POINTER,
29   JBIG2_SYMBOL_DICT_POINTER,
30   JBIG2_PATTERN_DICT_POINTER,
31   JBIG2_HUFFMAN_TABLE_POINTER
32 };
33 
34 class CJBig2_Segment {
35  public:
36   CJBig2_Segment();
37   ~CJBig2_Segment();
38 
39   uint32_t m_dwNumber;
40   union {
41     struct {
42       uint8_t type : 6;
43       uint8_t page_association_size : 1;
44       uint8_t deferred_non_retain : 1;
45     } s;
46     uint8_t c;
47   } m_cFlags;
48   int32_t m_nReferred_to_segment_count;
49   std::vector<uint32_t> m_Referred_to_segment_numbers;
50   uint32_t m_dwPage_association;
51   uint32_t m_dwData_length;
52 
53   uint32_t m_dwHeader_Length;
54   uint32_t m_dwObjNum;
55   uint32_t m_dwDataOffset;
56   JBig2_SegmentState m_State;
57   JBig2_ResultType m_nResultType;
58   std::unique_ptr<CJBig2_SymbolDict> m_SymbolDict;
59   std::unique_ptr<CJBig2_PatternDict> m_PatternDict;
60   std::unique_ptr<CJBig2_Image> m_Image;
61   std::unique_ptr<CJBig2_HuffmanTable> m_HuffmanTable;
62 };
63 
64 #endif  // CORE_FXCODEC_JBIG2_JBIG2_SEGMENT_H_
65