Computer Science 4 5 6 - III
Computer Science 4 5 6 - III
&
Data Storage
Deepanjal Shrestha
Nanjing University of Aeronautics and Astronautics
Page 1
Memory and data storage
• There are many file formats used to store
data, be this text, images or sound, in
computer systems.
• All computer systems have primary
memory and secondary memory storage.
• The main technologies used are magnetic,
optical and solid state
Page 2
File formats
• A number of different file formats are used
in computer systems.
– Musical Instrument Digital Interface (MIDI)
– MP3
– MP4
– jpeg
– text and number format.
Page 3
Musical Instrument Digital Interface
Page 4
Musical Instrument Digital Interface
• Each MIDI command has a specific
sequence of bytes.
• The first byte is the status byte – this
informs the MIDI device what function to
perform.
• Encoded in the status byte is the MIDI
channel.
• MIDI operates on 16 different channels,
which are numbered 0 to 15.
Page 5
Examples of MIDI commands
• These are
– note on/off: this indicates that a key (on an
electronic keyboard) has been
– pressed/released to produce/stop producing a
musical note
– key pressure: this indicates how hard the key
has been pressed (this could indicate
– loudness of the music note or whether any
vibrato has been used, and so on).
Page 6
MIDI
• Two additional bytes are required, a
PITCH BYTE, which tells the MIDI device
which note to play,
• VELOCITY BYTE, which tells the device
how loud to play the note.
• Both the electronic instruments and the
computer need a MIDI interface to allow
them to ‘talk’ to each other.
Page 7
MIDI
• MIDI operates on 16 channels.
• In fact the computer can send data out on
all 16 MIDI channels at the same time.
• For example, 16 MIDI devices, each set
up for a different MIDI channel, could be
connected to the computer
• MIDI files don’t contain any audio tracks,
their size, compared with an MP3 file, is
considerably smaller.
Page 8
Video of MIDI
Page 9
MPEG-3 (MP3)
• MPEG-3 (MP3) uses technology known as
AUDIO COMPRESSION to convert music
and other sounds into an MP3 file format.
• Essentially, this compression technology
will reduce the size of a normal music file
by about 90 per cent.
• For example, an 80 megabyte music CD
can be reduced to 8 megabytes using
MP3 technology
Page 10
MPEG-3 (MP3)
• Using file compression algorithms 90 per cent of
the file size can be compressed.
• This is done which use PERCEPTUAL MUSIC
SHAPING removing sounds that the human ear
can’t hear properly
• MP3 files use what is known as a LOSSY
FORMAT
• The quality of MP3 files can be different since it
depends on the BIT RATE.
• The higher the BIT rate the better the quality, i.e
more than 200 or higher gives sound close to CD
Page 11
MPEG-4 (MP4)
Page 12
Activity
• A CD is being used to store music. Each
minute’s worth of recording takes up 12
megabytes.
• The CD contains nine tracks which are the
following length (in minutes): 3, 5, 6, 4, 5,
2, 7, 8, 8. How much memory would these
nine tracks occupy on the CD?
Page 13
Activity
• If the CD was downloaded to a computer
and then all the tracks were put through an
MP3 compression algorithm, how much
memory would the nine tracks now occupy
(you may assume a 90 per cent file
reduction size)?
• Find the average size of each of the MP3
tracks, and then estimate how many MP3
files could be stored on an 800 megabyte
CD.
Page 14
Joint Photographic Experts Group
Page 15
Joint Photographic Experts Group
• One of the file formats used to reduce
photographic file sizes is known as JPEG.
• This is another example of lossy file
compression.
• Jpeg will reduce the RAW BITMAP image
by a factor of between 5 and 15 depending
on the quality of the original.
Page 16
JPEG
• An image that is 2048 pixels wide and
1536 pixels high is equal to 2048 × 1536
pixels; in other words, 3 145 728 pixels.
• This is often referred to as a 3-megapixel
image (although it is obviously slightly
larger).
• The file size of this image is determined by
the number of pixels.
Page 17
JPEG
• In the previous example, a 3-megapixel image
would be 3 megapixels × 3 colours.
• In other words, 9 megabytes (each pixel occupies
3 bytes because it is made up of the three main
colours: red, green and blue).
• TIFF and BMP are the highest image quality
because, unlike jpeg, they are not in a
compressed format.
• The same image stored in jpeg format would
probably occupy between 0.6 megabytes and 1.8
megabytes.
Page 18
Resolution and Megapixel
Page 19
Calculation of Bytes
Page 20
Activity
• An image is 1200 pixels by 1600
pixels. Calculate:
– the total number of pixels in the original
image
– the number of bytes occupied by this file
taking 3 bytes for 3 color
– the file size of the jpeg image (in
kilobytes) if the original image was
reduced by a factor of 8.
Page 21
Answer to Activity
– the total number of pixels in the original
image ( 1200 x 1600 = 1920000 pixels)
– the number of bytes occupied by this file
2 megapixel x 3 byte = 6 Megabyte
6 MB = 6 x 1024 x 1024 bytes
– the file size of the jpeg image (in
kilobytes) if the original image was
reduced by a factor of 8
6 x 1024 / 8 = 768 Kilobytes
Page 22
Activity
• A second image is 3072 pixels by 2304
pixels. Calculate:
– the total number of pixels in the original image
– the number of bytes occupied by this file (X)
– the file size of the jpeg image (in megabytes)
if the original image was reduced by a factor
of 5.
– How many uncompressed files of the size
calculated in part (X) could be stored on a 4-
Gigabyte memory card?
Page 23
Answers
• The total number of pixels in the original
image 3072 x 2304 pixels
– =7077888 pixels
• The number of bytes occupied by this file
– 7 Megapixel x 3 colour byte = 21 MB
– 21 x 1024 x 1024 = 22020096 bytes
• The file size of the jpeg image (in megabytes)
if the original image was reduced by a factor
of 5.
• 21/5 = 4.2 MB
Page 24
Answers
• How many uncompressed files of the size
calculated in part (X) could be stored on a
4-Gigabyte memory card?
– File size = 21 MB
= 21/1024 = 0.0205 GB
– For 4 GB memory card
4 / 0.0205 = 195.12 uncompressed files
Page 25
Activity
• Calculate pixels for
– 2048 x 2048
– 1,920 x 1536
• Calcuate the size for both in taking color
depth as 8 bit
– Bytes
– Kilobyte
– Megabyte
Page 26
Text and number file formats
• Text and numbers can be stored in a
number of formats. Text is usually stored in
an ASCII format
• When using spreadsheets or databases,
numbers can be stored different formats:
– real, e.g. 2.71678
– integer, e.g. 3
– date, e.g. 12/08/2016
– time, e.g. 19:45:50
– currency, e.g. R$ 15.50
Page 27
LOSSLESS FILE COMPRESSION
Page 28
LOSSY FILE COMPRESSION
• Lossy file compression is very different to
lossless file compression.
• With this technique, the file compression
algorithm eliminates unnecessary bits of data
as seen in MP3 and jpeg formats.
• It is impossible to get the original file back
once it is compressed.
• This is why it is chosen for files where
removing certain bits doesn’t detract from the
quality.
Page 29
Memory
Page 30
ROM Application
• ROM
– stores the factory settings such as remote
control frequencies
– stores the ‘start-up’ routines when the toy car
is first switched on
– stores the set routines; for example, how the
buttons on the hand-held device
– control turning left, acceleration, stopping, and
so on.
Page 31
RAM Application
• RAM
– the user may wish to program in their own
routines; these new instructions
– would be stored in the RAM chip
– the RAM chip will store the data/instructions
received from the remote control
Page 32
Activity
• Describe how ROM and RAM chips could
be used in the following devices:
– a microwave oven
– a refrigerator
– a remote-controlled model aeroplane; the
movement of the aeroplane is controlled by a
hand-held device.
Page 33
Solid-state Drives (SSD)
• Latency is an issue in HDDs as described
earlier.
• SOLID-STATE DRIVES (SSD) remove
this issue considerably.
• They have no moving parts and all data is
retrieved at the same rate.
• They don’t rely on magnetic properties
Page 34
Solid-state Drives (SSD)
• The most common type of solid-state
storage devices store data by controlling
the movement of electrons within NAND
chips.
• The data is stored as 0s and 1s in millions
of tiny transistors within the chip.
• This effectively produces a non-volatile
rewritable memory.
Page 35
Solid-state Drives (SSD)
• Solid-state storage devices sometimes use
ELECTRONICALLY ERASABLE
PROGRAMMABLE READ-ONLY MEMORY
(EEPROM) technology.
• The main difference is the use of NOR
chips rather than NAND.
• This makes them faster in operation but
devices using EEPROM are considerably
more expensive than those that use NAND
technology.
Page 36
Benefits of using SSD rather than HDD
Page 37
Benefits of using SSD rather than HDD
Page 38
CDS and DVDS
• Are described as OPTICAL STORAGE
DEVICES.
– Laser light is used to read data and to write
data in the surface of the disk.
– Both CDs and DVDs use a thin layer of metal
alloy or light-sensitive organic dye to store the
data.
– The data is stored in ‘pits’ and ‘bumps’ on the
spiral track.
– A red laser is used to read and write the data.
Page 39
DVDS
• DVD technology is slightly different to that
used in CDs.
• One of the main differences is the use of
DUAL-LAYERING which considerably
increases the storage capacity.
• Basically, this means that there are two
individual recording layers.
Page 40
DVDS
• Two layers of a standard DVD are joined
together with a transparent
(polycarbonate) spacer, and a very thin
reflector is also sandwiched between the
two layers.
• Reading and writing of the second layer is
done by a red laser focusing at a fraction
of a millimetre difference compared to the
first layer.
Page 41
DVDS
Page 42
The future of optical media
• In recent times both the CD and DVD are showing
signs of becoming obsolete
• Many people now store all their music in the following
ways:
– • on hard disk drive systems
– • in MP3 format on:
– • a computer/tablet
– • their mobile phone
– • a portable music player (such as iPod®)
– • using the ‘cloud’
– • by ‘streaming’
Page 43
How to estimate the size of a file
• Estimating the size of a text file is relatively
straightforward.
• Each character from the keyboard has a value
of 1 byte.
• Suppose we typed in the following message:
• This is text from the computer science text
book
• If we count the number of characters in the
text typed in, we get the number 48.
Page 44
Size of a file
Page 45
Calculating Size of Photo
Page 46
Size of Photo
Page 47
Size of File
• The photograph was 424 by 256 pixels
which confirms the file size of 325 632
bytes (318 kilobytes).
Page 48
Activity
• Estimate the size of a file for each of the
following:
– Text file containing 256 characters.
– Word processor document containing 1000
characters and a small image which is 256 ×
256 pixels in size (assume an extra 14KB for
other document features).
Page 49
Answers
• Text file containing 256 characters = 256
bytes (I byte for each character)
• Word processor contains1000 characters = 1000
bytes
• Image size is 256 × 256 pixels = 65536 x 3
=196608 bytes
• An extra 14KB
• Total = 1000+196608+(14x1024) =
211944 bytes
Page 50
Activity
• A security system contains a password
(16 characters long), a username (20
characters long), a small photo (256 × 640
pixels in size) and a security question (up
to 72 characters long).
• Estimate the file size needed to store all
this data.
Page 51
Thank You
Questions?
Page 52