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.