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