1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#ifndef __STREAM_LSBFENCODER_H
#define __STREAM_LSBFENCODER_H
#include "IInOutStreams.h"
#include "OutByte.h"
namespace NStream {
namespace NLSBF {
class CEncoder
{
COutByte m_Stream;
UINT32 m_BitPos;
BYTE m_CurByte;
public:
void Init(ISequentialOutStream *aStream)
{
m_Stream.Init(aStream);
m_BitPos = 8;
m_CurByte = 0;
}
HRESULT Flush()
{
if(m_BitPos < 8)
WriteBits(0, m_BitPos);
return m_Stream.Flush();
}
void WriteBits(UINT32 aValue, UINT32 aNumBits);
UINT32 GetBitPosition() const
{ return (8 - m_BitPos); }
UINT64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
};
class CReverseEncoder
{
CEncoder *m_Encoder;
public:
void Init(CEncoder *anEncoder)
{ m_Encoder = anEncoder; }
void WriteBits(UINT32 aValue, UINT32 aNumBits);
};
}}
#endif
|