zlib

zlib is a software library used for data compression. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program. zlib is also a crucial component of many software platforms including LinuxMac OS X, and iOS. It has also been used in gaming consoles such as the PlayStation 4PlayStation 3Wii UWiiXbox One and Xbox 360.

The first public version of zlib, 0.9, was released on 1 May 1995 and was originally intended for use with the libpng image library. It is free software, distributed under the zlib license.

Capabilities[edit]

Encapsulation[edit]

zlib compressed data are typically written with a gzip or a zlib wrapper. The wrapper encapsulates the raw DEFLATE data by adding a header and trailer. This provides stream identification and error detection that are not provided by the raw DEFLATE data.

The gzip header is larger than the zlib header, as it stores a file name and other file system information. This is the header format used in the ubiquitous gzip file format.

Algorithm[edit]

As of February 2010, zlib only supports one algorithm called DEFLATE, that is a variation of LZ77 (Lempel–Ziv 1977). This algorithm provides good compression on a wide variety of data with minimal use of system resources. This is also the algorithm used in theZIP archive format.

The header makes allowance for other algorithms, but none are currently implemented.

Resource use[edit]

zlib provides facilities for control of processor and memory use. A compression level value may be supplied that trades-off speed with compression. There are also facilities for conserving memory, useful in restricted memory environments such as some embedded systems.

Strategy[edit]

The compression can be optimized for specific types of data. If one is using the library to always compress specific types of data, then using a specific strategy may improve compression and performance. For example, if the data contain long lengths of repeated bytes, the RLE (run-length encoding) strategy may give good results at higher speed. For general data, the default strategy is preferred.

Error handling[edit]

Errors in compressed data may be detected and skipped. Further, if "full-flush" points are written to the compressed stream, then corrupt data can be skipped, and the decompression will resynchronize at the next flush point - although no error recovery of the corrupt data is provided. Full-flush points are useful for large data streams on unreliable channels, where some data loss is unimportant, such as in some multimedia applications. However, creating many flush points can affect the speed as well as amount (ratio) of compression.

Data length[edit]

There is no limit to the length of data that can be compressed or decompressed. Repeated calls to the library allow an unlimited numbers of blocks of data to be handled. Some ancillary code (counters) may suffer from overflow for long data streams, but this does not affect the actual compression or decompression.

When compressing a long (or infinite) data stream, it is advisable to write regular full-flush points.

Applications[edit]

Today, zlib is something of a de facto standard, to the point that zlib and DEFLATE are often used interchangeably in standards documents, with thousands of applications relying on it for compression, either directly or indirectly.[1] These include:

  • The Linux kernel, where zlib is used to implement compressed network protocols, compressed file systems, and to decompress the kernel image at boot time.
  • libpng, the reference implementation for the PNG image format, which specifies DEFLATE as the stream compression for its bitmap data.
  • libwww, an API for Web applications like Web browsers.
  • The Apache HTTP server, which uses zlib to implement HTTP/1.1.
  • The OpenSSH client and server, which rely on zlib to perform the optional compression offered by the Secure Shell protocol.
  • The OpenSSL and GnuTLS security libraries, which can optionally use zlib to compress TLS connections.
  • The FFmpeg multimedia library, which uses zlib to read and write the DEFLATE-compressed parts of stream formats such as Matroska.
  • The rsync remote file synchronizer, which uses zlib to implement optional protocol compression.
  • The dpkg and RPM package managers, which use zlib to unpack files from compressed software packages.
  • The Subversion and CVS version control systems, which use zlib to compress traffic to and from remote repositories.
  • The Git version control system uses zlib to store the contents of its data objects (blobs, trees, commits and tags).
  • The PostgreSQL RDBMS that uses zlib with custom dump format (pg_dump -Fc) for database backups.
  • The class System.IO.Compression.DeflateStream of the Microsoft .NET Framework 2.0 and higher.[2]
  • The "deflate" utility in TORNADO as part of VxWorks Operating System made by Wind River Systems uses zlib to compress boot ROM images.

zlib is also used in many embedded devices, such as the Apple iPhone and Sony PlayStation 3, because the code is portable, liberally licensed, and has a relatively small memory footprint.


From:https://en.wikipedia.org/wiki/Zlib

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值