| 319 | |
| 320 | |
| 321 | void Unpack::HuffDecode() |
| 322 | { |
| 323 | unsigned int CurByte,NewBytePlace; |
| 324 | unsigned int Length; |
| 325 | unsigned int Distance; |
| 326 | int BytePlace; |
| 327 | |
| 328 | unsigned int BitField=Inp.fgetbits(); |
| 329 | |
| 330 | if (AvrPlc > 0x75ff) |
| 331 | BytePlace=DecodeNum(BitField,STARTHF4,DecHf4,PosHf4); |
| 332 | else |
| 333 | if (AvrPlc > 0x5dff) |
| 334 | BytePlace=DecodeNum(BitField,STARTHF3,DecHf3,PosHf3); |
| 335 | else |
| 336 | if (AvrPlc > 0x35ff) |
| 337 | BytePlace=DecodeNum(BitField,STARTHF2,DecHf2,PosHf2); |
| 338 | else |
| 339 | if (AvrPlc > 0x0dff) |
| 340 | BytePlace=DecodeNum(BitField,STARTHF1,DecHf1,PosHf1); |
| 341 | else |
| 342 | BytePlace=DecodeNum(BitField,STARTHF0,DecHf0,PosHf0); |
| 343 | BytePlace&=0xff; |
| 344 | if (StMode) |
| 345 | { |
| 346 | if (BytePlace==0 && BitField > 0xfff) |
| 347 | BytePlace=0x100; |
| 348 | if (--BytePlace==-1) |
| 349 | { |
| 350 | BitField=Inp.fgetbits(); |
| 351 | Inp.faddbits(1); |
| 352 | if (BitField & 0x8000) |
| 353 | { |
| 354 | NumHuf=StMode=0; |
| 355 | return; |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | Length = (BitField & 0x4000) ? 4 : 3; |
| 360 | Inp.faddbits(1); |
| 361 | Distance=DecodeNum(Inp.fgetbits(),STARTHF2,DecHf2,PosHf2); |
| 362 | Distance = (Distance << 5) | (Inp.fgetbits() >> 11); |
| 363 | Inp.faddbits(5); |
| 364 | CopyString15(Distance,Length); |
| 365 | return; |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | else |
| 370 | if (NumHuf++ >= 16 && FlagsCnt==0) |
| 371 | StMode=1; |
| 372 | AvrPlc += BytePlace; |
| 373 | AvrPlc -= AvrPlc >> 8; |
| 374 | Nhfb+=16; |
| 375 | if (Nhfb > 0xff) |
| 376 | { |
| 377 | Nhfb=0x90; |
| 378 | Nlzb >>= 1; |