]> git.cworth.org Git - vogl/blob - src/voglcore/lzma_LzmaEnc.h
Initial vogl checkin
[vogl] / src / voglcore / lzma_LzmaEnc.h
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  *
25  **************************************************************************/
26
27 /*  LzmaEnc.h -- LZMA Encoder
28 2008-10-04 : Igor Pavlov : Public domain */
29
30 #ifndef __LZMAENC_H
31 #define __LZMAENC_H
32
33 #include "lzma_Types.h"
34
35 namespace vogl
36 {
37
38 #define LZMA_PROPS_SIZE 5
39
40     typedef struct _CLzmaEncProps
41     {
42         int level;             /*  0 <= level <= 9 */
43         UInt32 dictSize;       /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
44                       (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
45                        default = (1 << 24) */
46         int lc;                /* 0 <= lc <= 8, default = 3 */
47         int lp;                /* 0 <= lp <= 4, default = 0 */
48         int pb;                /* 0 <= pb <= 4, default = 2 */
49         int algo;              /* 0 - fast, 1 - normal, default = 1 */
50         int fb;                /* 5 <= fb <= 273, default = 32 */
51         int btMode;            /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
52         int numHashBytes;      /* 2, 3 or 4, default = 4 */
53         UInt32 mc;             /* 1 <= mc <= (1 << 30), default = 32 */
54         unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
55         int numThreads;        /* 1 or 2, default = 2 */
56     } CLzmaEncProps;
57
58     void LzmaEncProps_Init(CLzmaEncProps *p);
59     void LzmaEncProps_Normalize(CLzmaEncProps *p);
60     UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
61
62     /* ---------- CLzmaEncHandle Interface ---------- */
63
64     /* LzmaEnc_* functions can return the following exit codes:
65 Returns:
66   SZ_OK           - OK
67   SZ_ERROR_MEM    - Memory allocation error
68   SZ_ERROR_PARAM  - Incorrect paramater in props
69   SZ_ERROR_WRITE  - Write callback error.
70   SZ_ERROR_PROGRESS - some break from progress callback
71   SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
72 */
73
74     typedef void *CLzmaEncHandle;
75
76     CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
77     void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
78     SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
79     SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
80     SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
81                         ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
82     SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
83                            int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
84
85     /* ---------- One Call Interface ---------- */
86
87     /* LzmaEncode
88 Return code:
89   SZ_OK               - OK
90   SZ_ERROR_MEM        - Memory allocation error
91   SZ_ERROR_PARAM      - Incorrect paramater
92   SZ_ERROR_OUTPUT_EOF - output buffer overflow
93   SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
94 */
95
96     SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
97                     const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
98                     ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
99 }
100
101 #endif