Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LZO Decompression Buffer Size

Tags:

c

compression

lzo

I am using MiniLZO on a project for some really simple compression tasks. I am compressing with one program, and decompressing with another. I'd like to know how much space to allocate for the decompression buffer. I am fine with over-allocating space, if it can save me the trouble of having to annotate my output file with an integer declaring how much space the decompressed data should take. How would I figure out how much space it could possibly take?

After some consideration, I think this question boils down to the following: What is the maximum compression ratio of lzo1x compression?

like image 801
Benson Avatar asked May 09 '26 03:05

Benson


1 Answers

Since you control both the compressor and the decompressor, I suggest you compress the input in fixed-sized blocks. In my application I compress up to 64KB in each block, then emit the size of the compressed block and the compressed data itself, so the compressed stream actually looks like a series of compressed blocks:

length_of_block_1
block_1
length_of_block_2
block_2
...

The decompressor just reads each compressed block and decompresses it into a 64KB buffer, since I know the block was produced by compressing a 64KB block.

Hope that helps,

Eric Melski

like image 81
Eric Melski Avatar answered May 10 '26 19:05

Eric Melski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!