* keyframe default is now every 20 frames.
[swftools.git] / pdf2swf / xpdf / JBIG2Stream.h
1 //========================================================================
2 //
3 // JBIG2Stream.h
4 //
5 // Copyright 2002-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef JBIG2STREAM_H
10 #define JBIG2STREAM_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include "gtypes.h"
19 #include "Object.h"
20 #include "Stream.h"
21
22 class GList;
23 class JBIG2Segment;
24 class JBIG2Bitmap;
25 class JArithmeticDecoder;
26 class JArithmeticDecoderStats;
27 class JBIG2HuffmanDecoder;
28 struct JBIG2HuffmanTable;
29 class JBIG2MMRDecoder;
30
31 //------------------------------------------------------------------------
32
33 class JBIG2Stream: public FilterStream {
34 public:
35
36   JBIG2Stream(Stream *strA, Object *globalsStream);
37   virtual ~JBIG2Stream();
38   virtual StreamKind getKind() { return strJBIG2; }
39   virtual void reset();
40   virtual int getChar();
41   virtual int lookChar();
42   virtual GString *getPSFilter(int psLevel, char *indent);
43   virtual GBool isBinary(GBool last = gTrue);
44
45 private:
46
47   void readSegments();
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,
54                               int w, int h,
55                               Guint numInstances,
56                               Guint logStrips,
57                               int numSyms,
58                               JBIG2HuffmanTable *symCodeTab,
59                               Guint symCodeLen,
60                               JBIG2Bitmap **syms,
61                               Guint defPixel, Guint combOp,
62                               Guint transposed, Guint refCorner,
63                               int sOffset,
64                               JBIG2HuffmanTable *huffFSTable,
65                               JBIG2HuffmanTable *huffDSTable,
66                               JBIG2HuffmanTable *huffDTTable,
67                               JBIG2HuffmanTable *huffRDWTable,
68                               JBIG2HuffmanTable *huffRDHTable,
69                               JBIG2HuffmanTable *huffRDXTable,
70                               JBIG2HuffmanTable *huffRDYTable,
71                               JBIG2HuffmanTable *huffRSizeTable,
72                               Guint templ,
73                               int *atx, int *aty);
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,
83                                  int *atx, int *aty,
84                                  int mmrDataLength);
85   void readGenericRefinementRegionSeg(Guint segNum, GBool imm,
86                                       GBool lossless, Guint length,
87                                       Guint *refSegs,
88                                       Guint nRefSegs);
89   JBIG2Bitmap *readGenericRefinementRegion(int w, int h,
90                                            int templ, GBool tpgrOn,
91                                            JBIG2Bitmap *refBitmap,
92                                            int refDX, int refDY,
93                                            int *atx, int *aty);
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);
111
112   Guint pageW, pageH, curPageH;
113   Guint pageDefPixel;
114   JBIG2Bitmap *pageBitmap;
115   Guint defCombOp;
116   GList *segments;              // [JBIG2Segment]
117   GList *globalSegments;        // [JBIG2Segment]
118   Stream *curStr;
119   Guchar *dataPtr;
120   Guchar *dataEnd;
121
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;
141 };
142
143 #endif