Multimedia Specification Design and Production 2012 / Semester 1 / L3 Lecturer: Dr. Nikos Gazepidis...

Preview:

Citation preview

Multimedia Specification Design and Production

2012 / Semester 1 / L3Lecturer: Dr. Nikos Gazepidisgazepidis@ist.edu.gr

2

Introduction

Compress methods are key enabling techniques for multimedia applications.

Raw media takes much storage and bandwidth

A raw video with 30 frame/sec, resolution of 640x480, 24bit color

One second of video 30 * 640 * 480 * 3 = 27.6480 Mbytes

fps width height 3*8bit (True Colour)

One hour video is about 100Gbytes

Lossless Compression

3

Lossless vs. Lossy (Audio file example)

Lossless Compression

4

Some Terms

Lossless Compression

Encoder(compression)

Storage ornetworks

Decoder(decompression)

Data Input(a sequence of symbols from an alphabet)

Recovered data sequenceCode (a sequence of codewords)

Informationsource

Lossless compression: The recovered data is exactly the same as the input

Lossy compression: The recovered data approximates the input data

Compression ratio = bits used to represent the input data

bits of the code

5

Properties of Huffman Coding

Lossless Compression

…in Computer Science and information theory, Huffman coding is an entropy encoding algorithm used for lossless data compression.

Huffman coding uses longer codewords for symbols with smaller probabilities and shorter codewords for symbols that often occur.

The two longest codewords differ only in the last bit.

Huffman coding is not effective for cases when there are small number of symbols

6

Properties of Huffman Coding

Lossless Compression

“this is an example of a huffman tree”

Char Freq

Code

x 1 10010

u 1 00111

r 1 11000

p 1 10011

o 1 00110

l 1 11001

s 2 1011

t 2 0110

m 2 0111

n 2 0010

i 2 1000

h 2 1010

f 3 1101

e 4 000

a 4 010

space 7 111

parent node

leaves

‘1’‘0’

7

Dictionary Based

Lossless Compression

Dictionary based method is another way to capture the correlation of symbols.

Static dictionary Good when the data to be compressed is specific in some application. For instance, to compress a student database, the world “Name”, “Student ID” will often appear.

Static dictionary method does not work well if the source characteristics change.

Adaptive Dictionary

8

Compress Multimedia Data Losslessly

Lossless Compression

Model the media (audio, image, graphics data, or video as) as a source that generates symbols.

The naive way of choosing symbols: Pixels for images and videos Samples for audios Characters for text messages

Apply the lossless compression methods to the string of symbols.

9

PNG (Portable Network Graphics)

Lossless Compression

PNG is a lossless image compressing method based on LZ77

PNG supports three main image types: true color, grayscale and palette-based ("8-bit") PNG supports alpha channel

10

PNG (cont.)

Lossless Compression

PNG also supports interlaced coding and decoding

1 6 4 6 2 6 4 67 7 7 7 7 7 7 75 6 5 6 5 6 5 67 7 7 7 7 7 7 73 6 4 6 3 6 4 67 7 7 7 7 7 7 75 6 5 6 5 6 5 67 7 7 7 7 7 7 7

The scanning pattern in a 8x8 block. The whole image is partitioned into 8x8 blocks and scanned based on the pattern in each block.

11

File Compression - LZ Algorithm (Lempel & Ziv)

Lossless Compression

ZIP compression. This compression system is a very handy invention, especially for Web users, because it let users reduce the overall number of bits and bytes in a file so it can be transmitted faster over slower Internet connections, or take up less space on a disk.

Compression up to certain %Original files size

12

File Compression - LZ Algorithm

Lossless Compression

“Ask not what your country can do for you - ask what you can do for your country.” Quote by J.F. Kennedy, 1961

The above quote has 17 words made up of:

1. 61 letters2. 16 spaces3. 1 dash (-)4. 1 period (.)

Total: 79 units

Words Frequency

ask 2

what 2

your 2

country 2

can 2

do 2

for 2

you 2ask not wha

tyou

rcountr

ycan do for you

Unique Words

13

LZ Algorithm - Dictionary

Lossless Compression

“Ask not what your country can do for you - ask what you can do for your country.”

Dictionary(words+numbers)

1. ask 2. what 3. your 4. country 5. can 6. do 7. for 8. you

According to our dictionary the above quote can be:"1 not 2 3 4 5 6 7 8 - 1 2 8 5 6 7 3 4"

79units 3

7units

Quote ‘before’ compression

Quote ‘after’ compression

Dictionary

37

units 74units

14

LZ Algorithm - Searching for Patterns

Lossless Compression

“Ask not what your country can do for you - ask what you can do for your country.”

Possible patterns in a dictionary "t" followed by a space “ou” which appears in both "your" and "country“ “can do for you” which appears 2 times - 14 units

Dictionary

1. ask_2. what_ 3. you4. r_country 5. _can_do_for_you

"1not_2345_-_12354"

79units 4

1units

Quote ‘before’ compression

Quote ‘after’ compression

Dictionary

18

units 59units

15

LZ Algorithm - Searching for Patterns

Lossless Compression

“Ask not what your country can do for you - ask what you can do for your country.”

79units

59units

79units

74units

≈ -7.5% ≈ -25%

Pattern A Pattern B

16

GIF (Graphics Interchange Format)

Lossless Compression

GIF was devised by UNISYS and Compuserve.

GIF is based on LZW lossless compression.

GIF supports 8bit (256) color images only. Each image can have its own color table.

It supports transparency layer and simple animation functions.

It also supports interlaced coding and decoding.

17

Audio Compression

Lossless Compression

Audio can also be compressed in a similar way to image data.

For lossless audio compression, prediction is usually applied first. Simple prediction. Adaptive prediction.

Stereo decorrelation.

Entropy coding.

18

Audio Examples

Lossless Compression

FLAC (free lossless audio codec) Polynomial fitting prediction or linear prediction. Rice coding.

MPEG4-ALS Lossless audio coding standard in MPEG4. Adaptive Linear Prediction. Supports up to 65535 channels. Fast random access. Rice coding.

Apple lossless audio coding (ALAC)

19

MPEG-4 ALS System Diagram

Lossless Compression