📄 lbitio.h
字号:
if ( BII->BitsToGo < BitStrgLen ) \
{ \
LBitIO_ReadBuf(BII); \
BII->BitsToGo += 32 - BitStrgLen; \
BII->BitBuffer <<= (32 - BII->BitsToGo); \
} \
else \
{ \
BII->BitBuffer <<= BitStrgLen; \
BII->BitsToGo -= BitStrgLen; \
\
if ( BII->BitsToGo == 0 ) \
{ \
LBitIO_ReadBuf(BII); \
BII->BitsToGo = 32; \
} \
} } while(0) \
/* End LBitIO_SkipBits */
/************ now LOCAL versions ***********/
#define LocalLBitIO_Variables() \
ulong LocalBitBuffer; int LocalBitsToGo; \
ubyte *LocalBitArray,*LocalBitArrayPtr; /***/
#define LocalLBitIO_PutState(BII) \
BII->BitBuffer = LocalBitBuffer; \
BII->BitsToGo = LocalBitsToGo; \
BII->BitArray = LocalBitArray; \
BII->BitArrayPtr = LocalBitArrayPtr; /***/
#define LocalLBitIO_GetState(BII) \
LocalBitBuffer = BII->BitBuffer; \
LocalBitsToGo = BII->BitsToGo; \
LocalBitArray = BII->BitArray; \
LocalBitArrayPtr = BII->BitArrayPtr; /***/
/* write BitBuffer to BitArray */
#define LocalLBitIO_WriteBuf() \
*LocalBitArrayPtr++ = LocalBitBuffer>>24; \
*LocalBitArrayPtr++ = (LocalBitBuffer>>16)&0xFF; \
*LocalBitArrayPtr++ = (LocalBitBuffer>>8)&0xFF; \
*LocalBitArrayPtr++ = LocalBitBuffer&0xFF; /* */
/* read BitBuffer from BitArray */
#define LocalLBitIO_ReadBuf() \
LocalBitBuffer = *LocalBitArrayPtr++; LocalBitBuffer<<=8; \
LocalBitBuffer += *LocalBitArrayPtr++; LocalBitBuffer<<=8; \
LocalBitBuffer += *LocalBitArrayPtr++; LocalBitBuffer<<=8; \
LocalBitBuffer += *LocalBitArrayPtr++; /* */
/*
* Write <BitStrgLen> number of zero bits into the BII
* params: struct LocalLBitIOInfo * BII,long BitStrgLen
*
*/
#define LocalLBitIO_WriteZeroBits(BitStrgLen) \
if ( LocalBitsToGo < BitStrgLen ) \
{ \
LocalBitBuffer <<= LocalBitsToGo; \
LocalBitsToGo = BitStrgLen - LocalBitsToGo; \
LocalLBitIO_WriteBuf(); \
LocalBitBuffer = 0; \
LocalBitsToGo = 32 - LocalBitsToGo; \
} \
else \
{ \
LocalBitBuffer <<= BitStrgLen; \
LocalBitsToGo -= BitStrgLen; \
\
if ( LocalBitsToGo == 0 ) \
{ \
LocalLBitIO_WriteBuf(); \
LocalBitsToGo = 32; \
LocalBitBuffer = 0; \
} \
} \
/* End LocalLBitIO_WriteZeroBits */
/*
* Write <BitStrgLen> number of bits from BitStrg into the BII
* params: struct LocalLBitIOInfo * BII,ulong BitStrg,long BitStrgLen
*
*/
#define LocalLBitIO_WriteBits(BitStrg,BitStrgLen) \
if ( LocalBitsToGo < BitStrgLen ) \
{ \
LocalBitBuffer <<= LocalBitsToGo; \
LocalBitsToGo = BitStrgLen - LocalBitsToGo; \
LocalBitBuffer += BitStrg >> LocalBitsToGo; \
LocalLBitIO_WriteBuf(); \
LocalBitBuffer = BitStrg & ( ( 1 << LocalBitsToGo ) - 1 );\
LocalBitsToGo = 32 - LocalBitsToGo; \
} \
else \
{ \
LocalBitBuffer <<= BitStrgLen; \
LocalBitBuffer += BitStrg; \
LocalBitsToGo -= BitStrgLen ; \
\
if ( LocalBitsToGo == 0 ) \
{ \
LocalLBitIO_WriteBuf(); \
LocalBitsToGo = 32; \
LocalBitBuffer = 0; \
} \
} \
/* End LocalLBitIO_WriteBits */
/*
* Write a Bit to the BII - Bit may be True or False (need not be 0 or 1)
* params: struct LocalLBitIOInfo * BII,ulong Bit
*
*/
#define LocalLBitIO_WriteBit(Bit) \
LocalBitBuffer = (LocalBitBuffer<<1) + Bit; \
LocalBitsToGo--; \
if ( ! LocalBitsToGo ) \
{ \
LocalLBitIO_WriteBuf(); \
LocalBitsToGo = 32; \
LocalBitBuffer = 0; \
} \
/* End LocalLBitIO_WriteBit */
#define LocalLBitIO_WriteZeroBit() \
LocalBitBuffer <<= 1; \
LocalBitsToGo--; \
if ( ! LocalBitsToGo ) \
{ \
LocalLBitIO_WriteBuf(); \
LocalBitsToGo = 32; \
LocalBitBuffer = 0; \
} \
/* End LocalLBitIO_WriteZeroBit */
/*
* Reads bits into BitBuffer from BitArray
* must be done before any _Read commands
*
*/
#define LocalLBitIO_InitRead() LocalLBitIO_ReadBuf(); \
LocalBitsToGo = 32;
/* End LocalLBitIO_InitRead */
extern const ulong LBitIOReadBitMask;
/*
* Read a bit from BII into (bool Bit)
*
*/
#define LocalLBitIO_ReadBit(Bit) \
if ( LocalBitBuffer & LBitIOReadBitMask ) \
Bit = 1; \
else \
Bit = 0; \
LocalBitBuffer <<= 1; \
LocalBitsToGo --; \
if ( LocalBitsToGo == 0 ) \
{ \
LocalLBitIO_ReadBuf(); \
LocalBitsToGo = 32; \
} \
/* End LocalLBitIO_ReadBit */
/*
* Read <BitStrgLen> number of bits into BitStrg from the BII
* params: struct LocalLBitIOInfo * BII,ulong BitStrg,long BitStrgLen
*
* fills out BitStrg given BitStrgLen
* BitStrgLen must be less than 32
*
*/
#define LocalLBitIO_ReadBits(BitStrg,BitStrgLen) \
if ( LocalBitsToGo < BitStrgLen ) \
{ \
BitStrg = LocalBitBuffer >> ( 32 - BitStrgLen ); \
\
LocalLBitIO_ReadBuf(); \
\
LocalBitsToGo = 32 - BitStrgLen + LocalBitsToGo; \
BitStrg += LocalBitBuffer >> LocalBitsToGo; \
LocalBitBuffer <<= (32 - LocalBitsToGo); \
} \
else \
{ \
BitStrg = LocalBitBuffer >> ( 32 - BitStrgLen ); \
LocalBitBuffer <<= BitStrgLen; \
LocalBitsToGo -= BitStrgLen; \
\
if ( LocalBitsToGo == 0 ) \
{ \
LocalLBitIO_ReadBuf(); \
LocalBitsToGo = 32; \
} \
} \
/* End LocalLBitIO_ReadBits */
/*
* Read <BitStrgLen> number of bits into BitStrg from the BII
* params: struct LocalLBitIOInfo * BII,ulong BitStrg,long BitStrgLen
*
* fills out BitStrg given BitStrgLen
* BitStrgLen must be less than 32
*
* PeekBits is the same as ReadBits except that the BII
* is not advanced
*
*/
#define LocalLBitIO_PeekBits(BitStrg,BitStrgLen) \
BitStrg = LocalBitBuffer >> ( 32 - BitStrgLen ); \
if ( LocalBitsToGo < BitStrgLen ) \
{ \
ulong PeekBitBuf = (LocalBitArrayPtr[0]<<24)+(LocalBitArrayPtr[1]<<16)+(LocalBitArrayPtr[2]<<8)+(LocalBitArrayPtr[3]); \
BitStrg += ( PeekBitBuf >> ( 32 - BitStrgLen + LocalBitsToGo )); }
/* End LocalLBitIO_PeekBits */
/*
* Skip past <BitStrgLen> number of bits into BitStrg from the BII
* params: struct LocalLBitIOInfo * BII,long BitStrgLen
* BitStrgLen must be less than 32
*
*/
#define LocalLBitIO_SkipBits(BitStrgLen) \
if ( LocalBitsToGo < BitStrgLen ) \
{ \
LocalLBitIO_ReadBuf(); \
LocalBitsToGo += 32 - BitStrgLen; \
LocalBitBuffer <<= (32 - LocalBitsToGo); \
} \
else \
{ \
LocalBitBuffer <<= BitStrgLen; \
LocalBitsToGo -= BitStrgLen; \
\
if ( LocalBitsToGo == 0 ) \
{ \
LocalLBitIO_ReadBuf(); \
LocalBitsToGo = 32; \
} \
} \
/* End LocalLBitIO_SkipBits */
#endif // BIT_IO_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -