Coverage Report

Created: 2025-11-11 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/xpdf-4.05/xpdf/JBIG2Stream.h
Line
Count
Source
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
#include "gtypes.h"
15
#include "Object.h"
16
#include "Stream.h"
17
18
class GList;
19
class JBIG2Segment;
20
class JBIG2Bitmap;
21
class JArithmeticDecoder;
22
class JArithmeticDecoderStats;
23
class JBIG2HuffmanDecoder;
24
struct JBIG2HuffmanTable;
25
class JBIG2MMRDecoder;
26
27
//------------------------------------------------------------------------
28
29
class JBIG2Stream: public FilterStream {
30
public:
31
32
  JBIG2Stream(Stream *strA, Object *globalsStreamA);
33
  virtual ~JBIG2Stream();
34
  virtual Stream *copy();
35
0
  virtual StreamKind getKind() { return strJBIG2; }
36
  virtual void reset();
37
  virtual void close();
38
  virtual int getChar();
39
  virtual int lookChar();
40
  virtual int getBlock(char *blk, int size);
41
  virtual GString *getPSFilter(int psLevel, const char *indent,
42
             GBool okToReadStream);
43
  virtual GBool isBinary(GBool last = gTrue);
44
0
  virtual GBool hasStrongCompression() { return gTrue; }
45
46
private:
47
48
  void decodeImage();
49
  void readSegments();
50
  GBool readSymbolDictSeg(Guint segNum, Guint length,
51
        Guint *refSegs, Guint nRefSegs);
52
  void readTextRegionSeg(Guint segNum, GBool imm,
53
       GBool lossless, Guint length,
54
       Guint *refSegs, Guint nRefSegs);
55
  JBIG2Bitmap *readTextRegion(GBool huff, GBool refine,
56
            int w, int h,
57
            Guint numInstances,
58
            Guint logStrips,
59
            int numSyms,
60
            JBIG2HuffmanTable *symCodeTab,
61
            Guint symCodeLen,
62
            JBIG2Bitmap **syms,
63
            Guint defPixel, Guint combOp,
64
            Guint transposed, Guint refCorner,
65
            int sOffset,
66
            JBIG2HuffmanTable *huffFSTable,
67
            JBIG2HuffmanTable *huffDSTable,
68
            JBIG2HuffmanTable *huffDTTable,
69
            JBIG2HuffmanTable *huffRDWTable,
70
            JBIG2HuffmanTable *huffRDHTable,
71
            JBIG2HuffmanTable *huffRDXTable,
72
            JBIG2HuffmanTable *huffRDYTable,
73
            JBIG2HuffmanTable *huffRSizeTable,
74
            Guint templ,
75
            int *atx, int *aty);
76
  void readPatternDictSeg(Guint segNum, Guint length);
77
  void readHalftoneRegionSeg(Guint segNum, GBool imm,
78
           GBool lossless, Guint length,
79
           Guint *refSegs, Guint nRefSegs);
80
  void readGenericRegionSeg(Guint segNum, GBool imm,
81
          GBool lossless, Guint length);
82
  void mmrAddPixels(int a1, int blackPixels,
83
        int *codingLine, int *a0i, int w);
84
  void mmrAddPixelsNeg(int a1, int blackPixels,
85
           int *codingLine, int *a0i, int w);
86
  JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
87
         int templ, GBool tpgdOn,
88
         GBool useSkip, JBIG2Bitmap *skip,
89
         int *atx, int *aty,
90
         int mmrDataLength);
91
  void readGenericRefinementRegionSeg(Guint segNum, GBool imm,
92
              GBool lossless, Guint length,
93
              Guint *refSegs,
94
              Guint nRefSegs);
95
  JBIG2Bitmap *readGenericRefinementRegion(int w, int h,
96
             int templ, GBool tpgrOn,
97
             JBIG2Bitmap *refBitmap,
98
             int refDX, int refDY,
99
             int *atx, int *aty);
100
  void readPageInfoSeg(Guint length);
101
  void readEndOfStripeSeg(Guint length);
102
  void readProfilesSeg(Guint length);
103
  void readCodeTableSeg(Guint segNum, Guint length);
104
  void readExtensionSeg(Guint length);
105
  JBIG2Segment *findSegment(Guint segNum);
106
  void discardSegment(Guint segNum);
107
  void resetGenericStats(Guint templ,
108
       JArithmeticDecoderStats *prevStats);
109
  void resetRefinementStats(Guint templ,
110
          JArithmeticDecoderStats *prevStats);
111
  void resetIntStats(int symCodeLen);
112
  GBool readUByte(Guint *x);
113
  GBool readByte(int *x);
114
  GBool readUWord(Guint *x);
115
  GBool readULong(Guint *x);
116
  GBool readLong(int *x);
117
118
  GBool decoded;
119
  Object globalsStream;
120
  Guint pageW, pageH, curPageH;
121
  Guint pageDefPixel;
122
  JBIG2Bitmap *pageBitmap;
123
  Guint defCombOp;
124
  GList *segments;    // [JBIG2Segment]
125
  GList *globalSegments;  // [JBIG2Segment]
126
  Stream *curStr;
127
  Guchar *dataPtr;
128
  Guchar *dataEnd;
129
  Guint byteCounter;
130
  GBool done;
131
132
  JArithmeticDecoder *arithDecoder;
133
  JArithmeticDecoderStats *genericRegionStats;
134
  JArithmeticDecoderStats *refinementRegionStats;
135
  JArithmeticDecoderStats *iadhStats;
136
  JArithmeticDecoderStats *iadwStats;
137
  JArithmeticDecoderStats *iaexStats;
138
  JArithmeticDecoderStats *iaaiStats;
139
  JArithmeticDecoderStats *iadtStats;
140
  JArithmeticDecoderStats *iaitStats;
141
  JArithmeticDecoderStats *iafsStats;
142
  JArithmeticDecoderStats *iadsStats;
143
  JArithmeticDecoderStats *iardxStats;
144
  JArithmeticDecoderStats *iardyStats;
145
  JArithmeticDecoderStats *iardwStats;
146
  JArithmeticDecoderStats *iardhStats;
147
  JArithmeticDecoderStats *iariStats;
148
  JArithmeticDecoderStats *iaidStats;
149
  JBIG2HuffmanDecoder *huffDecoder;
150
  JBIG2MMRDecoder *mmrDecoder;
151
};
152
153
#endif