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