00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef JBIG2STREAM_H
00010 #define JBIG2STREAM_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "gtypes.h"
00019 #include "Object.h"
00020 #include "Stream.h"
00021
00022 class GList;
00023 class JBIG2Segment;
00024 class JBIG2Bitmap;
00025 class JArithmeticDecoder;
00026 class JArithmeticDecoderStats;
00027 class JBIG2HuffmanDecoder;
00028 struct JBIG2HuffmanTable;
00029 class JBIG2MMRDecoder;
00030
00031
00032
00033 class JBIG2Stream: public FilterStream {
00034 public:
00035
00036 JBIG2Stream(Stream *strA, Object *globalsStream);
00037 virtual ~JBIG2Stream();
00038 virtual StreamKind getKind() { return strJBIG2; }
00039 virtual void reset();
00040 virtual int getChar();
00041 virtual int lookChar();
00042 virtual GString *getPSFilter(int psLevel, char *indent);
00043 virtual GBool isBinary(GBool last = gTrue);
00044
00045 private:
00046
00047 void readSegments();
00048 void readSymbolDictSeg(Guint segNum, Guint length,
00049 Guint *refSegs, Guint nRefSegs);
00050 void readTextRegionSeg(Guint segNum, GBool imm,
00051 GBool lossless, Guint length,
00052 Guint *refSegs, Guint nRefSegs);
00053 JBIG2Bitmap *readTextRegion(GBool huff, GBool refine,
00054 int w, int h,
00055 Guint numInstances,
00056 Guint logStrips,
00057 int numSyms,
00058 JBIG2HuffmanTable *symCodeTab,
00059 Guint symCodeLen,
00060 JBIG2Bitmap **syms,
00061 Guint defPixel, Guint combOp,
00062 Guint transposed, Guint refCorner,
00063 int sOffset,
00064 JBIG2HuffmanTable *huffFSTable,
00065 JBIG2HuffmanTable *huffDSTable,
00066 JBIG2HuffmanTable *huffDTTable,
00067 JBIG2HuffmanTable *huffRDWTable,
00068 JBIG2HuffmanTable *huffRDHTable,
00069 JBIG2HuffmanTable *huffRDXTable,
00070 JBIG2HuffmanTable *huffRDYTable,
00071 JBIG2HuffmanTable *huffRSizeTable,
00072 Guint templ,
00073 int *atx, int *aty);
00074 void readPatternDictSeg(Guint segNum, Guint length);
00075 void readHalftoneRegionSeg(Guint segNum, GBool imm,
00076 GBool lossless, Guint length,
00077 Guint *refSegs, Guint nRefSegs);
00078 void readGenericRegionSeg(Guint segNum, GBool imm,
00079 GBool lossless, Guint length);
00080 JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
00081 int templ, GBool tpgdOn,
00082 GBool useSkip, JBIG2Bitmap *skip,
00083 int *atx, int *aty,
00084 int mmrDataLength);
00085 void readGenericRefinementRegionSeg(Guint segNum, GBool imm,
00086 GBool lossless, Guint length,
00087 Guint *refSegs,
00088 Guint nRefSegs);
00089 JBIG2Bitmap *readGenericRefinementRegion(int w, int h,
00090 int templ, GBool tpgrOn,
00091 JBIG2Bitmap *refBitmap,
00092 int refDX, int refDY,
00093 int *atx, int *aty);
00094 void readPageInfoSeg(Guint length);
00095 void readEndOfStripeSeg(Guint length);
00096 void readProfilesSeg(Guint length);
00097 void readCodeTableSeg(Guint segNum, Guint length);
00098 void readExtensionSeg(Guint length);
00099 JBIG2Segment *findSegment(Guint segNum);
00100 void discardSegment(Guint segNum);
00101 void resetGenericStats(Guint templ,
00102 JArithmeticDecoderStats *prevStats);
00103 void resetRefinementStats(Guint templ,
00104 JArithmeticDecoderStats *prevStats);
00105 void resetIntStats(int symCodeLen);
00106 GBool readUByte(Guint *x);
00107 GBool readByte(int *x);
00108 GBool readUWord(Guint *x);
00109 GBool readULong(Guint *x);
00110 GBool readLong(int *x);
00111
00112 Guint pageW, pageH, curPageH;
00113 Guint pageDefPixel;
00114 JBIG2Bitmap *pageBitmap;
00115 Guint defCombOp;
00116 GList *segments;
00117 GList *globalSegments;
00118 Stream *curStr;
00119 Guchar *dataPtr;
00120 Guchar *dataEnd;
00121
00122 JArithmeticDecoder *arithDecoder;
00123 JArithmeticDecoderStats *genericRegionStats;
00124 JArithmeticDecoderStats *refinementRegionStats;
00125 JArithmeticDecoderStats *iadhStats;
00126 JArithmeticDecoderStats *iadwStats;
00127 JArithmeticDecoderStats *iaexStats;
00128 JArithmeticDecoderStats *iaaiStats;
00129 JArithmeticDecoderStats *iadtStats;
00130 JArithmeticDecoderStats *iaitStats;
00131 JArithmeticDecoderStats *iafsStats;
00132 JArithmeticDecoderStats *iadsStats;
00133 JArithmeticDecoderStats *iardxStats;
00134 JArithmeticDecoderStats *iardyStats;
00135 JArithmeticDecoderStats *iardwStats;
00136 JArithmeticDecoderStats *iardhStats;
00137 JArithmeticDecoderStats *iariStats;
00138 JArithmeticDecoderStats *iaidStats;
00139 JBIG2HuffmanDecoder *huffDecoder;
00140 JBIG2MMRDecoder *mmrDecoder;
00141 };
00142
00143 #endif