Professional Documents
Culture Documents
com
Audio Coding
Quantization and Coding
S. R. M. Prasanna
FaaDoOEngineers.com
Dept of ECE,
IIT Guwahati,
prasanna@iitg.ernet.in
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
Basis (contd.)
FaaDoOEngineers.com
www.jntuworld.com
Distortion Measurement
Objective Measure: Signal-to-Noise Ratio (SNR)
Subjective Measure: Mean Opinion Score (MOS)
SNR Measurement
Let x(n), y(n) and e(n) be the input, output and error
during reconstruction for given codec, respectively
e(n) = x(n) y(n)
Let x2 , y2 and e2 are the variances of x(n), y(n) and
e(n), respectively
Assuming signals of length M samples to be zero
mean
PM 2
2
u = 1/M n=1 u (n), where u = x, y or e
FaaDoOEngineers.com
SNR =
SNR =
SNR =
signalpower
noisepower
PM
2
x
(n)
Pn=1
M
2
n=1 e (n)
www.jntuworld.com
signalvariance
reconstructionerrorvariance
FaaDoOEngineers.com
SNR (dB) =
x2
10log10( e2 )
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
Classification (contd.)
FaaDoOEngineers.com
www.jntuworld.com
Uniform Quantization
Step size is constant
No. of quant. levels Q = 2Rb , where Rb no. of bits
Signal amplitude s has the range (smax , smax )
Step size =
2smax
2Rb
FaaDoOEngineers.com
2
eq
2
12
s2max 2Rb
3
www.jntuworld.com
Nonuniform Quantization
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
-law quantizer
|g(s)| =
log(1+|s/smax |)
log(1+)
A-law quantizer
|g(s)| =
A|s/smax |
(1+log(A))
|g(s)| =
1+log(A|s/smax |)
(1+log(A))
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
Vector Quantization
Quantization of a block of data (vector) at a time
Each block of input data is allotted a unique binary code
by comparing with codebook entries
At the receiver the same codebook will be present
Synthesis of data is done using the received binary
words as indices to codebook.
FaaDoOEngineers.com
www.jntuworld.com
Bit Allocation
FaaDoOEngineers.com
www.jntuworld.com
1 PNf
i=1 di
Nf
ith unquantized
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
i2
x2i
3(22ni )
Substituting for ni in
we get K =
N
Nf
PNf
i=1 ni = N and
QNf 2
1
2Nf log2 ( i=1 xi )
simplifying for K
www.jntuworld.com
N
Nf
x2i
1
2 log2 ( QNf 2 N1
( i=1 xi ) f
FaaDoOEngineers.com
Example: N = 16, N = 64,
f
www.jntuworld.com
FaaDoOEngineers.com
and
GM
AM
www.jntuworld.com
Entropy Coding
Min. No. of Bits required to represent given audio
frame.
For given message X , according to Shannon it will be
given by the entropy He (X)
Entropy is a measure of uncertainty of a random
variable
FaaDoOEngineers.com
Let X = [4, 5, 6, 6, 2, 5, 4, 4, 5, 4, 4] = N = 11
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
Requirements (contd.)
Illustration: X = [4, 5, 6, 6, 2, 5, 4, 4, 1, 4, 4]
Symbol Set V = [1, 2, 4, 5, 6] and Probabilities
pi = [1/11, 1/11, 5/11, 2/11, 2/11] K = 5
PK
Entropy He (X) = i=1 pi log2 (pi ) = 2.04
Total symbols Nf = 11, Total bits N = 33
Uniform coding = 33/11=3 bit/symbol
Shannon-Fano Coding = 24/11 = 2.18 bits/symbol
Huffmann Coding = 23/11 = 2.09 bits/symbol
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com
Uncompress using inverse of -law
Select a 50 ms segment, plot it in TD and FD
www.jntuworld.com
FaaDoOEngineers.com
www.jntuworld.com
FaaDoOEngineers.com