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