Answer the question
In order to leave comments, you need to log in
How to determine the parameters of lzma compression by displaying information after a call?
There is a simple code written in lua
ekau.lzma_compress("test", function(data) print("data->", #data, #util.Compress("test"), data == util.Compress("test")) end)...
data->27 22 false
int
simpleCompress(elzma_file_format format, const unsigned char * inData,
size_t inLen, unsigned char ** outData,
size_t * outLen)
{
int rc;
elzma_compress_handle hand;
/* allocate compression handle */
hand = elzma_compress_alloc();
assert(hand != NULL);
/* configure the compression run with mostly default parameters */
rc = elzma_compress_config(hand, ELZMA_LC_DEFAULT,
ELZMA_LP_DEFAULT, ELZMA_PB_DEFAULT,
5, (1 << 24) /* 1mb */,
format, inLen);
/* fail if we couldn't allocate */
if (rc != ELZMA_E_OK) {
elzma_compress_free(&hand);
return rc;
}
/* now run the compression */
{
/* set up the context structure that will be passed to
* stream callbacks */
struct dataStream ds;
ds.inData = inData;
ds.inLen = inLen;
ds.outData = NULL;
ds.outLen = 0;
/* run the streaming compression */
rc = elzma_compress_run(hand, inputCallback, (void *) &ds,
outputCallback, (void *) &ds, NULL, NULL);
if (rc != ELZMA_E_OK) {
if (ds.outData != NULL) free(ds.outData);
elzma_compress_free(&hand);
return rc;
}
*outData = ds.outData;
*outLen = ds.outLen;
}
return rc;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question