<<

Why needs Compression? Video Compression Applications z Typical NTSC video z Cable TV distribution 460x340=148000 pels/frame, 30 frames/sec, 16 bits/pel (YIQ) z Interactive communications—videophone, videoconferencing, videotex. =71 Mbps z Digital storage —CD-ROM, CD-V, digital VTR. z Bandwidth are limited resource and expensive z Network database services video library, video information provider. z Storage—enormous for z Video-on-demand z Compression processing—relative cheap z z Video Camera, VCR, TV Receiver z Video surveillance z Comparison of NTSC and HDTV

Reference: “Discrete Cosine Transform Algorithms, Advantages, Application”, Rao and Yip, Academic Press, 1990.

chow CS525—DCT——Page 1- chow CS525—DCT——Page 2-

Applications vs. Bit Rates Why can video data be compressed?

Application Standard Range Fax CCITT G3/G4/JBIG 4.8-14.4 kbps Redundancy Still Image JPEG 56/64 kbps z Intraframe Videophone (analog) 9.6-19.2 kbps z Interframe Videophone (digital) CCITT H.261 px64 64-128 kbps Videoconferencing CCITT H.261 px64 320-1920 kbps Entertainment video MPEG 1-3 Mbps Broadcast video MPEG II 4-10 Mbps Intraframe JPEG JPEG 10-20 Mbps Digital VCR MPEG II 8-20 Mbps NTSC (very high quality) CCIR/ANSI 34/45 Mbps HDTV (broadcasting) FCC(US only) 20-25 Mbps HDTV (studio) 30-45 Mbps

chow CS525—DCT——Page 3- chow CS525—DCT——Page 4- Compression Techniques Concept z Spatial domain—DPCM, Transform, Subband, Vector quantization z Why can data be compressed?—Redundancy z Temporal domain—frame difference, z Orthogonal transform: —decorrelate data into a more compact form so that redundancy can be discarded more easily.

Y Y’

X’

X

chow CS525—DCT——Page 5- chow CS525—DCT——Page 6-

Orthogonal Transforms A typical Transform Coder/Decoder z There are many of them: Which is better? Input Blocking FDCT Thresholder Karhunen-Loeve Transform (KLT) Image optimal, complete decorrelates the random functions in its transform domain. Discrete Fourier Transform (DFT) Binary bit stream ZigZag Scan Discrete Slant Transform Entropy Quantizer Discrete Cosine Transform (DCT) 1974 Coder 1-D sequencing Discrete Sine Transform (DST) Coder Discrete Hadamard/Walsh Transform (DHT) Discrete Harr Transform

Entropy Inverse z DCT emerges as the choice of transform for Dequantizer —fast algorithms Decoder ZigZag Scan —performance (quality) Reconstructed —data-independent Output Image Thresholder Block IDCT Integration Compensator Decoder chow CS525—DCT——Page 7- chow CS525—DCT——Page 8- 2D-Discrete Cosine Transform (DCT) Example of 2D-DCT f(x,y) F(u,v) z 8x8 FDCT/IDCT formula 7 7 f(0,0) f(1,0) f(2,0) f(3,0) f(4,0) f(5,0) f(6,0) f(7,0) F(0,0) F(1,0) F(2,0) F(3,0) F(4,0) F(5,0) F(6,0) F(7,0) 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 1 ()2x + 1 uπ ()2y + 1 vπ 10000000 Fuv(), = ---Cu()Cv() fxy(), cos------cos ------4 ∑ ∑ 16 16 f(0,1) f(1,1) f(2,1) f(3,1) f(4,1) f(5,1) f(6,1) f(7,1)f F(0,1) F(1,1) F(2,1) F(3,1) F(4,1) F(5,1) F(6,1) F(7,1) 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 00000000 7 7 x = 0y = 0 F(0,2) F(1,2) F(2,2) F(3,2) F(4,2) F(5,2) F(6,2) F(7,2) 1 ()2x + 1 uπ ()2y + 1 vπ f(0,2) f(1,2) f(2,2) f(3,2) f(4,2) f(5,2) f(6,2) f(7,2)f fxy(), = --- Cu()Cv()Fuv(), cos------cos ------0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 00000000 4 ∑ ∑ 16 16 F(0,3) F(1,3) F(2,3) F(3,3) F(4,3) F(5,3) F(6,3) F(7,3) f(0,3) f(1,3) f(2,3) f(3,3) f(4,3) f(5,3) f(6,3) f(7,3)f x = 0 y = 0 00000000 () 1 () 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 where Ck = ------if k = 0 , otherwise Ck = 1 F(0,4) F(1,4) F(2,4) F(3,4) F(4,4) F(5,4) F(6,4) F(7,4) 2 f(0,4) f(1,4) f(2,4) f(3,4) f(4,4) f(5,4) f(6,4) f(7,4)f 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 00000000 z Separability property F(0,5) F(1,5) F(2,5) F(3,5) F(4,5) F(5,5) F(6,5) F(7,5) 7 7 f(0,5) f(1,5) f(2,5) f(3,5) f(4,5) f(5,5) f(6,5) f(7,5)f 00000000 1 1 ()2x + 1 uπ ()2y + 1 vπ 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 Fuv(), = ---Cu()∑ ---Cv()∑ fxy(), cos------cos ------F(0,6) F(1,6) F(2,6) F(3,6) F(4,6) F(5,6) F(6,6) F(7,6) 2 2 16 16 f(0,6) f(1,6) f(2,6) f(3,6) f(4,6) f(5,6) f(6,6) f(7,6)f 00000000 x = 0y = 0 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 The 2-D FDCT can be implemented by 1-D 8-point FDCT along the rows of F(0,7) F(1,7) F(2,7) F(3,7) F(4,7) F(5,7) F(6,7) F(7,7) f(0,7) f(1,7) f(2,7) f(3,7) f(4,7) f(5,7) f(6,7) f(7,7)f 00000000 fxy(), followed by 1-D 8-point FDCT along the columns of the matrix obtained 0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125 after the row transformation. 7 7 1 ()2x + 1 0π ()2y + 1 0π F()00, = ---C()0 C()0 fxy(), cos------cos------4 ∑ ∑ 16 16 x = 0y = 0

F(0,0)=1/4*1/2*(64*0.125)=1 C()0 = 1 ⁄ 2 chow CS525—DCT——Page 9- chow CS525—DCT——Page 10-

1D-DCT Properties of 1D-DCTs

7 -1 1 ()2x + 1 uπ z Only DCT-I and DCT-IV are involutary (F=F ) z 8-point DCT definition Fu()= ---Cu()∑ fx()cos ------2 16 z Inverse DCT-II≠DCT-II x = 0 z Consider f as a vector of n point data and F as a vector of transformed values z Since Matrix multiplication is a linear operation, all four DCTs retain linearity the above transformation can be represent by matrix operations F=cAf properties. F[ax + by] = aFx + bFy. z There are four different 1D-DCTs, the DCT-II was the first to be studied. z For properties related to scaling in time, shift in time, differentiation in time, and the convolution, see [DCT9x] by Rao and Yip.

chow CS525—DCT——Page 11- chow CS525—DCT——Page 12- A Fast 1D-DCT Algorithm Fast 1D-DCT based on Sparse Matrix Factorization based on Sparse Matrix Factorization This matrix operation needs only 2 additions and 2 subtractions. C()2 2 12/ ---- The 1D-DCT can be represented as X =  AN x 1 1 1 1 N ------00 x ------00 x + x Here we show how A4 can be decomposed into three sparser matrices. 1000 2 2 10 0 1 1 1000 2 2 1 x x + x Ci = cos[]iπ ⁄ k 0001 1 3 01 1 0 2 0001 1 3 2 k x ==C4 C4 00 C4 C4 00 1 1 1 1 0100 01Ð0 1 x 0100 x Ð x ------00ÐC1 C3 3 00ÐC1 C3 2 1000 2 2 2 2 0010 8 8 10 0Ð 1 x 0010 8 8 x Ð x 3 1 4 3 1 1 0001 1 3 3 1 00C8 C8 00C8 C8 C4 C4 C4 C4 0100 C3 ÐC1 C1 ÐC3 1 1 1 1 0010 8 8 8 8 This matrix operation needs 8 multiplications, 3 additions, and 1 subtraction. ------C1 C3 ÐC3 ÐC1 2 2 2 2 matrix 8 8 8 8 1 1 1 1 1 3 5 7 A = ------()x + x + ------()x + x ------()x + x + ------()x + x A = C C C C 4 1 4 2 3 1 4 2 3 4 8 8 8 8 factorization 1000 2 2 2 2 2 6 6 2 1 1 0001 1()3() 3()1() C8 C8 C8 C8 ------00 A x ==C4 x1 + x4 + C4 x2 + x3 C8 x2 Ð x3 + C8 x1 Ð x4 1000 2 2 10 0 1 4 3 7 1 5 0100 1()3() 1()3() C8 C8 C8 C8 0001 1 3 01 1 0 ÐC8 x2 Ð x3 + C8 x1 Ð x4 C4 x1 + x4 + C4 x2 + x3 C4 C4 00 0010 0100 01Ð0 1 3()1() 1()3() 1 3 C8 x2 Ð x3 + C8 x1 Ð x4 ÐC8 x2 Ð x3 + C8 x1 Ð x4 00ÐC8 C8 [A ]x requires 16 multiply 0010 10 0Ð 1 4 00C3 C1 This matrix operation involves only the shuffling (moving) of data and 12 add 8 8 Here [A4]x requires only 8 multiply and 8 add In total, there are only 8 multiplications, 5 additions, and 3 subtractions. chow CS525—DCT——Page 13- chow CS525—DCT——Page 14-

Mapping Matrices to Flowgraph Example: Mapping matrices to signal flowgraph z Matrix operations can be mapped to the signal flowgraph representations. z Signal flowgraphs can be mapped to the VLSI implementation very easily. 1 1 z ------00 x Signal flowgraphs can be mapped to equivalent implementations. 1000 2 2 10 0 1 1 z Signal flowgraphs make it easy to capture redundant data movement. 0001 1 3 01 1 0 x2 A x = C4 C4 00 0100 01Ð0 1 x 00ÐC1 C3 3 Steps: Map y=A A A x to the equivalent signal flowgraph (A is a NxN matrix) 0010 8 8 10 0Ð 1 x N 2 1 i 3 1 4 00C8 C8 A A 1. Draw N nodes top-down on the left hand side of a drawing area, label them 3 A2 1 x0(0) to x0(N-1). These are original values of input vector x. x0(0) x1(0) 1 x3(0)=y(0) ------x2(0) 2. To the left of x0, draw N nodes and label them x1(0) to x1(N-1). x1 is the result 2 1 C1 ------of A1x. 4 2 x0(1) 3. Examine values in A1. For each of the x0 elements, say x0(i), that contributes to x1(1) x2(1) x3(1)=y(1) C3 x1(j) draw an arrow from x0(i) to x1(j) with its A1 coefficient as label. E.g., 4 assume that x1(i)=A1(i,1)x0(1)+A1(i,3)x0(3) where A1(i,1) and A1(i,3) are the only non-negative elements in row A (i). Draw an arrow with label A (i,1) from x0(2) 1 1 1 x1(2) ÐC8 x2(2) x3(2)=y(2) x0(1) to x1(i). Draw an arrow with label A1(i,3) from x0(3) to x1(i). These arrows -1 3 represent the “flows” of signal from left to right. Coefficient of 1 is not labelled. C8 4. Repeat Steps 2 and 3 for (A , x2), (A , x3),..., and (A , xN). x0(3) 3 2 3 N -1 x1(3) 1 C8 x2(3) x3(3)=y(3) C8 5. xN is the same as y. A A1 A2 3 chow CS525—DCT——Page 15- chow CS525—DCT——Page 16- Algorithm for DCT-II, N=8 and its signal flowgraph Signal Flowgraph of DCT-II, N=8

Z. Wang, “Fast algorithms for the discrete W transform and for the discrete Fourier transform,” IEEE Trans. Accoust., Speech, and Signal Process., vol. ASSP-32, pp.8x3-816, Aug. 1984.

chow CS525—DCT——Page 17- chow CS525—DCT——Page 18-

IDCT-II, N=8 and its signal flowgraph Signal Flowgraph of IDCT-II, N=8

chow CS525—DCT——Page 19- chow CS525—DCT——Page 20- Comparison of Fast DCT-II Algorithms Exercises z Develop the program which implements the 1D-DCT-II in Page 1x with straight and compile the Fortran program given in the handout which implements Wang’s Fast DCT-II and IDCT-II. z Generate some random data to test and compare the performance of these two DCT-II implementations. z Compare the original data with the reconstructed data generated by applying Wang’s IDCT-II on the transformed data generated by applying Wang’s DCT- II on the original data, and discuss the impact of the computation errors introduced by round-off and truncation). z You can work as a group for this assignment.

chow CS525—DCT——Page 21- chow CS525—DCT——Page 22-