1370b324cSopenharmony_ci/*  LzmaEnc.h -- LZMA Encoder
2370b324cSopenharmony_ci2023-04-13 : Igor Pavlov : Public domain */
3370b324cSopenharmony_ci
4370b324cSopenharmony_ci#ifndef ZIP7_INC_LZMA_ENC_H
5370b324cSopenharmony_ci#define ZIP7_INC_LZMA_ENC_H
6370b324cSopenharmony_ci
7370b324cSopenharmony_ci#include "7zTypes.h"
8370b324cSopenharmony_ci
9370b324cSopenharmony_ciEXTERN_C_BEGIN
10370b324cSopenharmony_ci
11370b324cSopenharmony_ci#define LZMA_PROPS_SIZE 5
12370b324cSopenharmony_ci
13370b324cSopenharmony_citypedef struct
14370b324cSopenharmony_ci{
15370b324cSopenharmony_ci  int level;       /* 0 <= level <= 9 */
16370b324cSopenharmony_ci  UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
17370b324cSopenharmony_ci                      (1 << 12) <= dictSize <= (3 << 29) for 64-bit version
18370b324cSopenharmony_ci                      default = (1 << 24) */
19370b324cSopenharmony_ci  int lc;          /* 0 <= lc <= 8, default = 3 */
20370b324cSopenharmony_ci  int lp;          /* 0 <= lp <= 4, default = 0 */
21370b324cSopenharmony_ci  int pb;          /* 0 <= pb <= 4, default = 2 */
22370b324cSopenharmony_ci  int algo;        /* 0 - fast, 1 - normal, default = 1 */
23370b324cSopenharmony_ci  int fb;          /* 5 <= fb <= 273, default = 32 */
24370b324cSopenharmony_ci  int btMode;      /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
25370b324cSopenharmony_ci  int numHashBytes; /* 2, 3 or 4, default = 4 */
26370b324cSopenharmony_ci  unsigned numHashOutBits;  /* default = ? */
27370b324cSopenharmony_ci  UInt32 mc;       /* 1 <= mc <= (1 << 30), default = 32 */
28370b324cSopenharmony_ci  unsigned writeEndMark;  /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
29370b324cSopenharmony_ci  int numThreads;  /* 1 or 2, default = 2 */
30370b324cSopenharmony_ci
31370b324cSopenharmony_ci  // int _pad;
32370b324cSopenharmony_ci
33370b324cSopenharmony_ci  UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
34370b324cSopenharmony_ci                        Encoder uses this value to reduce dictionary size */
35370b324cSopenharmony_ci
36370b324cSopenharmony_ci  UInt64 affinity;
37370b324cSopenharmony_ci} CLzmaEncProps;
38370b324cSopenharmony_ci
39370b324cSopenharmony_civoid LzmaEncProps_Init(CLzmaEncProps *p);
40370b324cSopenharmony_civoid LzmaEncProps_Normalize(CLzmaEncProps *p);
41370b324cSopenharmony_ciUInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
42370b324cSopenharmony_ci
43370b324cSopenharmony_ci
44370b324cSopenharmony_ci/* ---------- CLzmaEncHandle Interface ---------- */
45370b324cSopenharmony_ci
46370b324cSopenharmony_ci/* LzmaEnc* functions can return the following exit codes:
47370b324cSopenharmony_ciSRes:
48370b324cSopenharmony_ci  SZ_OK           - OK
49370b324cSopenharmony_ci  SZ_ERROR_MEM    - Memory allocation error
50370b324cSopenharmony_ci  SZ_ERROR_PARAM  - Incorrect paramater in props
51370b324cSopenharmony_ci  SZ_ERROR_WRITE  - ISeqOutStream write callback error
52370b324cSopenharmony_ci  SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
53370b324cSopenharmony_ci  SZ_ERROR_PROGRESS - some break from progress callback
54370b324cSopenharmony_ci  SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
55370b324cSopenharmony_ci*/
56370b324cSopenharmony_ci
57370b324cSopenharmony_citypedef struct CLzmaEnc CLzmaEnc;
58370b324cSopenharmony_citypedef CLzmaEnc * CLzmaEncHandle;
59370b324cSopenharmony_ci// Z7_DECLARE_HANDLE(CLzmaEncHandle)
60370b324cSopenharmony_ci
61370b324cSopenharmony_ciCLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
62370b324cSopenharmony_civoid LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
63370b324cSopenharmony_ci
64370b324cSopenharmony_ciSRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
65370b324cSopenharmony_civoid LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
66370b324cSopenharmony_ciSRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
67370b324cSopenharmony_ciunsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
68370b324cSopenharmony_ci
69370b324cSopenharmony_ciSRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream,
70370b324cSopenharmony_ci    ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
71370b324cSopenharmony_ciSRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
72370b324cSopenharmony_ci    int writeEndMark, ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
73370b324cSopenharmony_ci
74370b324cSopenharmony_ci
75370b324cSopenharmony_ci/* ---------- One Call Interface ---------- */
76370b324cSopenharmony_ci
77370b324cSopenharmony_ciSRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
78370b324cSopenharmony_ci    const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
79370b324cSopenharmony_ci    ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
80370b324cSopenharmony_ci
81370b324cSopenharmony_ciEXTERN_C_END
82370b324cSopenharmony_ci
83370b324cSopenharmony_ci#endif
84