HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 41. CH38 CODECS: CODING AND DECODING 311


Theoretically, there are an infinite number of different ways that coding
could be done. But from a practical point of view, we need to agree on
one way, or at most a few ways, of doing it. Otherwise, communication is
difficult.


Acodec is a piece of software (usually) that codes (co...) and decodes
(..dec). It is used by the browser to decode the audio or video back into a
usable form.


41.1 With Codes, Shorter is Better


One of the earliest electronic codes is the one that was used with the original
telegraph. Morse code was built out of dots and dashes with extra space
between letters. It was a variable-length code, with “e”, the most common
letter in English, represented by the shortest code, a single dot. “q” and
“j,” much less common letters, were represented by longer codes.


http://en.wikipedia.org/wiki/Morse_codehas more.


Basing the Morse code on letter frequency was a good way to keep message
length short.


We do something similar with language. Words, which we use to encode our
thoughts, have varying lengths. Simple pronouns like “you,” “me,” “he,”
“she,” and “it” are very short. Words in everyday usage tend to be longer
but still manageable. Names of chemicals and drugs tend to be huge.


The secret is frequency. Frequent words and phrases become short. Less
frequent words are long. This is a good solution. It helps keep overall
message length short. Human language seems to naturally do this.


The bad news is that frequency depends on the sender and receiver of the
message. Russians might use “da” (yes) a lot more often than I do.


The result is that there are a lot of different coding schemes for just about
everything you can imagine, each having a place where it would be the best.


41.2 Patents


Patents are a common method for protecting Intellectual Property. When
inventors want the exclusive right to control how their inventions are used,

Free download pdf