LZO解压缓冲区大小
我在一个项目中使用 MiniLZO 来执行一些非常简单的压缩任务。 我用一个程序压缩,用另一个程序解压。 我想知道为解压缓冲区分配多少空间。 我对过度分配空间很满意,如果它可以省去我必须用整数注释输出文件来声明解压缩数据应占用多少空间的麻烦。 我如何计算出它可能占用多少空间?
经过一番思考,我认为这个问题归结为:lzo1x压缩的最大压缩比是多少?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您同时控制压缩器和解压缩器,因此我建议您将输入压缩为固定大小的块。 在我的应用程序中,我在每个块中压缩最多 64KB,然后发出压缩块的大小和压缩数据本身,因此压缩流实际上看起来像一系列压缩块:
解压缩器只是读取每个压缩块并将其解压缩为64KB 缓冲区,因为我知道该块是通过压缩 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:
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
解压缩数据的最大大小显然与您首先压缩的数据的最大大小相同。
如果您的输入大小有上限,那么我想您可以使用它,但我不得不说,这样做的常用方法是向压缩缓冲区添加一个标头,该标头指定未压缩的大小。
The max size of the decompressed data is clearly the same as the max size of the data you compressed in the first place.
If there is an upper bound on your input size then I guess you can use it, but I have to say the usual way of doing this is to add a header to your compressed buffer which specifies the uncompressed size.