29 #ifndef ZenBitStream_LEH
30 #define ZenBitStream_LEH
46 void Attach(
const int8u* Buffer_,
size_t Size_)
55 int32u
Get (
size_t HowMany)
57 ptr_BeforeLastCall=ptr;
60 static const int32u Mask[33]={
62 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
63 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
64 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff,
65 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
66 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff,
67 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
68 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff,
69 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff,
71 unsigned long m=Mask[HowMany];
75 if(endbyte+4>=storage){
77 if(endbyte*8+(
long)HowMany>storage*8){
85 ret|=ptr[1]<<(8-endbit);
87 ret|=ptr[2]<<(16-endbit);
89 ret|=ptr[3]<<(24-endbit);
90 if(HowMany>32 && endbit){
91 ret|=ptr[4]<<(32-endbit);
99 endbyte+=(long)HowMany/8;
100 endbit=(long)HowMany&7;
114 return storage*8-(endbyte*8+endbit);
133 return ptr_BeforeLastCall-buffer;
140 const unsigned char *buffer;
141 const unsigned char *ptr;
142 const unsigned char *ptr_BeforeLastCall;