LZO解压缓冲区大小

发布于 2024-07-18 16:55:22 字数 216 浏览 11 评论 0原文

我在一个项目中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的痛♀有谁懂 2024-07-25 16:55:22

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

length_of_block_1
block_1
length_of_block_2
block_2
...

解压缩器只是读取每个压缩块并将其解压缩为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:

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

白昼 2024-07-25 16:55:22

解压缩数据的最大大小显然与您首先压缩的数据的最大大小相同。

如果您的输入大小有上限,那么我想您可以使用它,但我不得不说,这样做的常用方法是向压缩缓冲区添加一个标头,该标头指定未压缩的大小。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文