~ubuntu-branches/ubuntu/trusty/advancecomp/trusty

« back to all changes in this revision

Viewing changes to 7z/LSBFEncoder.h

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ozarowski
  • Date: 2006-05-13 21:15:49 UTC
  • Revision ID: james.westby@ubuntu.com-20060513211549-2vu7peis643ojcm5
Tags: upstream-1.15
ImportĀ upstreamĀ versionĀ 1.15

Show diffs side-by-side

added added

removed removed

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