michael@0: // LSBFEncoder.cpp michael@0: michael@0: #include "StdAfx.h" michael@0: michael@0: #include "LSBFEncoder.h" michael@0: #include "Common/Defs.h" michael@0: michael@0: namespace NStream { michael@0: namespace NLSBF { michael@0: michael@0: void CEncoder::WriteBits(UInt32 value, int numBits) michael@0: { michael@0: while(numBits > 0) michael@0: { michael@0: if (numBits < m_BitPos) michael@0: { michael@0: m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos); michael@0: m_BitPos -= numBits; michael@0: return; michael@0: } michael@0: numBits -= m_BitPos; michael@0: m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos)))); michael@0: value >>= m_BitPos; michael@0: m_BitPos = 8; michael@0: m_CurByte = 0; michael@0: } michael@0: } michael@0: michael@0: }}