| 1 |
/* LzmaEnc.h -- LZMA Encoder |
| 2 |
2008-10-04 : Igor Pavlov : Public domain */ |
| 3 |
// ---------------------------------------------------------------------------- |
| 4 |
// Copyright (C) 2014 |
| 5 |
// David Freese, W1HKJ |
| 6 |
// |
| 7 |
// This file is part of flmsg |
| 8 |
// |
| 9 |
// flrig is free software; you can redistribute it and/or modify |
| 10 |
// it under the terms of the GNU General Public License as published by |
| 11 |
// the Free Software Foundation; either version 3 of the License, or |
| 12 |
// (at your option) any later version. |
| 13 |
// |
| 14 |
// flrig is distributed in the hope that it will be useful, |
| 15 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
// GNU General Public License for more details. |
| 18 |
// |
| 19 |
// You should have received a copy of the GNU General Public License |
| 20 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 |
// ---------------------------------------------------------------------------- |
| 22 |
|
| 23 |
#ifndef __LZMAENC_H |
| 24 |
#define __LZMAENC_H |
| 25 |
|
| 26 |
#include "Types.h" |
| 27 |
|
| 28 |
#define LZMA_PROPS_SIZE 5 |
| 29 |
|
| 30 |
typedef struct _CLzmaEncProps |
| 31 |
{ |
| 32 |
int level; /* 0 <= level <= 9 */ |
| 33 |
LZ_UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version |
| 34 |
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version |
| 35 |
default = (1 << 24) */ |
| 36 |
int lc; /* 0 <= lc <= 8, default = 3 */ |
| 37 |
int lp; /* 0 <= lp <= 4, default = 0 */ |
| 38 |
int pb; /* 0 <= pb <= 4, default = 2 */ |
| 39 |
int algo; /* 0 - fast, 1 - normal, default = 1 */ |
| 40 |
int fb; /* 5 <= fb <= 273, default = 32 */ |
| 41 |
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ |
| 42 |
int numHashBytes; /* 2, 3 or 4, default = 4 */ |
| 43 |
LZ_UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ |
| 44 |
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ |
| 45 |
int numThreads; /* 1 or 2, default = 2 */ |
| 46 |
} CLzmaEncProps; |
| 47 |
|
| 48 |
void LzmaEncProps_Init(CLzmaEncProps *p); |
| 49 |
void LzmaEncProps_Normalize(CLzmaEncProps *p); |
| 50 |
LZ_UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); |
| 51 |
|
| 52 |
|
| 53 |
/* ---------- CLzmaEncHandle Interface ---------- */ |
| 54 |
|
| 55 |
/* LzmaEnc_* functions can return the following exit codes: |
| 56 |
Returns: |
| 57 |
SZ_OK - OK |
| 58 |
SZ_ERROR_MEM - Memory allocation error |
| 59 |
SZ_ERROR_PARAM - Incorrect paramater in props |
| 60 |
SZ_ERROR_WRITE - Write callback error. |
| 61 |
SZ_ERROR_PROGRESS - some break from progress callback |
| 62 |
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) |
| 63 |
*/ |
| 64 |
|
| 65 |
typedef void * CLzmaEncHandle; |
| 66 |
|
| 67 |
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); |
| 68 |
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); |
| 69 |
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); |
| 70 |
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); |
| 71 |
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, |
| 72 |
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); |
| 73 |
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, |
| 74 |
int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); |
| 75 |
|
| 76 |
/* ---------- One Call Interface ---------- */ |
| 77 |
|
| 78 |
/* LzmaEncode |
| 79 |
Return code: |
| 80 |
SZ_OK - OK |
| 81 |
SZ_ERROR_MEM - Memory allocation error |
| 82 |
SZ_ERROR_PARAM - Incorrect paramater |
| 83 |
SZ_ERROR_OUTPUT_EOF - output buffer overflow |
| 84 |
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) |
| 85 |
*/ |
| 86 |
|
| 87 |
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, |
| 88 |
const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, |
| 89 |
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); |
| 90 |
|
| 91 |
#endif |