Decompression error - How to understand?

560 views
Skip to first unread message

shinba...@gmail.com

unread,
Apr 15, 2017, 2:37:25 PM4/15/17
to LZ4c
Hey guys, I am learning about LZ4 and Ive used the compression function with success already, but the decompression function inst just working.
Ive double checked the compressed and uncompressed sizes while compressing and stored before calling the LZ4_decompress_safe but,
Its returning the error: '-10' which I dont have idea what means. 
So, how do we understand these errors?

This is how my code is working right now. (I have tried LZ4_decompress_fast but the debugger breaks when calling LZ4_decompress_generic

//how arguments are arrenged
std::vector<unsigned char> outBuf;
outBuf.resize(65536);
char* dest = reinterpret_cast<char*>(outBuf.data());
char* srcBuf = reinterpret_cast<char*>(compressedData[x].data());
int rv = uncompressData(srcBuf, dest, compressedData[x].size(), outBuf.size());

int uncompressData(const char* inBuf, char* outBuf, int compressedSize, int UNCOMPRESSED_SIZE)
{
        //
UNCOMPRESSED_SIZE = 65536;
        int rv = LZ4_decompress_safe(inBuf, outBuf, compressedSize, UNCOMPRESSED_SIZE);
       
if (rv < 1)
               
print("Couldn't run LZ4_decompress_safe()... error code received is in exit code. " + std::to_string(rv));
       
       
return rv;
}

Please, help XD

Cyan

unread,
Apr 16, 2017, 5:48:37 AM4/16/17
to LZ4c
There is nothing in your sample that make it easy to spot a mistake.

-10 means the decoding failed, and relatively early (after byte 10).

My first idea would be to check if inBuf really contains the expected compressed data.
The sample seems to say so, but a second check wouldn't hurt.
Message has been deleted

shinba...@gmail.com

unread,
Apr 16, 2017, 12:11:29 PM4/16/17
to LZ4c
Thanks for the reply Cyan. Ive tested te uncompress function right after compressing the data and it worked, but, then, I am using Physfs to write the buffer that contains the compressed data (as std::vector<unsigned char>). When I open the file and read it to a string, still using Physfs, the output seems different than what was writting. I am considering somewhere between writing and reading the data from the file created is getting corrupted.. Should I use only buffers as char to do the whole procedure?

Cyan

unread,
Apr 16, 2017, 11:14:54 PM4/16/17
to LZ4c
Yes

shinba...@gmail.com

unread,
Apr 18, 2017, 6:08:13 PM4/18/17
to LZ4c
Thank you Cyan, Its working now. You've been of great help! 
Reply all
Reply to author
Forward
0 new messages