Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 1 | /* LzmaEnc.h -- LZMA Encoder |
| 2 | 2009-02-07 : Igor Pavlov : Public domain */ |
| 3 | |
| 4 | #ifndef __LZMA_ENC_H |
| 5 | #define __LZMA_ENC_H |
| 6 | |
| 7 | #include "Types.h" |
| 8 | |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 9 | #define LZMA_PROPS_SIZE 5 |
| 10 | |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 11 | struct CLzmaEncProps |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 12 | { |
| 13 | int level; /* 0 <= level <= 9 */ |
Alexandru Gagniuc | 91e9f27 | 2014-01-26 22:55:01 -0600 | [diff] [blame] | 14 | uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 15 | (1 << 12) <= dictSize <= (1 << 30) for 64-bit version |
| 16 | default = (1 << 24) */ |
| 17 | int lc; /* 0 <= lc <= 8, default = 3 */ |
| 18 | int lp; /* 0 <= lp <= 4, default = 0 */ |
| 19 | int pb; /* 0 <= pb <= 4, default = 2 */ |
| 20 | int algo; /* 0 - fast, 1 - normal, default = 1 */ |
| 21 | int fb; /* 5 <= fb <= 273, default = 32 */ |
| 22 | int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ |
| 23 | int numHashBytes; /* 2, 3 or 4, default = 4 */ |
Alexandru Gagniuc | 91e9f27 | 2014-01-26 22:55:01 -0600 | [diff] [blame] | 24 | uint32_t mc; /* 1 <= mc <= (1 << 30), default = 32 */ |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 25 | unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ |
| 26 | int numThreads; /* 1 or 2, default = 2 */ |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 27 | }; |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 28 | |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 29 | void LzmaEncProps_Init(struct CLzmaEncProps *p); |
| 30 | void LzmaEncProps_Normalize(struct CLzmaEncProps *p); |
| 31 | uint32_t LzmaEncProps_GetDictSize(const struct CLzmaEncProps *props2); |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 32 | |
| 33 | |
| 34 | /* ---------- CLzmaEncHandle Interface ---------- */ |
| 35 | |
| 36 | /* LzmaEnc_* functions can return the following exit codes: |
| 37 | Returns: |
| 38 | SZ_OK - OK |
| 39 | SZ_ERROR_MEM - Memory allocation error |
| 40 | SZ_ERROR_PARAM - Incorrect paramater in props |
| 41 | SZ_ERROR_WRITE - Write callback error. |
| 42 | SZ_ERROR_PROGRESS - some break from progress callback |
| 43 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) |
| 44 | */ |
| 45 | |
| 46 | typedef void * CLzmaEncHandle; |
| 47 | |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 48 | CLzmaEncHandle LzmaEnc_Create(struct ISzAlloc *alloc); |
| 49 | void LzmaEnc_Destroy(CLzmaEncHandle p, struct ISzAlloc *alloc, struct ISzAlloc *allocBig); |
| 50 | SRes LzmaEnc_SetProps(CLzmaEncHandle p, const struct CLzmaEncProps *props); |
Alexandru Gagniuc | 91e9f27 | 2014-01-26 22:55:01 -0600 | [diff] [blame] | 51 | SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, uint8_t *properties, size_t *size); |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 52 | SRes LzmaEnc_Encode(CLzmaEncHandle p, struct ISeqOutStream *outStream, struct ISeqInStream *inStream, |
| 53 | struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig); |
Alexandru Gagniuc | 91e9f27 | 2014-01-26 22:55:01 -0600 | [diff] [blame] | 54 | SRes LzmaEnc_MemEncode(CLzmaEncHandle p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen, |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 55 | int writeEndMark, struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig); |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 56 | |
| 57 | /* ---------- One Call Interface ---------- */ |
| 58 | |
| 59 | /* LzmaEncode |
| 60 | Return code: |
| 61 | SZ_OK - OK |
| 62 | SZ_ERROR_MEM - Memory allocation error |
| 63 | SZ_ERROR_PARAM - Incorrect paramater |
| 64 | SZ_ERROR_OUTPUT_EOF - output buffer overflow |
| 65 | SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) |
| 66 | */ |
| 67 | |
Alexandru Gagniuc | 91e9f27 | 2014-01-26 22:55:01 -0600 | [diff] [blame] | 68 | SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen, |
Alexandru Gagniuc | 9ad52fe | 2014-01-27 20:57:54 -0600 | [diff] [blame] | 69 | const struct CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark, |
| 70 | struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig); |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 71 | |
Stefan Reinauer | 2e200cd | 2012-10-30 14:02:45 -0700 | [diff] [blame] | 72 | #endif |