Compression Data representation Compression Why do we need

  • Slides: 16
Download presentation
Compression Data representation Compression • Why do we need it? • What does it

Compression Data representation Compression • Why do we need it? • What does it do?

Compression Data representation Compression • Is used to reduce the storage space that is

Compression Data representation Compression • Is used to reduce the storage space that is required to store a file. • Disk space in modern computers is much cheaper and higher capacity so the need for compression has reduced. • Now used for sending files over the internet. • The reduced file size helps to reduce the amount of buffering that is required whilst retaining the original quality.

Compression Data representation Compression techniques • Reduce file size • Mostly used with sound,

Compression Data representation Compression techniques • Reduce file size • Mostly used with sound, image and video file types • Two types: • Lossy compression (JPG, GIF, MP 3, MP 4) • Lossless compression (PNG, TIF, SVG, FLAC, WAV)

Compression Data representation Lossy compression • Permanently removes some data • Recreates the file

Compression Data representation Lossy compression • Permanently removes some data • Recreates the file using the remaining data and uses algorithms to guess the removed content • Uncompressed data is not the same as the original • Would this technique work for compressing a computer program?

Compression Data representation How lossy compression works • Similarly coloured pixels are all made

Compression Data representation How lossy compression works • Similarly coloured pixels are all made the same

Compression Data representation Run Length Encoding • Lossless compression • counts the bits that

Compression Data representation Run Length Encoding • Lossless compression • counts the bits that are repeated consecutively. • rather than storing each pixel individually, the file would instead store the pixel colour and the number of times it is repeated. 2 Repeat count 3 Colour 4 2 1 3 2 1

Compression Data representation Run Length Encoding Disadvantage • If a file does not contain

Compression Data representation Run Length Encoding Disadvantage • If a file does not contain many repetitions then this method of compression can actually increase file size • A single pixel would be stored as its colour and then the information that it is repeated only once. 2 2 1 1

Compression Data representation Lossless text compression • Finds patterns in the original text •

Compression Data representation Lossless text compression • Finds patterns in the original text • Encodes each pattern in a dictionary An eye for an eye, a tooth for a tooth. An_ eye _for_ an_ , _ a_ tooth 0 1 2 3 4 5 6 7 0000 0001 0010 0011 0100 0101 0110 0111

Compression Data representation Lossless text compression • 38 Characters including spaces = 38 bytes

Compression Data representation Lossless text compression • 38 Characters including spaces = 38 bytes (assuming an 8 -bit ASCII table is used) • 48 bits = 12 bytes = 32% of original size (plus codes). An_ eye _for_ an_ , _ a_ tooth 0 1 2 3 4 5 6 7 0000 0001 0010 0011 0100 0101 0110 0111 1 2 3 4 2 5 6 7 3 6 7 0 0001 0010 0011 0100 0010 0101 0110 0111 0011 0110 0111 0000

Compression Data representation Transmission of data over IP • Why use compression? • Download

Compression Data representation Transmission of data over IP • Why use compression? • Download speeds are increased • Data allowances are reduced • Voice can be transmitted fast enough to keep up with speech

Compression Data representation Downloading a music track • Dancing Queen by ABBA = 3

Compression Data representation Downloading a music track • Dancing Queen by ABBA = 3 m 51 sec = 231 seconds • MP 3 quality = 128 kbps • 231 x 128 kbps = 29, 568 kbs / 1024 / 8 = 3. 6 MB • CD quality = 1411 kbps • 231 x 1411 kbps = 325, 941 kbs / 1024 / 8 = 39. 79 MB • 11. 5 times faster with a compressed file Improvement in bandwidth of >36 MB

Compression Data representation Benefits of compression • Smaller files = fewer packets = faster

Compression Data representation Benefits of compression • Smaller files = fewer packets = faster transmission • Quicker to complete • Reduces traffic over the Internet • Less chance of collisions or transmission errors • Improves download speed of video, sound (including speech used for VOIP systems) and image files • Speeds up download of webpages that use images • Reduces space on disk / servers • Enables better streaming of music and video

Compression Data representation Buffering • Video or music streaming causes buffering if the download

Compression Data representation Buffering • Video or music streaming causes buffering if the download speed is slower than the playback speed • How could you reduce the chances of people experiencing buffering if you were the website owner?

Compression Data representation Common file standards • PDF – Fixed layout document that maintains

Compression Data representation Common file standards • PDF – Fixed layout document that maintains its original appearance regardless of the software used to view it • JPG – Lossy compressed files commonly used for website images • GIF – Lossy compressed images using only 256 colours, used for simple web graphics • PNG – Lossless compressed format using an alpha channel to preserve transparent backgrounds • MP 3 / MP 4 – Lossy music / video formats • ZIP - Lossless A ZIP file may contain one or more files or directories that may have been compressed

Compression Data representation Worksheet • Download this presentation and worksheet from: https: //ict 4

Compression Data representation Worksheet • Download this presentation and worksheet from: https: //ict 4 u. net/Computer. Science/compression. php • Complete as many of the tasks on the worksheet as you can

Compression Data representation Video • https: //www. youtube. com/watch? v=Ot. Dx. Dv. Cp. PL

Compression Data representation Video • https: //www. youtube. com/watch? v=Ot. Dx. Dv. Cp. PL 4 • Huffman coding explanation is from 2: 59 6: 00