|
1 // x86_2.h |
|
2 |
|
3 #ifndef __BRANCH_X86_2_H |
|
4 #define __BRANCH_X86_2_H |
|
5 |
|
6 #include "../../../Common/MyCom.h" |
|
7 #include "../RangeCoder/RangeCoderBit.h" |
|
8 #include "../../ICoder.h" |
|
9 |
|
10 namespace NCompress { |
|
11 namespace NBcj2 { |
|
12 |
|
13 const int kNumMoveBits = 5; |
|
14 |
|
15 #ifndef EXTRACT_ONLY |
|
16 |
|
17 class CEncoder: |
|
18 public ICompressCoder2, |
|
19 public CMyUnknownImp |
|
20 { |
|
21 Byte *_buffer; |
|
22 public: |
|
23 CEncoder(): _buffer(0) {}; |
|
24 ~CEncoder(); |
|
25 bool Create(); |
|
26 |
|
27 COutBuffer _mainStream; |
|
28 COutBuffer _callStream; |
|
29 COutBuffer _jumpStream; |
|
30 NCompress::NRangeCoder::CEncoder _rangeEncoder; |
|
31 NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2]; |
|
32 |
|
33 HRESULT Flush(); |
|
34 void ReleaseStreams() |
|
35 { |
|
36 _mainStream.ReleaseStream(); |
|
37 _callStream.ReleaseStream(); |
|
38 _jumpStream.ReleaseStream(); |
|
39 _rangeEncoder.ReleaseStream(); |
|
40 } |
|
41 |
|
42 class CCoderReleaser |
|
43 { |
|
44 CEncoder *_coder; |
|
45 public: |
|
46 CCoderReleaser(CEncoder *coder): _coder(coder) {} |
|
47 ~CCoderReleaser() { _coder->ReleaseStreams(); } |
|
48 }; |
|
49 |
|
50 public: |
|
51 |
|
52 MY_UNKNOWN_IMP |
|
53 |
|
54 HRESULT CodeReal(ISequentialInStream **inStreams, |
|
55 const UInt64 **inSizes, |
|
56 UInt32 numInStreams, |
|
57 ISequentialOutStream **outStreams, |
|
58 const UInt64 **outSizes, |
|
59 UInt32 numOutStreams, |
|
60 ICompressProgressInfo *progress); |
|
61 STDMETHOD(Code)(ISequentialInStream **inStreams, |
|
62 const UInt64 **inSizes, |
|
63 UInt32 numInStreams, |
|
64 ISequentialOutStream **outStreams, |
|
65 const UInt64 **outSizes, |
|
66 UInt32 numOutStreams, |
|
67 ICompressProgressInfo *progress); |
|
68 }; |
|
69 |
|
70 #endif |
|
71 |
|
72 class CDecoder: |
|
73 public ICompressCoder2, |
|
74 public CMyUnknownImp |
|
75 { |
|
76 public: |
|
77 CInBuffer _mainInStream; |
|
78 CInBuffer _callStream; |
|
79 CInBuffer _jumpStream; |
|
80 NCompress::NRangeCoder::CDecoder _rangeDecoder; |
|
81 NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2]; |
|
82 |
|
83 COutBuffer _outStream; |
|
84 |
|
85 void ReleaseStreams() |
|
86 { |
|
87 _mainInStream.ReleaseStream(); |
|
88 _callStream.ReleaseStream(); |
|
89 _jumpStream.ReleaseStream(); |
|
90 _rangeDecoder.ReleaseStream(); |
|
91 _outStream.ReleaseStream(); |
|
92 } |
|
93 |
|
94 HRESULT Flush() { return _outStream.Flush(); } |
|
95 class CCoderReleaser |
|
96 { |
|
97 CDecoder *_coder; |
|
98 public: |
|
99 CCoderReleaser(CDecoder *coder): _coder(coder) {} |
|
100 ~CCoderReleaser() { _coder->ReleaseStreams(); } |
|
101 }; |
|
102 |
|
103 public: |
|
104 MY_UNKNOWN_IMP |
|
105 HRESULT CodeReal(ISequentialInStream **inStreams, |
|
106 const UInt64 **inSizes, |
|
107 UInt32 numInStreams, |
|
108 ISequentialOutStream **outStreams, |
|
109 const UInt64 **outSizes, |
|
110 UInt32 numOutStreams, |
|
111 ICompressProgressInfo *progress); |
|
112 STDMETHOD(Code)(ISequentialInStream **inStreams, |
|
113 const UInt64 **inSizes, |
|
114 UInt32 numInStreams, |
|
115 ISequentialOutStream **outStreams, |
|
116 const UInt64 **outSizes, |
|
117 UInt32 numOutStreams, |
|
118 ICompressProgressInfo *progress); |
|
119 }; |
|
120 |
|
121 }} |
|
122 |
|
123 #endif |