1/* 2 LzmaStateDecode.h 3 LZMA Decoder interface (State version) 4 5 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) 6 http://www.7-zip.org/ 7 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. 13 14 SPECIAL EXCEPTION: 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. 20*/ 21 22#ifndef __LZMASTATEDECODE_H 23#define __LZMASTATEDECODE_H 24 25#include "LzmaTypes.h" 26 27/* #define _LZMA_PROB32 */ 28/* It can increase speed on some 32-bit CPUs, 29 but memory usage will be doubled in that case */ 30 31#ifdef _LZMA_PROB32 32#define CProb UInt32 33#else 34#define CProb UInt16 35#endif 36 37#define LZMA_RESULT_OK 0 38#define LZMA_RESULT_DATA_ERROR 1 39 40#define LZMA_BASE_SIZE 1846 41#define LZMA_LIT_SIZE 768 42 43#define LZMA_PROPERTIES_SIZE 5 44 45typedef struct _CLzmaProperties 46{ 47 int lc; 48 int lp; 49 int pb; 50 UInt32 DictionarySize; 51}CLzmaProperties; 52 53int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); 54 55#define LzmaGetNumProbs(lzmaProps) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((lzmaProps)->lc + (lzmaProps)->lp))) 56 57#define kLzmaInBufferSize 64 /* don't change it. it must be larger than kRequiredInBufferSize */ 58 59#define kLzmaNeedInitId (-2) 60 61typedef struct _CLzmaDecoderState 62{ 63 CLzmaProperties Properties; 64 CProb *Probs; 65 unsigned char *Dictionary; 66 67 unsigned char Buffer[kLzmaInBufferSize]; 68 int BufferSize; 69 70 UInt32 Range; 71 UInt32 Code; 72 UInt32 DictionaryPos; 73 UInt32 GlobalPos; 74 UInt32 DistanceLimit; 75 UInt32 Reps[4]; 76 int State; 77 int RemainLen; /* -2: decoder needs internal initialization 78 -1: stream was finished, 79 0: ok 80 > 0: need to write RemainLen bytes as match Reps[0], 81 */ 82 unsigned char TempDictionary[4]; /* it's required when DictionarySize = 0 */ 83} CLzmaDecoderState; 84 85#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; (vs)->BufferSize = 0; } 86 87/* LzmaDecode: decoding from input stream to output stream. 88 If finishDecoding != 0, then there are no more bytes in input stream 89 after inStream[inSize - 1]. */ 90 91int LzmaDecode(CLzmaDecoderState *vs, 92 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, 93 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed, 94 int finishDecoding); 95 96#endif 97