Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/dep/lzma/src/LzmaLib.c
4253 views
1
/* LzmaLib.c -- LZMA library wrapper
2
2023-04-02 : Igor Pavlov : Public domain */
3
4
#include "Precomp.h"
5
6
#include "Alloc.h"
7
#include "LzmaDec.h"
8
#include "LzmaEnc.h"
9
#include "LzmaLib.h"
10
11
Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,
12
unsigned char *outProps, size_t *outPropsSize,
13
int level, /* 0 <= level <= 9, default = 5 */
14
unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */
15
int lc, /* 0 <= lc <= 8, default = 3 */
16
int lp, /* 0 <= lp <= 4, default = 0 */
17
int pb, /* 0 <= pb <= 4, default = 2 */
18
int fb, /* 5 <= fb <= 273, default = 32 */
19
int numThreads /* 1 or 2, default = 2 */
20
)
21
{
22
CLzmaEncProps props;
23
LzmaEncProps_Init(&props);
24
props.level = level;
25
props.dictSize = dictSize;
26
props.lc = lc;
27
props.lp = lp;
28
props.pb = pb;
29
props.fb = fb;
30
props.numThreads = numThreads;
31
32
return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0,
33
NULL, &g_Alloc, &g_Alloc);
34
}
35
36
37
Z7_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen,
38
const unsigned char *props, size_t propsSize)
39
{
40
ELzmaStatus status;
41
return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc);
42
}
43
44