LZW在低记忆条件下的压缩/解压缩 [英] LZW compression/decompression under low memory conditions

查看:216
本文介绍了LZW在低记忆条件下的压缩/解压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以给指针如何在低内存条件(<2k)下实现lzw压缩/解压缩。是可能的吗?

Can anybody give pointers how I can implement lzw compression/decompression in low memory conditions (< 2k). is that possible?

推荐答案

每个人使用的zlib库都淹没了其他问题我很确定它不会为你的情况工作。我有一个更多的记忆可能是16K和couldnt得到它适合。

The zlib library that everyone uses is bloated among other problems (for embedded). I am pretty sure it wont work for your case. I had a little more memory maybe 16K and couldnt get it to fit. It allocates and zeros large chunks of memory and keeps copies of stuff, etc. The algorithm can maybe do it but finding existing code is the challenge.

我用

我处理重复数据,挤压几个K下来几百,我认为压缩约50%,不是很大,但做了工作和解压缩例程很小。上面的lzfx包很小,不像zlib,像两个主要的函数,有代码在那里,没有几十个文件。你可能改变缓冲区的深度,或许改进压缩算法,如果你愿意的话。我确实有必要修改解压缩代码(像20或30行代码可能)它是指针重和我切换到数组,因为在我的嵌入式环境中的指针是在错误的地方。烧写可能是一个额外的寄存器或不取决于你如何实现它和你的编译器。我也这样做,所以我可以抽象的提取和字节的存储,因为我把它们包装到内存的无字节可寻址。

I was dealing with repetitive data and trying to squeeze a few K down into a few hundred, I think the compression was about 50%, not great but did the job and the decompression routine was tiny. The lzfx package above is small, not like zlib, like two main functions that have the code right there, not dozens of files. You could likely change the depth of the buffer, perhaps improve the compression algorithm if you so desire. I did have to modify the decompression code (like 20 or 30 lines of code perhaps) it was pointer heavy and I switched it to arrays because in my embedded environment the pointers were in the wrong place. Burns maybe an extra register or not depending on how you implement it and your compiler. I also did that so I could abstract the fetches and the stores of the bytes as I had them packed into memory that wasnt byte addressable.

如果你找到更好的东西,请post它在这里或ping我通过stackoverflow,我也很感兴趣其他嵌入式解决方案。我搜索了很多,上面是唯一有用的一个,我发现,我很幸运,我的数据是这样压缩得足够好使用算法...现在。

If you find something better please post it here or ping me through stackoverflow, I am also very interested in other embedded solutions. I searched quite a bit and the above was the only useful one I found and I was lucky that my data was such that it compressed well enough using that algorithm...for now.

这篇关于LZW在低记忆条件下的压缩/解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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