Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of...

29
1 1 @NTUEE DSP/IC Lab Fundamentals of Lossy Video Compression 2 @NTUEE DSP/IC Lab Image Sequence Model time

Transcript of Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of...

Page 1: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

1

1@NTUEE DSP/IC Lab

Fundamentals of Lossy Video Compression

2@NTUEE DSP/IC Lab

Image Sequence Model

time

Page 2: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

2

3@NTUEE DSP/IC Lab

Two-stage video coding process

Fig 4.2

4@NTUEE DSP/IC Lab

Stage 1 : Reducing Temporal Redundancy

• Segment a frame into macroblocks.

• Output energy is increased with the degree of temporalredundancy.

• Interframe coder .

Page 3: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

3

5@NTUEE DSP/IC Lab

Stage 2 : Reducing Spatial Redundancy

• Processing the difference frame (spatially correlated )from stage 1.

• Using DCT coding.

• Intraframe coder.

• Hybrid coding method.

6@NTUEE DSP/IC Lab

Motion Compensation

• The process of compensating for the displacement ofmoving objects from one frame to another.

• It is preceded by motion estimation.

• Similar with DPCM.

Page 4: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

4

7@NTUEE DSP/IC Lab

22 vuk +=

4.3

8@NTUEE DSP/IC Lab

Performance Evaluation

• 2-D correlated ( intraframe )

• Differencing ( interframe )

• Motion-compensation ( interframe )

• Hybrid ( interframe /intraframe )

Questions before using interframe coding:• How does intraframe coding compare to interframe

coding?• How do hybrid coding schemes compare to

intraframe or interframe coding alone?• Does the added complexity of motion compensation warrant its use

Page 5: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

5

9@NTUEE DSP/IC Lab

• K is the displacement distance

• K>8 offers no improvement,means no correlation

• All cases show that FD isgood enough. Intraframecoding does the job best .

Frame differencing with no motion compensation

4.522 vuk +=

10@NTUEE DSP/IC Lab

Motion-compensated prediction

• There are 40%improvement evenat high motion-estimation error of+/- 1 pixel.

• Different motionprecision achievedifferentperformance.

4.6

DR e

2

2log2

1 σ=

Page 6: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

6

11@NTUEE DSP/IC Lab

Motion-compensated predictionv.s. intraframe coding

4.7

12@NTUEE DSP/IC Lab

Hybrid Coding: Motion-compensated video followedby intraframe coding

4.8

• Hybrid coding can getbetter results.

Page 7: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

7

13@NTUEE DSP/IC Lab

Rate-distortion functions for Hybrid, interframe,and intraframe video coding

4.9

14@NTUEE DSP/IC Lab

R(D) Summary

4.10

Page 8: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

8

15@NTUEE DSP/IC Lab

Motion-compensated prediction

• Hybrid coding method is quite effective.

• In interframe coding , the motion-estimationproblem takes an important role.

16@NTUEE DSP/IC Lab

Motion Compensation Algorithmsin Video Coding

Page 9: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

9

17@NTUEE DSP/IC Lab

Motion Estimation

q Objective Predict current frame from neighboring frames

q Motion Estimation Algorithm– Pixel-based method (Pel-Recursive Algorithm)

• Large computation overhead

– Block-based method

• Regularity and simplicity

• Suitable for hardware implementation

– Object-based method (content-based)A Crucial to make possible a high degree of video

compression

18@NTUEE DSP/IC Lab

Block-Matching Motion EstimationBlock-Matching Motion Estimation

Motion Vector

Search Range

Current Frame

Reference Frame

Xt(p,q)

the block at location (p,q) in t-th frame

Motion Vector Vt(p.q) =(Veci,Vecj)

Ω

Ω the location in the search rangethat has the maximum correlation value between blocks in temporally adjacent frames

Page 10: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

10

19@NTUEE DSP/IC Lab

Factors of Affecting Block-Matching Algorithm(BMA)

+Search Algorithm

+Match Criterion

+Search Range

N+2p

N+2pp

N

N

Current Frame Block

Search Range in Reference Frame

20@NTUEE DSP/IC Lab

PPPB BB B B B B B

P: Predict FrameB: Bi-directional Frame

H.261

MPEGH.263

I

I

I

I: Intra Frame

Coding of Moving Pictures

Page 11: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

11

21@NTUEE DSP/IC Lab

Search Algorithmsp Two-Dimensional Full Search(2DFS)

– Exhaustive search

– Extremely Large Computation

p Fast Search– Assumption: Monotonic Distortion Function

– Reduce computation at the expense of accuracy

m 2-D Logarithmic Search

m Modified 2-D Logarithmic Search

m Three-Step Hierarchical Search

m Cross Search

m One-at-a-time Search

m Parallel Hierarchical One-Dimensional Search

m One-Dimensional Full Search

Brief Review of Previous AlgorithmsBrief Review of Previous Algorithms

22@NTUEE DSP/IC Lab

Fast Search Algorithms

Page 12: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

12

23@NTUEE DSP/IC Lab

24@NTUEE DSP/IC Lab

0 Hardware-Oriented

0 Full Data Reuse

0 Regular Data Flow

0 Fixed-Step Operation

0 Good Performance

One-Dimensional Full Search

Ref: Mei-Juan Chen, Liang-Gee Chen and Tzi-Dar Chiueh, “One-Dimensional Full Search Motion Estimation Algorithm for Video Coding”, IEEE Transactions on Circuits and Systems for Video Technology, Vol.4, No.5, October 1994.

For (i= -P to +P) Veci’= i | min D(i,j)

For (j= -P to +P) Vecj’= j | min D(Veci’,j)

For (i= -P/2 to +P/2) Veci = i | min D(i+Veci’,Vecj’)

For (j= -P/2 to +P/2) Vecj = j | min D(Veci,j+Vecj’)

Motion Vector = (Veci,Vecj)

Fast Search Algorithms

Page 13: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

13

25@NTUEE DSP/IC Lab

Performance Comparison

Miss America Train Calendar Table Tennis

PSNR (dB )

2DFS 38.64 19.57 25.48

1DFS 38.39 19.45 24.55

3Step 38.20 19.40 24.06

Entropy (bits/pixel)

2D FS 3.49 5.93 5.27

1DFS 3.52 5.94 5.39

3Step 3.56 5.94 5.47

30 frames/sec Sequences

26@NTUEE DSP/IC Lab

Matching Criteria

m Cross-Correlation Function(CCF)

m Mean Squared Error(MSE)

m Mean Absolute Error(MAE)

m Pel Difference Classification(PDC)

m Minimized Maximum Error (MiniMax)

xt(k,l) : luminance for the location (k,l) in Xt(p,q)xt-1(k+i,l+j) : luminance for the shifted location by i pels and j lines within the search range

Page 14: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

14

27@NTUEE DSP/IC Lab

Matching Criteria

Cross-Correlation Function(CCF)

CCF(i,j)=

(Veci,Vecj)=(i,j) | max CCF(i,j)

x k l x k i l j

x k l x k i l j

t tl

N

k

N

tl

N

k

N

tl

N

k

N

( , ) ( , )

( , ) ( , )

⋅ −==

==−

==

+ +

+ +

∑∑

∑∑ ∑∑

111

2

11

1

2

12

11

1

2

Mean Squared Error(MSE)

MSE(i,j)=

(Veci,Vecj)=(i,j) | min MSE(i,j)

[ ]12 1

2

11Nx k l x k i l jt t

l

N

k

N

( , ) ( , )− + +−==∑∑

--> most widely used in software

28@NTUEE DSP/IC Lab

Matching Criteria

Mean Absolute Error(MAE)

MAE(i,j)=

(Veci,Vecj)=(i,j) | min MAE(i,j)

12 1

11Nx k l x k i l jt t

l

N

k

N

( , ) ( , )− + +−==∑∑

Pel Difference Classification(PDC)

T k l i j x k l x k i l j Threshold

otherwise

t t( , , , ) , ( , ) ( , )

,

= − + + ≤−1

0

1

G(i,j)= T k l i jl

N

k

N

( , , , )== ∑∑ 11

(Veci,Vecj)=(i,j) | max G(i,j)

Most Widely Used in hardwareMost Widely Used in hardware

Page 15: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

15

29@NTUEE DSP/IC Lab

Matching Criteria

Minimized Maximum Error (MiniMax)

G(i,j)= max | (Veci,Vecj)= (i,j) | min G(i,j)

x k l x k i l jt t( , ) ( , )− + +−1

8-bit Subtractor

AbsoluteFunction

16-bitAccumulator

8-bit Subtractor

AbsoluteFunction

8-bitComparator

PE of MAE

PE of MiniMax

HardwareReduction

30@NTUEE DSP/IC Lab

Architecture Design and Chip Implementation

m One-Dimensional Full Search

m MiniMax Criterion

Technology 0.8 um CMOS

Chip Size 6.5 mm x 5.3 mm

Number of

Transistors

48170

Chip Clock 43 MHz

Number of Pads 61

Power Dissipation 383 mW

Page 16: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

16

31@NTUEE DSP/IC Lab

Subjective Quality

Min-max MAE

Min-max MAE

Table Tennis I

Table Tennis II

1DFS’

32@NTUEE DSP/IC Lab

Min-max MAE

Min-max MAE

Salesman

Train & Calendar

Page 17: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

17

33@NTUEE DSP/IC Lab

Other Approaches: Pixel Subsampling for MAE calculations

34@NTUEE DSP/IC Lab

• For each MAE value , we use only 1/4 of the pixels.

• But every pixel in the block will be used.

• It minimizes the possibility of not considering one-pixel-wide horizontal , vertical and diagonal lines .

Pixel Subsampling for MAE calculations

Page 18: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

18

35@NTUEE DSP/IC Lab

Projections for MAE calculations

36@NTUEE DSP/IC Lab

Predictive Motion EstimationPredictive Motion Estimation Using Boundary/Side Match Using Boundary/Side Match

1 MotivationmRelieve huge computation complexity imposed

on full search for large search range motionestimation

mMPEG and HDTV applications

mLittle attention paid in the past

1 GoalmProvide solutions for the computation reduction

of increasing search area

mObject-based concept

Page 19: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

19

37@NTUEE DSP/IC Lab

p Temporal Prediction

mInter-Frame Prediction

p Spatial Prediction

mInter-Block Prediction

mMedian Vector Prediction

mProposed Boundary Match Prediction

mProposed Side Match Prediction

(e.g. one-quarter of search range )

Predictive Motion Estimation Algorithms

δωV p qt ( , )

V p q E V p q V p q V p qt t t t( , )

[( , )] ( , ) , ( , )= + ≤δ δ ω

E V p qt[

( , )] :Predicted Motion Vector

:Refined Displacement

:Reduced Search Range

Ω

38@NTUEE DSP/IC Lab

E V p q V p qt t[

( , )] ( , )= −1

E V p q V p qt s[

( , )] ( , )=E V p q Median Vt

v V cs

[

( , )] arg=∈

Inter-Frame Prediction

Inter-Block Prediction Median Vector Prediction

V V p q V p q V p qcs t t t= − − + − ( , ), ( , ), ( , )1 1 1 1

Page 20: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

20

39@NTUEE DSP/IC Lab

Boundary/Side Match

0A motion object often covers many small blocks

0Blocks in the same object have similar motion vectors

0Spatial Neighboring Blocks– Very likely move in the same direction with similar velocities

– Highly correlated or dependent

0Utilize the high spatial correlation between theboundary pixels of adjacent blocks to determinea more accurate initial motion estimation center

0Other applications– Vector quantization (VQ)

– Recovery of lost vector or channel error

– Transform coded image reconstruction

40@NTUEE DSP/IC Lab

Boundary Match

X(p,q)

X(p,q-1)

X(p-1,q)

[ ][ ]

[ ] [ ]

[ ] [ ]

X p q x x x

X p q x x x

d X p q X p q

d X p q X p q

E

l

c

l l l nT

l

r

l l n l

bm V p q j

r

n j

r

j

n

bm V p q j

c

n j

c

j

n

t

t

( , ) ( , , , )

( , ) ( , , , )

( , ) ( , )

( , ) ( , )

[

, ( , ) , ,

, ( , ) , ,

=

=

= − −

= − −

−=

−=

1 2

1 2

1 11

1 11

1

1

L

L

( , )] arg ,V p q Min dt

v Vbm v

cs

=∈

V V p q V p qcs t t= − − ( , ), ( , )1 1

column vector

row vector

Page 21: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

21

41@NTUEE DSP/IC Lab

Side Match

Xc(p,q)

X(p,q-1)

X(p-1,q) X(p+1,q)

X(p,q+1)V V p q V p q V p qcs t t t= − − + − ( , ), ( , ), ( , )1 1 1 1

[ ] [ ]

[ ] [ ]

[ ] [ ]

[ ] [ ]

d X p q X p q

d X p q X p q

d X p q X p q

d X p q X p q

d

smU MC j

r

n j

r

j

n

smL MC j

c

n j

c

j

n

smR MC n j

c

j

c

j

n

smD MC n j

r

j

r

j

n

sm

= − −

= − −

= − +

= − +

=

=

=

=

=

( , ) ( , )

( , ) ( , )

( , ) ( , )

( , ) ( , )

, ,

, ,

, ,

, ,

11

11

11

11

1

1

1

1

d d d d

E V p q Min d

smU smL smR smD

tv V

sm vcs

+ + +

=∈

[( , )] arg ,

dsmL

dsmD

dsmU

dsmR

minimum gray-level transition across four boundaries

42@NTUEE DSP/IC Lab

Computation Comparison

Algorithms Search Range Computation Complexity

( SD/block )

Full Search -p ~ p (2p+1)2 x m x n

Inter- Frame -p/2 ~ p/2 (p+1)2 x m x n

Inter- Block -p ~ p - p/2 ~ p/2 [ 1/4(2p+1)2 + 3/4(p+1)2 ] x m x n

Median - p/2 ~ p/2 (p+1)2 x m x n +6

Boundary Match - p/2 ~ p/2 (p+1)2 x m x n + m + n

Side Match - p/2 ~ p/2 (p+1)2 x m x n+ 6( m + n )

Page 22: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

22

43@NTUEE DSP/IC Lab

Objective Performance Measurement

PSNRMSE

= ×10255

10

2

log

)(1

22 log)()(log)(iep

iii

ii epepepEntropy ⋅=⋅−= ∑∑

Entropy of Prediction Error (bits/pixel)

PSNR: Peak-to-Peak Signal-to-Noise Ratio

(dB)

predicted image compared to the original image

p ei( ) : probability of occurrence of prediction error pattern

44@NTUEE DSP/IC Lab

PSNR Comparison

Algorithms 30 frames/sec 15 frames/sec 10 frames/sec

Full Search 27.33 26.90 26.49

Inter-Frame 25.73 25.23 24.66

Inter-Block 26.09 25.52 25.22

Median 25.57 24.93 24.23

Boundary Match 26.40 26.03 25.68

Side Match 26.52 26.17 25.77

IDFS 26.23 25.09 24.49

3-Step 24.94 23.06 23.26

Block size 8x8 60 frames Table Tennis Sequence

Page 23: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

23

45@NTUEE DSP/IC Lab

vs Frame Number

46@NTUEE DSP/IC Lab

Error Entropy vs Frame Number

Page 24: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

24

47@NTUEE DSP/IC Lab

Frame Rate 30 frames/sec 15 frames/sec 10 frames/sec

Algorithms ED HR ED HR ED HR

Inter-Frame 23.52 72.92% 60.05 67.50% 74.67 62.46%

Inter-Block 13.05 76.88% 54.54 71.37% 72.82 67.55%

Median 20.63 73.33% 57.15 66.98% 82.41 60.64%

Boundary Match 10.08 79.70% 47.88 74.76% 66.91 70.73%

Side Match 9.97 80.93% 46.08 75.72% 65.18 71.86%

IDFS 26.71 61.97% 95.13 41.74% 132.27 31.55%

3-Step 23.14 50.81% 100.92 30.39% 144.47 23.80%

Motion Vector Characteristics

MV Euclidean Distance(ED) (Vx-V ) +(V -V )

Hit Ratio(HR) |V -V |<=2 and |V -V |<=2Criterion:

@NTUEE DSP/IC Lab

Motion Vector Distribution

2DFS Side Match

1DFS 3Step

block size 8x8 15 frames/sec Table Tennis Sequence

Page 25: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

25

49@NTUEE DSP/IC Lab

Subjective Quality16x16 blocks15 frames/sec Table Tennis Sequence

Original 2DFS

Inter-Frame Inter-Block Boundary Match

1DFS 3Step Side Match

50@NTUEE DSP/IC Lab

Hierarchical Motion Estimation

Page 26: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

26

51@NTUEE DSP/IC Lab

Hierarchical Motion Estimation

Level 2

52@NTUEE DSP/IC Lab

Hierarchical Motion Estimation

Level 1

Page 27: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

27

53@NTUEE DSP/IC Lab

54@NTUEE DSP/IC Lab

• It requires increased storage to keep pictures at differentresolutions.

• Motion vector may be inaccurate for regions containingsmall objects .

• Low-pass filter can reduce noise.

Hierarchical Motion Estimation

Page 28: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

@NTUEE DSP/IC Lab

Operations Comparison of Motion-Estimation Methods

56@NTUEE DSP/IC Lab

Page 29: Fundamentals of Lossy Video Compressionlad.dsc.ufcg.edu.br/multimidia/lossy_video.pdf · Factors of Affecting Block-Matching Algorithm(BMA) +Search Algorithm +Match Criterion +Search

29

57@NTUEE DSP/IC Lab

Sub-pixel-accurate motion estimation

58@NTUEE DSP/IC Lab

Bidirectional Temporal Prediction forProgressive Video

• Reference frame must be I or P-frame

• B-picture

• 2 MV