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

Method ReadTables20

Libraries/unrar/unpack20.cpp:166–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165
166bool Unpack::ReadTables20()
167{
168 byte BitLength[BC20];
169 byte Table[MC20*4];
170 if (Inp.InAddr>ReadTop-25)
171 if (!UnpReadBuf())
172 return false;
173 uint BitField=Inp.getbits();
174 UnpAudioBlock=(BitField & 0x8000)!=0;
175
176 if (!(BitField & 0x4000))
177 memset(UnpOldTable20,0,sizeof(UnpOldTable20));
178 Inp.addbits(2);
179
180 uint TableSize;
181 if (UnpAudioBlock)
182 {
183 UnpChannels=((BitField>>12) & 3)+1;
184 if (UnpCurChannel>=UnpChannels)
185 UnpCurChannel=0;
186 Inp.addbits(2);
187 TableSize=MC20*UnpChannels;
188 }
189 else
190 TableSize=NC20+DC20+RC20;
191
192 for (uint I=0;I<BC20;I++)
193 {
194 BitLength[I]=(byte)(Inp.getbits() >> 12);
195 Inp.addbits(4);
196 }
197 MakeDecodeTables(BitLength,&BlockTables.BD,BC20);
198 for (uint I=0;I<TableSize;)
199 {
200 if (Inp.InAddr>ReadTop-5)
201 if (!UnpReadBuf())
202 return false;
203 uint Number=DecodeNumber(Inp,&BlockTables.BD);
204 if (Number<16)
205 {
206 Table[I]=(Number+UnpOldTable20[I]) & 0xf;
207 I++;
208 }
209 else
210 if (Number==16)
211 {
212 uint N=(Inp.getbits() >> 14)+3;
213 Inp.addbits(2);
214 if (I==0)
215 return false; // We cannot have "repeat previous" code at the first position.
216 else
217 while (N-- > 0 && I<TableSize)
218 {
219 Table[I]=Table[I-1];
220 I++;
221 }
222 }
223 else

Callers

nothing calls this directly

Calls 2

getbitsMethod · 0.80
addbitsMethod · 0.80

Tested by

no test coverage detected