Vous êtes sur la page 1sur 95

# 3: Discrete Cosine Transform

• DFT Problems
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary 3: Discrete Cosine Transform
• MATLAB routines

DFT Problems

## 3: Discrete Cosine Transform

• DFT Problems
For processing 1-D or 2-D signals (especially coding), a common method is
• DCT + to divide the signal into “frames” and then apply an invertible transform to
• Basis Functions
• DCT of sine wave each frame that compresses the information into few coefficients.
• DCT Properties
• Energy Conservation The DFT has some problems when used for this purpose:
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

DFT Problems

## 3: Discrete Cosine Transform

• DFT Problems
For processing 1-D or 2-D signals (especially coding), a common method is
• DCT + to divide the signal into “frames” and then apply an invertible transform to
• Basis Functions
• DCT of sine wave each frame that compresses the information into few coefficients.
• DCT Properties
• Energy Conservation The DFT has some problems when used for this purpose:
• Energy Compaction
N
• Frame-based coding
• Lapped Transform +
• N real x[n] ↔ N complex X[k] : 2 real, 2 − 1 conjugate pairs
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

DFT Problems

## 3: Discrete Cosine Transform

• DFT Problems
For processing 1-D or 2-D signals (especially coding), a common method is
• DCT + to divide the signal into “frames” and then apply an invertible transform to
• Basis Functions
• DCT of sine wave each frame that compresses the information into few coefficients.
• DCT Properties
• Energy Conservation The DFT has some problems when used for this purpose:
• Energy Compaction
N
• Frame-based coding
• Lapped Transform +
• N real x[n] ↔ N complex X[k] : 2 real, 2 − 1 conjugate pairs
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

DFT Problems

## 3: Discrete Cosine Transform

• DFT Problems
For processing 1-D or 2-D signals (especially coding), a common method is
• DCT + to divide the signal into “frames” and then apply an invertible transform to
• Basis Functions
• DCT of sine wave each frame that compresses the information into few coefficients.
• DCT Properties
• Energy Conservation The DFT has some problems when used for this purpose:
• Energy Compaction
N
• Frame-based coding
• Lapped Transform +
• N real x[n] ↔ N complex X[k] : 2 real, 2 − 1 conjugate pairs
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## • DFT ∝ the DTFT of a periodic signal formed by replicating x[n] .

⇒ Spurious frequency components from boundary discontinuity.

N=20

f=0.08

DFT Problems

## 3: Discrete Cosine Transform

• DFT Problems
For processing 1-D or 2-D signals (especially coding), a common method is
• DCT + to divide the signal into “frames” and then apply an invertible transform to
• Basis Functions
• DCT of sine wave each frame that compresses the information into few coefficients.
• DCT Properties
• Energy Conservation The DFT has some problems when used for this purpose:
• Energy Compaction
N
• Frame-based coding
• Lapped Transform +
• N real x[n] ↔ N complex X[k] : 2 real, 2 − 1 conjugate pairs
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## • DFT ∝ the DTFT of a periodic signal formed by replicating x[n] .

⇒ Spurious frequency components from boundary discontinuity.

N=20

f=0.08

DCT +

## To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in

3: Discrete Cosine Transform
• DFT Problems
• DCT + reverse order and insert a zero between each pair of samples:
• Basis Functions
• DCT of sine wave y[r]
• DCT Properties
• Energy Conservation
• Energy Compaction →
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT) 0 12 23
• MDCT Basis Elements
Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
• Summary
• MATLAB routines

DCT +

## To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in

3: Discrete Cosine Transform
• DFT Problems
• DCT + reverse order and insert a zero between each pair of samples:
• Basis Functions
• DCT of sine wave y[r]
• DCT Properties
• Energy Conservation
• Energy Compaction →
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT) 0 12 23
• MDCT Basis Elements
Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
• Summary
• MATLAB routines Result is real, symmetric and anti-periodic:
Y[k]

12
0 23

DCT +

## To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in

3: Discrete Cosine Transform
• DFT Problems
• DCT + reverse order and insert a zero between each pair of samples:
• Basis Functions
• DCT of sine wave y[r]
• DCT Properties
• Energy Conservation
• Energy Compaction →
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT) 0 12 23
• MDCT Basis Elements
Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
• Summary
• MATLAB routines Result is real, symmetric and anti-periodic: only need first N values
Y[k]

12 ÷2
0 23 −→

DCT +

## To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in

3: Discrete Cosine Transform
• DFT Problems
• DCT + reverse order and insert a zero between each pair of samples:
• Basis Functions
• DCT of sine wave y[r]
• DCT Properties
• Energy Conservation
• Energy Compaction →
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT) 0 12 23
• MDCT Basis Elements
Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
• Summary
• MATLAB routines Result is real, symmetric and anti-periodic: only need first N values
Y[k]

12 ÷2
0 23 −→

PN −1
Forward DCT: XC [k] = n=0 x[n] cos 2π(2n+1)k
4N for k = 0 : N − 1

DCT +

## To form the Discrete Cosine Transform (DCT), replicate x[0 : N − 1] but in

3: Discrete Cosine Transform
• DFT Problems
• DCT + reverse order and insert a zero between each pair of samples:
• Basis Functions
• DCT of sine wave y[r]
• DCT Properties
• Energy Conservation
• Energy Compaction →
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT) 0 12 23
• MDCT Basis Elements
Take the DFT of length 4N real, symmetric, odd-sample-only sequence.
• Summary
• MATLAB routines Result is real, symmetric and anti-periodic: only need first N values
Y[k]

12 ÷2
0 23 −→

PN −1 2π(2n+1)k
Forward DCT: XC [k] = n=0 x[n] cos 4N for k = 0 : N − 1
1 2
PN −1 2π(2n+1)k
Inverse DCT: x[n] = N X[0] + N k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

Basis Functions

## 3: Discrete Cosine Transform

1
PN −1 kn
• DFT Problems DFT basis functions: x[n] = N k=0 X[k]ej2π N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

P −1 2π(2n+1)k
1
DCT basis functions: x[n] = N X[0] + N2 N
k=1 X[k] cos 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 4 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m
• Basis Functions
• DCT of sine wave
f= N
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
x[n] N=20
f=0.10
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m
• Basis Functions
• DCT of sine wave
f= N
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
x[n] N=20
f=0.10
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

|XF [k]|

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m m
• Basis Functions
• DCT of sine wave
f= N f 6= N
• DCT Properties
• Energy Conservation
• Energy Compaction x[n] N=20 N=20
• Frame-based coding
f=0.10 f=0.08
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines |XF [k]|

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m m
• Basis Functions
• DCT of sine wave
f= N f 6= N
• DCT Properties
• Energy Conservation
• Energy Compaction x[n] N=20 N=20
• Frame-based coding
f=0.10 f=0.08
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines |XF [k]|

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m m
• Basis Functions
• DCT of sine wave
f= N f 6= N
• DCT Properties
• Energy Conservation
• Energy Compaction x[n] N=20 N=20
• Frame-based coding
f=0.10 f=0.08
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines |XF [k]|

## DFT: Real→Complex; Freq range [0, 1]; Poorly localized unless

−1
f= mN ; |X F [k]| ∝ k for N f < k ≪ N
2

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m m
• Basis Functions
• DCT of sine wave
f= N f 6= N
• DCT Properties
• Energy Conservation
• Energy Compaction x[n] N=20 N=20
• Frame-based coding
f=0.10 f=0.08
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines |XF [k]|

|XC [k]|

## DFT: Real→Complex; Freq range [0, 1]; Poorly localized unless

f= Nm
; |XF [k]| ∝ k −1 for N f < k ≪ N 2

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT of sine wave

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems DCT: XC [k] = n=0 4N
• DCT +
m m
• Basis Functions
• DCT of sine wave
f= N f 6= N
• DCT Properties
• Energy Conservation
• Energy Compaction x[n] N=20 N=20
• Frame-based coding
f=0.10 f=0.08
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines |XF [k]|

|XC [k]|

## DFT: Real→Complex; Freq range [0, 1]; Poorly localized unless

f= N m
; |XF [k]| ∝ k −1 for N f < k ≪ N 2
DCT: Real→Real; Freq range [0, 0.5]; Well localized ∀f ;
|XC [k]| ∝ k−2 for 2N f < k < N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 5 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding • Symmetric: X[−k] = X[k] since cos −αk = cos +αk
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding • Symmetric: X[−k] = X[k] since cos −αk = cos +αk
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements • Anti-periodic: X[k + 2N ] = −X[k]
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding • Symmetric: X[−k] = X[k] since cos −αk = cos +αk
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements • Anti-periodic: X[k + 2N ] = −X[k] because:
• Summary
• MATLAB routines
◦ 2π(2n + 1)(k + 2N ) = 2π(2n + 1)k + 8πN n + 4N π
◦ cos (θ + π) = − cos θ

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding • Symmetric: X[−k] = X[k] since cos −αk = cos +αk
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements • Anti-periodic: X[k + 2N ] = −X[k] because:
• Summary
• MATLAB routines
◦ 2π(2n + 1)(k + 2N ) = 2π(2n + 1)k + 8πN n + 4N π
◦ cos (θ + π) = − cos θ
⇒X[N ] = 0 since X[N ] = X[−N ] = −X[−N + 2N ]

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

DCT Properties

PN −1
x[n] cos 2π(2n+1)k
3: Discrete Cosine Transform
• DFT Problems Definition: X[k] = n=0 4N
• DCT +
• Basis Functions
• DCT of sine wave
• Linear: αx[n] + βy[n] → αX[k] + βY [k]
• DCT Properties
• Energy Conservation • “Convolution←→Multiplication” property of DFT does not hold /
• Energy Compaction
• Frame-based coding • Symmetric: X[−k] = X[k] since cos −αk = cos +αk
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements • Anti-periodic: X[k + 2N ] = −X[k] because:
• Summary
• MATLAB routines
◦ 2π(2n + 1)(k + 2N ) = 2π(2n + 1)k + 8πN n + 4N π
◦ cos (θ + π) = − cos θ
⇒X[N ] = 0 since X[N ] = X[−N ] = −X[−N + 2N ]
• Periodic: X[k + 4N ] = −X[k + 2N ] = X[k]

## DSP and Digital Filters (2017-10120) Transforms: 3 – 6 / 14

Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14

Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2
• Summary Energy: E = n=0 |x[n]|
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14

Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2 1 2 2
PN −1 2
• Summary Energy: E = n=0 |x[n]| = N |X[0]| + N n=1 |X[n]|
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14

Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2 1 2 2
PN −1 2
• Summary Energy: E = n=0 |x[n]| = N |X[0]| + N n=1 |X[n]|
• MATLAB routines
In diagram above: E → 2E→ 8N E→≈ 0.5N E

## DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14

Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2 1 2 2
PN −1 2
• Summary Energy: E = n=0 |x[n]| = N |X[0]| + N n=1 |X[n]|
• MATLAB routines
In diagram above: E → 2E→ 8N E→≈ 0.5N E

2
|X[n]|2 )
P P
Orthogonal DCT (preserves energy: |x[n]| =

## Note: MATLAB dct() calculates the ODCT

DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14
Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2 1 2 2
PN −1 2
• Summary Energy: E = n=0 |x[n]| = N |X[0]| + N n=1 |X[n]|
• MATLAB routines
In diagram above: E → 2E→ 8N E→≈ 0.5N E

2
|X[n]|2 )
P P
Orthogonal DCT (preserves energy: |x[n]| =
q P
 1 N −1 x[n] k=0
N n=0
ODCT: X[k] = q
 2 PN −1 x[n] cos 2π(2n+1)k k =
6 0
N n=0 4N

## Note: MATLAB dct() calculates the ODCT

DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14
Energy Conservation

## 3: Discrete Cosine Transform PN −1 2π(2n+1)k

• DFT Problems DCT: X[k] = n=0 x[n] cos 4N
−1
X[0] + N2 k=1 X[k] cos 2π(2n+1)k
N
• DCT +
1
P
• Basis Functions IDCT: x[n] = N 4N
• DCT of sine wave
Y[k]
• DCT Properties y[r]
• Energy Conservation
rep DFT 12 ÷2
• Energy Compaction → → 0 23 →
• Frame-based coding
• Lapped Transform + 0 12 23
• MDCT (Modified DCT)
• MDCT Basis Elements PN −1 2 1 2 2
PN −1 2
• Summary Energy: E = n=0 |x[n]| = N |X[0]| + N n=1 |X[n]|
• MATLAB routines
In diagram above: E → 2E→ 8N E→≈ 0.5N E

2
|X[n]|2 )
P P
Orthogonal DCT (preserves energy: |x[n]| =
q P
 1 N −1 x[n] k=0
N n=0
ODCT: X[k] = q
 2 PN −1 x[n] cos 2π(2n+1)k k = 6 0
N n=0 4N
q q P
1 2 N −1 2π(2n+1)k
IODCT: x[n] = N X[0] + N k=1 X[k] cos 4N

## Note: MATLAB dct() calculates the ODCT

DSP and Digital Filters (2017-10120) Transforms: 3 – 7 / 14
Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
p
• DCT Properties Example: Markov Process: x[n] = ρx[n − 1] + 1 − ρ2 u[n]
• Energy Conservation
• Energy Compaction
where
u[n] is i.i.d. unit Gaussian.
• Frame-based coding Then x2 [n] = 1 and hx[n]x[n − 1]i = ρ.
• Lapped Transform +
Covariance of vector x is Si,j = xx i,j = ρ|i−j| .

H
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
p
• DCT Properties Example: Markov Process: x[n] = ρx[n − 1] + 1 − ρ2 u[n]
• Energy Conservation
• Energy Compaction
where
u[n] is i.i.d. unit Gaussian.
• Frame-based coding Then x2 [n] = 1 and hx[n]x[n − 1]i = ρ.
• Lapped Transform +
Covariance of vector x is Si,j = xx i,j = ρ|i−j| .

H
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines
Suppose ODCT of x is Cx
D and DFT isEFx.
H
Covariance of Cx is Cxx CH = CSCH (similarly FSFH )
Diagonal elements give mean coefficient energy.

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
p
• DCT Properties Example: Markov Process: x[n] = ρx[n − 1] + 1 − ρ2 u[n]
• Energy Conservation
• Energy Compaction
where
u[n] is i.i.d. unit Gaussian.
• Frame-based coding Then x2 [n] = 1 and hx[n]x[n − 1]i = ρ.
• Lapped Transform +
Covariance of vector x is Si,j = xx i,j = ρ|i−j| .

H
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines
Suppose ODCT of x is Cx
D and DFT isEFx.
H
Covariance of Cx is Cxx CH = CSCH (similarly FSFH )
Diagonal elements give mean coefficient energy.

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
p
• DCT Properties Example: Markov Process: x[n] = ρx[n − 1] + 1 − ρ2 u[n]
• Energy Conservation
• Energy Compaction
where
u[n] is i.i.d. unit Gaussian.
• Frame-based coding Then x2 [n] = 1 and hx[n]x[n − 1]i = ρ.
• Lapped Transform +
Covariance of vector x is Si,j = xx i,j = ρ|i−j| .

H
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines
Suppose ODCT of x is Cx
D and DFT isEFx.
H
Covariance of Cx is Cxx CH = CSCH (similarly FSFH )
Diagonal elements give mean coefficient energy.
• Used in MPEG and JPEG (superseded by
JPEG2000 using wavelets)
• Used in speech recognition to decorrelate
spectral coeficients: DCT of log spectrum

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Energy Compaction

## 3: Discrete Cosine Transform

• DFT Problems
If consecutive x[n] are positively correlated, DCT concentrates energy in a
• DCT + few X[k] and decorrelates them.
• Basis Functions
• DCT of sine wave
p
• DCT Properties Example: Markov Process: x[n] = ρx[n − 1] + 1 − ρ2 u[n]
• Energy Conservation
• Energy Compaction
where
u[n] is i.i.d. unit Gaussian.
• Frame-based coding Then x2 [n] = 1 and hx[n]x[n − 1]i = ρ.
• Lapped Transform +
Covariance of vector x is Si,j = xx i,j = ρ|i−j| .

H
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines
Suppose ODCT of x is Cx
D and DFT isEFx.
H
Covariance of Cx is Cxx CH = CSCH (similarly FSFH )
Diagonal elements give mean coefficient energy.
• Used in MPEG and JPEG (superseded by
JPEG2000 using wavelets)
• Used in speech recognition to decorrelate
spectral coeficients: DCT of log spectrum

## Energy compaction good for coding (low-valued coefficients can be set to 0)

Decorrelation good for coding and for probability modelling

## DSP and Digital Filters (2017-10120) Transforms: 3 – 8 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
• DCT of sine wave X[k] k=30/220
• DCT Properties
• Energy Conservation
y[n]
• Energy Compaction
• Frame-based coding y[n]-x[n]
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
X[k] k=30/220
• DCT of sine wave
• DCT Properties
• Apply DCT to each frame
• Energy Conservation
y[n]
• Energy Compaction
• Frame-based coding y[n]-x[n]
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
X[k] k=30/220
• DCT of sine wave
• DCT Properties
• Apply DCT to each frame
• Energy Conservation
y[n]
• Energy Compaction • Encode DCT
• Frame-based coding y[n]-x[n]
• Lapped Transform
• MDCT (Modified DCT)
+
◦ e.g. keep only 30 X[k]
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
X[k] k=30/220
• DCT of sine wave
• DCT Properties
• Apply DCT to each frame
• Energy Conservation
y[n]
• Energy Compaction • Encode DCT
• Frame-based coding y[n]-x[n]
• Lapped Transform
• MDCT (Modified DCT)
+
◦ e.g. keep only 30 X[k]
• MDCT Basis Elements
• Summary • Apply IDCT → y[n]
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
X[k] k=30/220
• DCT of sine wave
• DCT Properties
• Apply DCT to each frame
• Energy Conservation
y[n]
• Energy Compaction • Encode DCT
• Frame-based coding y[n]-x[n]
• Lapped Transform
• MDCT (Modified DCT)
+
◦ e.g. keep only 30 X[k]
• MDCT Basis Elements
• Summary • Apply IDCT → y[n]
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14

Frame-based coding

## 3: Discrete Cosine Transform

• DFT Problems
• Divide continuous signal
x[n]
• DCT + into frames
• Basis Functions
X[k] k=30/220
• DCT of sine wave
• DCT Properties
• Apply DCT to each frame
• Energy Conservation
y[n]
• Energy Compaction • Encode DCT
• Frame-based coding y[n]-x[n]
• Lapped Transform
• MDCT (Modified DCT)
+
◦ e.g. keep only 30 X[k]
• MDCT Basis Elements
• Summary • Apply IDCT → y[n]
• MATLAB routines

## Problem: Coding may create discontinuities at frame boundaries

e.g. JPEG, MPEG use 8 × 8 pixel blocks

## 8.3 kB (PNG) 1.6 kB (JPEG) 0.5 kB (JPEG)

DSP and Digital Filters (2017-10120) Transforms: 3 – 9 / 14
Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave
• DCT Properties x[n] N 2N 3N 4N
• Energy Conservation
• Energy Compaction
• Frame-based coding X0[k]
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements y0[n]
• Summary
• MATLAB routines

0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation
• Energy Compaction
• Frame-based coding X0[k]
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements y0[n]
• Summary
• MATLAB routines

0 N 2N 3N 4N

MDCT: 2N → N coefficients

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements y0[n]
• Summary
• MATLAB routines

0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

IMDCT
• MATLAB routines
→ y1 [N : 3N − 1] y1[n]

0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
X2[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

IMDCT
• MATLAB routines
→ y1 [N : 3N − 1] y1[n]
y2[n]

x[2N : 4N − 1]
MDCT
→ X2 [2N : 3N − 1]
0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
X2[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

IMDCT
• MATLAB routines
→ y1 [N : 3N − 1] y1[n]
y2[n]

x[2N : 4N − 1]
MDCT
→ X2 [2N : 3N − 1]
IMDCT
→ y2 [2N : 4N − 1] 0 N 2N 3N 4N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
X2[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

IMDCT
• MATLAB routines
→ y1 [N : 3N − 1] y1[n]
y2[n]

x[2N : 4N − 1] y[n]
MDCT
→ X2 [2N : 3N − 1]
IMDCT
→ y2 [2N : 4N − 1] 0 N 2N 3N 4N

## y[n] = y0 [n] + y1 [n] + y2 [n]

MDCT: 2N → N coefficients, IMDCT: N → 2N samples
Add yi [n] together to get y[n]. Only two non-zero terms far any n.

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

Lapped Transform +

## 3: Discrete Cosine Transform

• DFT Problems
Modified Discrete Cosine Transform (MDCT): overlapping frames 2N long
• DCT +
• Basis Functions x[0 : 2N − 1]
• DCT of sine wave MDCT
• DCT Properties → X0 [0 : N − 1] x[n] N 2N 3N 4N
• Energy Conservation IMDCT
• Energy Compaction → y0 [0 : 2N − 1]
• Frame-based coding X0[k]
• Lapped Transform
• MDCT (Modified DCT)
+
x[N : 3N − 1] X1[k]
X2[k]
MDCT
• MDCT Basis Elements
• Summary
→ X1 [N : 2N − 1] y0[n]

IMDCT
• MATLAB routines
→ y1 [N : 3N − 1] y1[n]
y2[n]

x[2N : 4N − 1] y[n]
MDCT
→ X2 [2N : 3N − 1] y[n]-x[n] = error
IMDCT
→ y2 [2N : 4N − 1] 0 N 2N 3N 4N

## y[n] = y0 [n] + y1 [n] + y2 [n]

MDCT: 2N → N coefficients, IMDCT: N → 2N samples
Add yi [n] together to get y[n]. Only two non-zero terms far any n.
Errors cancel exactly: Time-domain alias cancellation (TDAC)

## DSP and Digital Filters (2017-10120) Transforms: 3 – 10 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N

## If x and X are column vectors, then X = Mx

2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
If x and X are column vectors, then X = Mx
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
1
If x, X and y are column vectors, then X = Mx and y = N MT X
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
1
If x, X and y are column vectors, then X = Mx and y = N MT X = N1 MT Mx
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
1
If x, X and y are column vectors, then X = Mx and y = N MT X = N1 MT Mx
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .
1
Quasi-Orthogonality: The 2N × 2N matrix, N MT M, is almost the identity:
   
  1 ··· 0 0 ··· 1
I−J 0  . .  .. . .. 
1 T
NM M = 1
with I =  .. . . . ..  , J =  .

2 0 I+J . . . 
0 ··· 1 1 ··· 0

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
1
If x, X and y are column vectors, then X = Mx and y = N MT X = N1 MT Mx
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .
1
Quasi-Orthogonality: The 2N × 2N matrix, N MT M, is almost the identity:
   
  1 ··· 0 0 ··· 1
I−J 0  . .  .. . .. 
1 T
NM M = 1
with I =  .. . . . ..  , J =  .

2 0 I+J . . . 
0 ··· 1 1 ··· 0
When two consective y frames are overlapped by N samples, the second half of the
first frame has thus been multiplied by 21 (I + J) and the first half of the second frame
by 21 (I − J). When these y frames are added together, the corresponding x samples
have been multiplied by 12 (I + J) + 12 (I − J) = I giving perfect reconstruction.

## DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14

MDCT (Modified DCT)

P2N −1
MDCT: X[k] = n=0 x[n] cos 2π(2n+1+N
8N
)(2k+1)
0≤k<N
PN −1
IMDCT: y[n] = 1
N k=0 X[k] cos 2π(2n+1+N
8N
)(2k+1)
0 ≤ n < 2N
1
If x, X and y are column vectors, then X = Mx and y = N MT X = N1 MT Mx
2π(2n+1+N )(2k+1)
where M is an N × 2N matrix with mk,n = cos 8N .
1
Quasi-Orthogonality: The 2N × 2N matrix, N MT M, is almost the identity:
   
  1 ··· 0 0 ··· 1
I−J 0  . .  .. . .. 
1 T
NM M = 1
with I =  .. . . . ..  , J =  .

2 0 I+J . . . 
0 ··· 1 1 ··· 0
When two consective y frames are overlapped by N samples, the second half of the
first frame has thus been multiplied by 21 (I + J) and the first half of the second frame
by 21 (I − J). When these y frames are added together, the corresponding x samples
have been multiplied by 12 (I + J) + 12 (I − J) = I giving perfect reconstruction.
Normally the 2N -long x and y frames are windowed before the MDCT and again after
the IMDCT to avoid any discontinuities; if the window is symmetric and satisfies
w2 [i] + w2 [i + N ] = 2 the perfect reconstruction property is still true.
DSP and Digital Filters (2017-10120) Transforms: 3 – 11 / 14
MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 12 / 14

MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
1
• Energy Conservation In vector notation: X = Mx and y = N MT X = N1 MT Mx
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 12 / 14

MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
1
• Energy Conservation In vector notation: X = Mx and y = N MT X = N1 MT Mx
• Energy Compaction
• Frame-based coding
• Lapped Transform + The rows of M form the
• MDCT (Modified DCT)
• MDCT Basis Elements
MDCT basis elements.
• Summary
• MATLAB routines

## DSP and Digital Filters (2017-10120) Transforms: 3 – 12 / 14

MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
1
• Energy Conservation In vector notation: X = Mx and y = N MT X = N1 MT Mx
• Energy Compaction
• Frame-based coding
• Lapped Transform + The rows of M form the
• MDCT (Modified DCT)
• MDCT Basis Elements
MDCT basis elements.
• Summary
• MATLAB routines

Example (N = 4):

M= 
0.56 0.20 −0.20 −0.56 −0.83 −0.98 −0.98 −0.83
 −0.98
 −0.56 0.56 0.98 0.20 −0.83 −0.83 0.20 
 0.20 0.83 −0.83 −0.20 0.98 −0.56 −0.56 0.98 
0.83 −0.98 0.98 −0.83 0.56 −0.20 −0.20 0.56

## DSP and Digital Filters (2017-10120) Transforms: 3 – 12 / 14

MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
1
• Energy Conservation In vector notation: X = Mx and y = N MT X = N1 MT Mx
• Energy Compaction
• Frame-based coding
• Lapped Transform + The rows of M form the
• MDCT (Modified DCT)
• MDCT Basis Elements
MDCT basis elements.
• Summary
• MATLAB routines

Example (N = 4):

M= 
0.56 0.20 −0.20 −0.56 −0.83 −0.98 −0.98 −0.83
 −0.98
 −0.56 0.56 0.98 0.20 −0.83 −0.83 0.20 
 0.20 0.83 −0.83 −0.20 0.98 −0.56 −0.56 0.98 
0.83 −0.98 0.98 −0.83 0.56 −0.20 −0.20 0.56

## DSP and Digital Filters (2017-10120) Transforms: 3 – 12 / 14

MDCT Basis Elements

P2N −1
x[n] cos 2π(2n+1+N )(2k+1)
3: Discrete Cosine Transform
• DFT Problems MDCT: X[k] = n=0 8N 0≤k<N
• DCT +
PN −1
1
X[k] cos 2π(2n+1+N )(2k+1)
• Basis Functions
• DCT of sine wave IMDCT: y[n] = N k=0 8N 0 ≤ n < 2N
• DCT Properties
1
• Energy Conservation In vector notation: X = Mx and y = N MT X = N1 MT Mx
• Energy Compaction
• Frame-based coding
• Lapped Transform + The rows of M form the
• MDCT (Modified DCT)
• MDCT Basis Elements
MDCT basis elements.
• Summary
• MATLAB routines

Example (N = 4):

M= 
0.56 0.20 −0.20 −0.56 −0.83 −0.98 −0.98 −0.83
 −0.98
 −0.56 0.56 0.98 0.20 −0.83 −0.83 0.20 
 0.20 0.83 −0.83 −0.20 0.98 −0.56 −0.56 0.98 
0.83 −0.98 0.98 −0.83 0.56 −0.20 −0.20 0.56

The basis frequencies are {0.5, 1.5, 2.5, 3.5} times the fundamental.

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x ←

x

• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +
 ←

• Equivalent to a DFT of time-shifted double-length x x

• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←
− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N
• Aliasing errors cancel out when overlapping output frames are added

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N
• Aliasing errors cancel out when overlapping output frames are added
• Similar to DCT for energy compaction and decorrelation ,

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N
• Aliasing errors cancel out when overlapping output frames are added
• Similar to DCT for energy compaction and decorrelation ,
• Overlapping windowed frames can avoid edge discontinuities ,

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N
• Aliasing errors cancel out when overlapping output frames are added
• Similar to DCT for energy compaction and decorrelation ,
• Overlapping windowed frames can avoid edge discontinuities ,
• Used in audio coding: MP3, WMA, AC-3, AAC, Vorbis, ATRAC

Summary

## 3: Discrete Cosine Transform

DCT: Discrete Cosine Transform
• DFT Problems
• DCT +

• Equivalent to a DFT of time-shifted double-length x x ←− 
• Basis Functions
• DCT of sine wave • Often scaled to make an orthogonal transform (ODCT)
• DCT Properties
• Energy Conservation
• Better than DFT for energy compaction and decorrelation ,
• Energy Compaction ◦ Energy Compaction: Most energy is in only a few coefficients
• Frame-based coding
• Lapped Transform +
◦ Decorrelation: The coefficients are uncorrelated with each other
• MDCT (Modified DCT) • Nice convolution property of DFT is lost /
• MDCT Basis Elements
• Summary
• MATLAB routines MDCT: Modified Discrete Cosine Transform
• Lapped transform: 2N → N → 2N
• Aliasing errors cancel out when overlapping output frames are added
• Similar to DCT for energy compaction and decorrelation ,
• Overlapping windowed frames can avoid edge discontinuities ,
• Used in audio coding: MP3, WMA, AC-3, AAC, Vorbis, ATRAC
For further details see Mitra: 5.

MATLAB routines

## 3: Discrete Cosine Transform

• DFT Problems dct, idct ODCT with optional zero-padding
• DCT +
• Basis Functions
• DCT of sine wave
• DCT Properties
• Energy Conservation
• Energy Compaction
• Frame-based coding
• Lapped Transform +
• MDCT (Modified DCT)
• MDCT Basis Elements
• Summary
• MATLAB routines