From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../7zstub/src/7zip/Common/LSBFEncoder.h | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h (limited to 'other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h') diff --git a/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h b/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h new file mode 100644 index 000000000..1c50b8e76 --- /dev/null +++ b/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h @@ -0,0 +1,51 @@ +// Stream/LSBFEncoder.h + +#ifndef __STREAM_LSBFENCODER_H +#define __STREAM_LSBFENCODER_H + +#include "../IStream.h" +#include "OutBuffer.h" + +namespace NStream { +namespace NLSBF { + +class CEncoder +{ + COutBuffer m_Stream; + int m_BitPos; + Byte m_CurByte; +public: + bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); } + void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); } + void ReleaseStream() { m_Stream.ReleaseStream(); } + void Init() + { + m_Stream.Init(); + m_BitPos = 8; + m_CurByte = 0; + } + HRESULT Flush() + { + FlushByte(); + return m_Stream.Flush(); + } + + void FlushByte() + { + if(m_BitPos < 8) + m_Stream.WriteByte(m_CurByte); + m_BitPos = 8; + m_CurByte = 0; + } + + void WriteBits(UInt32 value, int numBits); + UInt32 GetBitPosition() const { return (8 - m_BitPos); } + UInt64 GetProcessedSize() const { + return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; } + void WriteByte(Byte b) { m_Stream.WriteByte(b);} +}; + + +}} + +#endif -- cgit v1.2.3