1 /* Lzma2Dec.h -- LZMA2 Decoder
2 2018-02-19 : Igor Pavlov : Public domain */
11 /* ---------- State Interface ---------- */
25 #define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
26 #define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc)
27 #define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc)
29 SRes
Lzma2Dec_AllocateProbs(CLzma2Dec
*p
, Byte prop
, ISzAllocPtr alloc
);
30 SRes
Lzma2Dec_Allocate(CLzma2Dec
*p
, Byte prop
, ISzAllocPtr alloc
);
31 void Lzma2Dec_Init(CLzma2Dec
*p
);
35 It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
36 LZMA_FINISH_ANY - use smallest number of input bytes
37 LZMA_FINISH_END - read EndOfStream marker after decoding
42 LZMA_STATUS_FINISHED_WITH_MARK
43 LZMA_STATUS_NOT_FINISHED
44 LZMA_STATUS_NEEDS_MORE_INPUT
45 SZ_ERROR_DATA - Data error
48 SRes
Lzma2Dec_DecodeToDic(CLzma2Dec
*p
, SizeT dicLimit
,
49 const Byte
*src
, SizeT
*srcLen
, ELzmaFinishMode finishMode
, ELzmaStatus
*status
);
51 SRes
Lzma2Dec_DecodeToBuf(CLzma2Dec
*p
, Byte
*dest
, SizeT
*destLen
,
52 const Byte
*src
, SizeT
*srcLen
, ELzmaFinishMode finishMode
, ELzmaStatus
*status
);
55 /* ---------- LZMA2 block and chunk parsing ---------- */
58 Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data.
59 It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code:
60 - LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input.
61 - LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read.
62 CLzma2Dec::unpackSize contains unpack size of that chunk
68 LZMA_STATUS_NOT_SPECIFIED // data error
69 LZMA_STATUS_FINISHED_WITH_MARK
70 LZMA_STATUS_NOT_FINISHED //
71 LZMA_STATUS_NEEDS_MORE_INPUT
72 LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused
74 LZMA2_PARSE_STATUS_NEW_BLOCK
= LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ 1,
75 LZMA2_PARSE_STATUS_NEW_CHUNK
78 ELzma2ParseStatus
Lzma2Dec_Parse(CLzma2Dec
*p
,
79 SizeT outSize
, // output size
80 const Byte
*src
, SizeT
*srcLen
,
81 int checkFinishBlock
// set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position.
85 LZMA2 parser doesn't decode LZMA chunks, so we must read
86 full input LZMA chunk to decode some part of LZMA chunk.
88 Lzma2Dec_GetUnpackExtra() returns the value that shows
89 max possible number of output bytes that can be output by decoder
90 at current input positon.
93 #define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0);
96 /* ---------- One Call Interface ---------- */
100 It has meaning only if the decoding reaches output limit (*destLen).
101 LZMA_FINISH_ANY - use smallest number of input bytes
102 LZMA_FINISH_END - read EndOfStream marker after decoding
107 LZMA_STATUS_FINISHED_WITH_MARK
108 LZMA_STATUS_NOT_FINISHED
109 SZ_ERROR_DATA - Data error
110 SZ_ERROR_MEM - Memory allocation error
111 SZ_ERROR_UNSUPPORTED - Unsupported properties
112 SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
115 SRes
Lzma2Decode(Byte
*dest
, SizeT
*destLen
, const Byte
*src
, SizeT
*srcLen
,
116 Byte prop
, ELzmaFinishMode finishMode
, ELzmaStatus
*status
, ISzAllocPtr alloc
);