Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Common/LSBFEncoder.h')
-rwxr-xr-xCPP/7zip/Common/LSBFEncoder.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/CPP/7zip/Common/LSBFEncoder.h b/CPP/7zip/Common/LSBFEncoder.h
index 72c84d9f..d50aef0b 100755
--- a/CPP/7zip/Common/LSBFEncoder.h
+++ b/CPP/7zip/Common/LSBFEncoder.h
@@ -38,7 +38,23 @@ public:
m_CurByte = 0;
}
- void WriteBits(UInt32 value, int numBits);
+ void WriteBits(UInt32 value, int numBits)
+ {
+ while(numBits > 0)
+ {
+ if (numBits < m_BitPos)
+ {
+ m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos);
+ m_BitPos -= numBits;
+ return;
+ }
+ numBits -= m_BitPos;
+ m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos))));
+ value >>= m_BitPos;
+ m_BitPos = 8;
+ m_CurByte = 0;
+ }
+ }
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }