1 //========================================================================
5 // Copyright 2002-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
25 class JArithmeticDecoder;
26 class JArithmeticDecoderStats;
27 class JBIG2HuffmanDecoder;
28 struct JBIG2HuffmanTable;
29 class JBIG2MMRDecoder;
31 //------------------------------------------------------------------------
33 class JBIG2Stream: public FilterStream {
36 JBIG2Stream(Stream *strA, Object *globalsStream);
37 virtual ~JBIG2Stream();
38 virtual StreamKind getKind() { return strJBIG2; }
40 virtual int getChar();
41 virtual int lookChar();
42 virtual GString *getPSFilter(int psLevel, char *indent);
43 virtual GBool isBinary(GBool last = gTrue);
48 void readSymbolDictSeg(Guint segNum, Guint length,
49 Guint *refSegs, Guint nRefSegs);
50 void readTextRegionSeg(Guint segNum, GBool imm,
51 GBool lossless, Guint length,
52 Guint *refSegs, Guint nRefSegs);
53 JBIG2Bitmap *readTextRegion(GBool huff, GBool refine,
58 JBIG2HuffmanTable *symCodeTab,
61 Guint defPixel, Guint combOp,
62 Guint transposed, Guint refCorner,
64 JBIG2HuffmanTable *huffFSTable,
65 JBIG2HuffmanTable *huffDSTable,
66 JBIG2HuffmanTable *huffDTTable,
67 JBIG2HuffmanTable *huffRDWTable,
68 JBIG2HuffmanTable *huffRDHTable,
69 JBIG2HuffmanTable *huffRDXTable,
70 JBIG2HuffmanTable *huffRDYTable,
71 JBIG2HuffmanTable *huffRSizeTable,
74 void readPatternDictSeg(Guint segNum, Guint length);
75 void readHalftoneRegionSeg(Guint segNum, GBool imm,
76 GBool lossless, Guint length,
77 Guint *refSegs, Guint nRefSegs);
78 void readGenericRegionSeg(Guint segNum, GBool imm,
79 GBool lossless, Guint length);
80 JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
81 int templ, GBool tpgdOn,
82 GBool useSkip, JBIG2Bitmap *skip,
85 void readGenericRefinementRegionSeg(Guint segNum, GBool imm,
86 GBool lossless, Guint length,
89 JBIG2Bitmap *readGenericRefinementRegion(int w, int h,
90 int templ, GBool tpgrOn,
91 JBIG2Bitmap *refBitmap,
94 void readPageInfoSeg(Guint length);
95 void readEndOfStripeSeg(Guint length);
96 void readProfilesSeg(Guint length);
97 void readCodeTableSeg(Guint segNum, Guint length);
98 void readExtensionSeg(Guint length);
99 JBIG2Segment *findSegment(Guint segNum);
100 void discardSegment(Guint segNum);
101 void resetGenericStats(Guint templ,
102 JArithmeticDecoderStats *prevStats);
103 void resetRefinementStats(Guint templ,
104 JArithmeticDecoderStats *prevStats);
105 void resetIntStats(int symCodeLen);
106 GBool readUByte(Guint *x);
107 GBool readByte(int *x);
108 GBool readUWord(Guint *x);
109 GBool readULong(Guint *x);
110 GBool readLong(int *x);
112 Guint pageW, pageH, curPageH;
114 JBIG2Bitmap *pageBitmap;
116 GList *segments; // [JBIG2Segment]
117 GList *globalSegments; // [JBIG2Segment]
122 JArithmeticDecoder *arithDecoder;
123 JArithmeticDecoderStats *genericRegionStats;
124 JArithmeticDecoderStats *refinementRegionStats;
125 JArithmeticDecoderStats *iadhStats;
126 JArithmeticDecoderStats *iadwStats;
127 JArithmeticDecoderStats *iaexStats;
128 JArithmeticDecoderStats *iaaiStats;
129 JArithmeticDecoderStats *iadtStats;
130 JArithmeticDecoderStats *iaitStats;
131 JArithmeticDecoderStats *iafsStats;
132 JArithmeticDecoderStats *iadsStats;
133 JArithmeticDecoderStats *iardxStats;
134 JArithmeticDecoderStats *iardyStats;
135 JArithmeticDecoderStats *iardwStats;
136 JArithmeticDecoderStats *iardhStats;
137 JArithmeticDecoderStats *iariStats;
138 JArithmeticDecoderStats *iaidStats;
139 JBIG2HuffmanDecoder *huffDecoder;
140 JBIG2MMRDecoder *mmrDecoder;