Discete cosine transform (DCT)


Quantization


Zigzag ordering

Zigzag ordering is to convert a two-dimensional array to a one-dimensional sequence run-length coding. The MPEG-2 stardard introduced a new run-length entropy scanning pattern (on the right hand side), it is more efficient for the interlaced video signal.

A sample of a macro block

-22

17

1

1

0

0

0

0

-21

-15

1

0

0

0

0

0

11

3

-4

0

0

0

0

0

-3

2

2

0

0

0

0

0

0

-1

-1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

Run-Amplitude pairs of above DCT block is as following:

Zigzap scanning

Run

0

0

0

0

0

0

0

0

0

0

7

0

0

0

Amplitude

-22

-21

11

-3

17

-15

1

1

3

2

-1

2

-4

1

EOF

Alternative scanning

Run

0

0

0

0

0

0

0

0

0

0

1

0

5

0

3

Amplitude

-22

17

-21

11

-15

1

1

1

3

-3

2

-4

2

-1

-1

EOF


Entropy coding

Symbol

Probability

A

0.39

B

0.24

C

0.18

D

0.09

E

0.07

F

0.03

.

Symbol Probability

.

A

0.39

.

B

0.24

.

C

0.18

(0)E 0.07 \
(1)F 0.03 /

M

0.10

.

D

0.09

.

 .

Symbol

Probability

 .

A

0.39

.

.

B

0.24

(0) E 0.07 \
(1) F 0.03 /

(0) M 0.10 \

N

0.19

.

(1) D 0.09 /

.

.

C

0.18

.

 .

.

Symbol

Probability

 .

 .

.

A

0.39

(0) E 0.07 \
(1) F 0.03 /

(0) M 0.10 \

(0) N 0.19

O

0.27

.

(1) D 0.09 /

.

.

(1) C 0.18

.

.

.

B

0.24

.

 .

.

.

Symbol

Probability

(0) E 0.07 \
(1) F 0.03 /

(0) M 0.10 \

(0) N 0.19 \

(0) O 0.27 \





(0) P





0.27

.

(1) D 0.09 /

.

.

(1) C 0.18 /

.

.

.

(1) B 0.24 /

.

.

.

.

(1) A

0.39

Symbol

Probability

Code

A

0.39

1

B

0.24

01

C

0.18

001

D

0.09

0001

E

0.07

00000

F

0.03

00001