2345联盟安装系统,2345系统安装,2345联盟推广,2345系统下载,2345一键安装,2345联盟官网,2345系统重装,2345联盟注册,2345系统ISO,2345联盟赚钱,2345系统纯净版,2345联盟代理,2345系统安装教程,2345联盟任务,2345系统GHOST,2345联盟提现,2345系统激活,2345联盟作弊,2345系统兼容,2345联盟软件,2345系统优化,2345联盟平台,2345系统64位,2345联盟合作,2345系统安装包,2345联盟返利,2345系统正版,2345联盟推广方法,2345系统U盘安装,2345联盟佣金,2345系统驱动,2345联盟规则,2345系统PE安装,2345联盟账号,2345系统备份,2345联盟体验,2345系统安全,2345联盟教程,2345系统定制,2345联盟审核,2345系统更新,2345联盟收益,2345系统版本,2345联盟玩法,2345系统装机,2345联盟策略,2345系统镜像,2345联盟工具,2345系统硬盘安装,2345联盟评价,2345系统使用,2345联盟常见问题,2345系统修复,2345联盟经验,2345系统启动盘,2345联盟优缺点,2345系统卸载,2345联盟数据,2345系统破解,2345联盟合规,2345系统封装,2345联盟技巧,2345系统设置,2345联盟骗局,2345系统还原,2345联盟真实性,2345系统速度,2345联盟心得,2345系统内存,2345联盟流程,2345系统错误,2345联盟风险,2345系统蓝屏,2345联盟免责,2345系统安装失败,2345联盟客服,2345系统帮助,2345联盟反馈,2345系统推荐,2345联盟口碑,2345系统评测,2345联盟对比,2345系统性能,2345联盟总结,2345系统最新版,2345联盟2026,2345系统安装步骤,2345联盟SEO,2345系统关键词,2345联盟排名,2345系统搜索,2345联盟引流,2345系统优化技巧,2345联盟流量,2345系统装机量,2345联盟转化率,2345系统用户评价,2345联盟成功率,2345系统安装时长,2345联盟收益截图,2345系统兼容性,2345联盟操作,2345系统自动安装,2345联盟心得分享,2345系统静默安装,2345联盟实战,2345系统无人值守,2345联盟经验分享,2345系统快速安装,2345联盟教程大全,2345系统安装问题,2345联盟解决方案 后台管理
📢 欢迎访问系统之家!所有资源均经过安全检测。

zlib Technical Details

发布时间:2026-11-07 | 浏览:1
📥 下载地址(文章开头)
电脑助手解决一切电脑问题。
Technical Details Maximum Expansion Factor zlib 's compression method, an LZ77 variant called deflation, emits compressed data as a sequence of blocks. Various block types are allowed, one of which is stored blocks—these are simply composed of the raw input data plus a few header bytes. In the worst possible case, where the other block types would expand the data, deflation falls back to stored (uncompressed) blocks. Thus for the default settings used by deflateInit() , compress() , and compress2() , the only expansion is an overhead of five bytes per 16 KB block (about 0.03%), plus a one-time overhead of six bytes for the entire stream. Even if the last or only block is smaller than 16 KB, the overhead is still five bytes. In the absolute worst case of a single-byte input stream, the overhead therefore amounts to 1100% (eleven bytes of overhead, one byte of actual data). For larger stream sizes, the overhead approaches the limiting value of 0.03%. deflateInit2() includes arguments for windowBits and memLevel that permit settings other than the defaults. These parameters can be used to adjust the memory required for the compressor as well as the decompressor for special applications, though usually with a reduction in compression. For various combinations of the allowed values for those parameters, the expansion can be larger than for the default settings. The worst case choice of parameters can result in an expansion of at most 13.5%, plus eleven bytes. The deflateBound() and compressBound() functions can be used to provide an upper limit on the expansion in order to permit the allocation of an output buffer assured to be large enough to hold the entire compressed output. deflateBound() takes into account any deflateInit2() options. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Maximum Expansion Factor zlib 's compression method, an LZ77 variant called deflation, emits compressed data as a sequence of blocks. Various block types are allowed, one of which is stored blocks—these are simply composed of the raw input data plus a few header bytes. In the worst possible case, where the other block types would expand the data, deflation falls back to stored (uncompressed) blocks. Thus for the default settings used by deflateInit() , compress() , and compress2() , the only expansion is an overhead of five bytes per 16 KB block (about 0.03%), plus a one-time overhead of six bytes for the entire stream. Even if the last or only block is smaller than 16 KB, the overhead is still five bytes. In the absolute worst case of a single-byte input stream, the overhead therefore amounts to 1100% (eleven bytes of overhead, one byte of actual data). For larger stream sizes, the overhead approaches the limiting value of 0.03%. deflateInit2() includes arguments for windowBits and memLevel that permit settings other than the defaults. These parameters can be used to adjust the memory required for the compressor as well as the decompressor for special applications, though usually with a reduction in compression. For various combinations of the allowed values for those parameters, the expansion can be larger than for the default settings. The worst case choice of parameters can result in an expansion of at most 13.5%, plus eleven bytes. The deflateBound() and compressBound() functions can be used to provide an upper limit on the expansion in order to permit the allocation of an output buffer assured to be large enough to hold the entire compressed output. deflateBound() takes into account any deflateInit2() options. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Maximum Expansion Factor zlib 's compression method, an LZ77 variant called deflation, emits compressed data as a sequence of blocks. Various block types are allowed, one of which is stored blocks—these are simply composed of the raw input data plus a few header bytes. In the worst possible case, where the other block types would expand the data, deflation falls back to stored (uncompressed) blocks. Thus for the default settings used by deflateInit() , compress() , and compress2() , the only expansion is an overhead of five bytes per 16 KB block (about 0.03%), plus a one-time overhead of six bytes for the entire stream. Even if the last or only block is smaller than 16 KB, the overhead is still five bytes. In the absolute worst case of a single-byte input stream, the overhead therefore amounts to 1100% (eleven bytes of overhead, one byte of actual data). For larger stream sizes, the overhead approaches the limiting value of 0.03%. deflateInit2() includes arguments for windowBits and memLevel that permit settings other than the defaults. These parameters can be used to adjust the memory required for the compressor as well as the decompressor for special applications, though usually with a reduction in compression. For various combinations of the allowed values for those parameters, the expansion can be larger than for the default settings. The worst case choice of parameters can result in an expansion of at most 13.5%, plus eleven bytes. The deflateBound() and compressBound() functions can be used to provide an upper limit on the expansion in order to permit the allocation of an output buffer assured to be large enough to hold the entire compressed output. deflateBound() takes into account any deflateInit2() options. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. deflateInit2() includes arguments for windowBits and memLevel that permit settings other than the defaults. These parameters can be used to adjust the memory required for the compressor as well as the decompressor for special applications, though usually with a reduction in compression. For various combinations of the allowed values for those parameters, the expansion can be larger than for the default settings. The worst case choice of parameters can result in an expansion of at most 13.5%, plus eleven bytes. The deflateBound() and compressBound() functions can be used to provide an upper limit on the expansion in order to permit the allocation of an output buffer assured to be large enough to hold the entire compressed output. deflateBound() takes into account any deflateInit2() options. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The deflateBound() and compressBound() functions can be used to provide an upper limit on the expansion in order to permit the allocation of an output buffer assured to be large enough to hold the entire compressed output. deflateBound() takes into account any deflateInit2() options. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Maximum Compression Factor Empirically, the deflate method is capable of compression factors exceeding 1000:1. (The test case was a 50MB file filled with zeros; it compressed to roughly 49 KB.) Mark loves to calculate stuff like this and reports that the theoretical limit for the zlib format (as opposed to its implementation in the currently available sources) is 1032:1. To quote him, The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The limit comes from the fact that one length/distance pair can represent at most 258 output bytes. A length requires at least one bit and a distance requires at least one bit, so two bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A dynamic block has no length restriction, so you could get arbitrarily close to the limit of 1032:1. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. He goes on to note that the current implementation limits its dynamic blocks to about 8 KB (corresponding to 8MB of input data); together with a few bits of overhead, this implies an actual compression limit of about 1030.3:1. Not only that, but the compressed data stream is itself likely to be rather compressible (in this special case only), so running it through deflate again should produce further gains. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. By way of comparison, note that a version of run-length encoding optimized for this sort of unusual data file—that is, by using 32-bit integers for the lengths rather than the more usual 8-bit bytes or 16-bit words—could encode the test file in five bytes. That would be a compression factor of 10,000,000:1 (or 10.000.000:1 for you Europeans, or 10 7 :1 for all of you engineers and scientists whose browsers support superscripts). Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Finally, please note that this level of compression is extremely rare and only occurs with really trivial files (e.g., a megabyte of zeros). More typical zlib compression ratios are on the order of 2:1 to 5:1. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Compression Factor Design Quirk A design choice in the zlib implementation (as opposed to the zlib and deflate specifications) limits match distances to 2 windowBits - 262 rather than the 2 windowBits that one might naively expect. This limitation mainly affects applications that try to optimize decoder memory usage by reducing the window size for small files; in some cases, compression might be degraded because an otherwise valid match (according to the spec) near the theoretical distance limit won't be found by zlib. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. One workaround would be to set the window size to the next larger power of two for encoding (but no more than the maximum size of 32 KB, obviously) and then modify the CINFO field in the zlib header after the stream is compressed. Such an approach is not recommended, however, and should be attempted only by experts. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green.
📥 下载地址(文章中间)
电脑助手解决一切电脑问题。
Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Memory Footprint zlib 's memory footprint can also be specified fairly precisely. It is larger for compression than for decompression, and the exact requirements depend on how the library was compiled. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The memory requirements for compression depend on two parameters, windowBits and memLevel : deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. deflate memory usage (bytes) = (1 << (windowBits+2)) + (1 << (memLevel+9)) + 6 KB For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. For the default values of 15 and 8, respectively, this is 268 KB, where the approximately 6 KB is for the deflate data structure. Both windowBits and memLevel can be set to lower values at compile time via the MAX_WBITS and MAX_MEM_LEVEL macros, but only at a cost in compression efficiency. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The memory requirements for decompression depend only on windowBits , but this is, in a sense, a harsher limitation: whereas data streams compressed with a smaller window will merely be a bit larger than they would have otherwise, a reduced window size for decompression means that streams compressed with larger windows cannot be decompressed at all . Having said that: inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. inflate memory usage (bytes) = (1 << windowBits) + 7 KB Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Typically, therefore, inflate() requires no more than 40 KB of storage on a 64-bit machine. This includes the 32768-byte sliding window and approximately 7 KB for the inflate data structure. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Adler-32 versus CRC-32 Both Adler-32 and CRC-32 ( cyclic redundancy check ) are 32-bit checks. But while the CRC can take on any 32-bit value (2 32 possibilities), Adler-32 is limited to 65521 2 possibilities. So the probability of a false positive on random errors for CRC-32 is 2.3283 x 10 -10 , whereas it is very slightly higher for Adler-32 at 2.3294 x 10 -10 . The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The above assumes that all the values are accessible given the amount of data. That is true after only four bytes for the CRC-32, but Adler-32 requires, on the average, about 0.5 KB of data to get rolling—or 1 KB if it's ASCII data (text). So if the Adler-32 is used on significantly less than about a kilobyte, it will be noticeably weaker than a CRC-32 on the same small block. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. A properly constructed CRC- n has the nice property that a burst of n bits or less of errors is always detectable. This is not always true for Adler-32—it can detect all one- or two-byte errors but can miss some three-byte errors. However, Adler-32 has been constructed to minimize the ways to make small changes in the data that result in the same check value, through the use of sums significantly larger than the bytes and by using a prime (65521) for the modulus. (Though see the paper linked below.) This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. This last potential weakness is not a major concern in the application of Adler-32 to zlib (or any other history-based compressor), since if there is an error at some point in a stream, it will be massively propagated after that. It would be of concern in an application with transmission or storage that has a borderline signal-to-noise ratio, for which small numbers of random errors are expected. For that sort of application one would certainly want to use a CRC or, better yet, Reed-Solomon or other error-correction coding. Even in this case, if the data being transmitted or stored uses some sort of history-dependent compression (as in zlib ) and was compressible to begin with , then an Adler-32 used after decompression would be adequate since the decompressor would significantly amplify any small errors in the compressed stream. (For incompressible data, most modern compressors operate in a pass-through mode, so the original comment about using a CRC or ECC holds.) The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. The main reason for Adler-32 is, of course, speed in software implementations. The authors wanted a check on zlib's decompression, without incurring a significant speed penalty just for the check. Jean-loup would not agree to Mark's appeal to include a CRC check on the decompressed data, due to the added execution time. So Mark came up with the Adler-32 as a faster but still effective alternative to a CRC-32 on decompressed data. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. An alternative to Adler-32 is Fletcher-32, which replaces the modulo of 65521 with 65535. This paper shows that Fletcher-32 is superior for channels with low-rate random bit errors. However as noted above, you should be using a CRC or error-correcting codes on such channels. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Click here for an informal explanation of the deflate algorithm . Click here to return to the zlib Home Page . Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green. Last modified 8 Jan 2022 Web page copyright © 1996-2022 Greg Roelofs, Jean-loup Gailly and Mark Adler . zlib software copyright © 1995-2022 Jean-loup Gailly and Mark Adler . zlib.org domain name donated by Andrew Green.
📥 下载地址(文章结尾)
电脑助手解决一切电脑问题。