054-Q: What are the compression algorithms?

Source: Internet
Author: User
ArticleDirectory
    • Introduction
    • Compression Algorithm Classification
    • Common compression algorithms/programs
    • Real-world examples
    • Lzma SDK and zlib Programming
    • Simple comparison between zlib and lzma
    • References

Http://www.cnblogs.com/jackdong/admin/EditPosts.aspx? Opt = 1

Memory Data Compression is used in recent projects (after the client compresses the data in the memory, it will be transmitted to the server, the server will be decompressed, deserialized, and stored in the database ).

Naturally, I think of zlib and lzma sdks.

Introduction

In computer science and information theory, data compression or source encoding is a process in which information is expressed by a specific encoding mechanism using a data bit element (or other information-related unit) that is less than the encoding.

Data Compression can be achieved because most real-world data has statistical redundancy.

Compression Algorithm Category

Http://zh.wikipedia.org/wiki/%E6%95%B0%E6%8D% AE %E5%8E%8B%E7%BC%A9

Lossy Compression

Http://zh.wikipedia.org/wiki/Category:%E6%9C%89%E6%8D%9F%E5%8E%8B%E7%BC%A9%E7% AE %97%E6%B3%95

Lossless Compression

Http://zh.wikipedia.org/wiki/Category:%E6%97%A0%E6%8D%9F%E5%8E%8B%E7%BC%A9%E7% AE %97%E6%B3%95

Common compression algorithms \ Program Rle

Http://zh.wikipedia.org/wiki/%E8%A1%8C%E7%A8%8B%E9%95%BF%E5%BA%A6%E7%BC%96%E7%A0%81

User ID

Http://zh.wikipedia.org/wiki/%E5%93%88%E5%A4% AB %E6%9B%BC%E7%BC%96%E7%A0%81

Zip

Http://zh.wikipedia.org/wiki/ZIP_ (% E7 % AE % 97% E6 % B3 % 95)

Lzma

Http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm

Deflate

Http://zh.wikipedia.org/zh-cn/DEFLATE

Real-world examples

Lzma SDK and zlib Programming

Both sdks provide some simple memory data compression methods.

Zlib

Zlib uses the deflate algorithm.

Http://zlib.net

The website is still being renewed.

Compile: nmake-F Win32 \ makefile. MSC

By default, the MD option is used for compiling. If you need Mt, modify the cflags In The makefile.

Simple Code

Lzma SDK

Lzma algorithm.

Http://www.7-zip.org/sdk.html

Use the C interface.

Simple code

Simple comparison between zlib and lzma

It can be seen that lzma compression is more time-consuming. The compressed data is smaller than zlib, but the decompression speed is as fast as zlib.

Download test project

Http://www.cppblog.com/Files/everett/compress_test.7z

References

Http://www.cppblog.com/windcsn/archive/2006/01/06/2476.aspx

Http://bbs.chinaunix.net/thread-149731-1-1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.