diff options
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h')
-rw-r--r-- | 3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h | 144 |
1 files changed, 73 insertions, 71 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h b/3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h index 79a713f1711..627e505d184 100644 --- a/3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h +++ b/3rdparty/lzma/CPP/7zip/Compress/Bcj2Coder.h @@ -3,60 +3,57 @@ #ifndef __COMPRESS_BCJ2_CODER_H #define __COMPRESS_BCJ2_CODER_H +#include "../../../C/Bcj2.h" + #include "../../Common/MyCom.h" #include "../ICoder.h" -#include "RangeCoderBit.h" - namespace NCompress { namespace NBcj2 { -const int kNumMoveBits = 5; +class CBaseCoder +{ +protected: + Byte *_bufs[BCJ2_NUM_STREAMS + 1]; + UInt32 _bufsCurSizes[BCJ2_NUM_STREAMS + 1]; + UInt32 _bufsNewSizes[BCJ2_NUM_STREAMS + 1]; + + HRESULT Alloc(bool allocForOrig = true); +public: + CBaseCoder(); + ~CBaseCoder(); +}; + #ifndef EXTRACT_ONLY class CEncoder: public ICompressCoder2, - public CMyUnknownImp + public ICompressSetCoderProperties, + public ICompressSetBufSize, + public CMyUnknownImp, + public CBaseCoder { - Byte *_buffer; - bool Create(); - - COutBuffer _mainStream; - COutBuffer _callStream; - COutBuffer _jumpStream; - NCompress::NRangeCoder::CEncoder _rangeEncoder; - NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusEncoder[256 + 2]; + UInt32 _relatLim; - HRESULT Flush(); -public: - void ReleaseStreams() - { - _mainStream.ReleaseStream(); - _callStream.ReleaseStream(); - _jumpStream.ReleaseStream(); - _rangeEncoder.ReleaseStream(); - } - - class CCoderReleaser - { - CEncoder *_coder; - public: - CCoderReleaser(CEncoder *coder): _coder(coder) {} - ~CCoderReleaser() { _coder->ReleaseStreams(); } - }; + HRESULT CodeReal(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams, + ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams, + ICompressProgressInfo *progress); public: - MY_UNKNOWN_IMP + MY_UNKNOWN_IMP3(ICompressCoder2, ICompressSetCoderProperties, ICompressSetBufSize) - HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, - ICompressProgressInfo *progress); - STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, + STDMETHOD(Code)(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams, + ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams, ICompressProgressInfo *progress); - CEncoder(): _buffer(0) {}; + + STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); + + STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size); + STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size); + + CEncoder(); ~CEncoder(); }; @@ -64,49 +61,54 @@ public: class CDecoder: public ICompressCoder2, + public ICompressSetFinishMode, + public ICompressSetInStream2, + public ISequentialInStream, + public ICompressSetOutStreamSize, public ICompressSetBufSize, - public CMyUnknownImp + public CMyUnknownImp, + public CBaseCoder { - CInBuffer _mainInStream; - CInBuffer _callStream; - CInBuffer _jumpStream; - NCompress::NRangeCoder::CDecoder _rangeDecoder; - NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusDecoder[256 + 2]; + unsigned _extraReadSizes[BCJ2_NUM_STREAMS]; + UInt64 _inStreamsProcessed[BCJ2_NUM_STREAMS]; + HRESULT _readRes[BCJ2_NUM_STREAMS]; + CMyComPtr<ISequentialInStream> inStreams[BCJ2_NUM_STREAMS]; + + bool _finishMode; + bool _outSizeDefined; + UInt64 _outSize; + UInt64 _outSize_Processed; + CBcj2Dec dec; + + void InitCommon(); + // HRESULT ReadSpec(); + +public: + MY_UNKNOWN_IMP6( + ICompressCoder2, + ICompressSetFinishMode, + ICompressSetInStream2, + ISequentialInStream, + ICompressSetOutStreamSize, + ICompressSetBufSize + ); + + STDMETHOD(Code)(ISequentialInStream * const *inStreams, const UInt64 * const *inSizes, UInt32 numInStreams, + ISequentialOutStream * const *outStreams, const UInt64 * const *outSizes, UInt32 numOutStreams, + ICompressProgressInfo *progress); - COutBuffer _outStream; - UInt32 _inBufSizes[4]; - UInt32 _outBufSize; + STDMETHOD(SetFinishMode)(UInt32 finishMode); -public: - void ReleaseStreams() - { - _mainInStream.ReleaseStream(); - _callStream.ReleaseStream(); - _jumpStream.ReleaseStream(); - _rangeDecoder.ReleaseStream(); - _outStream.ReleaseStream(); - } - - HRESULT Flush() { return _outStream.Flush(); } - class CCoderReleaser - { - CDecoder *_coder; - public: - CCoderReleaser(CDecoder *coder): _coder(coder) {} - ~CCoderReleaser() { _coder->ReleaseStreams(); } - }; + STDMETHOD(SetInStream2)(UInt32 streamIndex, ISequentialInStream *inStream); + STDMETHOD(ReleaseInStream2)(UInt32 streamIndex); -public: - MY_UNKNOWN_IMP1(ICompressSetBufSize); - HRESULT CodeReal(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, - ICompressProgressInfo *progress); - STDMETHOD(Code)(ISequentialInStream **inStreams, const UInt64 **inSizes, UInt32 numInStreams, - ISequentialOutStream **outStreams, const UInt64 **outSizes, UInt32 numOutStreams, - ICompressProgressInfo *progress); + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); + + STDMETHOD(SetOutStreamSize)(const UInt64 *outSize); STDMETHOD(SetInBufSize)(UInt32 streamIndex, UInt32 size); STDMETHOD(SetOutBufSize)(UInt32 streamIndex, UInt32 size); + CDecoder(); }; |