~ubuntu-branches/ubuntu/wily/unrar-nonfree/wily-proposed

« back to all changes in this revision

Viewing changes to unpack.hpp

  • Committer: Package Import Robot
  • Author(s): Nick Andrik
  • Date: 2013-01-21 23:07:40 UTC
  • mfrom: (1.2.13)
  • Revision ID: package-import@ubuntu.com-20130121230740-yky1izwyj5x16wq1
Tags: 1:4.2.4-0.1
* Non-maintainer upload

* New upstream release (Closes: #687839)

* Add shared library binary and headers packages
  - Add entries into control file
  - Add libunrar0.{install,link,symbols} files
  - Add libunrar0-dev.install file
  - Patch missing binary object targets for library building
    (fix_missing_symbols)
  - Rename previous unrar-nonfree.{1,dirs,install,prerm,postint} file to
    unrar.* ones
  - Make sure libunrar.so is built (Closes: #485492, LP: #390263)
* Converted package to CDBS:
  - Simplified rules file
  - Added cdbs build-deps
* Added hardening support (Closes: #694611)
  - Updated compatibility version to 9
  - Added versioned dpkg-dev build-dep
* Updated copyright information:
  - Machine-readable format
  - Added missing files/licenses
* General maintentance:
  - Moved the homepage field in cortol file to the appropriate place
  - Bumped standards version to 3.9.4
  - Remove versioned conflict dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
// Maximum allowed number of compressed bits processed in quick mode.
7
7
#define MAX_QUICK_DECODE_BITS 10
8
8
 
 
9
// Maximum number of filters per entire data block.
 
10
#define MAX_FILTERS 1024
 
11
 
9
12
// Decode compressed bit fields to alphabet numbers.
10
13
struct DecodeTable
11
14
{
33
36
 
34
37
  // Translates compressed bits (up to QuickBits length)
35
38
  // to position in alphabet in quick mode.
36
 
  uint QuickNum[1<<MAX_QUICK_DECODE_BITS];
 
39
  // 'ushort' saves some memory and even provides a little speed gain
 
40
  // comparting to 'uint' here.
 
41
  ushort QuickNum[1<<MAX_QUICK_DECODE_BITS];
37
42
 
38
43
  // Translate the position in code list to position in alphabet.
39
44
  // We do not allocate it dynamically to avoid performance overhead
41
46
  // as array dimension. Real size of this array is defined in MaxNum.
42
47
  // We use this array if compressed bit field is too lengthy
43
48
  // for QuickLen based translation.
44
 
  uint DecodeNum[LARGEST_TABLE_SIZE];
 
49
  // 'ushort' saves some memory and even provides a little speed gain
 
50
  // comparting to 'uint' here.
 
51
  ushort DecodeNum[LARGEST_TABLE_SIZE];
45
52
};
46
53
 
47
54
struct UnpackFilter
73
80
class Unpack:private BitInput
74
81
{
75
82
  private:
76
 
    friend class Pack;
77
83
 
78
84
    void Unpack29(bool Solid);
79
85
    bool UnpReadBuf();
87
93
    inline int SafePPMDecodeChar();
88
94
    void CopyString();
89
95
    inline void InsertOldDist(unsigned int Distance);
90
 
    inline void InsertLastMatch(unsigned int Length,unsigned int Distance);
91
96
    void UnpInitData(int Solid);
92
97
    _forceinline void CopyString(uint Length,uint Distance);
93
98
    bool ReadEndOfBlock();
126
131
    DecodeTable DD;  // Decode distances.
127
132
    DecodeTable LDD; // Decode lower bits of distances.
128
133
    DecodeTable RD;  // Decode repeating distances.
129
 
    DecodeTable BD;  // Decod bit lengths in Huffman table.
 
134
    DecodeTable BD;  // Decode bit lengths in Huffman table.
130
135
 
131
136
    unsigned int OldDist[4],OldDistPtr;
132
 
    unsigned int LastDist,LastLength;
 
137
    unsigned int LastLength;
 
138
 
 
139
    // LastDist is necessary only for RAR2 and older with circular OldDist
 
140
    // array. In RAR3 last distance is always stored in OldDist[0].
 
141
    unsigned int LastDist;
133
142
 
134
143
    unsigned int UnpPtr,WrPtr;
135
144
    
141
150
    // unless we are at the end of file.
142
151
    int ReadBorder;
143
152
 
144
 
    unsigned char UnpOldTable[HUFF_TABLE_SIZE];
 
153
    byte UnpOldTable[HUFF_TABLE_SIZE];
145
154
 
146
155
    int UnpBlockType;
147
156
 
148
157
    byte *Window;
149
 
    bool ExternalWindow;
150
158
 
151
159
 
152
160
    int64 DestUnpSize;
167
175
    void GetFlagsBuf();
168
176
    void OldUnpInitData(int Solid);
169
177
    void InitHuff();
170
 
    void CorrHuff(unsigned int *CharSet,unsigned int *NumToPlace);
 
178
    void CorrHuff(ushort *CharSet,byte *NumToPlace);
171
179
    void OldCopyString(unsigned int Distance,unsigned int Length);
172
180
    uint DecodeNum(uint Num,uint StartPos,uint *DecTab,uint *PosTab);
173
181
    void OldUnpWriteBuf();
174
182
 
175
 
    unsigned int ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
176
 
    unsigned int Place[256],PlaceA[256],PlaceB[256],PlaceC[256];
177
 
    unsigned int NToPl[256],NToPlB[256],NToPlC[256];
 
183
    ushort ChSet[256],ChSetA[256],ChSetB[256],ChSetC[256];
 
184
    byte NToPl[256],NToPlB[256],NToPlC[256];
178
185
    unsigned int FlagBuf,AvrPlc,AvrPlcB,AvrLn1,AvrLn2,AvrLn3;
179
186
    int Buf60,NumHuf,StMode,LCount,FlagsCnt;
180
187
    unsigned int Nhfb,Nlzb,MaxDist3;
198
205
  public:
199
206
    Unpack(ComprDataIO *DataIO);
200
207
    ~Unpack();
201
 
    void Init(byte *Window=NULL);
 
208
    void Init();
202
209
    void DoUnpack(int Method,bool Solid);
203
210
    bool IsFileExtracted() {return(FileExtracted);}
204
211
    void SetDestSize(int64 DestSize) {DestUnpSize=DestSize;FileExtracted=false;}