2013-10-08 15:07:03 +08:00
|
|
|
/* LzmaEnc.h -- LZMA Encoder
|
2022-08-29 14:23:38 +08:00
|
|
|
2019-10-30 : Igor Pavlov : Public domain */
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
#ifndef __LZMA_ENC_H
|
|
|
|
#define __LZMA_ENC_H
|
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
#include "7zTypes.h"
|
2013-10-08 15:07:03 +08:00
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
EXTERN_C_BEGIN
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
#define LZMA_PROPS_SIZE 5
|
|
|
|
|
|
|
|
typedef struct _CLzmaEncProps
|
|
|
|
{
|
2022-08-29 14:23:38 +08:00
|
|
|
int level; /* 0 <= level <= 9 */
|
2013-10-08 15:07:03 +08:00
|
|
|
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
2022-08-29 14:23:38 +08:00
|
|
|
(1 << 12) <= dictSize <= (3 << 29) for 64-bit version
|
|
|
|
default = (1 << 24) */
|
2013-10-08 15:07:03 +08:00
|
|
|
int lc; /* 0 <= lc <= 8, default = 3 */
|
|
|
|
int lp; /* 0 <= lp <= 4, default = 0 */
|
|
|
|
int pb; /* 0 <= pb <= 4, default = 2 */
|
|
|
|
int algo; /* 0 - fast, 1 - normal, default = 1 */
|
|
|
|
int fb; /* 5 <= fb <= 273, default = 32 */
|
|
|
|
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
|
|
|
|
int numHashBytes; /* 2, 3 or 4, default = 4 */
|
2022-08-29 14:23:38 +08:00
|
|
|
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
|
2013-10-08 15:07:03 +08:00
|
|
|
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
|
|
|
|
int numThreads; /* 1 or 2, default = 2 */
|
2022-08-29 14:23:38 +08:00
|
|
|
|
|
|
|
UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
|
|
|
|
Encoder uses this value to reduce dictionary size */
|
|
|
|
|
|
|
|
UInt64 affinity;
|
2013-10-08 15:07:03 +08:00
|
|
|
} CLzmaEncProps;
|
|
|
|
|
|
|
|
void LzmaEncProps_Init(CLzmaEncProps *p);
|
|
|
|
void LzmaEncProps_Normalize(CLzmaEncProps *p);
|
|
|
|
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------- CLzmaEncHandle Interface ---------- */
|
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
/* LzmaEnc* functions can return the following exit codes:
|
|
|
|
SRes:
|
2013-10-08 15:07:03 +08:00
|
|
|
SZ_OK - OK
|
|
|
|
SZ_ERROR_MEM - Memory allocation error
|
|
|
|
SZ_ERROR_PARAM - Incorrect paramater in props
|
2022-08-29 14:23:38 +08:00
|
|
|
SZ_ERROR_WRITE - ISeqOutStream write callback error
|
|
|
|
SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
|
2013-10-08 15:07:03 +08:00
|
|
|
SZ_ERROR_PROGRESS - some break from progress callback
|
2022-08-29 14:23:38 +08:00
|
|
|
SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
|
2013-10-08 15:07:03 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef void * CLzmaEncHandle;
|
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
|
|
|
|
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
|
|
|
|
2013-10-08 15:07:03 +08:00
|
|
|
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
2022-08-29 14:23:38 +08:00
|
|
|
void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
|
2013-10-08 15:07:03 +08:00
|
|
|
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
|
2022-08-29 14:23:38 +08:00
|
|
|
unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
|
|
|
|
|
2013-10-08 15:07:03 +08:00
|
|
|
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
2022-08-29 14:23:38 +08:00
|
|
|
ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
2013-10-08 15:07:03 +08:00
|
|
|
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
2022-08-29 14:23:38 +08:00
|
|
|
int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
/* ---------- One Call Interface ---------- */
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
|
|
|
|
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
|
2022-08-29 14:23:38 +08:00
|
|
|
ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
|
2013-10-08 15:07:03 +08:00
|
|
|
|
2022-08-29 14:23:38 +08:00
|
|
|
EXTERN_C_END
|
2013-10-08 15:07:03 +08:00
|
|
|
|
|
|
|
#endif
|