MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ShortLZ

Method ShortLZ

Libraries/unrar/unpack15.cpp:117–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115#define GetShortLen2(pos) ((pos)==3 ? Buf60+3:ShortLen2[pos])
116
117void Unpack::ShortLZ()
118{
119 static unsigned int ShortLen1[]={1,3,4,4,5,6,7,8,8,4,4,5,6,6,4,0};
120 static unsigned int ShortXor1[]={0,0xa0,0xd0,0xe0,0xf0,0xf8,0xfc,0xfe,
121 0xff,0xc0,0x80,0x90,0x98,0x9c,0xb0};
122 static unsigned int ShortLen2[]={2,3,3,3,4,4,5,6,6,4,4,5,6,6,4,0};
123 static unsigned int ShortXor2[]={0,0x40,0x60,0xa0,0xd0,0xe0,0xf0,0xf8,
124 0xfc,0xc0,0x80,0x90,0x98,0x9c,0xb0};
125
126
127 unsigned int Length,SaveLength;
128 unsigned int LastDistance;
129 unsigned int Distance;
130 int DistancePlace;
131 NumHuf=0;
132
133 unsigned int BitField=Inp.fgetbits();
134 if (LCount==2)
135 {
136 Inp.faddbits(1);
137 if (BitField >= 0x8000)
138 {
139 CopyString15((unsigned int)LastDist,LastLength);
140 return;
141 }
142 BitField <<= 1;
143 LCount=0;
144 }
145
146 BitField>>=8;
147
148// not thread safe, replaced by GetShortLen1 and GetShortLen2 macro
149// ShortLen1[1]=ShortLen2[3]=Buf60+3;
150
151 if (AvrLn1<37)
152 {
153 for (Length=0;;Length++)
154 if (((BitField^ShortXor1[Length]) & (~(0xff>>GetShortLen1(Length))))==0)
155 break;
156 Inp.faddbits(GetShortLen1(Length));
157 }
158 else
159 {
160 for (Length=0;;Length++)
161 if (((BitField^ShortXor2[Length]) & (~(0xff>>GetShortLen2(Length))))==0)
162 break;
163 Inp.faddbits(GetShortLen2(Length));
164 }
165
166 if (Length >= 9)
167 {
168 if (Length == 9)
169 {
170 LCount++;
171 CopyString15((unsigned int)LastDist,LastLength);
172 return;
173 }
174 if (Length == 14)

Callers

nothing calls this directly

Calls 2

fgetbitsMethod · 0.80
faddbitsMethod · 0.80

Tested by

no test coverage detected