Quantization
Quantization
X
Q
Natural coding Gray Coding
+7 111 110
+5 110 111
+3 101 101
+1 100 100
-1 011 000
-3 010 001
-5 001 011
-7 000 010
With this gray code, a single bit error will result in
an amplitude error of only 2.
Unless the MSB is in error.
7
Waveforms in a PCM system for M=8
M=8
( ) d PCM Signal
( ) c Error
Signal
( ) , , b Analog Signal PAM Signal Quantized PAM
Signal
( ) a Quantizer Input output
characteristics
2
2 log ( )
is the number of Quantization levels
is thenumber of bits per sample
n
M n M
M
n
Quantization
Analog source has infinite levels
In order to process the source output
digitally, the source have to be
quantized to a finite number of levels
Reduce number of bits to a finite number
Introduce some distortion
Quantization error can be modeled as White
process
The information lost in the quantization
process can never be recovered
Classification of
quantization
Scalar Quantization
Each source output is quantized
individually
Further Divided into
Uniform quantization
Equal quantization region
Nonuniform quantization
Various length quantization region
Vector quantization
Blocks of source output are quantized
Scalar Quantization
( )
i i i
x Q x x
)
1
1
x
)
2
x
)
3
x
)
N
x
)
x
( ) Q x
Quantization Error
i
x x
)
Signal-to-Quantization-Noise
Ratio
Mean-Square Quantization Error
Where f
x
(x) denotes pdf(probability
density function) of the source
random variables
SQNR(Signal-to-Quantization-Noise
Ratio)
2
1
( ) ( )
i
N
i X
i
D x x f x dx
)
2
10
[ ]
10log
dB
E X
SQNR
D
Uniform Quantization
Equal quantization range
1
( ~ ] a
2
( , ] a a +
3
( , 2 ] a a + +
( ( 2) , )
N
a N +
1
x
)
2
x
)
3
x
)
N
x
)
a
Uniform Quantization
Optimal Quantization Level
The Centroid of the interval (Center of
mass)
)
Uniform Quantization
Symmetric pdf with even N (N=6)
Uniform Vs.
Gaussian
+ a 4
+ a 3
+ a 2
+ a
a
-
x
=0
6
x
)
5
x
)
4
x
)
3
x
)
2
x
)
1
x
)
+ a 4
+ a 3
+ a 2
+ a
a
-
x
=0
6
x
)
5
x
)
4
x
)
3
x
)
2
x
)
1
x
)
Center is given
Only one
parameter
is chosen to
minimize
distortion
Nonuniform Quantization
Uniform Vs.
Nonuniform
+ a 3
+ a 2
+ a
a
-
x
4
x
)
3
x
)
2
x
)
1
x
)
5
x
)
=0
a4
a3
a2
a1
-
x
4
x
)
3
x
)
2
x
)
1
x
)
5
x
)
=0
Different
Quantization
Region
Uniform
Quantization
Region
Nonuniform Quantization
Superior than Uniform quantization
Less Distortion
Higher SQNR
Lloyd-Max Conditions for optimal condition
) )
)
, 1
i
x i N
)
L
, 1
i
x i N
)
L
, 1
i
a i N L
Homework
Illustrative Problem 4.8
Problems
4.12
Uniform Quantization
Symmetric pdf with even N (N=5)
Uniform Vs.
Gaussian
+ a 3
+ a 2
+ a
a
-
x
4
x
)
3
x
)
2
x
)
1
x
)
5
x
)
=0
+ a 3
+ a 2
+ a
a
-
x
4
x
)
3
x
)
2
x
)
1
x
)
5
x
)
=0
Homework
Illustrative Problem
4.4, 4.5, 4.7
Problems
4.6, 4.7
20
2. Audio
2.3 Digitization
2.4.3 MP3
Contents
21
Audio: speech, music or synthesized
audio.
Audio signals are analog.
Audio Perception
T
f
1
24
2.2 Audio Bandwidth
25
Signal Characteristic
Example:
q
A signal may have infinite number of
components.
FIn this case, bandwidth is defined to be
the frequency range over which x% (say,
99%) of the energy of the signal lies.
29
2.2 Audio Bandwidth
Effect of Limited Bandwidth
q
If a network does not have sufficient
bandwidth to send all the frequency
components of a signal
Fsome frequency components are omitted
Fthe signal is distorted.
F
q
If a network has a larger bandwidth to
send more frequency components of an
audio signal
Fthe audio signal is relatively less distorted.
30
31
2.3 Digitization
Digitization: convert an analog audio
signal to digital form via sampling
and quantization.
Sampling
q
Sample the magnitude of the audio
signal at a certain rate.
32
2.3 Digitization
Example
Telephone systems transmit voice signal
. components with at most 4000 Hz Sampling
/ . rate should be 8000 samples sec
34
Quantization
q
If N bits are used to represent a
sample value, there are 2
N
distinct quantization values.
q
Each sample value is rounded
to the nearest quantization
value, so there may be
quantization error.
2.3
Digitization
35
2.3
Digitization
. . 2 4 1 Differential PCM
q Differential PCM . is a compressed version of PCM It
has
lower bit rate but its voice quality may be
. poorer
q Differential PCM
Voice signal changes slowly compared with the
. sampling rate
q Successive sample values have a small
. difference
q
q Use fewer bits to encode the difference
between the current sample value and the
. previous one
q
q , Lower bit rate but voice quality may be
degraded when voice amplitude changes
. abruptly
38
2.4 Audio
Compression
Exam ple
q , For PC M in digitaltelephony sam pling rate is 8000
/ . sam ples sec and 8 bits are used for each sam ple
. D ata rate is 64 kbps
q
q If differentialPC M is adopted and 6 bits are used to
encode the difference betw een successive sam ple
, . values data rate is reduced to 48 kbps
39
2.4 Audio
Compression
41
2.4 Audio
Compression
. . 2 4 3 MP3
. . - CD audio has a data rate of 1 411 Mbps Well known
: compression method for CD audio MP3.
q : . ( MP3 MPEG audio layer 3 MPEG
specifies three audio compression
.) layers
q
q MP3 adopts perceptual coding to
attain a high compression ratio
and provide very good audio
. quality
43
2.4 Audio
Compression
Perceptual Coding
q It is based on the science of psychoacoustics, which
. studies how people perceive sound
q
q It exploits certain flaws in the human auditory system
, for compression such that the compressed audio sounds
about the same to human even though its signal
. waveform may become quite different
44
2.4 Audio
Compression
Respond logarithmically to
intensity (amplitude) of light
Human ears
Respond to frequencies in 20 Hz to 20
kHz range
Discrete-to-continuous
conversion could be as
simple as sample and hold
Analog
Lowpass
Filter
Discrete
to
Continuou
s
Conversio
n
f
s
Lecture
7
Analog
Lowpass
Filter
Quantize
r
Sampler at
sampling
rate of f
s
Lecture
8
Lecture
4
74
Types of Quantizers
Quantization is an interpretation of a
continuous quantity by a finite set
of discrete values
Amplitude quantization approximates
its input by a discrete amplitude
taken from finite set of values
System Property Amplitude
Quantizer
Sampler Sampler +
Quantizer
Linearity Yes
Time-invariance No
Causality Yes
Memoryless Yes
, For the sampler stay in the continuous
time domain at the input and output to
decide on time invariance
75
Public Switched Telephone
Network
Sample voice signals at 8000
samples/s
Quantize voice to 8 bits/sample
+
+
x
y
= / 256 in US Japan and A = . 87 6 in
Europe
'
+
+
+
1
1
log 1
log 1
1
0
log 1
x
A
if
A
x A
A
x if
A
x A
y
Maximum
data rate?
kbps
law
x
1
1
y
A law
x
1
1
76
Uniform Quantization
Round to nearest integer (midtread)
Step size
1
3
3
1 2
2
3
2
3
2
,
`
.
|
1
3
3
1 2
) 2 ( 1
2
x
Q[x]
1 -2
-2
1
x
Q[x]
1 -2
-1
1
2
Used in
- slide 8
10
77
Handling Overflow
Example: Consider set of integers {-
2, -1, 0, 1}
Why 10 log
10
?
For amplitude A,
A
dB
= 20 log
10
A
With power P A
2
,
P
dB
= 10 log
10
A
2
P
dB
= 20 log
10
A
80
Dynamic Range in Audio
Sound Pressure Level (SPL)
Reference in dB SPL is 20 Pa
(threshold of hearing)
Noise is difference
of output and
input signals
Signal-to-noise
ratio (SNR)
derivation
Quantize to B bits
Quantization error
Assumptions
m (- m
max
, m
max
)
Uniform midrise
quantizer
Quantization error
(noise) is
uniformly
distributed
Number of
quantization
levels L = 2
B
is
large enough
so that
Q
B
[ ]
m v
m v m m Q q
B
] [
L L
1
1
1
82
Quantization Error (Noise)
Analysis
Deterministic signal x(t)
w/ Fourier transform
X(f)
Power spectrum is
square of absolute
value of magnitude
response (phase is
ignored)
Multiplication in Fourier
domain is convolution
in time domain
Conjugation in Fourier
domain is reversal &
conjugation in time
Autocorrelation of
x(t)
Maximum value
(when it exists) is
at R
x
(0)
R
x
( ) is even
symmetric,
i.e. R
x
( ) = R
x
(-
)
) ( ) ( ) ( ) (
*
2
f X f X f X f P
x
{ ) ( * ) ( ) ( ) (
* *
x x F f X f X
) ( * ) ( ) (
*
x x R
x
t
1
x(t)
0 T
s
R
x
( )
-T
s
T
s
T
s
83
Quantization Error (Noise)
Analysis
Two-sided random signal n(t)
+ + dt t n t n t n t n E R
n
) ( ) ( ) ( ) ( ) (
* *
{ ) ( * ) ( ) ( ) ( ) ( ) ( ) (
* * *
n n dt t n t n t n t n E R
n
84
Quantization Error (Noise)
Analysis
Quantizer step size
Quantization error
q is sample of zero-
mean random
process Q
q is uniformly
distributed
Input power:
P
average,m
SNR exponential in
B
Adding 1 bit
increases SNR by
factor of 4
Derivation of SNR
in deciBels on
next slide
L
m
L
m
max max
2
1
2
2 2
q
{
B
Q
zero
Q Q
m
Q E
2 2
max
2
2
2 2 2
2
3
1
12
B
Q
m
P P
2
2
max
m average,
2
m average,
2
3
SNR
Power Noise
Power Signal
SNR
,
`
.
|
85
Quantization Error (Noise)
Analysis
SNR in dB = constant + 6.02 dB/bit *
B
,
`
.
|
,
`
.
|
'
<
> +
0
3 / 1
0 0
0 0
0
3 / 1
0 0
for
for
for
) (
V v v V V
V v V v
V v V v V
v A
'
<
>
0 0
0 0
0 0
for
for
for
) (
V v V
V v V v
V v V
v D
Optional