Compression ratios for different zlib compression levels

夙愿已清 提交于 2021-02-07 18:29:40

问题


I am considering what level of zlib compression to use, and I am curious about the different compression rates for the different compression levels that can be specified in zlib commands. The zlib manual has the following constants for specifying the compression level:

#define Z_NO_COMPRESSION         0
#define Z_BEST_SPEED             1
#define Z_BEST_COMPRESSION       9
#define Z_DEFAULT_COMPRESSION  (-1)

Clearly, a lower the number means lower latency for compression and deflation at the cost of a less-compressed file, while a higher number favors better compression at the cost of higher latency.

My question is, what compression ratios can be expected for the different compression levels? This zlib web page says, More typical zlib compression ratios are on the order of 2:1 to 5:1 in the context of maximum compression, but are there also compression ratios / ranges for the other compression factors as well?


回答1:


There is no answer for your question that is independent of the data. You can predict neither compression ratios, nor ratios of compression ratios just from the respective compression levels. The levels reflect how hard the compressor looks for matching strings in the previous 32K of data. That's all.



来源:https://stackoverflow.com/questions/40595352/compression-ratios-for-different-zlib-compression-levels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!