15 #ifndef ZenBitStream_LEH
16 #define ZenBitStream_LEH
32 void Attach(
const int8u* Buffer_,
size_t Size_)
41 int32u
Get (
size_t HowMany)
43 ptr_BeforeLastCall=ptr;
46 static const int32u Mask[33]={
48 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
49 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
50 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
51 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
52 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
53 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
54 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
55 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
57 unsigned long m=Mask[HowMany];
61 if(endbyte+4>=storage){
63 if(endbyte*8+(
long)HowMany>storage*8){
71 ret|=ptr[1]<<(8-endbit);
73 ret|=ptr[2]<<(16-endbit);
75 ret|=ptr[3]<<(24-endbit);
76 if(HowMany>32 && endbit){
77 ret|=ptr[4]<<(32-endbit);
85 endbyte+=(long)HowMany/8;
86 endbit=(long)HowMany&7;
100 return storage*8-(endbyte*8+endbit);
119 return ptr_BeforeLastCall-buffer;
126 const unsigned char *buffer;
127 const unsigned char *ptr;
128 const unsigned char *ptr_BeforeLastCall;