all repos — mgba @ 2dc710feeb0e36fc2179ec7c5f90b3d0430dd00c

mGBA Game Boy Advance Emulator

src/third-party/lzma/LzmaEnc.h (view raw)

 1/*  LzmaEnc.h -- LZMA Encoder
 22013-01-18 : Igor Pavlov : Public domain */
 3
 4#ifndef __LZMA_ENC_H
 5#define __LZMA_ENC_H
 6
 7#include "7zTypes.h"
 8
 9EXTERN_C_BEGIN
10
11#define LZMA_PROPS_SIZE 5
12
13typedef struct _CLzmaEncProps
14{
15  int level;       /*  0 <= level <= 9 */
16  UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
17                      (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
18                       default = (1 << 24) */
19  UInt64 reduceSize; /* estimated size of data that will be compressed. default = 0xFFFFFFFF.
20                        Encoder uses this value to reduce dictionary size */
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
33void LzmaEncProps_Init(CLzmaEncProps *p);
34void LzmaEncProps_Normalize(CLzmaEncProps *p);
35UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
36
37
38/* ---------- CLzmaEncHandle Interface ---------- */
39
40/* LzmaEnc_* functions can return the following exit codes:
41Returns:
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
50typedef void * CLzmaEncHandle;
51
52CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
53void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
54SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
55SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
56SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
57    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
58SRes 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
64Return 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
72SRes 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
76EXTERN_C_END
77
78#endif