goat3d

diff libs/openctm/liblzma/LzmaLib.c @ 14:188c697b3b49

- added a document describing the goat3d file format chunk hierarchy - started an alternative XML-based file format - added the openctm library
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Sep 2013 04:47:05 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/openctm/liblzma/LzmaLib.c	Thu Sep 26 04:47:05 2013 +0300
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* LzmaLib.c -- LZMA library wrapper
     1.5 +2008-08-05
     1.6 +Igor Pavlov
     1.7 +Public domain */
     1.8 +
     1.9 +#include "LzmaEnc.h"
    1.10 +#include "LzmaDec.h"
    1.11 +#include "Alloc.h"
    1.12 +#include "LzmaLib.h"
    1.13 +
    1.14 +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
    1.15 +static void SzFree(void *p, void *address) { p = p; MyFree(address); }
    1.16 +static ISzAlloc g_Alloc = { SzAlloc, SzFree };
    1.17 +
    1.18 +MY_STDAPI LzmaCompress(unsigned char *dest, size_t  *destLen, const unsigned char *src, size_t  srcLen,
    1.19 +  unsigned char *outProps, size_t *outPropsSize,
    1.20 +  int level, /* 0 <= level <= 9, default = 5 */
    1.21 +  unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */
    1.22 +  int lc, /* 0 <= lc <= 8, default = 3  */
    1.23 +  int lp, /* 0 <= lp <= 4, default = 0  */
    1.24 +  int pb, /* 0 <= pb <= 4, default = 2  */
    1.25 +  int fb,  /* 5 <= fb <= 273, default = 32 */
    1.26 +  int numThreads, /* 1 or 2, default = 2 */
    1.27 +  int algo /* 0 = fast, 1 = normal */
    1.28 +)
    1.29 +{
    1.30 +  CLzmaEncProps props;
    1.31 +  LzmaEncProps_Init(&props);
    1.32 +  props.level = level;
    1.33 +  props.dictSize = dictSize;
    1.34 +  props.lc = lc;
    1.35 +  props.lp = lp;
    1.36 +  props.pb = pb;
    1.37 +  props.fb = fb;
    1.38 +  props.numThreads = numThreads;
    1.39 +  props.algo = algo;
    1.40 +
    1.41 +  return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0,
    1.42 +      NULL, &g_Alloc, &g_Alloc);
    1.43 +}
    1.44 +
    1.45 +
    1.46 +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t  *destLen, const unsigned char *src, size_t  *srcLen,
    1.47 +  const unsigned char *props, size_t propsSize)
    1.48 +{
    1.49 +  ELzmaStatus status;
    1.50 +  return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc);
    1.51 +}