Compression

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Compression

Compression is the process of reducing the size of a data file whilst still retaining most or
even all, of the original information. You can compress most types of file, including
documents, music files, video and image files.

Data streaming services compress their files to reduce the amount of bandwidth needed to
transfer files. If they use uncompressed files, the service would be very slow.

Why do we compress files? The main reasons are:


1. Less storage space required for files
2. Faster downloads and uploads
3. Smaller file attachments for email
4. Coping with slow links when streaming

Compression ratio: Original data/Compressed data size

Compression ratio: Original bit rate/Compressed bit rate

Lossy compression: If file size is an issue, then it may be acceptable to discard some of the
original information. That way, less data needs to be stored. This is called ‘lossy
compression’. Lossy compression is irreversible. Once the data bytes and thrown away, they
cannot be recovered. Lossy compression always involves loss of quality. For example, if a
raw image was converted to a lossy jpeg file, that file should not be opened and re-
compressed again as the degradation becomes noticeable.

Lossy compression – Music: An uncompressed 3-minute CD-quality stereo music file would
need 31MB of storage. And yet a typical MP3 song is only about 3MB, ten times smaller.
This reduction in file size is possible due to lossy compression. The uncompressed music
recording includes data for frequencies that the human ear cannot hear. Those frequencies
can be safely discarded without the listener ever noticing their absence. Also, people cannot
hear a quiet sound the instant before or after a loud sound. So, the data for the quiet sound
can be discarded. This effect is called ‘masking’. MPEG level 3 (MP£) is a widely used lossy
algorithm for compressing music. It makes use of these effects and more. It can reduce CD
music from 1.4Mbit/s down to 128kbit/s with almost no degradation in audio quality – a
compression ratio of better than 10.

Lossy compression – Video: Uncompressed video files can be huge and so they can benefit
from lossy compression algorithms being applied. This also applies to video streams to
reduce the bit rate required. A very popular lossy algorithm is the H.264 standard, otherwise
known as MP4. An uncompressed video has 24 frames per second. Each frame is a complete
image made up of millions of pixels. This video data is compressed by using ‘key frame”
Keyframes allow for a very high amount of compression if the image is mostly unchanging
background with just as few pixels changing at a time. The compression is less effective if
almost every pixel changes frame-to-frame.
Lossless compression: Lossless compression reduces a file’s size and yet retains all of the
data. It is less effective at reducing file sizes than lossy compression, but it is reversible
unlike lossy compression.

Lossless compression is done by using patterns within the data which allows the algorithm
to encode the data more efficiently than the raw data. There are two widely used
algorithms, run length encoding and human encoding.

Examples of lossless compression:

 PNG (Image format)


 WAV and FLAC
 .ZIP

Lossy Compression Lossless Compression


Removes data to reduce file size No data loss
Achieves more compression than lossless Results in less compression than lossy
Results in reduced quality No loss of quality
Irreversible process, discarded data cannot Reversible process, the exact
be recovered uncompressed data can be recovered

You might also like