Вы находитесь на странице: 1из 6

Coding Requirements

Let us consider the general requirements uncompressed CD quality stereo audio


imposed on most multimedia systems: stream needs 176400 bytes=sec. A raw
digitised PAL TV signal needs
Storage — multimedia elements require
(13:5M H z + 6:75M H z + 6:75M H z )  8bits
COMP3600 Multimedia Systems much more storage space than simple
= 216  106bits=sec
text. For example, a full screen true = 27  106 Bytes=sec:
Data Compression colour image is
640  480  3 = 921600 bytes:
Interaction — to support fast interaction, the
end-to-end delay should be small. A
Wai Wong
The size of one second of uncompressed ‘face-to-face’ application, such as video
CD quality stereo audio is conferencing, requires the delay to be
44 1: kHz  2  2 = 176400 bytes: less than 50ms. Furthermore, multimedia
elements have to be accessed randomly.
The size of one second of uncompressed
PAL video is Conclusion:

384  288   3 25 frames = 8294400 bytes:  Multimedia elements are very large.
Throughput — continuous media require  We need to reduce the data size using
very large throughput. For example, an compression.

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 1 (199901) Slide 2

Kinds of coding methods Categories of Compression Techniques


 lossless — the compression process D = D’’
does not reduce the amount of informa-
Run-length coding
tion.
Entropy coding Huffman coding
Compression Decompression Arithmetic coding
The original can be reconstructed ex- Prediction DPCM
actly. DM
D’ Source coding Transformation FFT
DCT
Vector Quantisation
D not = D’’
JPEG
 lossy — the compression process re-
Hybrid coding MPEG
H.261
duces the amount of information. Compression Decompression
 Entropy coding is lossless.
Only an approximation of the original can  Source coding and hybrid coding are lossy.
be reconstructed. D’

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 3 (199901) Slide 4
Coding techniques Run-length coding
 Vector Quantisation — a data stream is Since the code is shorter than the data Digital images, audio and video data For example:
divided into blocks of n bytes (where n > pattern, compression is achieved. The stream often contain sequences of the same
ABCD CCCCCCCC
| {z } DBEC
1 ). A predefined table contains a set of popular zip application used this method bytes.
compressed to
patterns is used to code the data blocks. to compress files.
#
 LZW — a general compression algorithm ABCD C !8 DBEC
capable of working on almost any type  Differential coding — (also know as By replacing the sequence with its length,
prediction or relative coding) The most In practice, there are many variances of this
of data. It builds a data dictionary a substantial reduction of data can be
known coding of this kind is DPCM (Dif- basic compression techniques.
of data occurring in an uncompressed achieved.
ferential Pulse Code Modulation). This One particular variance, known as zero
data stream. Patterns of data are
method encodes the difference between suppression, assumes that only one symbol
identified and are matched to entries in
the consecutive samples instead of the in the data stream appear very often, for
the dictionary. When a match is found
sample values. For example, A special flag that does not occur in the example, a 0 in scanned text. A sequence
the code of the entry is output.
data can be used to indicate the length of of zeros is replaced by a flag and the number
Pattern Code sequence. of occurrences.
Begin 1 PCM 215 218 210 212 208 . . .
End 2 DPCM 215 3 -8 2 -4 . . .
tion 3
... ...
DM (Delta Modulation) is a modification
Input function Begin x := 3; . . . of DPCM. The difference is coded with a
Output func@3 @1@4 . . . single bit.
COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 5 (199901) Slide 6

Tabulators Huffman coding


A further variation is known as tabulators.  makeup code for 128 white pixels — 10010
The principle of Huffman coding is to  the two entries in the probability table is
A table of symbols is defined to replace  terminating code for 4 white pixels — 1011 assign shorter code for symbol that has replaced by a new entry whose value is
sequences of different lengths of identical higher probability of occurring in the data the sum of the probabilities of the two
White Codes Black Codes
bytes/bits. For example, the CCITT Group 0 00110101 0 0000110111 stream. characters.
3 compression scheme defines the coding 1 000111 1 010
table shown. 2 0111 2 11
The length of the Huffman code is optimal.
For example, a data stream has only
 repeat the two steps above until there
3 1000 3 10 is only one entry and a binary tree
For example,
4 1011 4 011 five symbols ABCDE with the following
11100000111100 containing all characters is formed.
5 1100 5 0011 probabilities:
is coded as 6
7
1110
1111
6
7
0010
00011
p(A) = :
0 16  assign 0 to the left branches and 1 to the
1011000110111
8 10011 8 000101 p(B ) = :
0 51
right branches of the binary tree.
The compression ratio can be up to 10 : 1
to 20 : 1. The codes for run-length of 0 to
10
9 10100
00111
9
10
000100
0000100
p(C ) = 0:09
 the Huffman code of each character can
64 are known as terminating codes. For run-
   
p(D) = 0:13 be read from the tree starting from the
length longer than 64 bits, it is encoded using
more than one code. One or more makeup 64 11011 64 0000001111 p(E ) = 0:11 root.
codes represent multiple of 64 bits of the run- 128 10010 128 000011001000
192 010111 192 000011001001 A 011
length, and this is followed by a terminating
    A huffman code tree is created using the B 1
code. For example, the run-length of 132
white pixels is encoded by the following two 1728 01001011 1728 0000001100101 following procedures: C 000
codes: EOL 000000000001 EOL 00000000000
 two characters with the lowest probabili- D 010
ties are combined to form a binary tree. E 001

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 7 (199901) Slide 8
An example of Huffman code tree JPEG
 JPEG (stands for Joint Photographic The JPEG standard have three levels of
p(AD)
=0.29
Experts Group) is a joint ISO and CCITT definition as follows:

p(CE)
working group for developing standards
for compressing still images
 Baseline system — must reasonably
=0.20 decompress colour images, maintain a
p(D) =0.13 p(A)=0.16 Completed Tree  The JPEG image compression standard high compression ratio, and handle from
STEP 2 became an international standard in 4bits/pixel to 16bits/pixel.
p(ABCDE)
p(C) =0.09 p(E)=0.11 =1.00 1992
 Extended system — covers the various
 JPEG can be applied to colour or gray-
0 1
STEP 1 encoding aspects such as variable-
p(CEAD)
scale images length encoding, progressive encoding,
p(B)=0.51

0
=0.49
1  By changing appropriate parameters, the and hierarchical mode of encoding.
p(CEAD)
=0.49 user can select  Special lossless function — ensures that
p(CE) p(AD)
– the quality of the reproduced image at the resolution at which the image is
=0.20 =0.29
1
compressed, decompression results in
0 1 0 – compression processing time
p(CE)=0.20 p(AD)=0.29
no loss of any detail the was in the
– the size of the compressed image original image.
p(C) =0.09 p(E)=0.11 p(D) =0.13 p(A)=0.16
STEP 3

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 9 (199901) Slide 10

JPEG Compression Process JPEG — Preparation

Entropy
Preparation Processing encoding

 A source image consists of at least one and at most


Run-length
- Pixel - Predictor - Quantisation - - C
n

Huffman
255 planes.
C3
Block, MCU FDCT  Each plane Ci may have different number of pixels C2
Arithmetic in the horizontal (Xi) and vertical (Yi) dimension. C1

 The resolution of the individual plane may be


different. ...
...
.

 Each pixel is represented by a number of bits p


where 2  p  12. .....
..
..... Y i

 The meaning of the value in these planes is not


specified in the standard. .....
.. ..... ..... ........
...
..
.....
...

 The image is divided into  8 8 blocks. X i

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 11 (199901) Slide 12
JPEG — Discrete Cosine Transform JPEG — Quantisation
 DCT transforms the data from a spatial  The DCT algorithm is symmetrical, and  The DCT output matrix is quantised to coefficient can be dropped to reduce the
domain to a frequency domain. an inverse DCT algorithm can be used to reduce the precision of the coefficients data size
 It removes redundancy in the data. decompress an image.
 This increases the compression  JPEG baseline algorithm defines a set of
 It is proven to be the optimal transform for The DCT coefficients of each 8  8 blocks are  DCT ; is known as the DC coefficient
(0 0) quantisation tables
large classes of images. calculated using the formula below. which represents the basic colour, i.e.,
2 3 2 3 wave-length, of the image block  Each element q in the table, known as
(2x + 1)i (2y j 7
DCT (i; j ) = p 1
CiCj
7 X
X 7
pxy cos 6
4
N
7
5 cos
6
4
+ 1)

N
5  The other DCT coefficients are known
quantum is used in the following formula
2N x=0 y=0 2 2 to calculate the quantised coefficients Q:
as AC coefficients which represent the
where Ci; Cj = p12 for i; j = 0, otherwise Ci; Cj = 1. frequency components of the data block DCTij
Here is an example. On the left is the 8  8 block of pixels, and on the right is the DCT Qij
 AC coefficients further away from the DC
=
qij
coefficients.
On the left is quantum matrix for quality level 1, and on the right the result of quantising
the example from previous page.
132 126 138 140 144 145 147 155 172 -18 15 -8 23 -9 -14 19
136 140 140 147 140 148 155 156 21 -34 24 -8 -10 11 14 7 4 7 10 13 16 19 22 25 43 3 2 0 0 0 0 0
140 143 144 148 150 152 154 155 -9 -8 -4 6 -5 4 3 -1 7 10 13 16 19 22 25 28 3 3 2 0 0 0 0 0
144 144 146 145 149 150 153 160 -10 6 -5 4 -4 4 2 1 10 13 16 19 22 25 28 31 1 0 0 0 0 0 0 0
150 152 155 156 150 145 144 140 -8 -2 -3 5 -3 3 4 6 13 16 19 22 25 28 31 34 1 0 0 0 0 0 0 0
144 145 146 148 143 158 150 140 4 -2 -4 6 -4 4 2 1 16 19 22 25 28 31 34 37 0 0 0 0 0 0 0 0
150 156 157 156 140 146 156 145 4 -3 -4 5 6 3 1 1 19 22 25 28 31 34 37 40 0 0 0 0 0 0 0 0
148 145 146 148 156 160 140 145 0 -8 -4 3 2 1 4 0 22 25 28 31 34 37 40 43 0 0 0 0 0 0 0 0
25 28 31 34 37 40 43 46 0 0 0 0 0 0 0 0

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 13 (199901) Slide 14

JPEG — Entropy Encoding MPEG


 The DC-coefficients are treated sepa-  The AC-coefficients are encoded using  MPEG (stands for Moving Picture Ex- 2. Processing
rately from the AC-coefficients Huffman and/or arithmetic encoding perts Group) is also a joint ISO and 3. Quantisation
CCITT working group for developing
A DC-coefficient is encoded as the standards for compressing still images
4. Entropy Encoding
difference between the current coefficient  They are put in a zig-zag order as shown
and the previous one in the diagram below  The MPEG video compression standard In the preparation stage, unlike JPEG,
became an international standard in MPEG defines the format of the images.
1993  Each image consists of three compo-
DC AC
01 AC 07  MPEG uses technology defined in other nents — YUV

DCi 1 DCi
standards, such as JPEG and H.261  The luminance component has twice as
 It defines a basic data rate of many samplesin the horizontal and ver-
1.2Mbits/sec tical axes as the other two components
Blocki 1 Blocki
 It is suitable for symmetric as well
(known as colour sub-sampling

asymmetric compression It follows the  The resolution of the luminance compo-


reference scheme that consists of four nent should not exceed 768 pixels
AC 70 AC 77 stages of processing:
 for each component, a pixel is coded with
1. Preparation eight bits

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 15 (199901) Slide 16
How MPEG encode the video stream Group of Pictures
In order to achieve higher compression coded using the predictive technique with The I-, P- and B-frames are often arranged I P B B P B B P B B B B
ratio, MPEG uses the fact the image on reference to the previous I-frame and/or into groups, known as Group of pictures
consecutive frames differ relative small. It previous P-frame. (GOP). A typical GOP consists of twelve This is known as the transmission sequence.
uses a temporal prediction technique to
encode the frame so that the storage  B-frame (Bi-directionally predictive-
frames in the following sequence:
When random access function is required,
coded frame) — It requires information IBBPBBPBBPBB the I-frames will be used as index, and the
requirement is greatly reduced.
Common MPEG data stream consists of of the previous and following I- and P- When the video is transfered and decoded, accessing to the video will be in a resolution
four kinds of frames: frames for encoding and decoding. the frames are in the following order: of twelve frames.
 I-frame (Intra-frame) — it is a self  D-frame (DC-coded frame) Only the
contained frame, and it is coded without lowest frequency component of image is I B B P B B P
reference to any other frames. encoded. It is used in fast forward or fast
 P-frame (Predictive-coded frame) — It is rewind.

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 17 (199901) Slide 18

I-frame encoding Summary


I-frames are compressed using JPEG carried out in real-time, i.e., on average
compression technique, however, the com- 1=30sec ' 33ms for 30 frame/sec video
pression/decompression processing must be stream.  Compression methods — lossless vs. lossy
 Entropy coding — run-length encoding, Huffman encoding
 Source coding — prediction (DPCM, DM), transformation (DCT)
MPEG-2
 MPEG-2 is a newer video encoding
 hybrid coding — JPEG, MPEG
pixels/line line/frame frames/sec
standard which builds on MPEG-1 352 288 30
 It supports higher video quality and 720 576 30
higher data rate (up to 80 Mbits/sec) 1920 1152 60

 It supports several resolutions:

COMP3600 Multimedia Systems 8. Data Compression COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 19 (199901) Slide 20
Original frames
1 2 3 4 5 6 7 8 9
MPEG
Compression
I B B P B B P B B
I P B B P B B B B
Transmission / receiving order
COMP3600 Multimedia Systems 8. Data Compression
(199901) Slide 21

Вам также может понравиться