Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp @ 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/Archive/Lzma/LzmaFiltersDecode.cpp Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,86 @@ 1.4 +// LzmaFiltersDecode.cpp 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "LzmaFiltersDecode.h" 1.9 + 1.10 +namespace NArchive { 1.11 +namespace NLzma { 1.12 + 1.13 +static const UInt64 k_LZMA = 0x030101; 1.14 +static const UInt64 k_BCJ = 0x03030103; 1.15 + 1.16 +HRESULT CDecoder::Code( 1.17 + DECL_EXTERNAL_CODECS_LOC_VARS 1.18 + const CHeader &block, 1.19 + ISequentialInStream *inStream, ISequentialOutStream *outStream, 1.20 + UInt64 *inProcessedSize, ICompressProgressInfo *progress) 1.21 +{ 1.22 + *inProcessedSize = (UInt64)(Int64)-1; 1.23 + 1.24 + if (block.FilterMethod > 1) 1.25 + return E_NOTIMPL; 1.26 + 1.27 + if (!_lzmaDecoder) 1.28 + { 1.29 + RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_LZMA, _lzmaDecoder, false)); 1.30 + if (_lzmaDecoder == 0) 1.31 + return E_NOTIMPL; 1.32 + } 1.33 + 1.34 + { 1.35 + CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties; 1.36 + _lzmaDecoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties); 1.37 + if (!setDecoderProperties) 1.38 + return E_NOTIMPL; 1.39 + RINOK(setDecoderProperties->SetDecoderProperties2(block.LzmaProps, 5)); 1.40 + } 1.41 + 1.42 + bool filteredMode = (block.FilterMethod == 1); 1.43 + 1.44 + CMyComPtr<ICompressSetOutStream> setOutStream; 1.45 + 1.46 + if (filteredMode) 1.47 + { 1.48 + if (!_bcjStream) 1.49 + { 1.50 + CMyComPtr<ICompressCoder> coder; 1.51 + RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_BCJ, coder, false)); 1.52 + if (!coder) 1.53 + return E_NOTIMPL; 1.54 + coder.QueryInterface(IID_ISequentialOutStream, &_bcjStream); 1.55 + if (!_bcjStream) 1.56 + return E_NOTIMPL; 1.57 + } 1.58 + 1.59 + _bcjStream.QueryInterface(IID_ICompressSetOutStream, &setOutStream); 1.60 + if (!setOutStream) 1.61 + return E_NOTIMPL; 1.62 + RINOK(setOutStream->SetOutStream(outStream)); 1.63 + outStream = _bcjStream; 1.64 + } 1.65 + 1.66 + const UInt64 *unpackSize = block.HasUnpackSize() ? &block.UnpackSize : NULL; 1.67 + RINOK(_lzmaDecoder->Code(inStream, outStream, NULL, unpackSize, progress)); 1.68 + 1.69 + if (filteredMode) 1.70 + { 1.71 + CMyComPtr<IOutStreamFlush> flush; 1.72 + _bcjStream.QueryInterface(IID_IOutStreamFlush, &flush); 1.73 + if (flush) 1.74 + { 1.75 + RINOK(flush->Flush()); 1.76 + } 1.77 + RINOK(setOutStream->ReleaseOutStream()); 1.78 + } 1.79 + 1.80 + CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize; 1.81 + _lzmaDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize, &getInStreamProcessedSize); 1.82 + if (getInStreamProcessedSize) 1.83 + { 1.84 + RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(inProcessedSize)); 1.85 + } 1.86 + return S_OK; 1.87 +} 1.88 + 1.89 +}}