/* Lzma86.h -- LZMA + x86 (BCJ) Filter12023-03-03 : Igor Pavlov : Public domain */23#ifndef ZIP7_INC_LZMA86_H4#define ZIP7_INC_LZMA86_H56#include "7zTypes.h"78EXTERN_C_BEGIN910#define LZMA86_SIZE_OFFSET (1 + 5)11#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)1213/*14It's an example for LZMA + x86 Filter use.15You can use .lzma86 extension, if you write that stream to file.16.lzma86 header adds one additional byte to standard .lzma header.17.lzma86 header (14 bytes):18Offset Size Description190 1 = 0 - no filter, pure LZMA20= 1 - x86 filter + LZMA211 1 lc, lp and pb in encoded form222 4 dictSize (little endian)236 8 uncompressed size (little endian)242526Lzma86_Encode27-------------28level - compression level: 0 <= level <= 9, the default value for "level" is 5.2930dictSize - The dictionary size in bytes. The maximum value is31128 MB = (1 << 27) bytes for 32-bit version321 GB = (1 << 30) bytes for 64-bit version33The default value is 16 MB = (1 << 24) bytes, for level = 5.34It's recommended to use the dictionary that is larger than 4 KB and35that can be calculated as (1 << N) or (3 << N) sizes.36For better compression ratio dictSize must be >= inSize.3738filterMode:39SZ_FILTER_NO - no Filter40SZ_FILTER_YES - x86 Filter41SZ_FILTER_AUTO - it tries both alternatives to select best.42Encoder will use 2 or 3 passes:432 passes when FILTER_NO provides better compression.443 passes when FILTER_YES provides better compression.4546Lzma86Encode allocates Data with MyAlloc functions.47RAM Requirements for compressing:48RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize49filterMode FilterBlockSize50SZ_FILTER_NO 051SZ_FILTER_YES inSize52SZ_FILTER_AUTO inSize535455Return code:56SZ_OK - OK57SZ_ERROR_MEM - Memory allocation error58SZ_ERROR_PARAM - Incorrect paramater59SZ_ERROR_OUTPUT_EOF - output buffer overflow60SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)61*/6263enum ESzFilterMode64{65SZ_FILTER_NO,66SZ_FILTER_YES,67SZ_FILTER_AUTO68};6970SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,71int level, UInt32 dictSize, int filterMode);727374/*75Lzma86_GetUnpackSize:76In:77src - input data78srcLen - input data size79Out:80unpackSize - size of uncompressed stream81Return code:82SZ_OK - OK83SZ_ERROR_INPUT_EOF - Error in headers84*/8586SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);8788/*89Lzma86_Decode:90In:91dest - output data92destLen - output data size93src - input data94srcLen - input data size95Out:96destLen - processed output size97srcLen - processed input size98Return code:99SZ_OK - OK100SZ_ERROR_DATA - Data error101SZ_ERROR_MEM - Memory allocation error102SZ_ERROR_UNSUPPORTED - unsupported file103SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer104*/105106SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);107108EXTERN_C_END109110#endif111112113