0% found this document useful (0 votes)
20 views

Data Representation - File Compression - 1

File compression reduces file sizes by removing unnecessary data, allowing files to take up less storage space and transmit faster. There are two main types of file compression: lossless compression reconstructs the original file while lossy compression results in some loss of detail. Common file compression applications include MP3 and MP4 for audio and video, JPEG and PNG for images, and RLE for a variety of file formats.

Uploaded by

gemmaepitong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Data Representation - File Compression - 1

File compression reduces file sizes by removing unnecessary data, allowing files to take up less storage space and transmit faster. There are two main types of file compression: lossless compression reconstructs the original file while lossy compression results in some loss of detail. Common file compression applications include MP3 and MP4 for audio and video, JPEG and PNG for images, and RLE for a variety of file formats.

Uploaded by

gemmaepitong
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

File Compression

• Reducing the file size of a file


✓ Save storage space
✓ Reduce the time taken to stream or transmit data

LO1: Define file compression.


Types of File Compression

• Lossless – all the data from the original file can be


reconstructed when the file is uncompressed again
(applicable to spreadsheet file)
• Lossy – file compression algorithm which eliminates
unnecessary data, usually results in some loss of
detail when compared to original; impossible to
reconstruct (ex. MP3, JPEG)

LO2: Differentiate lossy and lossless compression.


File Compression Applications (MP3)

• MP3 uses technology known as audio compression to convert


music and other sounds into an MP3 file format, which reduce
the size of a normal music file by 90%
• MP3 uses perceptual music shaping – removes certain sounds
which has frequencies that are outside the human hearing range,
if two sounds are played at the same time, only the louder one
can be heard by the ear, so softer sound is eliminated
• Bit rate – refers to the number of bits per second used when
creating sound file (between 80 to 320 kilobits per second), 200
kilobits or higher gives a sound quality close to a normal CD
3

LO2: Discuss the file compression applications.


File Compression Applications (MP4)

• MP4 file format allows the storage of multimedia


files rather than just sound.
• MP4 includes music, videos, photos and animation

LO2: Discuss the file compression applications.


File Compression Applications (Bitmap Images)

• Both the file size and quality of image are reduced.


Example is JPEG
• JPEG reduces the raw bit-map image by a factor of
between 5 to 15 depending on the quality of the
original
• Vector graphics can also undergo some form of file
compression like scalable vector graphics (.svg)

LO2: Discuss the file compression applications.


File Compression Applications (Run-Length Encoding -
RLE)
• Used to compress a number of different file formats
• A form of lossless compression that reduces the size of a string of
adjacent, identical data (such as repeated colours in an image)
• A repeated string is encoded into two values.
• First value represents the number of identical data items (such as
characters) while the second value represents the code of the data
item
a a a a a b b b b c c d d d d d
05 97 04 98 02 99 05 100

LO2: Discuss the file compression applications.


File Compression Applications (Run-Length Encoding -
RLE)
• One issue occurs with a string such as ‘cdcdcdcdcd’ where
compression is not very effective. To cope with this we use a flag.
• A flag preceding data indicates that what follows are the number of
repeating units (for example, 255 05 97 where 255 is the flag and
the other two numbers indicate that there are five items with ASCII
code 97).
• When the flag is not used, the next bytes are taken with their face
value and a run of 1 (fo example, 01 99 means one character with
ASCII code 99 follows).

LO2: Discuss the file compression applications.


File Compression Applications (Run-Length Encoding -
RLE)

String aaaaaaaaa bbbbbbbbbb c d c d c d eeeeeeee


Code 08 97 10 98 01 99 01 100 01 99 01 100 01 99 01 100 08 101

• The original string contains 32 characters and would occupy 32


bytes of storage. The coded version contains 18 values and would
require 18 bytes of storage.
• Introducing a flag (255 in this case) produces:

255 08 97 255 10 98 100 99 100 99 255 08 101


• Has 15 values and would require 15 bytes, which is reduction of
about 53%. 8

LO2: Discuss the file compression applications.


File Compression Applications (Run-Length Encoding –
RLE - Characters)

String aaaaaaaaa bbbbbbbbbb c d c d c d eeeeeeee


Code 08 97 10 98 01 99 01 100 01 99 01 100 01 99 01 100 08 101

• The original string contains 32 characters and would occupy 32


bytes of storage. The coded version contains 18 values and would
require 18 bytes of storage.
• Introducing a flag (255 in this case) produces:

255 08 97 255 10 98 100 99 100 99 255 08 101


• Has 15 values and would require 15 bytes, which is reduction of
about 53%. 9

LO2: Discuss the file compression applications.


10

LO2: Discuss the file compression applications.


11

LO2: Discuss the file compression applications.


12

LO2: Discuss the file compression applications.


13

LO2: Discuss the file compression applications.


3-2-1
3 things you learned
2 things you have a question about
1 thing you want the teacher to know
Act 1i
Do the activity 1i on page 25

Homework: Answer the end of chapter


questions on page 25-26 of your
coursebook. Due: 24-Sept-2023

You might also like