ByteSizeNotes Chapter 1.3
Chapter 1.3

Data Storage & Compression

Data is measured in the following units

  • Bit
  • Nibble
  • Byte (1 byte = 2 nibbles)
  • Kibibyte
  • Mebibyte
  • Gibibyte
  • Tebibyte
  • Pebibyte
  • Exbibyte

Calculating File Sizes

  • Calculating the size of an image file: resolution × colour depth (answer is in bits)
  • Calculating the size of a sound file: sample rate (Hz) × sample resolution × length (seconds)

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)
  • To make it small enough to attach to an email

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?

  • 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)
  • They want to be able to edit the original sound file
  • They want the highest sound quality for the file // They want the sound to be closest to the original recording using lossy would reduce the sound quality using lossy will permanently remove some of the data // no data will be permanently removed with lossless
  • Used when file size is more important than quality
  • Considerably smaller file size than lossless, quality may be adequate
  • Used for streaming as transmission of smaller files is faster

**Explain why lossy compression is not suitable for compressing a text

file**

  • Data will be permanently removed and that could be important/necessary data
  • Lossy is not suitable for text files as it will damage/corrupt the file

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 occurrences 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
  • 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

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