| 1 | /* Lzma86Enc.h -- LZMA + x86 (BCJ) Filter Encoder |
| 2 | 2008-08-05 |
| 3 | Igor Pavlov |
| 4 | Public domain */ |
| 5 | |
| 6 | #ifndef __LZMA86ENC_H |
| 7 | #define __LZMA86ENC_H |
| 8 | |
| 9 | #include "Types.h" |
| 10 | |
| 11 | /* |
| 12 | It's an example for LZMA + x86 Filter use. |
| 13 | You can use .lzma86 extension, if you write that stream to file. |
| 14 | .lzma86 header adds one additional byte to standard .lzma header. |
| 15 | .lzma86 header (14 bytes): |
| 16 | Offset Size Description |
| 17 | 0 1 = 0 - no filter, |
| 18 | = 1 - x86 filter |
| 19 | 1 1 lc, lp and pb in encoded form |
| 20 | 2 4 dictSize (little endian) |
| 21 | 6 8 uncompressed size (little endian) |
| 22 | |
| 23 | |
| 24 | Lzma86_Encode |
| 25 | ------------- |
| 26 | level - compression level: 0 <= level <= 9, the default value for "level" is 5. |
| 27 | |
| 28 | |
| 29 | dictSize - The dictionary size in bytes. The maximum value is |
| 30 | 128 MB = (1 << 27) bytes for 32-bit version |
| 31 | 1 GB = (1 << 30) bytes for 64-bit version |
| 32 | The default value is 16 MB = (1 << 24) bytes, for level = 5. |
| 33 | It's recommended to use the dictionary that is larger than 4 KB and |
| 34 | that can be calculated as (1 << N) or (3 << N) sizes. |
| 35 | For better compression ratio dictSize must be >= inSize. |
| 36 | |
| 37 | filterMode: |
| 38 | SZ_FILTER_NO - no Filter |
| 39 | SZ_FILTER_YES - x86 Filter |
| 40 | SZ_FILTER_AUTO - it tries both alternatives to select best. |
| 41 | Encoder will use 2 or 3 passes: |
| 42 | 2 passes when FILTER_NO provides better compression. |
| 43 | 3 passes when FILTER_YES provides better compression. |
| 44 | |
| 45 | Lzma86Encode allocates Data with MyAlloc functions. |
| 46 | RAM Requirements for compressing: |
| 47 | RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize |
| 48 | filterMode FilterBlockSize |
| 49 | SZ_FILTER_NO 0 |
| 50 | SZ_FILTER_YES inSize |
| 51 | SZ_FILTER_AUTO inSize |
| 52 | |
| 53 | |
| 54 | Return code: |
| 55 | SZ_OK - OK |
| 56 | SZ_ERROR_MEM - Memory allocation error |
| 57 | SZ_ERROR_PARAM - Incorrect paramater |
| 58 | SZ_ERROR_OUTPUT_EOF - output buffer overflow |
| 59 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) |
| 60 | */ |
| 61 | |
| 62 | enum ESzFilterMode |
| 63 | { |
| 64 | SZ_FILTER_NO, |
| 65 | SZ_FILTER_YES, |
| 66 | SZ_FILTER_AUTO |
| 67 | }; |
| 68 | |
| 69 | SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, |
| 70 | int level, UInt32 dictSize, int filterMode); |
| 71 | |
| 72 | #endif |