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

Method ReadTables30

Libraries/unrar/unpack30.cpp:628–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626
627
628bool Unpack::ReadTables30()
629{
630 byte BitLength[BC];
631 byte Table[HUFF_TABLE_SIZE30];
632 if (Inp.InAddr>ReadTop-25)
633 if (!UnpReadBuf30())
634 return(false);
635 Inp.faddbits((8-Inp.InBit)&7);
636 uint BitField=Inp.fgetbits();
637 if (BitField & 0x8000)
638 {
639 UnpBlockType=BLOCK_PPM;
640 return(PPM.DecodeInit(this,PPMEscChar));
641 }
642 UnpBlockType=BLOCK_LZ;
643
644 PrevLowDist=0;
645 LowDistRepCount=0;
646
647 if (!(BitField & 0x4000))
648 memset(UnpOldTable,0,sizeof(UnpOldTable));
649 Inp.faddbits(2);
650
651 for (uint I=0;I<BC;I++)
652 {
653 uint Length=(byte)(Inp.fgetbits() >> 12);
654 Inp.faddbits(4);
655 if (Length==15)
656 {
657 uint ZeroCount=(byte)(Inp.fgetbits() >> 12);
658 Inp.faddbits(4);
659 if (ZeroCount==0)
660 BitLength[I]=15;
661 else
662 {
663 ZeroCount+=2;
664 while (ZeroCount-- > 0 && I<ASIZE(BitLength))
665 BitLength[I++]=0;
666 I--;
667 }
668 }
669 else
670 BitLength[I]=Length;
671 }
672 MakeDecodeTables(BitLength,&BlockTables.BD,BC30);
673
674 const uint TableSize=HUFF_TABLE_SIZE30;
675 for (uint I=0;I<TableSize;)
676 {
677 if (Inp.InAddr>ReadTop-5)
678 if (!UnpReadBuf30())
679 return(false);
680 uint Number=DecodeNumber(Inp,&BlockTables.BD);
681 if (Number<16)
682 {
683 Table[I]=(Number+UnpOldTable[I]) & 0xf;
684 I++;
685 }

Callers

nothing calls this directly

Calls 3

faddbitsMethod · 0.80
fgetbitsMethod · 0.80
DecodeInitMethod · 0.80

Tested by

no test coverage detected