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

Method ReadTables

Libraries/unrar/unpack50.cpp:579–681  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577
578
579bool Unpack::ReadTables(BitInput &Inp,UnpackBlockHeader &Header,UnpackBlockTables &Tables)
580{
581 if (!Header.TablePresent)
582 return true;
583
584 if (!Inp.ExternalBuffer && Inp.InAddr>ReadTop-25)
585 if (!UnpReadBuf())
586 return false;
587
588 byte BitLength[BC];
589 for (uint I=0;I<BC;I++)
590 {
591 uint Length=(byte)(Inp.fgetbits() >> 12);
592 Inp.faddbits(4);
593 if (Length==15)
594 {
595 uint ZeroCount=(byte)(Inp.fgetbits() >> 12);
596 Inp.faddbits(4);
597 if (ZeroCount==0)
598 BitLength[I]=15;
599 else
600 {
601 ZeroCount+=2;
602 while (ZeroCount-- > 0 && I<ASIZE(BitLength))
603 BitLength[I++]=0;
604 I--;
605 }
606 }
607 else
608 BitLength[I]=Length;
609 }
610
611 MakeDecodeTables(BitLength,&Tables.BD,BC);
612
613 byte Table[HUFF_TABLE_SIZE];
614 const uint TableSize=HUFF_TABLE_SIZE;
615 for (uint I=0;I<TableSize;)
616 {
617 if (!Inp.ExternalBuffer && Inp.InAddr>ReadTop-5)
618 if (!UnpReadBuf())
619 return false;
620 uint Number=DecodeNumber(Inp,&Tables.BD);
621 if (Number<16)
622 {
623 Table[I]=Number;
624 I++;
625 }
626 else
627 if (Number<18)
628 {
629 uint N;
630 if (Number==16)
631 {
632 N=(Inp.fgetbits() >> 13)+3;
633 Inp.faddbits(3);
634 }
635 else
636 {

Callers

nothing calls this directly

Calls 2

fgetbitsMethod · 0.80
faddbitsMethod · 0.80

Tested by

no test coverage detected