1 /* Lzma86.h -- LZMA + x86 (BCJ) Filter
2 2013-01-18 : Igor Pavlov : Public domain */
11 #define LZMA86_SIZE_OFFSET (1 + 5)
12 #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
15 It's an example for LZMA + x86 Filter use.
16 You can use .lzma86 extension, if you write that stream to file.
17 .lzma86 header adds one additional byte to standard .lzma header.
18 .lzma86 header (14 bytes):
19 Offset Size Description
20 0 1 = 0 - no filter, pure LZMA
21 = 1 - x86 filter + LZMA
22 1 1 lc, lp and pb in encoded form
23 2 4 dictSize (little endian)
24 6 8 uncompressed size (little endian)
29 level - compression level: 0 <= level <= 9, the default value for "level" is 5.
31 dictSize - The dictionary size in bytes. The maximum value is
32 128 MB = (1 << 27) bytes for 32-bit version
33 1 GB = (1 << 30) bytes for 64-bit version
34 The default value is 16 MB = (1 << 24) bytes, for level = 5.
35 It's recommended to use the dictionary that is larger than 4 KB and
36 that can be calculated as (1 << N) or (3 << N) sizes.
37 For better compression ratio dictSize must be >= inSize.
40 SZ_FILTER_NO - no Filter
41 SZ_FILTER_YES - x86 Filter
42 SZ_FILTER_AUTO - it tries both alternatives to select best.
43 Encoder will use 2 or 3 passes:
44 2 passes when FILTER_NO provides better compression.
45 3 passes when FILTER_YES provides better compression.
47 Lzma86Encode allocates Data with MyAlloc functions.
48 RAM Requirements for compressing:
49 RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize
50 filterMode FilterBlockSize
58 SZ_ERROR_MEM - Memory allocation error
59 SZ_ERROR_PARAM - Incorrect paramater
60 SZ_ERROR_OUTPUT_EOF - output buffer overflow
61 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
71 SRes
Lzma86_Encode(Byte
*dest
, size_t *destLen
, const Byte
*src
, size_t srcLen
,
72 int level
, UInt32 dictSize
, int filterMode
);
79 srcLen - input data size
81 unpackSize - size of uncompressed stream
84 SZ_ERROR_INPUT_EOF - Error in headers
87 SRes
Lzma86_GetUnpackSize(const Byte
*src
, SizeT srcLen
, UInt64
*unpackSize
);
93 destLen - output data size
95 srcLen - input data size
97 destLen - processed output size
98 srcLen - processed input size
101 SZ_ERROR_DATA - Data error
102 SZ_ERROR_MEM - Memory allocation error
103 SZ_ERROR_UNSUPPORTED - unsupported file
104 SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
107 SRes
Lzma86_Decode(Byte
*dest
, SizeT
*destLen
, const Byte
*src
, SizeT
*srcLen
);