blob: 8f5d8efd6535844b3181456c29d570ac53014de1 [file] [log] [blame]
bashi@chromium.orgc2a93752012-05-02 00:18:22 +00001/* LzmaEnc.h -- LZMA Encoder
agl@chromium.org92ae1612012-06-26 19:58:38 +000022009-02-07 : Igor Pavlov : Public domain
3in the public domain */
bashi@chromium.orgc2a93752012-05-02 00:18:22 +00004
5#ifndef __LZMA_ENC_H
6#define __LZMA_ENC_H
7
8#include "Types.h"
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#define LZMA_PROPS_SIZE 5
15
16typedef struct _CLzmaEncProps
17{
18 int level; /* 0 <= level <= 9 */
19 UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
20 (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
21 default = (1 << 24) */
22 int lc; /* 0 <= lc <= 8, default = 3 */
23 int lp; /* 0 <= lp <= 4, default = 0 */
24 int pb; /* 0 <= pb <= 4, default = 2 */
25 int algo; /* 0 - fast, 1 - normal, default = 1 */
26 int fb; /* 5 <= fb <= 273, default = 32 */
27 int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
28 int numHashBytes; /* 2, 3 or 4, default = 4 */
29 UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
30 unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
31 int numThreads; /* 1 or 2, default = 2 */
32} CLzmaEncProps;
33
34void LzmaEncProps_Init(CLzmaEncProps *p);
35void LzmaEncProps_Normalize(CLzmaEncProps *p);
36UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
37
38
39/* ---------- CLzmaEncHandle Interface ---------- */
40
41/* LzmaEnc_* functions can return the following exit codes:
42Returns:
43 SZ_OK - OK
44 SZ_ERROR_MEM - Memory allocation error
45 SZ_ERROR_PARAM - Incorrect paramater in props
46 SZ_ERROR_WRITE - Write callback error.
47 SZ_ERROR_PROGRESS - some break from progress callback
48 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
49*/
50
51typedef void * CLzmaEncHandle;
52
53CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
54void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
55SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
56SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
57SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
58 ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
59SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
60 int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
61
62/* ---------- One Call Interface ---------- */
63
64/* LzmaEncode
65Return code:
66 SZ_OK - OK
67 SZ_ERROR_MEM - Memory allocation error
68 SZ_ERROR_PARAM - Incorrect paramater
69 SZ_ERROR_OUTPUT_EOF - output buffer overflow
70 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
71*/
72
73SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
74 const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
75 ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif