Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Compress/Bcj2Coder.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,125 @@ 1.4 +// Bcj2Coder.h 1.5 + 1.6 +#ifndef __COMPRESS_BCJ2_CODER_H 1.7 +#define __COMPRESS_BCJ2_CODER_H 1.8 + 1.9 +#include "../../Common/MyCom.h" 1.10 + 1.11 +#include "../ICoder.h" 1.12 + 1.13 +#include "RangeCoderBit.h" 1.14 + 1.15 +namespace NCompress { 1.16 +namespace NBcj2 { 1.17 + 1.18 +const int kNumMoveBits = 5; 1.19 + 1.20 +#ifndef EXTRACT_ONLY 1.21 + 1.22 +class CEncoder: 1.23 + public ICompressCoder2, 1.24 + public CMyUnknownImp 1.25 +{ 1.26 + Byte *_buffer; 1.27 +public: 1.28 + CEncoder(): _buffer(0) {}; 1.29 + ~CEncoder(); 1.30 + bool Create(); 1.31 + 1.32 + COutBuffer _mainStream; 1.33 + COutBuffer _callStream; 1.34 + COutBuffer _jumpStream; 1.35 + NCompress::NRangeCoder::CEncoder _rangeEncoder; 1.36 + NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2]; 1.37 + 1.38 + HRESULT Flush(); 1.39 + void ReleaseStreams() 1.40 + { 1.41 + _mainStream.ReleaseStream(); 1.42 + _callStream.ReleaseStream(); 1.43 + _jumpStream.ReleaseStream(); 1.44 + _rangeEncoder.ReleaseStream(); 1.45 + } 1.46 + 1.47 + class CCoderReleaser 1.48 + { 1.49 + CEncoder *_coder; 1.50 + public: 1.51 + CCoderReleaser(CEncoder *coder): _coder(coder) {} 1.52 + ~CCoderReleaser() { _coder->ReleaseStreams(); } 1.53 + }; 1.54 + 1.55 +public: 1.56 + 1.57 + MY_UNKNOWN_IMP 1.58 + 1.59 + HRESULT CodeReal(ISequentialInStream **inStreams, 1.60 + const UInt64 **inSizes, 1.61 + UInt32 numInStreams, 1.62 + ISequentialOutStream **outStreams, 1.63 + const UInt64 **outSizes, 1.64 + UInt32 numOutStreams, 1.65 + ICompressProgressInfo *progress); 1.66 + STDMETHOD(Code)(ISequentialInStream **inStreams, 1.67 + const UInt64 **inSizes, 1.68 + UInt32 numInStreams, 1.69 + ISequentialOutStream **outStreams, 1.70 + const UInt64 **outSizes, 1.71 + UInt32 numOutStreams, 1.72 + ICompressProgressInfo *progress); 1.73 +}; 1.74 + 1.75 +#endif 1.76 + 1.77 +class CDecoder: 1.78 + public ICompressCoder2, 1.79 + public CMyUnknownImp 1.80 +{ 1.81 +public: 1.82 + CInBuffer _mainInStream; 1.83 + CInBuffer _callStream; 1.84 + CInBuffer _jumpStream; 1.85 + NCompress::NRangeCoder::CDecoder _rangeDecoder; 1.86 + NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2]; 1.87 + 1.88 + COutBuffer _outStream; 1.89 + 1.90 + void ReleaseStreams() 1.91 + { 1.92 + _mainInStream.ReleaseStream(); 1.93 + _callStream.ReleaseStream(); 1.94 + _jumpStream.ReleaseStream(); 1.95 + _rangeDecoder.ReleaseStream(); 1.96 + _outStream.ReleaseStream(); 1.97 + } 1.98 + 1.99 + HRESULT Flush() { return _outStream.Flush(); } 1.100 + class CCoderReleaser 1.101 + { 1.102 + CDecoder *_coder; 1.103 + public: 1.104 + CCoderReleaser(CDecoder *coder): _coder(coder) {} 1.105 + ~CCoderReleaser() { _coder->ReleaseStreams(); } 1.106 + }; 1.107 + 1.108 +public: 1.109 + MY_UNKNOWN_IMP 1.110 + HRESULT CodeReal(ISequentialInStream **inStreams, 1.111 + const UInt64 **inSizes, 1.112 + UInt32 numInStreams, 1.113 + ISequentialOutStream **outStreams, 1.114 + const UInt64 **outSizes, 1.115 + UInt32 numOutStreams, 1.116 + ICompressProgressInfo *progress); 1.117 + STDMETHOD(Code)(ISequentialInStream **inStreams, 1.118 + const UInt64 **inSizes, 1.119 + UInt32 numInStreams, 1.120 + ISequentialOutStream **outStreams, 1.121 + const UInt64 **outSizes, 1.122 + UInt32 numOutStreams, 1.123 + ICompressProgressInfo *progress); 1.124 +}; 1.125 + 1.126 +}} 1.127 + 1.128 +#endif