• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Bcj2Coder.h
2 
3 #ifndef __COMPRESS_BCJ2_CODER_H
4 #define __COMPRESS_BCJ2_CODER_H
5 
6 #include "../../Common/MyCom.h"
7 
8 #include "../ICoder.h"
9 
10 #include "RangeCoderBit.h"
11 
12 namespace NCompress {
13 namespace NBcj2 {
14 
15 const unsigned kNumMoveBits = 5;
16 
17 #ifndef EXTRACT_ONLY
18 
19 class CEncoder:
20   public ICompressCoder2,
21   public CMyUnknownImp
22 {
23   Byte *_buf;
24 
25   COutBuffer _mainStream;
26   COutBuffer _callStream;
27   COutBuffer _jumpStream;
28   NRangeCoder::CEncoder _rc;
29   NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2];
30 
31   HRESULT Flush();
32 
33 public:
34   MY_UNKNOWN_IMP
35 
36   HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
37       ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
38       ICompressProgressInfo *progress);
39   STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
40       ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
41       ICompressProgressInfo *progress);
42 
CEncoder()43   CEncoder(): _buf(0) {};
44   ~CEncoder();
45 };
46 
47 #endif
48 
49 class CDecoder:
50   public ICompressCoder2,
51   public ICompressSetBufSize,
52   public CMyUnknownImp
53 {
54   CInBuffer _mainStream;
55   CInBuffer _callStream;
56   CInBuffer _jumpStream;
57   NRangeCoder::CDecoder _rc;
58   NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2];
59 
60   COutBuffer _outStream;
61   UInt32 _inBufSizes[4];
62   UInt32 _outBufSize;
63 
64 public:
65   MY_UNKNOWN_IMP1(ICompressSetBufSize);
66 
67   HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
68       ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
69       ICompressProgressInfo *progress);
70   STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams,
71       ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams,
72       ICompressProgressInfo *progress);
73 
74   STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size);
75   STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size);
76 
77   CDecoder();
78 };
79 
80 }}
81 
82 #endif
83