Mercurial > vba-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 // LzmaFiltersDecode.cpp | |
2 | |
3 #include "StdAfx.h" | |
4 | |
5 #include "LzmaFiltersDecode.h" | |
6 | |
7 namespace NArchive { | |
8 namespace NLzma { | |
9 | |
10 static const UInt64 k_LZMA = 0x030101; | |
11 static const UInt64 k_BCJ = 0x03030103; | |
12 | |
13 HRESULT CDecoder::Code( | |
14 DECL_EXTERNAL_CODECS_LOC_VARS | |
15 const CHeader &block, | |
16 ISequentialInStream *inStream, ISequentialOutStream *outStream, | |
17 UInt64 *inProcessedSize, ICompressProgressInfo *progress) | |
18 { | |
19 *inProcessedSize = (UInt64)(Int64)-1; | |
20 | |
21 if (block.FilterMethod > 1) | |
22 return E_NOTIMPL; | |
23 | |
24 if (!_lzmaDecoder) | |
25 { | |
26 RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_LZMA, _lzmaDecoder, false)); | |
27 if (_lzmaDecoder == 0) | |
28 return E_NOTIMPL; | |
29 } | |
30 | |
31 { | |
32 CMyComPtr<ICompressSetDecoderProperties2> setDecoderProperties; | |
33 _lzmaDecoder.QueryInterface(IID_ICompressSetDecoderProperties2, &setDecoderProperties); | |
34 if (!setDecoderProperties) | |
35 return E_NOTIMPL; | |
36 RINOK(setDecoderProperties->SetDecoderProperties2(block.LzmaProps, 5)); | |
37 } | |
38 | |
39 bool filteredMode = (block.FilterMethod == 1); | |
40 | |
41 CMyComPtr<ICompressSetOutStream> setOutStream; | |
42 | |
43 if (filteredMode) | |
44 { | |
45 if (!_bcjStream) | |
46 { | |
47 CMyComPtr<ICompressCoder> coder; | |
48 RINOK(CreateCoder(EXTERNAL_CODECS_LOC_VARS k_BCJ, coder, false)); | |
49 if (!coder) | |
50 return E_NOTIMPL; | |
51 coder.QueryInterface(IID_ISequentialOutStream, &_bcjStream); | |
52 if (!_bcjStream) | |
53 return E_NOTIMPL; | |
54 } | |
55 | |
56 _bcjStream.QueryInterface(IID_ICompressSetOutStream, &setOutStream); | |
57 if (!setOutStream) | |
58 return E_NOTIMPL; | |
59 RINOK(setOutStream->SetOutStream(outStream)); | |
60 outStream = _bcjStream; | |
61 } | |
62 | |
63 const UInt64 *unpackSize = block.HasUnpackSize() ? &block.UnpackSize : NULL; | |
64 RINOK(_lzmaDecoder->Code(inStream, outStream, NULL, unpackSize, progress)); | |
65 | |
66 if (filteredMode) | |
67 { | |
68 CMyComPtr<IOutStreamFlush> flush; | |
69 _bcjStream.QueryInterface(IID_IOutStreamFlush, &flush); | |
70 if (flush) | |
71 { | |
72 RINOK(flush->Flush()); | |
73 } | |
74 RINOK(setOutStream->ReleaseOutStream()); | |
75 } | |
76 | |
77 CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize; | |
78 _lzmaDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize, &getInStreamProcessedSize); | |
79 if (getInStreamProcessedSize) | |
80 { | |
81 RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(inProcessedSize)); | |
82 } | |
83 return S_OK; | |
84 } | |
85 | |
86 }} |