1/* Lzma86.h -- LZMA + x86 (BCJ) Filter 22009-08-14 : Igor Pavlov : Public domain */ 3 4#ifndef __LZMA86_H 5#define __LZMA86_H 6 7#include "Types.h" 8 9EXTERN_C_BEGIN 10 11#define LZMA86_SIZE_OFFSET (1 + 5) 12#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8) 13 14/* 15It's an example for LZMA + x86 Filter use. 16You 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) 25 26 27Lzma86_Encode 28------------- 29level - compression level: 0 <= level <= 9, the default value for "level" is 5. 30 31dictSize - 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. 38 39filterMode: 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. 46 47Lzma86Encode allocates Data with MyAlloc functions. 48RAM Requirements for compressing: 49 RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize 50 filterMode FilterBlockSize 51 SZ_FILTER_NO 0 52 SZ_FILTER_YES inSize 53 SZ_FILTER_AUTO inSize 54 55 56Return code: 57 SZ_OK - OK 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) 62*/ 63 64enum ESzFilterMode 65{ 66 SZ_FILTER_NO, 67 SZ_FILTER_YES, 68 SZ_FILTER_AUTO 69}; 70 71SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, 72 int level, UInt32 dictSize, int filterMode); 73 74 75/* 76Lzma86_GetUnpackSize: 77 In: 78 src - input data 79 srcLen - input data size 80 Out: 81 unpackSize - size of uncompressed stream 82 Return code: 83 SZ_OK - OK 84 SZ_ERROR_INPUT_EOF - Error in headers 85*/ 86 87SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize); 88 89/* 90Lzma86_Decode: 91 In: 92 dest - output data 93 destLen - output data size 94 src - input data 95 srcLen - input data size 96 Out: 97 destLen - processed output size 98 srcLen - processed input size 99 Return code: 100 SZ_OK - OK 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 105*/ 106 107SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen); 108 109EXTERN_C_END 110 111#endif 112