Download Memory & Storage: Lesson 9 Compression and more Slides Computer science in PDF only on Docsity! Memory & Storage: Lesson 9 Compression Starter • HD TV has a resolution of 1920px x 1080px • This results in 2.1 megapixels per frame • Each pixel uses 24-bit colour • This means each frame needs about 50 megabits • There are 25 frames per second resulting in a total amount of data being 1.25 gigabits per second How can we possibly stream this through internet connections that are typically under 70 Mb/s in the UK? Memory & Storage: Lesson 9 Compression Compression techniques • Compression is the name given to algorithms which reduce file sizes • Decompression is the process where compressed data is restored to its original format • Compression is heavily used with sound, image and video files • There are two types of compression: • Lossy compression (JPG, GIF, MP3) • Lossless compression (PNG, TIFF) Memory & Storage: Lesson 9 Compression Compression Ratio • The level of compression is measured by its compression ratio. • The compression ratio is: The size of the compressed file divided by the size of the original. • The ratio will be a number between 0 and 1; the closer the ratio is to 0, the tighter the compression. Memory & Storage: Lesson 9 Compression Compression techniques • Reduce file size • Mostly used with sound, image and video file types • Two types: • Lossy compression (JPG, GIF, MP3) • Lossless compression (PNG, TIF, SVG) Memory & Storage: Lesson 9 Compression Lossy Compression • The file is compressed to a smaller size but some information is lost during the process. • The original file cannot be perfectly reconstructed. When would this sort of compression be useful? Memory & Storage: Lesson 9 Compression How lossy compression works Similarly coloured pixels are all made the same Memory & Storage: Lesson 9 Compression Lossy compression: Artefacts • Lossy compression results in small mistakes known as ‘digital artefacts’ appearing in images and video • Noise can often be seen where there are contrasting colours • Blocks can often result from lossy compression Memory & Storage: Lesson 9 Compression Using Lossy Compression Images • Using lossy compression will result in a lower quality image, however you can still make out the subject of the image. More compression=Lower Quality Sound & Video • MP3 files use lossy compression to remove frequencies too high for most people to hear. • Lossy also removes quieter sounds that are played at the same time as loud sounds. Voice • Voice is transmitted using lossy compression. You can still understand and hear the voice, however you notice a difference in quality. Memory & Storage: Lesson 9 Compression Dictionary Compression 1 2 3 4 2 5 6 7 3 6 7 0 0001 0010 0011 0100 0010 0101 0110 0111 0011 0110 0111 0000 An eye for an eye , a tooth for a tooth . Memory & Storage: Lesson 9 Compression Calculating Compression Reduction Original File size- compressed file size = answer Answer/original file size = % in reduction Original file= 120 bytes, compressed to 73 bytes 120 bytes - 73 = 47 47/120= 0.39 = 39% reduction in size Memory & Storage: Lesson 9 Compression Lossy or Lossless…? • A website image • A zipped file of text files and images • A PDF instruction manual • The latest Radiohead album Memory & Storage: Lesson 9 Compression Task 1: Compression Navigation: � Student G-Suite � Computer Studies � GCSE Computer Science � Unit 1: Computer Systems � 1.2: Memory & Storage � Lesson 9: Compression � Worksheet 1 1. Complete Task 1 on the worksheet 2. Complete page 84 in the CGP: Practice Exam Questions book • Use Page 75 in the CGP: Revision Guide book to help you Memory & Storage: Lesson 9 Compression 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? Memory & Storage: Lesson 9 Compression Video streaming • The files for video streaming are compressed • The TV or computer needs to decompress the data as it is playing the video • Before the video begins playing, it will buffer a sufficient amount to allow for the network occasionally being slow • If the website or server detects that the connection is slow, it may be able to start sending an alternative lower quality file Memory & Storage: Lesson 9 Compression Common file standards File format Type of compression File usage JPEG Lossy Photos PNG Lossless Images/photos, may include transparency ZIP Lossless Document compression GIF Lossless Simple images, may include animation MP4 Lossy Video file format MP3 Lossy Music format FLAC / ALAC Lossless Lossless Music format (Free / Apple) Memory & Storage: Lesson 9 Compression Task 2: Compression Uses Navigation: � Student G-Suite � Computer Studies � GCSE Computer Science � Unit 1: Computer Systems � 1.2: Memory & Storage � Lesson 9: Compression � Worksheet 1 Complete Task 2 – Compression uses Memory & Storage: Lesson 9 Compression Plenary • With a partner, take it in turns to explain the following: • The need for compression • Lossy compression • Some of the effects of lossy compression on images and sound files • Lossless compression