Difference between revisions of "Information on Audio Codecs"

From TD-er's Wiki
Jump to navigationJump to search
 
(23 intermediate revisions by 5 users not shown)
Line 1: Line 1:
X-lite has various codecs implemented. From the[http://www.xten.com/docs/CounterPath_UserGuideXLite-XPRO.pdf  User’s Guide for X-Lite and X-PRO] p.34 we learn the following:
+
Codecs are used to convert an analog voice signal to digitally encoded version. Codecs vary in the sound quality, the bandwidth required, the computational requirements, etc.  
"When two VoIP systems are establishing a call, they negotiate an audio compression codec they
 
are going to use. Which audio compression codec to choose depends on many factors: which
 
audio compression codecs are installed on both systems, bandwidth limitations, desired sound
 
quality, etc. During the negotiation, X-Lite/X-PRO offers to the remote system the first audio
 
compression codec from the list. If the remote system rejects the audio compression codec, XLite/X-PRO offers the next one from top to bottom until they both accept the audio compression
 
codec.
 
  
Also there is written that the X-Lite/X-Pro versions support 6 different audio compression codecs, G.711A and G.711U being the codecs with the best sound quality but with low voice compression.  
+
Each service, program, phone, gateway, etc typically supports several different codecs, and when talking to each other, negotiate which codec they will use.  
  
== G.711A & G.711U ==
+
 
 +
X-lite has various audio codecs implemented. The [http://www.xten.com/index.php?menu=Products&smenu=compare implemented audio codecs] of the X-lite 3.0 version are DVI4, G.711 uLaw/aLaw, GSM, iLBC as (narrow band audio codecs) and BV-32, BV FEC, DVI4, L16 PCM (wide band audio codecs). Eyebeam version 1.5 has a wider range of codecs available.
 +
 
 +
 
 +
=== G.711A & G.711U ===
 +
 
 +
[http://en.wikipedia.org/wiki/G.711 G.711] is a codec primarily used in telephony, released in 1972. It samples the analogue voice input signal using pulse-code modulation (PCM) at a sampling rate of 8000 samples/second.
 +
 
 +
The G.711 standard has two algorithms: the A-law (mostly used in Europe) and the U-law algorithm (used in North America and Japan).
 +
 
 +
The G.711 codec encodes the pulse-code modulation samples (sampling rate of 8000 samples/second) to logarithmic 8-bit samples. This will lead to a (8000 times 8-bit=) 64 kbit/s bitstream. Note that this is the datastream without information send in the headers of the packages, so the actual datastream will be higher. Because the sampling rate of 8000 samples/second and the encoding to 8-bit samples are intrinsic properties of the codec, the bitstream can not exceed 64 kbit/s. If one wants to increase the quality of the voice by increasing the used bandwidth (> 64 kbit/s) one has to use another codec.
 +
 
 +
=== Various codecs compared ===
 +
The following sites were used to build the following comparison:
 +
* [http://www.voip-wiki.de/tiki-index.php?page=guest-voip VoIP-wiki.de] (german website)
 +
* [http://www.speex.org/comparison/ Speex.org]
 +
* [http://www.voip-info.org/wiki/view/Codecs VoIP-info.org] - Codecs-page.
 +
 
 +
{| border="1" cellspacing="0"
 +
! Codec
 +
! Compression method
 +
! Transfer rate
 +
! NEB
 +
! Frame size
 +
|-
 +
|G.711 
 +
|Pulse Code Modulation (PCM) 
 +
|64 Kbps
 +
|87.2 Kbps
 +
|20 ms
 +
|-
 +
|G.726 
 +
|Adaptive Differential Pulse Code Modulation (ADPCM)
 +
|16-40 Kbps
 +
|55.2 Kbps
 +
|
 +
|-
 +
|G.728
 +
|Low Delay Code Excited Linear Prediction (LD-CELP) 
 +
|16 Kbps
 +
|31.5 Kbps
 +
|0,625ms
 +
|-
 +
|G.729/G.729A
 +
|Conjugate Structure Algebraic Code Excited Linear Prediction (CD-ACELP)
 +
|8 Kbps
 +
|31.2 Kbps
 +
|10 ms
 +
|-
 +
|G.723.1 
 +
|Mulptiple Maximum Likehood Quantization (MPMLQ) 
 +
|6.3 Kbit/s
 +
|21.9 Kbps
 +
|37.5 ms
 +
|-
 +
|G.723
 +
|ACELP 
 +
|5,3 Kbps
 +
|20.8 Kbps
 +
|
 +
|-
 +
|GSM
 +
|Global System for Mobile communications
 +
|13 Kbps
 +
|
 +
|20ms
 +
|-
 +
|[http://www.speex.org/ Speex] Narrowband (8kHz)
 +
|Patent-free audio compression
 +
|2.15-24.6 Kbps
 +
|
 +
|20ms
 +
|-
 +
|[http://www.speex.org/ Speex] Wideband (16kHz)
 +
|Patent-free audio compression
 +
|4-44.2 Kbps
 +
|
 +
|20ms
 +
|-
 +
|DVI4   
 +
|ADPCM
 +
|32 Kbps
 +
|
 +
|
 +
|-
 +
|iLBC   
 +
|Internet Low Bandwidth Codec (free)
 +
|13,3 Kbps
 +
|
 +
|30ms
 +
|-
 +
|iLBC   
 +
|Internet Low Bandwidth Codec (free)
 +
|15,2 Kbps
 +
|27.7 Kbps
 +
|20ms
 +
|-
 +
|L16 PCM 
 +
|PCM
 +
|128 Kbps
 +
|
 +
|
 +
|-
 +
|EVCR 
 +
|Enhanced Variable Rate Codec
 +
|8 Kbps
 +
|
 +
|
 +
|-
 +
|}
 +
 
 +
''NEB = Nominal Ethernet Bandwidth (one direction)''
 +
 
 +
 
 +
'''Notes''':
 +
* G711u/a - Requires 64+Kbps (inbound and outbound) continuous data stream for a quality call, plus the SIP signal. A 128Kbps connection has shown to be the minimal connection needed in our testing.
 +
* G723 - Requires 6.4+Kbps (I and O) continuous data stream and also needs room for the SIP signal, 28.8Kbps connection has shown to be the minimal connection.
 +
 
 +
 
 +
* From the maximum voice quality point of view, when enough bandwidth is available, the best quality can be obtained by using the L16 PCM codec. This L16 PCM codec is the same as the G.711 codec, however the L16 PCM codec samples to 16 bits samples instead of the 8 bits samples in the case of the G.711 codec.
 +
 
 +
* Asterisk will resample all codecs internally to 8000 samples/sec. This means using for example the Speex Wide-band (16 kHz sample-rate) or even Ultra-wide-band (32 kHz sample-rate) with Asterisk is useless.
 +
 
 +
*Codecs with a frame-size other than 20 ms, appear to work bad with Asterisk. This may have to do with the IAX-protocol.
 +
 
 +
 
 +
==Audio codec translations==
 +
When Asterisk can choose between different codecs (prerecorded samples) and also when conversions between codecs have to be made (e.g. bandwidth=low), Asterisk will choose the best codec out of the conversion-matrix.
 +
 
 +
In the Asterisk CLI this machine-specific matrix can be shown: (N.B. matrix is taken from a P3 machine)
 +
asterisk1*CLI> show translation
 +
          Translation times between formats (in milliseconds)
 +
          Source Format (Rows) Destination Format(Columns)
 +
        g723  gsm  ulaw  alaw  g726 adpcm  slin lpc10  g729 speex  ilbc
 +
  g723    -    -    -    -    -    -    -    -    -    -    -
 +
    gsm    -    -    3    3    7    3    2    8    -    86    30
 +
  ulaw    -    7    -    1    6    2    1    7    -    85    29
 +
  alaw    -    7    1    -    6    2    1    7    -    85    29
 +
  g726    -    10    5    5    -    5    4    10    -    88    32
 +
  adpcm    -    7    2    2    6    -    1    7    -    85    29
 +
  slin    -    6    1    1    5    1    -    6    -    84    28
 +
  lpc10    -    12    7    7    11    7    6    -    -    90    34
 +
  g729    -    -    -    -    -    -    -    -    -    -    -
 +
  speex    -    12    7    7    11    7    6    12    -    -    34
 +
  ilbc    -    14    9    9    13    9    8    14    -    92    -
 +
 
 +
The list of available codecs can be made visible like this:
 +
asterisk1*CLI> show audio codecs
 +
Disclaimer: this command is for informational purposes only.
 +
        It does not indicate anything about your configuration.
 +
        INT    BINARY        HEX  TYPE    NAME  DESC
 +
--------------------------------------------------------------------------------
 +
          1 (1 <<  0)      (0x1)  audio    g723  (G.723.1)
 +
          2 (1 <<  1)      (0x2)  audio    gsm  (GSM)
 +
          4 (1 <<  2)      (0x4)  audio    ulaw  (G.711 u-law)
 +
          8 (1 <<  3)      (0x8)  audio    alaw  (G.711 A-law)
 +
        16 (1 <<  4)    (0x10)  audio    g726  (G.726)
 +
        32 (1 <<  5)    (0x20)  audio  adpcm  (ADPCM)
 +
        64 (1 <<  6)    (0x40)  audio    slin  (16 bit Signed Linear PCM)
 +
        128 (1 <<  7)    (0x80)  audio  lpc10  (LPC10)
 +
        256 (1 <<  8)    (0x100)  audio    g729  (G.729A)
 +
        512 (1 <<  9)    (0x200)  audio  speex  (SpeeX)
 +
      1024 (1 << 10)    (0x400)  audio    ilbc  (iLBC)
 +
 
 +
==[[Links#Audio_codecs|Links]]==

Latest revision as of 20:45, 20 February 2007

Codecs are used to convert an analog voice signal to digitally encoded version. Codecs vary in the sound quality, the bandwidth required, the computational requirements, etc.

Each service, program, phone, gateway, etc typically supports several different codecs, and when talking to each other, negotiate which codec they will use.


X-lite has various audio codecs implemented. The implemented audio codecs of the X-lite 3.0 version are DVI4, G.711 uLaw/aLaw, GSM, iLBC as (narrow band audio codecs) and BV-32, BV FEC, DVI4, L16 PCM (wide band audio codecs). Eyebeam version 1.5 has a wider range of codecs available.


G.711A & G.711U

G.711 is a codec primarily used in telephony, released in 1972. It samples the analogue voice input signal using pulse-code modulation (PCM) at a sampling rate of 8000 samples/second.

The G.711 standard has two algorithms: the A-law (mostly used in Europe) and the U-law algorithm (used in North America and Japan).

The G.711 codec encodes the pulse-code modulation samples (sampling rate of 8000 samples/second) to logarithmic 8-bit samples. This will lead to a (8000 times 8-bit=) 64 kbit/s bitstream. Note that this is the datastream without information send in the headers of the packages, so the actual datastream will be higher. Because the sampling rate of 8000 samples/second and the encoding to 8-bit samples are intrinsic properties of the codec, the bitstream can not exceed 64 kbit/s. If one wants to increase the quality of the voice by increasing the used bandwidth (> 64 kbit/s) one has to use another codec.

Various codecs compared

The following sites were used to build the following comparison:

Codec Compression method Transfer rate NEB Frame size
G.711 Pulse Code Modulation (PCM) 64 Kbps 87.2 Kbps 20 ms
G.726 Adaptive Differential Pulse Code Modulation (ADPCM) 16-40 Kbps 55.2 Kbps
G.728 Low Delay Code Excited Linear Prediction (LD-CELP) 16 Kbps 31.5 Kbps 0,625ms
G.729/G.729A Conjugate Structure Algebraic Code Excited Linear Prediction (CD-ACELP) 8 Kbps 31.2 Kbps 10 ms
G.723.1 Mulptiple Maximum Likehood Quantization (MPMLQ) 6.3 Kbit/s 21.9 Kbps 37.5 ms
G.723 ACELP 5,3 Kbps 20.8 Kbps
GSM Global System for Mobile communications 13 Kbps 20ms
Speex Narrowband (8kHz) Patent-free audio compression 2.15-24.6 Kbps 20ms
Speex Wideband (16kHz) Patent-free audio compression 4-44.2 Kbps 20ms
DVI4 ADPCM 32 Kbps
iLBC Internet Low Bandwidth Codec (free) 13,3 Kbps 30ms
iLBC Internet Low Bandwidth Codec (free) 15,2 Kbps 27.7 Kbps 20ms
L16 PCM PCM 128 Kbps
EVCR Enhanced Variable Rate Codec 8 Kbps

NEB = Nominal Ethernet Bandwidth (one direction)


Notes:

  • G711u/a - Requires 64+Kbps (inbound and outbound) continuous data stream for a quality call, plus the SIP signal. A 128Kbps connection has shown to be the minimal connection needed in our testing.
  • G723 - Requires 6.4+Kbps (I and O) continuous data stream and also needs room for the SIP signal, 28.8Kbps connection has shown to be the minimal connection.


  • From the maximum voice quality point of view, when enough bandwidth is available, the best quality can be obtained by using the L16 PCM codec. This L16 PCM codec is the same as the G.711 codec, however the L16 PCM codec samples to 16 bits samples instead of the 8 bits samples in the case of the G.711 codec.
  • Asterisk will resample all codecs internally to 8000 samples/sec. This means using for example the Speex Wide-band (16 kHz sample-rate) or even Ultra-wide-band (32 kHz sample-rate) with Asterisk is useless.
  • Codecs with a frame-size other than 20 ms, appear to work bad with Asterisk. This may have to do with the IAX-protocol.


Audio codec translations

When Asterisk can choose between different codecs (prerecorded samples) and also when conversions between codecs have to be made (e.g. bandwidth=low), Asterisk will choose the best codec out of the conversion-matrix.

In the Asterisk CLI this machine-specific matrix can be shown: (N.B. matrix is taken from a P3 machine)

asterisk1*CLI> show translation
         Translation times between formats (in milliseconds)
          Source Format (Rows) Destination Format(Columns)
        g723   gsm  ulaw  alaw  g726 adpcm  slin lpc10  g729 speex  ilbc
  g723     -     -     -     -     -     -     -     -     -     -     -
   gsm     -     -     3     3     7     3     2     8     -    86    30
  ulaw     -     7     -     1     6     2     1     7     -    85    29
  alaw     -     7     1     -     6     2     1     7     -    85    29
  g726     -    10     5     5     -     5     4    10     -    88    32
 adpcm     -     7     2     2     6     -     1     7     -    85    29
  slin     -     6     1     1     5     1     -     6     -    84    28
 lpc10     -    12     7     7    11     7     6     -     -    90    34
  g729     -     -     -     -     -     -     -     -     -     -     -
 speex     -    12     7     7    11     7     6    12     -     -    34
  ilbc     -    14     9     9    13     9     8    14     -    92     -

The list of available codecs can be made visible like this:

asterisk1*CLI> show audio codecs
Disclaimer: this command is for informational purposes only.
       It does not indicate anything about your configuration.
       INT    BINARY        HEX   TYPE    NAME   DESC
--------------------------------------------------------------------------------
         1 (1 <<  0)      (0x1)  audio    g723   (G.723.1)
         2 (1 <<  1)      (0x2)  audio     gsm   (GSM)
         4 (1 <<  2)      (0x4)  audio    ulaw   (G.711 u-law)
         8 (1 <<  3)      (0x8)  audio    alaw   (G.711 A-law)
        16 (1 <<  4)     (0x10)  audio    g726   (G.726)
        32 (1 <<  5)     (0x20)  audio   adpcm   (ADPCM)
        64 (1 <<  6)     (0x40)  audio    slin   (16 bit Signed Linear PCM)
       128 (1 <<  7)     (0x80)  audio   lpc10   (LPC10)
       256 (1 <<  8)    (0x100)  audio    g729   (G.729A)
       512 (1 <<  9)    (0x200)  audio   speex   (SpeeX)
      1024 (1 << 10)    (0x400)  audio    ilbc   (iLBC)

Links