8.3. Codecs
Codecs are
generally understood to be various mathematical models used to
digitally encode (and compress) analog audio information. Many of
these models take into account the human brain's ability to form an
impression from incomplete information. We've all seen optical
illusions; likewise, voice-compression algorithms take advantage of our tendency to interpret
what we believe we should hear,
rather than what we actually
hear. The purpose of the various
encoding algorithms is to strike a balance between efficiency and
quality.
Originally, the term CODEC referred to a
COder/DECoder: a device that converts between analog and digital.
Now, the term seems to relate more to
COmpression/DECompression.
Before we dig into the individual codecs, take a
look at Table
8-1it's a quick reference that you
may want to refer back to.
Table 8-1. Codec quick reference
Codec
|
Data bitrate (kbps)
|
Licence required?
|
G.711
|
64 kbps
|
No
|
G.726
|
16, 24, or 32 kbps
|
No
|
G.723.1
|
5.3 or 6.3 kbps
|
Yes (no for passthrough)
|
G.729A
|
8 kbps
|
Yes (no for passthrough)
|
GSM
|
13 kbps
|
No
|
iLBC
|
13.3 kbps (30-ms frames) or 15.2 kbps (20-ms
frames)
|
No
|
Speex
|
Variable (between 2.15 and 22.4 kbps)
|
No
|
8.3.1.
8.3.1.1. G.711
G.711 is the fundamental codec of the PSTN. In
fact, if someone refers to PCM (discussed in the previous chapter)
with respect to a telephone network, you are allowed to think of
G.711. Two companding methods are used: m-law in North America and A-law in the rest of the
world. Either one delivers an 8-bit word transmitted 8,000 times
per second. If you do the math, you will see that this requires
64,000 bits to be transmitted per second.
Many people will tell you that G.711 is an
uncompressed codec. This is not exactly true, as companding is
considered a form of compression. What is true is that G.711 is the
base codec from which all of the others are derived.
8.3.1.2. G.726
This codec has been around for some time (it
used to be G.721, which is now obsolete), and it is one of the
original compressed codecs. It is also known as Adaptive
Differential Pulse-Code Modulation (ADPCM) , and it can run at several bitrates. The
most common rates are 16 kbps, 24 kbps, and 32 kbps. As of this
writing, Asterisk currently supports only the ADPCM-32 rate, which
is far and away the most popular rate for this codec.
G.726 offers
quality nearly identical to G.711, but it uses only half the
bandwidth. This is possible because rather than sending the result
of the quantization measurement, it sends only enough information
to describe the difference between the current sample and the
previous one. G.726 fell from favor in the 1990s due to its
inability to carry modem and fax signals, but because of its
bandwidth/CPU performance ratio it is now making a comeback. G.726
is especially attractive because it does not require a lot of
computational work from the system.
8.3.1.3. G.723.1
Not to be confused with G.723 (which is another
obsolete version of ADPCM), this codec is designed for low-bitrate
speech. It has two data bitrate settings: 5.3 kbps and 6.3 kbps.
G.723.1 is one of the codecs required for compliance with the H.323
protocol (although other codecs may be employed by H.323). It is
currently encumbered by patents and thus requires licensing if used
in commercial applications. What this means is that while you can
switch two G.723.1 calls through your Asterisk system, you are not
allowed to decode them without a license.
8.3.1.4. G.729A
Considering how little bandwidth it uses, G.729A
delivers impressive sound quality. It does this through the use of
Conjugate-Structure Algebraic-Code-Excited Linear Prediction
(CS-ACELP) . Because of patents, you can't
use G729A without paying a licensing fee; however, it is extremely
popular and is thus well supported on many different phones and
systems.
To achieve its impressive compression ratio,
this codec requires an equally impressive amount of effort from the
CPU. In an Asterisk system, the use of heavily compressed codecs
will quickly bog down the CPU.
G.729A uses 8 kbps of bandwidth.
8.3.1.5. GSM
GSM is the darling
codec of Asterisk. This codec does not come encumbered with a
licensing requirement the way that G.723.1 and G.729A do, and it
offers outstanding performance with respect to the demand it places
on the CPU. The sound quality is generally considered to be of a
lesser grade than that produced by G.729A, but as much of this
comes down to personal opinion, be sure to try it out.
GSM operates at 13 kbps.
8.3.1.6. iLBC
The Internet Low Bitrate Codec (iLBC) provides an attractive mix of low bandwidth
usage and quality, and it is especially well suited to sustaining
reasonable quality on lossy network links.
Naturally, Asterisk supports it (and support
elsewhere is growing), but it is not as popular as the ITU codecs
and thus may not be compatible with common IP telephones and
commercial VoIP systems. IETF RFCs 3951 and 3952 have been
published in support of iLBC, and iLBC is on the IETF standards
track.
Because iLBC uses complex algorithms to achieve
its high levels of compression, it has a fairly high CPU cost in
Asterisk.
While you are allowed to use iLBC without paying
royalty fees, the holder of the iLBC patent, Global IP Sound
(GIPS), wants to know whenever you use it in a commercial
application. The way you do that is by downloading and printing a
copy of the iLBC license, signing it, and returning it to them. If
you want to read about iLBC and its license, you can do so at
http://www.ilbcfreeware.org.
iLBC operates at 13.3 kbps (30-ms frames) and
15.2 kbps (20-ms frames).
8.3.1.7. Speex
Speex is a Variable Bitrate (VBR) codec, which
means that it is able to dynamically modify its bitrate to respond
to changing network conditions. It is offered in both narrowband
and wideband versions, depending on whether you want telephone
quality or better.
Speex is a totally free codec, licensed under
the Xiph.org variant of the BSD license.
An Internet draft for Speex is available, and
more information about Speex can be found at its home page
(http://www.speex.org).
Speex can operate at anywhere from 2.15 to 22.4
kbps, due to its variable bitrate
8.3.1.8. MP3
Sure thing, MP3 is
a codec. Specifically, it's the Moving Picture Experts Group Audio
Layer 3 Encoding Standard. With a name
like that, it's no wonder we call it MP3! In Asterisk, the MP3
codec is typically used for Music on Hold (MoH). MP3 is not a
telephony codec, as it is optimized for music, not voice;
nevertheless, it's very popular with VoIP telephony systems as a
method of delivering Music on Hold.
|
Be aware that music cannot usually be broadcast
without a license. Many people assume that there is no legal
problem with connecting a radio station or CD as a Music on Hold
source, but this is very rarely true.
|
|
|