LZO减压缓冲区大小 [英] LZO Decompression Buffer Size

查看:122
本文介绍了LZO减压缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目上使用MiniLZO来执行一些非常简单的压缩任务。我正在用一个程序压缩,而用另一个程序解压缩。我想知道为减压缓冲区分配多少空间。我可以使用过度分配的空间,如果这样可以省去麻烦的话,那就是必须用一个整数来注释输出文件,该整数声明解压缩的数据应该占用多少空间。我将如何计算可能需要多少空间?

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?

经过一番考虑,我认为这个问题可以归结为以下内容:最大压缩量是多少? lzo1x压缩的比率?

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

推荐答案

由于您同时控制了压缩器和解压缩器,因此建议您压缩输入在固定大小的块中。在我的应用程序中,我在每个块中最多压缩64KB,然后发出压缩块的大小和压缩数据本身,因此压缩流实际上看起来像一系列压缩块:

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
...

解压缩器仅读取每个压缩块并将其解压缩到64KB缓冲区中,因为我知道该块是通过压缩64KB块产生的。

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.

希望有帮助,

埃里克·梅尔斯基

这篇关于LZO减压缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆