Skip to main content

linear_to_alaw

Function linear_to_alaw 

Source
pub fn linear_to_alaw(sample: i16) -> u8
Expand description

Encode one linear PCM16 sample as an A-law byte (ITU-T G.711).

G.711 defines the encoder on a 13-bit input; the 16-bit sample is taken to that domain with an arithmetic shift and a negative sample’s magnitude is -v - 1, which equals the one’s complement ITU-T G.191’s alaw_compress takes. Bit-exact with G.191 for every input (reference_tests).