written 7.7 years ago by | • modified 6.2 years ago |
In companding, we convert the signal into digital domain non-linearly to achieve compression.
Here the weaker signals are amplified by larger factors while the stronger signals are amplified by smaller factors.
There are two types of companding:
μ-law companding
A-law companding
The μ-law and A-law companding standards employ logarithm based functions to encode audio samples for ISDN (Integrated Services Digital Network) digital telephony services by means of non-linear quantization.
μ-law companding
It is used in North America and Japan.
It uses the fact that low amplitude of speech signal contain more information than high amplitude.
Hence we can use non-linear quantization.
μ-law encoder inputs 14bit samples and outputs 8 bit codewords.
Since encoder receives 14 bit signed input sample x, the input range is (-8192, +8191).
This input sample is normalised to the interval (-1, +1) using the following logarithmic expression:
8 bit code = sgn(x) (ln[1+μ|x|])/(ln[1+μ])
Where sgn(x) = where μ=0 to 255.
- The 8-bit codeword in (-1, 1) is then scaled to the range (-256, 255) using following format recommended by G.711 standard.
P | S1 | S2 | S0 | Q3 | Q2 | Q1 | Q0 |
---|---|---|---|---|---|---|---|
Here, P represents the sign of the input sample. Bits S2, S1 and S0 are the segment code. Q3, Q2 and Q0 are the quantization code.
Encoder:
The encoder determines the segment code by adding a bias of 33 to the absolute value of input sample.
Determining the bit position of the most significant one bit among bits 5 to 12 of the input and subtracting 5 from that position.
The 4 bit quantization code is set to 4 bits following the bit position determined in step b.
The encoder ignores the remaining bits of the input sample and inverts the code word at its output.
Decoder:
The qunatization code is multiplied by 2 and then the bias of 33 is added to the result.
The result of step a. is multiplied by 2SC where SC is segment code.
This result is decremented by a bias of 33.
The sign of the result is determined using bit P.
A-law companding
Encoder:
The A-law encoder inputs 13 bit samples and outputs 8 bit code words.
The range of signed input is (-4096, +4095) and this input sample x is normalised to interval (-1, 1) using logarithmic expression.
8 bit code = sgn(x) (A |x|)/(1+ln(A)) for 0 ≤ |x|≤ 1/A
= sgn(x) (1+ln(A|x|))/(1+ln(A)) for 1/A ≤ |x| ≤ 1
This code word is then scaled to (-256, 255) using following format recommended by G.711 standard.
P | S1 | S2 | S0 | Q3 | Q2 | Q1 | Q0 |
---|---|---|---|---|---|---|---|
The bit pattern P determines the sign of the input samples.
The segment code is determined as
A) Determine the bit position of the most significant bit in the input.
B) If such a position is found, the segment code becomes the position determined in step a. minus 4 otherwise it becomes 0.
C) The 4 bit QC is set to the 4 bits following the bit position determined in step a. or half of the input value if the segment code is 0.
D) The encoder ignores the remaining bits of the input sample and it inverts the bit P and the even numbered bits of the code word bit it is output.
Decoder:
A) It inverts bit P and the even numbered bits of the code.
B) If the segment code is non-zero, the decoder multiplies the quantization code by 2 and increments this by a bias of 33. This result is then multiplied by $2^{SC}$ – 1.
C) Bit P is used to determine the sign of the output sample.