| 1 | /* Lzma86.h -- LZMA + x86 (BCJ) Filter\r |
| 2 | 2013-01-18 : Igor Pavlov : Public domain */\r |
| 3 | \r |
| 4 | #ifndef __LZMA86_H\r |
| 5 | #define __LZMA86_H\r |
| 6 | \r |
| 7 | #include "7zTypes.h"\r |
| 8 | \r |
| 9 | EXTERN_C_BEGIN\r |
| 10 | \r |
| 11 | #define LZMA86_SIZE_OFFSET (1 + 5)\r |
| 12 | #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)\r |
| 13 | \r |
| 14 | /*\r |
| 15 | It's an example for LZMA + x86 Filter use.\r |
| 16 | You can use .lzma86 extension, if you write that stream to file.\r |
| 17 | .lzma86 header adds one additional byte to standard .lzma header.\r |
| 18 | .lzma86 header (14 bytes):\r |
| 19 | Offset Size Description\r |
| 20 | 0 1 = 0 - no filter, pure LZMA\r |
| 21 | = 1 - x86 filter + LZMA\r |
| 22 | 1 1 lc, lp and pb in encoded form\r |
| 23 | 2 4 dictSize (little endian)\r |
| 24 | 6 8 uncompressed size (little endian)\r |
| 25 | \r |
| 26 | \r |
| 27 | Lzma86_Encode\r |
| 28 | -------------\r |
| 29 | level - compression level: 0 <= level <= 9, the default value for "level" is 5.\r |
| 30 | \r |
| 31 | dictSize - The dictionary size in bytes. The maximum value is\r |
| 32 | 128 MB = (1 << 27) bytes for 32-bit version\r |
| 33 | 1 GB = (1 << 30) bytes for 64-bit version\r |
| 34 | The default value is 16 MB = (1 << 24) bytes, for level = 5.\r |
| 35 | It's recommended to use the dictionary that is larger than 4 KB and\r |
| 36 | that can be calculated as (1 << N) or (3 << N) sizes.\r |
| 37 | For better compression ratio dictSize must be >= inSize.\r |
| 38 | \r |
| 39 | filterMode:\r |
| 40 | SZ_FILTER_NO - no Filter\r |
| 41 | SZ_FILTER_YES - x86 Filter\r |
| 42 | SZ_FILTER_AUTO - it tries both alternatives to select best.\r |
| 43 | Encoder will use 2 or 3 passes:\r |
| 44 | 2 passes when FILTER_NO provides better compression.\r |
| 45 | 3 passes when FILTER_YES provides better compression.\r |
| 46 | \r |
| 47 | Lzma86Encode allocates Data with MyAlloc functions.\r |
| 48 | RAM Requirements for compressing:\r |
| 49 | RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize\r |
| 50 | filterMode FilterBlockSize\r |
| 51 | SZ_FILTER_NO 0\r |
| 52 | SZ_FILTER_YES inSize\r |
| 53 | SZ_FILTER_AUTO inSize\r |
| 54 | \r |
| 55 | \r |
| 56 | Return code:\r |
| 57 | SZ_OK - OK\r |
| 58 | SZ_ERROR_MEM - Memory allocation error\r |
| 59 | SZ_ERROR_PARAM - Incorrect paramater\r |
| 60 | SZ_ERROR_OUTPUT_EOF - output buffer overflow\r |
| 61 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)\r |
| 62 | */\r |
| 63 | \r |
| 64 | enum ESzFilterMode\r |
| 65 | {\r |
| 66 | SZ_FILTER_NO,\r |
| 67 | SZ_FILTER_YES,\r |
| 68 | SZ_FILTER_AUTO\r |
| 69 | };\r |
| 70 | \r |
| 71 | SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,\r |
| 72 | int level, UInt32 dictSize, int filterMode);\r |
| 73 | \r |
| 74 | \r |
| 75 | /*\r |
| 76 | Lzma86_GetUnpackSize:\r |
| 77 | In:\r |
| 78 | src - input data\r |
| 79 | srcLen - input data size\r |
| 80 | Out:\r |
| 81 | unpackSize - size of uncompressed stream\r |
| 82 | Return code:\r |
| 83 | SZ_OK - OK\r |
| 84 | SZ_ERROR_INPUT_EOF - Error in headers\r |
| 85 | */\r |
| 86 | \r |
| 87 | SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);\r |
| 88 | \r |
| 89 | /*\r |
| 90 | Lzma86_Decode:\r |
| 91 | In:\r |
| 92 | dest - output data\r |
| 93 | destLen - output data size\r |
| 94 | src - input data\r |
| 95 | srcLen - input data size\r |
| 96 | Out:\r |
| 97 | destLen - processed output size\r |
| 98 | srcLen - processed input size\r |
| 99 | Return code:\r |
| 100 | SZ_OK - OK\r |
| 101 | SZ_ERROR_DATA - Data error\r |
| 102 | SZ_ERROR_MEM - Memory allocation error\r |
| 103 | SZ_ERROR_UNSUPPORTED - unsupported file\r |
| 104 | SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer\r |
| 105 | */\r |
| 106 | \r |
| 107 | SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);\r |
| 108 | \r |
| 109 | EXTERN_C_END\r |
| 110 | \r |
| 111 | #endif\r |