Title: Video Compression
1Video Compression
- MPEG Motion Picture Expert Group
- Lossy compression of video
- First approximation JPEG on each frame
- Added compression remove inter-frame redundancy
- Frame types
- I frames intrapicture
- P frames predicted picture
- B frames bidirectional predicted picture
2Motion Compensation
3Encoding
4Luminance
5Example
- Example sequence transmitted as I P B B I B B
6B and P frames
- coordinate for the macroblock in the frame
- motion vector relative to previous reference
frame - motion vector relative to subsequent reference
frame (B only) - delta for each pixel in the macro block
7Effectiveness
- typically 90-to-1
- as high as 150-to-1
- 30-to-1 for I frames
- P B frames get another 3 to 5x
8Frame at time N
9Frame at time N1
10Error without motion compensation
11Error with motion compensation
12Coding Order
13MPEG Stream Format
14Example
126 71 10
250 14 29
71 30 33
- Assume a 3x3 Macroblock after the DCT
- Given the JPEG Quantization table
- The Quantized frequency coefficients
- DCT(1,0)250
- ?250/15.5? ?17.16?17
- RLE(42,5,17,2,0,0,0,0,0)1-42,1-5,1-17,1-2,5-0
- Now do Huffman encoding with symbols 1,42,5,17,2,
0
3 15 31
15 31 59
31 59 75
42 5 0
17 0 0
2 0 0
15Huffman Encoding
- Huffman encoding allows you to encode data with
the minimal number of bits - We need to encode the RLE 1-42,1-5,1-17,1-2,5-0
- There are 10 occurrences of symbols
- 1 occurs 4/1040 of the time
- 42 occurs 1/1010
- 5 occurs 2/1020
- 17 occurs 1/1010
- 2 occurs 1/1010
- 0 occurs 1/1010
Symbol Weight
1 4
5 2
42 1
17 1
2 1
0 1
16Algorithm
- Given a alphabet A, construct a Huffman encoding
tree T Create one node for each character of
the alphabet A. Let each node have a field
containing its weight which is the probability of
that letter appearing in a message. Now
repeatedly perform the following two steps
1) pick two nodes n1 and n2 that have the
smallest weights 2) and replace them with a
new node whose children are n1 and n2 and whose
weight is the sum of the weights of n1 and n2.
Each time we perform this step will replace two
nodes in the alphabet with one, until eventually
only one single node remains as this is the root
of the tree T.
17Building Huffman Tree
1-42,1-5,1-17,1-2,5-01 0010 1 01 1 0011 1 0000
01 0001 1001 0101 1001 1100 0001 00010x959c11
W4
I5
0
1
Symbol Weight
11 4
501 2
420010 1
170011 1
20000 1
00001 1
1
I4
W6
1
0
W4
5
I3
0
1
I1
I2
W2
W2
0
0
1
1
2
0
42
17
18LZ encoding example
Encode for characters a,b,c a b b c c a b a c a b
b b a b a b a b b b b 1 2 2 3 3 4 1 8 5 2
9 13 12 2
1 a 8 ca 15 bab
2 b 9 aba 16 bbbb
3 c 10 ac 17
4 ab 11 cab 18
5 bb 12 bbb 19
6 bc 13 ba 20
7 cc 14 abab 21
19LZ decoding
- 1 2 2 3 3 4 1 8 5 2 9 13 12 2
- a b b c c a b a c a b b b a b a b a b b b b
1 a 8 ca 15 bab
2 b 9 aba 16 bbbb
3 c 10 ac 17
4 ab 11 cab 18
5 bb 12 bbb 19
6 bc 13 ba 20
7 cc 14 abab 21
20PNG
- The Portable Network Graphics (PNG) format was
designed to replace the older and simpler GIF
format and, to some extent, the much more complex
TIFF format. - For the Web, PNG really has three main advantages
over GIF - alpha channels (variable transparency),
- gamma correction (cross-platform control of image
brightness), and - two-dimensional interlacing (a method of
progressive display).
21PNG
- For image editing, either professional or
otherwise, PNG provides a useful format for the
storage of intermediate stages of editing. Since
PNG's compression is fully lossless--and since it
supports up to 48-bit truecolor or 16-bit
grayscale--saving, restoring and re-saving an
image will not degrade its quality, unlike
standard JPEG (even at its highest quality
settings). - Most of all, PNG is not patented
22MP3
- MP is short for MPEG, or Motion Picture Experts
Group, a widely accepted way to compress digital
video and audio. - MP3 is short for MPEG-1, audio layer 3. It is a
subset of MPEG compression that can take a
20-megabyte, two-minute track on a music CD
loaded into a PC's CD-ROM drive and reduce it to
just a tad over 1.4 megabytes, about the size of
a single floppy disk. Layer 3 quality is better
than layer 2, but not as good as layer 4, which
is coming soon and will provide full CD quality.
MP3 was invented in 1991.
23Overview
24Details
- The filter bank used in MPEG Layer-3 uses
Discrete Cosine Transform - The perceptual model gives preference to
frequencies we are more sensitive to - Joint stereo coding takes advantage of the fact
that both channels are frequently the same - Quantization, larger values are automatically
coded with less accuracy - The quantized values are coded by Huffman
coding.
25Network Security
26Cryptography
- Cryptography functions
- Secret key (e.g., DES)
- Public key (e.g., RSA)
- Message digest (e.g., MD5)
- Security services
- Privacy preventing unauthorized release of
information - Authentication verifying identity of the remote
participant - Integrity making sure message has not been
altered
27Taxonomy
28Encryption Algorithms
- Private Key (DES)
- 64-bit key (56-bits 8-bit parity)
- 16 rounds
29L
R
i -1
i 1
- Each round
- Function F and generation of Ki for each round
not shown - Repeat for larger messages
K
F
i
L
R
i
i
30Public Key (RSA)
- Generate a public and private key
- choose two large prime numbers p and q (each 256
bits) - multiply p and q together to get n (at most 512
bits) - chose the encryption key e, such that e and n are
relatively prime e(p-1) x (q-1). - two numbers are relatively prime if they have no
common factor greater than one. - compute decryption key d such that
- d e-1 mod(n)
- construct public key as lte, ngt
- construct private key as ltd, ngt
- discard (do not disclose) original primes p and q
31Multiplicative inverse
- With n7
- 42 mod 7 1
- 4 and 2 are multiplicative inverses mod 7
32Encryption Decryption
- c me mod n
- m cd mod n(me mod n)d mod nmedmod n
- Since e and d are multiplicitive inverses m
plaintext
plaintext
Encrypt w/
Decrypt w/
Public Key
Private Key
ciphertext
33Breaking RSA
- 1977 challenge to break 430-bit message with
RSA-129 - Estimated 40 Quadrillion years to factor large
composites - April 1994 broken with 5000 MIP-years of CPU
- On Aug. 22, 1999, a group led by H. te Riele
completed factorization of RSA-155, 35.7 CPU
years 8000MIP Years - Breakage can be easier if something is known
about the key generation (time of day)
34Breaking DES
- 1999 56-bit DES broken in 22 hours on network of
machines
35Message Digest
- Cryptographic checksum
- just as a regular checksum protects the receiver
from accidental changes to the message, a
cryptographic checksum protects the receiver from
malicious changes to the message.
36One-way function
- given a cryptographic checksum for a message, it
is virtually impossible to figure out what
message produced that checksum it is not
computationally feasible to find two messages
that hash to the same cryptographic checksum.
37Relevance
- if you are given a checksum for a message and you
are able to compute exactly the same checksum for
that message, then it is highly likely this
message produced the checksum you were given.
38Speed
- DES on 175MHz Alpha 36Mbps
- RSA 1Kbps
- MD5 80Mbps (as much as 10x DES)
- In hardware DES1Gbps, RSA64Kbps
39Authentication Protocols
40Kerberos
- Trusted third party (Kerberos)
B
A
S
A, B
E((T,L,K,B),K ),
A
E((T,L,K,A),K )
B
E((A,T),K), E(T,L,K,A),K )
B
E(T1,K)
41Public key authentication
A
B
E(x, Public )
B
x
42Message Integrity Protocols
- Digital signature using RSA
- special case of a message integrity where the
code can only have been generated by one
participant - compute signature with private key and verify
with public key
43Keyed MD5
- sender
- m MD5(m k) E(k, private)
- receiver
- recovers random key using the sender's public key
- applies MD5 to the concatenation of this random
key message - compares result with checksum sent with message