Pulse code modulation (PCM) of voice frequencies  
Status  In force 

Year started  1972 
Latest version  (02/00) February 2000 
Organization  ITUT 
Related standards  G.191, G.711.0, G.711.1, G.729 
Domain  audio compression 
Website  https://www.itu.int/rec/TRECG.711 
Floatingpoint formats 

IEEE 754 
Other 
G.711 is a narrowband audio codec originally designed for use in telephony that provides tollquality audio at 64 kbit/s. G.711 passes audio signals in the range of 300–3400 Hz and samples them at the rate of 8,000 samples per second, with the tolerance on that rate of 50 parts per million (ppm). Nonuniform (logarithmic) quantization with 8 bits is used to represent each sample, resulting in a 64 kbit/s bit rate. There are two slightly different versions: μlaw, which is used primarily in North America and Japan, and Alaw, which is in use in most other countries outside North America.
G.711 is an ITUT standard (Recommendation) for audio companding, titled Pulse code modulation (PCM) of voice frequencies released for use in 1972. It is a required standard in many technologies, such as in the H.320 and H.323 standards.^{[1]} It can also be used for fax communication over IP networks (as defined in T.38 specification).
Two enhancements to G.711 have been published: G.711.0 utilizes lossless data compression to reduce the bandwidth usage and G.711.1 increases audio quality by increasing bandwidth.
G.711 defines two main companding algorithms, the μlaw algorithm and Alaw algorithm. Both are logarithmic, but Alaw was specifically designed to be simpler for a computer to process. The standard also defines a sequence of repeating code values which defines the power level of 0 dB.
The μlaw and Alaw algorithms encode 14bit and 13bit signed linear PCM samples (respectively) to logarithmic 8bit samples. Thus, the G.711 encoder will create a 64 kbit/s bitstream for a signal sampled at 8 kHz.^{[1]}
G.711 μlaw tends to give more resolution to higher range signals while G.711 Alaw provides more quantization levels at lower signal levels.
The terms PCMU, G711u or G711MU for G711 μlaw, and PCMA or G711A for G711 Alaw, are used.^{[2]}
Main article: Alaw algorithm 
Alaw encoding thus takes a 13bit signed linear audio sample as input and converts it to an 8 bit value as follows:
Linear input code ^{[note 1]} 
Compressed code XOR 01010101 
Linear output code ^{[note 2]} 

s0000000abcdx 
s000abcd 
s0000000abcd1

s0000001abcdx 
s001abcd 
s0000001abcd1

s000001abcdxx 
s010abcd 
s000001abcd10

s00001abcdxxx 
s011abcd 
s00001abcd100

s0001abcdxxxx 
s100abcd 
s0001abcd1000

s001abcdxxxxx 
s101abcd 
s001abcd10000

s01abcdxxxxxx 
s110abcd 
s01abcd100000

s1abcdxxxxxxx 
s111abcd 
s1abcd1000000

Where s
is the sign bit, s
is its inverse (i.e. positive values are encoded with MSB = s = 1), and bits marked x
are discarded. Note that the first column of the table uses different representation of negative values than the third column. So for example, input decimal value −21 is represented in binary after bit inversion as 1000000010100, which maps to 00001010 (according to the first row of the table). When decoding, this maps back to 1000000010101, which is interpreted as output value −21 in decimal. Input value +52 (0000000110100 in binary) maps to 10011010 (according to the second row), which maps back to 0000000110101 (+53 in decimal).
This can be seen as a floatingpoint number with 4 bits of mantissa m (equivalent to a 5bit precision), 3 bits of exponent e and 1 sign bit s, formatted as seeemmmm
with the decoded linear value y given by formula
which is a 13bit signed integer in the range ±1 to ±(2^{12} − 2^{6}). Note that no compressed code decodes to zero due to the addition of 0.5 (half of a quantization step).
In addition, the standard specifies that all resulting even bits (LSB is even) are inverted before the octet is transmitted. This is to provide plenty of 0/1 transitions to facilitate the clock recovery process in the PCM receivers. Thus, a silent Alaw encoded PCM channel has the 8 bit samples coded 0xD5 instead of 0x80 in the octets.
When data is sent over E0 (G.703), MSB (sign) is sent first and LSB is sent last.
ITUT STL^{[3]} defines the algorithm for decoding as follows (it puts the decoded values in the 13 most significant bits of the 16bit output data type).
void alaw_expand(lseg, logbuf, linbuf)
long lseg;
short *linbuf;
short *logbuf;
{
short ix, mant, iexp;
long n;
for (n = 0; n < lseg; n++)
{
ix = logbuf[n] ^ (0x0055); /* retoggle toggled bits */
ix &= (0x007F); /* remove sign bit */
iexp = ix >> 4; /* extract exponent */
mant = ix & (0x000F); /* now get mantissa */
if (iexp > 0)
mant = mant + 16; /* add leading '1', if exponent > 0 */
mant = (mant << 4) + (0x0008); /* now mantissa left justified and */
/* 1/2 quantization step added */
if (iexp > 1) /* now left shift according exponent */
mant = mant << (iexp  1);
linbuf[n] = logbuf[n] > 127 /* invert, if negative sample */
? mant
: mant;
}
}
See also "ITUT Software Tool Library 2009 User's manual" that can be found at.^{[4]}
Main article: μlaw algorithm 
The μlaw (sometimes referred to as ulaw, G.711Mu, or G.711μ) encoding takes a 14bit signed linear audio sample in two's complement representation as input, inverts all bits after the sign bit if the value is negative, adds 33 (binary 100001) and converts it to an 8 bit value as follows:
Linear input value ^{[note 1]} 
Compressed code XOR 11111111 
Linear output value ^{[note 2]} 

s00000001abcdx 
s000abcd 
s00000001abcd1

s0000001abcdxx 
s001abcd 
s0000001abcd10

s000001abcdxxx 
s010abcd 
s000001abcd100

s00001abcdxxxx 
s011abcd 
s00001abcd1000

s0001abcdxxxxx 
s100abcd 
s0001abcd10000

s001abcdxxxxxx 
s101abcd 
s001abcd100000

s01abcdxxxxxxx 
s110abcd 
s01abcd1000000

s1abcdxxxxxxxx 
s111abcd 
s1abcd10000000

Where s
is the sign bit, and bits marked x
are discarded.
In addition, the standard specifies that the encoded bits are inverted before the octet is transmitted. Thus, a silent μlaw encoded PCM channel has the 8 bit samples transmitted 0xFF instead of 0x00 in the octets.
Adding 33 is necessary so that all values fall into a compression group and it is subtracted back when decoding.
Breaking the encoded value formatted as seeemmmm
into 4 bits of mantissa m, 3 bits of exponent e and 1 sign bit s, the decoded linear value y is given by formula
which is a 14bit signed integer in the range ±0 to ±8031.
Note that 0 is transmitted as 0xFF, and −1 is transmitted as 0x7F, but when received the result is 0 in both cases.
G.711.0, also known as G.711 LLC, utilizes lossless data compression to reduce the bandwidth usage by as much as 50 percent.^{[5]} The Lossless compression of G.711 pulse code modulation standard was approved by ITUT in September 2009.^{[6]}^{[7]}
G.711.1 is an extension to G.711, published as ITUT Recommendation G.711.1 in March 2008. Its formal name is Wideband embedded extension for G.711 pulse code modulation.^{[7]}^{[8]}^{[9]}
G.711.1, allows the addition of narrowband and/or wideband (16000 samples/s) enhancements, each at 25% of the bitrate of the (included) base G.711 bitstream, leading to data rates of 64, 80 or 96 kbit/s.
G.711.1 is compatible with G.711 at 64 kbit/s,^{[10]} hence an efficient deployment in existing G.711based voice over IP (VoIP) infrastructures is foreseen. The G.711.1 coder can encode signals at 16 kHz with a bandwidth of 50–7000 Hz at 80 and 96 kbit/s, and for 8kHz sampling the output may produce signals with a bandwidth ranging from 50 up to 4000 Hz, operating at 64 and 80 kbit/s.^{[8]}
The G.711.1 encoder creates an embedded bitstream structured in three layers corresponding to three available bit rates: 64, 80 and 96 kbit/s. The bitstream does not contain any information on which layers are contained, an implementation would require outband signalling on which layers are available. The three G.711.1 layers are: log companded pulse code modulation (PCM) of the lower band including noise feedback, embedded PCM extension with adaptive bit allocation for enhancing the quality of the base layer in the lower band, and weighted vector quantization coding of the higher band based on modified discrete cosine transformation (MDCT).^{[8]}
Two extensions for G.711.1 are planned in 2010: superwideband extension (bandwidth to 14000 Hz) and lossless bitstream compression.^{[11]}
The patents for G.711, released in 1972, have expired, so it may be used without the need for a licence.^{[1]}