Everything you ever wanted to know about a Codec

Report
Everything you ever wanted to
know about a Codec
But were afraid to ask????
It’s software
• In simplest form, a codec is a software
algorithm that transforms data from one
format to another
• Stands for coder-decoder or compressorde-compressor
• Codec used to compress file must be the
same used to decompress file
Two main types
• Lossless codecs – the original can be
recreated exactly for the compressed file
• Lossy codecs – decompressed file is an
approximation of the original file. How
approximate depends on amount of
compression used
Many file formats use codecs
•
•
•
•
JPEG images - lossy
GIF images - lossy
ZIP files - lossless
StuffIt archives - lossless
How lossless codecs work
• Original files can be recreated exactly
• Takes advantage of redundant information
reprenting more efficiently
• AAAAAAAA becomes 8A – reducing storage by
75%
• Huffman coding replaces frequently occurring
sequences with shorter code
– Hyper Text Markup Language becomes HTML.
• When de-compressed HTML becomes
Hyper Text Markup Language
• Great for quality concerns – but minimal
compression ratios.
• Would not work well for Streaming Media,
for example.
Lossy codecs
•GIF
•JPEG
They are only approximations of the original
image
• Achieve much higher rates of file size
reduction by discarding data that is
deemed unnecessary or redundant.
• Since information is discarded, recreating
the original file exactly is not possible
when file is de-compressed.
• Ideally, some data can be discarded and
not missed.
Poor, poor Codecs
• The codecs job is difficult and
underappreciated – they must try to keep
the most important information in the file
and discard the rest.
• In cases of extreme compression, codecs
MUST be ruthless in discarding data
• They try to retain original quality – or to
retain at least enough information to keep
you interested.
• Try to take some time to tell codecs you
love and appreciate them.
• Theirs is a tough and thankless job.
Streaming Media Codecs
• It’s a tough job – but somebody’s gotta do
it.
– Uncompressed audio = 1.4Mbits per second
– Raw video >25Mbytes per second for full
screen NTSC (National Television Standards
Committee decided on 30 frames per second
as the standard)
– 56K modem downloading at the speed of wait
Extreme Compression
• Staggering divide between raw bit rates of
audio and video and bit rates available to
Internet users bridged by codecs
• If sustained 34K data rate (of 56K modem)
CD-quality audio must be compressed
approximately 40:1.
• With video, compression numbers are
ludicrous
Perceptual Coding
• What is a conscientious codec to do?
– Use models about how humans perceive
audio and video
– Allow for reasonably intelligent decisions
about what to keep and what to throw out
• When digitizing audio and video, goal is to
accurately represent input signal
– Audio: sample input 44,100 times per second,
using 16-bit words to represent each sample.
Assumes our ears give equal attention to
each and frequency
– Video: assumes that 24 bits of information
needed for every pixel on the screen, all 640
X 480 of them, 30 times a second - NOT
• Human eyes and ears register extremely wide
range of audio and video inputs, though both are
more sensitive to particular ranges of audio and
video spectrum.
• And, what is perceived is determined by the
brain, which filters raw information.
• Perceptual coding makes decisions about
compressing audio and video based on how
humans perceive sight and sound.
• For example – loud sounds take precedence
over quieter sounds in the brain; bright objects
and movement take visual precedence
• Evolved from primitive survival characteristics –
it was more important to hear the saber tooth
tiger roaring at you than your wife telling you to
take out the trash; and, you want to be able to
see that bright tiger running through the grass
toward you.
• Humans retain these perceptual
characteristics –
• perceptual coding is effective in keeping
what is “important” and “discarding” what
is not important.
Audio Codecs
• Balance between fidelity, frequency
response, dynamics & number of
channels.
• Collapsing from stereo to mono – cuts
amount of data in half
• Sampling rate – further reduces data to be
processed –
– frequency response and
– sample bit depth
• FM radio – frequency - 12KhZ – drop
frequency response and maintain quality
• For voice – 8kHz or even 5kHz
• Thus don’t have to use full 16 bits to
represent dynamic range
• Technology making it even better – need
less to sound good
What about music?
• Must be prepared for wide range of
sounds – from screaming bass guitar to
cymbals to soft flute in the background.
• Thus, special AND different codecs for
audio, speech and video
• Voice codecs and music codecs are
completely different
• Not interchangeable – voice codecs make
music sound awful –
• and mostly visa versa.
Video Coding
• Video content with motion – smooth at
about 20 fps
• Little motion can go below that
• But that is still not enough
• Economize by using inter-frame
compression
• Theoretically, much of frame will remain
unchanged between frames
• Digitize or encode only the section of the
frame that changes
• Video codec digitizes one complete frame
to establish all elements in the frame
• After background established –
subsequent frames digitize only changing
elements or differences –
• Establishing frames are keyframes
• Rest are called difference frames
• Video keyframes allow you to change an
effect over time, or move the position and
size of the frame over time.
• Video keyframes are used during custom
special effects, but are not needed for
most common operations.
• That’s all I want to confuse you with
• Just remember the jist

similar documents