1 | /* |
2 | Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net ) |
3 | Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org ) |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License version 2.1 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with this library; if not, write to the Free Software |
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ |
18 | |
19 | #ifndef __LZARITHMETIC_DECODER_H |
20 | #define __LZARITHMETIC_DECODER_H |
21 | |
22 | #include "winout.h" |
23 | #include "lzma.h" |
24 | #include "lencoder.h" |
25 | #include "litcoder.h" |
26 | |
27 | namespace NCompress { |
28 | namespace NLZMA { |
29 | |
30 | typedef CMyBitDecoder<kNumMoveBitsForMainChoice> CMyBitDecoder2; |
31 | |
32 | class CDecoder |
33 | { |
34 | NStream::NWindow::COut m_OutWindowStream; |
35 | CMyRangeDecoder m_RangeDecoder; |
36 | |
37 | CMyBitDecoder2 m_MainChoiceDecoders[kNumStates][NLength::kNumPosStatesMax]; |
38 | CMyBitDecoder2 m_MatchChoiceDecoders[kNumStates]; |
39 | CMyBitDecoder2 m_MatchRepChoiceDecoders[kNumStates]; |
40 | CMyBitDecoder2 m_MatchRep1ChoiceDecoders[kNumStates]; |
41 | CMyBitDecoder2 m_MatchRep2ChoiceDecoders[kNumStates]; |
42 | CMyBitDecoder2 m_MatchRepShortChoiceDecoders[kNumStates][NLength::kNumPosStatesMax]; |
43 | |
44 | CBitTreeDecoder<kNumMoveBitsForPosSlotCoder, kNumPosSlotBits> m_PosSlotDecoder[kNumLenToPosStates]; |
45 | |
46 | CReverseBitTreeDecoder2<kNumMoveBitsForPosCoders> m_PosDecoders[kNumPosModels]; |
47 | CReverseBitTreeDecoder<kNumMoveBitsForAlignCoders, kNumAlignBits> m_PosAlignDecoder; |
48 | // CBitTreeDecoder2<kNumMoveBitsForPosCoders> m_PosDecoders[kNumPosModels]; |
49 | // CBitTreeDecoder<kNumMoveBitsForAlignCoders, kNumAlignBits> m_PosAlignDecoder; |
50 | |
51 | NLength::CDecoder m_LenDecoder; |
52 | NLength::CDecoder m_RepMatchLenDecoder; |
53 | |
54 | NLiteral::CDecoder m_LiteralDecoder; |
55 | |
56 | UINT32 m_DictionarySize; |
57 | |
58 | UINT32 m_PosStateMask; |
59 | |
60 | HRESULT Create(); |
61 | |
62 | HRESULT Init(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream); |
63 | |
64 | HRESULT Flush() { return m_OutWindowStream.Flush(); } |
65 | |
66 | HRESULT CodeReal(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize); |
67 | |
68 | public: |
69 | |
70 | CDecoder(); |
71 | |
72 | HRESULT Code(ISequentialInStream *anInStream, ISequentialOutStream *anOutStream, const UINT64 *anInSize, const UINT64 *anOutSize); |
73 | HRESULT ReadCoderProperties(ISequentialInStream *anInStream); |
74 | |
75 | HRESULT SetDictionarySize(UINT32 aDictionarySize); |
76 | HRESULT SetLiteralProperties(UINT32 aLiteralPosStateBits, UINT32 aLiteralContextBits); |
77 | HRESULT SetPosBitsProperties(UINT32 aNumPosStateBits); |
78 | }; |
79 | |
80 | }} |
81 | |
82 | #endif |
83 | |