1.3 Data storage & compression
How computers represent text sounds and images
Data is measured in the following units:
- Bit
- Nibble
- byte (1 byte= 2 nibbles)
- Kibibyte
- Mebibyte
- Gibibyte
- Tebibyte
- Pebibyte
- Exbibyte
Calculating the size of an image file:
- resolution x colour depth (answer is in bits)
Calculating the size of a sound file:
- sample rate(Hz) x sample resolution x length (seconds)
Compression
What is compression?
- The reduction of FILE size
Why should we compress a file?
- Less bandwidth will be required
- Less storage will be required on the device
- Shorter transmission time (less time to download/upload)
Difference between Lossy and Lossless Compression
- Lossy compression is permanent, lossless can be recovered to its original form
- Lossy compression reduces the file size more than lossless compression
When to use Lossless or Lossy Compression?
Lossless
- Used when File quality is more important than file size
- Used when file needs to be recoverable to original form (eg. Text file or source code)
Lossy
- Used when file size is more important than quality
- Considerably smaller file size than lossless, quality may be adaquate
- used for streaming as transmission of smaller files is faster
Lossless compression of files
How is a text file compressed with lossless?
- Compression algorithm is used
- ..such as RLE(run length encoding)
- Repeating words/characters/phrases are identified
- …and indexed
- …With the number of occurances
- …With their position
How is a video file compressed with lossless?
- Compression algorithm is used
- ..such as RLE(run length encoding)
- Repeating frames/pixels are identified
- …and indexed
- it records the changes between frames/pixels
- No data is permanently removed
How is a sound file compressed with lossless?
- Compression algorithm is used
- ..such as RLE
- Repeating patterns in the music are identified (or repeated sounds/notes)
- ..and indexed
- List Item
- No data is permanently removed
How is an image file compressed with lossless?
- Compression algorithm is used
- ..such as RLE
- Repeating colours are identified
- ..and indexed
- ..with the number of occurrences
- No data is permanently removed
Lossy compression of files
Video file
- Compression algorithm is used
- Reduce colour depth
- Reduce image resolution
- Reduce frame rate
- Reduce frame rate
Image file
- Compression algorithm is used
- Reduce colour depth
- Reduce image resolution
- Data is permanently removed
Sound file
- Compression algorithm is used
- Reduce sampling rate
- Reduce sound resolution
- Data is permanently removed