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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +// LSBFEncoder.cpp
     1.5 +
     1.6 +#include "StdAfx.h"
     1.7 +
     1.8 +#include "LSBFEncoder.h"
     1.9 +#include "Common/Defs.h"
    1.10 +
    1.11 +namespace NStream {
    1.12 +namespace NLSBF {
    1.13 +
    1.14 +void CEncoder::WriteBits(UInt32 value, int numBits)
    1.15 +{
    1.16 +  while(numBits > 0)
    1.17 +  {
    1.18 +    if (numBits < m_BitPos)
    1.19 +    {
    1.20 +      m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
    1.21 +      m_BitPos -= numBits;
    1.22 +      return;
    1.23 +    }
    1.24 +    numBits -= m_BitPos;
    1.25 +    m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
    1.26 +    value >>= m_BitPos;
    1.27 +    m_BitPos = 8;
    1.28 +    m_CurByte = 0;
    1.29 +  }
    1.30 +}
    1.31 +
    1.32 +}}

mercurial