mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-14 16:11:38 -06:00
3.13
This commit is contained in:
59
7zip/Common/LSBFEncoder.h
Executable file
59
7zip/Common/LSBFEncoder.h
Executable file
@@ -0,0 +1,59 @@
|
||||
// Stream/LSBFEncoder.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __STREAM_LSBFENCODER_H
|
||||
#define __STREAM_LSBFENCODER_H
|
||||
|
||||
#include "../IStream.h"
|
||||
#include "OutBuffer.h"
|
||||
|
||||
namespace NStream {
|
||||
namespace NLSBF {
|
||||
|
||||
class CEncoder
|
||||
{
|
||||
COutBuffer 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 ReleaseStream()
|
||||
{
|
||||
m_Stream.ReleaseStream();
|
||||
}
|
||||
*/
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user