xref: /titanic_51/usr/src/common/lzma/LzmaEnc.h (revision a31148363f598def767ac48c5d82e1572e44b935)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*  LzmaEnc.h -- LZMA Encoder
7 2008-10-04 : Igor Pavlov : Public domain */
8 
9 #ifndef __LZMAENC_H
10 #define __LZMAENC_H
11 
12 #include "Types.h"
13 
14 #define LZMA_PROPS_SIZE 5
15 
16 typedef 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 
34 extern void LzmaEncProps_Init(CLzmaEncProps *p);
35 void LzmaEncProps_Normalize(CLzmaEncProps *p);
36 UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
37 
38 
39 /* ---------- CLzmaEncHandle Interface ---------- */
40 
41 /* LzmaEnc_* functions can return the following exit codes:
42 Returns:
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 
51 typedef void * CLzmaEncHandle;
52 
53 CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
54 void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
55 SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
56 SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
57 SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
58     ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
59 SRes 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
65 Return 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 
73 extern SRes 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 #endif
78