3 LZMA Decoder interface (State version)
5 LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
8 LZMA SDK is licensed under two licenses:
9 1) GNU Lesser General Public License (GNU LGPL)
10 2) Common Public License (CPL)
11 It means that you can select one of these two licenses and
12 follow rules of that license.
15 Igor Pavlov, as the author of this code, expressly permits you to
16 statically or dynamically link your code (or bind by name) to the
17 interfaces of this file without subjecting your linked code to the
18 terms of the CPL or GNU LGPL. Any modifications or additions
19 to this file, however, are subject to the LGPL or CPL terms.
22 #ifndef __LZMASTATEDECODE_H
23 #define __LZMASTATEDECODE_H
25 /* #define _LZMA_PROB32 */
26 /* It can increase speed on some 32-bit CPUs,
27 but memory usage will be doubled in that case */
29 /* #define _LZMA_SYSTEM_SIZE_T */
30 /* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
34 #ifdef _LZMA_UINT32_IS_ULONG
35 #define UInt32 unsigned long
37 #define UInt32 unsigned int
42 #ifdef _LZMA_SYSTEM_SIZE_T
53 #define CProb unsigned short
56 #define LZMA_RESULT_OK 0
57 #define LZMA_RESULT_DATA_ERROR 1
59 #define LZMA_BASE_SIZE 1846
60 #define LZMA_LIT_SIZE 768
62 #define LZMA_PROPERTIES_SIZE 5
64 typedef struct _CLzmaProperties
69 UInt32 DictionarySize
;
72 int LzmaDecodeProperties(CLzmaProperties
*propsRes
, const unsigned char *propsData
, int size
);
74 #define LzmaGetNumProbs(lzmaProps) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((lzmaProps)->lc + (lzmaProps)->lp)))
76 #define kLzmaInBufferSize 64 /* don't change it. it must be larger than kRequiredInBufferSize */
78 #define kLzmaNeedInitId (-2)
80 typedef struct _CLzmaDecoderState
82 CLzmaProperties Properties
;
84 unsigned char *Dictionary
;
86 unsigned char Buffer
[kLzmaInBufferSize
];
96 int RemainLen
; /* -2: decoder needs internal initialization
97 -1: stream was finished,
99 > 0: need to write RemainLen bytes as match Reps[0],
101 unsigned char TempDictionary
[4]; /* it's required when DictionarySize = 0 */
104 #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; (vs)->BufferSize = 0; }
106 /* LzmaDecode: decoding from input stream to output stream.
107 If finishDecoding != 0, then there are no more bytes in input stream
108 after inStream[inSize - 1]. */
110 int LzmaDecode(CLzmaDecoderState
*vs
,
111 const unsigned char *inStream
, SizeT inSize
, SizeT
*inSizeProcessed
,
112 unsigned char *outStream
, SizeT outSize
, SizeT
*outSizeProcessed
,