Skip to main content

Module g711

Module g711 

Source
Expand description

G.711 µ-law and A-law (ITU-T G.711).

Two logarithmic 8-bit codecs, both ancient and both still the only thing every endpoint on earth agrees on. The compression is a piecewise-linear approximation of a logarithm: a sign bit, a 3-bit exponent and a 4-bit mantissa.

What makes these worth testing carefully rather than round-tripping: the round trip is lossy by design, so “encode then decode gives back the input” is false for almost every input and cannot be the test. The reference values below come from the ITU algorithm, and what the round trip does guarantee is that a decoded value re-encodes to the same code — the codec is idempotent on its own output, which is the property that matters when audio passes through more than one hop.

Functions§

alaw_decode
Decode one A-law code.
alaw_decode_all
Decode a buffer of A-law.
alaw_encode
Encode one sample to A-law.
alaw_encode_all
Encode a buffer of samples to A-law.
ulaw_decode
Decode one µ-law code.
ulaw_decode_all
Decode a buffer of µ-law.
ulaw_encode
Encode one sample to µ-law.
ulaw_encode_all
Encode a buffer of samples to µ-law.