other-licenses/7zstub/src/7zip/Common/LSBFEncoder.cpp

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:8c995f204039
1 // LSBFEncoder.cpp
2
3 #include "StdAfx.h"
4
5 #include "LSBFEncoder.h"
6 #include "Common/Defs.h"
7
8 namespace NStream {
9 namespace NLSBF {
10
11 void CEncoder::WriteBits(UInt32 value, int numBits)
12 {
13 while(numBits > 0)
14 {
15 if (numBits < m_BitPos)
16 {
17 m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
18 m_BitPos -= numBits;
19 return;
20 }
21 numBits -= m_BitPos;
22 m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
23 value >>= m_BitPos;
24 m_BitPos = 8;
25 m_CurByte = 0;
26 }
27 }
28
29 }}

mercurial