170 likes | 283 Views
Multimedia Communications EG 371 and EG 348. Dr Matthew Roach Lecture 4 C ompression &formats cont. Lossless: Huffman compression. Huffman compression reduces average code length to represent symbols of an alphabet occur frequently short length codes constructing a binary tree
E N D
Multimedia CommunicationsEG 371 and EG 348 Dr Matthew Roach Lecture 4 Compression &formats cont. Multimedia communications EG-371 Dr Matt Roach
Lossless: Huffman compression • Huffman compression • reduces average code length • to represent symbols of an alphabet • occur frequently • short length codes • constructing a binary tree • arranging the symbols • adding two lowest probabilities • Sum of last two symbols is 1. • Code words formed tracing tree path • assigning 0s and 1s to the branches Multimedia communications EG-371 Dr Matt Roach
Huffman coding • Determine the Huffman code for the following set of symbols: • Step 1 – List symbols in order of decreasing probability Multimedia communications EG-371 Dr Matt Roach
Step 2 – Get 2 symbols with lowest probability. Give the combined symbol a new name: • m2(0.15) + m0(0.1.0) A(0.25) • Step 3 – Create a new list and repeat the process: Multimedia communications EG-371 Dr Matt Roach
C 0.61 m1 0.36 m1 0.36 B 0.39 D 1.0 m3 0.20 A 0.25 m1 0.36 B 0.39 m4 0.19 m3 0.20 A 0.25 m2 0.15 m4 0.19 m0 0.10 An alternative approach is to construct this tree Multimedia communications EG-371 Dr Matt Roach
Root 0 1 C 0.61 B 0.39 1 0 1 0 m1 0.36 A 0.25 m4 0.19 m3 0.20 0 1 m2 0.15 m0 0.10 Assign bits (0,1) to the tree branches Codewords determined by tracing the path from root node to symbol leaf: Compression is achieved by allocating frequently occurring symbols with shorter codewords. Multimedia communications EG-371 Dr Matt Roach
How much compression? • 5 symbols • 3-bits for each symbol. • message [m0m1m2m3m4] • require 5x3=15 bits. • Huffman coding • require 12 bits compression of 15:12 Multimedia communications EG-371 Dr Matt Roach
Example • Consider the message babbage babble baggage label bagel • Construct a Huffman code and determine the compression ratio. Multimedia communications EG-371 Dr Matt Roach
Solution • construct a probability table • counting occurrence of each letters Multimedia communications EG-371 Dr Matt Roach
Solution C 0.6 b 0.3 b 0.3 B 0.4 D 1.0 a 0.233 A 0.3 b 0.3 B 0.4 g 0.166 a 0.233 A 0.3 e 0.166 g 0.166 1 0.133 Multimedia communications EG-371 Dr Matt Roach
Solution Root 0 1 C 0.6 B 0.4 1 0 1 0 b 0.3 A 0.3 g 0.166 a 0.233 0 1 e 0.166 l 0.133 Multimedia communications EG-371 Dr Matt Roach
Solution • babbage babble baggage label bagel • 5 symbols (bagel) • 30 characters • uncompressed • 3 bits/symbol • 90 bits. • Huffman gives a compression of approx. 9:7 Multimedia communications EG-371 Dr Matt Roach
Multimedia CommunicationsEG 371 and EG 348 Dr Matthew Roach Lecture 4 Formats cont. Multimedia communications EG-371 Dr Matt Roach
Common Container Formats • AVI (.avi) • M-JPEG, DivX, nearly any format (not Sorenson). • Quicktime • Locked Apple Sorenson codec, or for Cinepak (free), also mjpeg • WMV (.wmv) • MPEG4; nearly any codec, Microsoft spinoffs of MPEG-4 • ASF ("Advanced Streaming Format", .asf) • a subset of wmv, intended primarily for streaming: an early Microsoft implementation of an MPEG4 codec. Multimedia communications EG-371 Dr Matt Roach
Common Codecs • MPEG-1 • Old, supported by everything (at least up to 352x240), reasonably efficient. • A good format for the web • Video quality is not as crisp as MPEG-2 • Small file size • Good picture quality • Compressed format • Require special playback program • Cannot Edit • MPEG-2 • A souped-up version of MPEG-1, with better compression. 720x480. Used in HDTV, DVD, and SVCD. • Good Quality, Can burn onto DVD disc • Large file size, 4.7GB for 2 hours of video • MPEG-4 • A family of codecs, some of which are open, others Microsoft proprietary. • MJPEG ("Motion JPEG") • A codec consisting of a stream of JPEG images. Common in video from digital cameras, but it doesn't compress well, so it's not good for web distribution. Multimedia communications EG-371 Dr Matt Roach
Common Codecs cont. • WMV ("Windows Media Video") • A collection of Microsoft proprietary video codecs. • Since version 7, it has used a special version of MPEG4. • Small file size • Good picture quality • Ideal for web transmission • Compressed format • Cannot Edit • RM ("Real Media") • a closed codec developed by Real Networks for streaming video and audio. Maybe also a container? • DivX • incomplete early MPEG-4 codec inside an AVI container; DivX 4 and later are a more full MPEG-4 codec.. No resolution limit. Requires more horsepower to play than mpeg1, but less than mpeg2. • Hard to find mac and windows players. • Good Quality with reasonably small file size • Not a standard video format • Cannot produce video onto DVD or CD Multimedia communications EG-371 Dr Matt Roach
Common Codecs cont. • DV ("Digital Video") • Usually used for video grabbed via firewire off a video camera. Fixed at 720x480 @ 29.97FPS, or 720x576 @ 25 FPS. Not very highly compressed. • Superb quality, record back to DV tape • Large file size, 25GB for 60 min of video • Sorenson 3: • Apple's proprietary codec, commonly used for distributing movie trailers (inside a quicktime container). • Quicktime 6: • Apple's implementation of an MPEG4 codec. • Good picture quality • Ideal for web transmission • Larger file size (compare to other streamable formats) • Cannot Edit Multimedia communications EG-371 Dr Matt Roach