+++ /dev/null
-/* LzmaDec.h -- LZMA Decoder\r
-2018-04-21 : Igor Pavlov : Public domain */\r
-\r
-#ifndef __LZMA_DEC_H\r
-#define __LZMA_DEC_H\r
-\r
-#include "7zTypes.h"\r
-\r
-EXTERN_C_BEGIN\r
-\r
-/* #define _LZMA_PROB32 */\r
-/* _LZMA_PROB32 can increase the speed on some CPUs,\r
- but memory usage for CLzmaDec::probs will be doubled in that case */\r
-\r
-typedef\r
-#ifdef _LZMA_PROB32\r
- UInt32\r
-#else\r
- UInt16\r
-#endif\r
- CLzmaProb;\r
-\r
-\r
-/* ---------- LZMA Properties ---------- */\r
-\r
-#define LZMA_PROPS_SIZE 5\r
-\r
-typedef struct _CLzmaProps\r
-{\r
- Byte lc;\r
- Byte lp;\r
- Byte pb;\r
- Byte _pad_;\r
- UInt32 dicSize;\r
-} CLzmaProps;\r
-\r
-/* LzmaProps_Decode - decodes properties\r
-Returns:\r
- SZ_OK\r
- SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
-\r
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);\r
-\r
-\r
-/* ---------- LZMA Decoder state ---------- */\r
-\r
-/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.\r
- Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */\r
-\r
-#define LZMA_REQUIRED_INPUT_MAX 20\r
-\r
-typedef struct\r
-{\r
- /* Don't change this structure. ASM code can use it. */\r
- CLzmaProps prop;\r
- CLzmaProb *probs;\r
- CLzmaProb *probs_1664;\r
- Byte *dic;\r
- SizeT dicBufSize;\r
- SizeT dicPos;\r
- const Byte *buf;\r
- UInt32 range;\r
- UInt32 code;\r
- UInt32 processedPos;\r
- UInt32 checkDicSize;\r
- UInt32 reps[4];\r
- UInt32 state;\r
- UInt32 remainLen;\r
-\r
- UInt32 numProbs;\r
- unsigned tempBufSize;\r
- Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];\r
-} CLzmaDec;\r
-\r
-#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }\r
-\r
-void LzmaDec_Init(CLzmaDec *p);\r
-\r
-/* There are two types of LZMA streams:\r
- - Stream with end mark. That end mark adds about 6 bytes to compressed size.\r
- - Stream without end mark. You must know exact uncompressed size to decompress such stream. */\r
-\r
-typedef enum\r
-{\r
- LZMA_FINISH_ANY, /* finish at any point */\r
- LZMA_FINISH_END /* block must be finished at the end */\r
-} ELzmaFinishMode;\r
-\r
-/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!\r
-\r
- You must use LZMA_FINISH_END, when you know that current output buffer\r
- covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.\r
-\r
- If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,\r
- and output value of destLen will be less than output buffer size limit.\r
- You can check status result also.\r
-\r
- You can use multiple checks to test data integrity after full decompression:\r
- 1) Check Result and "status" variable.\r
- 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.\r
- 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.\r
- You must use correct finish mode in that case. */\r
-\r
-typedef enum\r
-{\r
- LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */\r
- LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */\r
- LZMA_STATUS_NOT_FINISHED, /* stream was not finished */\r
- LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */\r
- LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */\r
-} ELzmaStatus;\r
-\r
-/* ELzmaStatus is used only as output value for function call */\r
-\r
-\r
-/* ---------- Interfaces ---------- */\r
-\r
-/* There are 3 levels of interfaces:\r
- 1) Dictionary Interface\r
- 2) Buffer Interface\r
- 3) One Call Interface\r
- You can select any of these interfaces, but don't mix functions from different\r
- groups for same object. */\r
-\r
-\r
-/* There are two variants to allocate state for Dictionary Interface:\r
- 1) LzmaDec_Allocate / LzmaDec_Free\r
- 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs\r
- You can use variant 2, if you set dictionary buffer manually.\r
- For Buffer Interface you must always use variant 1.\r
-\r
-LzmaDec_Allocate* can return:\r
- SZ_OK\r
- SZ_ERROR_MEM - Memory allocation error\r
- SZ_ERROR_UNSUPPORTED - Unsupported properties\r
-*/\r
- \r
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);\r
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);\r
-\r
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);\r
-void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc);\r
-\r
-/* ---------- Dictionary Interface ---------- */\r
-\r
-/* You can use it, if you want to eliminate the overhead for data copying from\r
- dictionary to some other external buffer.\r
- You must work with CLzmaDec variables directly in this interface.\r
-\r
- STEPS:\r
- LzmaDec_Construct()\r
- LzmaDec_Allocate()\r
- for (each new stream)\r
- {\r
- LzmaDec_Init()\r
- while (it needs more decompression)\r
- {\r
- LzmaDec_DecodeToDic()\r
- use data from CLzmaDec::dic and update CLzmaDec::dicPos\r
- }\r
- }\r
- LzmaDec_Free()\r
-*/\r
-\r
-/* LzmaDec_DecodeToDic\r
- \r
- The decoding to internal dictionary buffer (CLzmaDec::dic).\r
- You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!\r
-\r
-finishMode:\r
- It has meaning only if the decoding reaches output limit (dicLimit).\r
- LZMA_FINISH_ANY - Decode just dicLimit bytes.\r
- LZMA_FINISH_END - Stream must be finished after dicLimit.\r
-\r
-Returns:\r
- SZ_OK\r
- status:\r
- LZMA_STATUS_FINISHED_WITH_MARK\r
- LZMA_STATUS_NOT_FINISHED\r
- LZMA_STATUS_NEEDS_MORE_INPUT\r
- LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
- SZ_ERROR_DATA - Data error\r
-*/\r
-\r
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,\r
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- Buffer Interface ---------- */\r
-\r
-/* It's zlib-like interface.\r
- See LzmaDec_DecodeToDic description for information about STEPS and return results,\r
- but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need\r
- to work with CLzmaDec variables manually.\r
-\r
-finishMode:\r
- It has meaning only if the decoding reaches output limit (*destLen).\r
- LZMA_FINISH_ANY - Decode just destLen bytes.\r
- LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-*/\r
-\r
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,\r
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);\r
-\r
-\r
-/* ---------- One Call Interface ---------- */\r
-\r
-/* LzmaDecode\r
-\r
-finishMode:\r
- It has meaning only if the decoding reaches output limit (*destLen).\r
- LZMA_FINISH_ANY - Decode just destLen bytes.\r
- LZMA_FINISH_END - Stream must be finished after (*destLen).\r
-\r
-Returns:\r
- SZ_OK\r
- status:\r
- LZMA_STATUS_FINISHED_WITH_MARK\r
- LZMA_STATUS_NOT_FINISHED\r
- LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK\r
- SZ_ERROR_DATA - Data error\r
- SZ_ERROR_MEM - Memory allocation error\r
- SZ_ERROR_UNSUPPORTED - Unsupported properties\r
- SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).\r
-*/\r
-\r
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,\r
- const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,\r
- ELzmaStatus *status, ISzAllocPtr alloc);\r
-\r
-EXTERN_C_END\r
-\r
-#endif\r