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 _JBIG2_SEGMENT_H_
8 #define _JBIG2_SEGMENT_H_
9 #include "JBig2_Define.h"
10 #include "JBig2_SymbolDict.h"
11 #include "JBig2_PatternDict.h"
12 #include "JBig2_Module.h"
13 #include "JBig2_HuffmanTable.h"
14 #define JBIG2_GET_INT32(buf) (((buf)[0]<<24) | ((buf)[1]<<16) | ((buf)[2]<<8) | (buf)[3])
15 #define JBIG2_GET_INT16(buf) (((buf)[0]<<8) | (buf)[1])
16 typedef enum {
17     JBIG2_SEGMENT_HEADER_UNPARSED,
18     JBIG2_SEGMENT_DATA_UNPARSED,
19     JBIG2_SEGMENT_PARSE_COMPLETE,
20     JBIG2_SEGMENT_PAUSED,
21     JBIG2_SEGMENT_ERROR
22 } JBig2_SegmentState;
23 typedef enum {
24     JBIG2_VOID_POINTER	= 0,
25     JBIG2_IMAGE_POINTER,
26     JBIG2_SYMBOL_DICT_POINTER,
27     JBIG2_PATTERN_DICT_POINTER,
28     JBIG2_HUFFMAN_TABLE_POINTER
29 } JBig2_ResultType;
30 class CJBig2_Segment : public CJBig2_Object
31 {
32 public:
33 
34     CJBig2_Segment();
35 
36     ~CJBig2_Segment();
37 
38     void init();
39 
40     void clean();
41 public:
42     FX_DWORD m_dwNumber;
43     union {
44         struct {
45             FX_BYTE type					:	6;
46             FX_BYTE page_association_size	:	1;
47             FX_BYTE deferred_non_retain		:	1;
48         } s;
49         FX_BYTE c;
50     } m_cFlags;
51     FX_INT32 m_nReferred_to_segment_count;
52     FX_DWORD * m_pReferred_to_segment_numbers;
53     FX_DWORD m_dwPage_association;
54     FX_DWORD m_dwData_length;
55 
56     FX_DWORD m_dwHeader_Length;
57     FX_BYTE  *m_pData;
58     JBig2_SegmentState m_State;
59     JBig2_ResultType m_nResultType;
60     union {
61         CJBig2_SymbolDict	*sd;
62         CJBig2_PatternDict	*pd;
63         CJBig2_Image		*im;
64         CJBig2_HuffmanTable	*ht;
65         FX_LPVOID			 vd;
66     } m_Result;
67 };
68 #endif
69