Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getbits.hpp « Original « Rar29 « Compress « 7zip - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8819f53ab5576297e767de10c6887706fb961aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _RAR_GETBITS_
#define _RAR_GETBITS_

class BitInput
{
  public:
    enum BufferSize {MAX_SIZE=0x8000};
  protected:
    int InAddr,InBit;
  public:
    BitInput();
    ~BitInput();

    byte *InBuf;

    void InitBitInput()
    {
      InAddr=InBit=0;
    }
    void addbits(int Bits)
    {
      Bits+=InBit;
      InAddr+=Bits>>3;
      InBit=Bits&7;
    }
    unsigned int getbits()
    {
      unsigned int BitField=(uint)InBuf[InAddr] << 16;
      BitField|=(uint)InBuf[InAddr+1] << 8;
      BitField|=(uint)InBuf[InAddr+2];
      BitField >>= (8-InBit);
      return(BitField & 0xffff);
    }
    void faddbits(int Bits);
    unsigned int fgetbits();
};
#endif