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