summaryrefslogtreecommitdiffstats
path: root/depends/lzma/pavlov/LzmaEnc.h
blob: 961436e46a71f4f283b015ce0f6711757354d276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*  LzmaEnc.h -- LZMA Encoder
2008-10-04 : Igor Pavlov : Public domain */

#ifndef __LZMAENC_H
#define __LZMAENC_H

#include "Types.h"

#define LZMA_PROPS_SIZE 5

typedef struct _CLzmaEncProps
{
	int level;		 /*  0 <= level <= 9 */
	uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
						(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
						 default = (1 << 24) */
	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 */
	uint32_t mc;		   /* 1 <= mc <= (1 << 30), default = 32 */
	unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
	int numThreads;		/* 1 or 2, default = 2 */
} CLzmaEncProps;

void LzmaEncProps_Init(CLzmaEncProps *p);
void LzmaEncProps_Normalize(CLzmaEncProps *p);
uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);

/* ---------- CLzmaEncHandle Interface ---------- */

/* LzmaEnc_* functions can return the following exit codes:
Returns:
  SZ_OK           - OK
  SZ_ERROR_MEM    - Memory allocation error
  SZ_ERROR_PARAM  - Incorrect paramater in props
  SZ_ERROR_WRITE  - Write callback error.
  SZ_ERROR_PROGRESS - some break from progress callback
  SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
*/

typedef void *CLzmaEncHandle;

CLzmaEncHandle LzmaEnc_Create();
void LzmaEnc_Destroy(CLzmaEncHandle p);
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, uint8_t *properties, size_t *size);
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
					ICompressProgress *progress);
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, uint8_t *dest, size_t *destLen, const uint8_t *src,
					   size_t srcLen, int writeEndMark, ICompressProgress *progress);

/* ---------- One Call Interface ---------- */

/* LzmaEncode
Return code:
  SZ_OK               - OK
  SZ_ERROR_MEM        - Memory allocation error
  SZ_ERROR_PARAM      - Incorrect paramater
  SZ_ERROR_OUTPUT_EOF - output buffer overflow
  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
*/

SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
				const CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize,
				int writeEndMark, ICompressProgress *progress);

#endif