03.08.2013 Views

Lo Standard JPEG per la Compressione di Immagini Fisse - InfoCom

Lo Standard JPEG per la Compressione di Immagini Fisse - InfoCom

Lo Standard JPEG per la Compressione di Immagini Fisse - InfoCom

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Capitolo 3<br />

<strong>Lo</strong> <strong>Standard</strong> <strong>JPEG</strong> <strong>per</strong> <strong>la</strong> <strong>Compressione</strong> <strong>di</strong><br />

<strong>Immagini</strong> <strong>Fisse</strong><br />

Contenuto<br />

3.1 Introduzione . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48<br />

3.2 Modalità Sequenziale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50<br />

3.2.1 Trasformata Dicreta del Coseno (DCT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50<br />

3.2.2 Quantizzatore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

3.2.3 Co<strong>di</strong>ficatore Entropico . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53<br />

3.2.4 Deco<strong>di</strong>ficatore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55<br />

3.3 Modalità Progressiva . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

3.4 Modalità Gerarchica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58<br />

3.1 Introduzione<br />

<strong>Lo</strong> standard <strong>JPEG</strong>3.1 è forse il più <strong>di</strong>ffuso standard <strong>di</strong> compressione <strong>per</strong> immagini fisse. Tale <strong>di</strong>ffusione è dovuta<br />

principalmente al fatto che tale standard <strong>per</strong>mette <strong>di</strong> ottenere alti rapporti <strong>di</strong> compressione su immagini naturali a<br />

frote <strong>di</strong> una <strong>per</strong><strong>di</strong>ta <strong>di</strong> qualità generalmente contenuta entro limiti accettabili.<br />

Occorre, inoltre, tenere in considerazione il fatto che lo standard è “a<strong>per</strong>to”, nel senso che chiunque può<br />

liberamente implementare il proprio co<strong>di</strong>ficatore/deco<strong>di</strong>ficatore <strong>JPEG</strong>.<br />

Il numero massimo <strong>di</strong> componenti, o canali, costituenti l’immagine è fissato in 255.<br />

3.1Joint Photographic Ex<strong>per</strong>ts Group, ufficialmente ISO/JTC1/SC2/WG10, o<strong>per</strong>ante in stretta, informale, col<strong>la</strong>borazione con il gruppo<br />

CCITT/SGVIII. L’attributo joint si riferisce proprio a questa col<strong>la</strong>borazione tra ISO (International <strong>Standard</strong> Organization) e CCITT (Commitee<br />

Consultatif Internationale des Telephones et Telegraphs). Dal 1992, l’organismo ITU (International Telecommunication Union) raccoglie le<br />

attività del CCCIT, del CCIR (Commitee Consultatif Internationale des Ra<strong>di</strong>o), del IFRB (International Frequency Registration Board), e del BDM<br />

(Bureau des Developpement des Telecommunications).<br />

48


3.1. INTRODUZIONE 49<br />

Un’immagine a colori è rappresentata me<strong>di</strong>ante tre canali, tipicamente uno <strong>di</strong> luminanza (Y ), e due <strong>di</strong> crominanza<br />

(CR,CB). 3.2<br />

Figura 3.1: Sottocampionamento del<strong>la</strong> crominanza. Il simbolo X rappresenta un generico campione <strong>di</strong> luminanza, i due semiquadrati<br />

rappresentano una coppia <strong>di</strong> campioni CRCB con<strong>di</strong>visa da quattro campioni <strong>di</strong> luminanza.<br />

La crominanza è sottocampionanta <strong>di</strong> un fattore 2 in entrambe le <strong>di</strong>rezioni, e quin<strong>di</strong> quattro pixel <strong>di</strong> luminanza<br />

con<strong>di</strong>vidono <strong>la</strong> stessa crominanza, ve<strong>di</strong> Fig.3.1.<br />

Modalità <strong>di</strong> funzionamento<br />

<strong>Lo</strong> standard <strong>JPEG</strong> prevede quattro <strong>di</strong>stinte modalità <strong>di</strong> funzionamento:<br />

• Sequenziale (con DCT, con <strong>per</strong><strong>di</strong>ta);<br />

• Progressiva (con DCT, con <strong>per</strong><strong>di</strong>ta);<br />

• Senza Per<strong>di</strong>ta;<br />

• Gerarchica (con o senza DCT, con o senza <strong>per</strong><strong>di</strong>ta).<br />

3.2 Dai coefficienti tricromatici del sistema <strong>di</strong> riferimento colorimetrico NTSC, i.e. RN ,GN ,BN , <strong>la</strong> trasformazione in luminanza/crominanza<br />

si ottiene nel modo seguente:<br />

Y =0.299 · RN +0.587 · GN +0.114 · BN<br />

CR = RN − Y<br />

CB = BN − Y<br />

;<br />

RN = CR + Y<br />

BN = CB + Y<br />

GN = Y − 0.299 · RN − 0.114 · BN<br />

0.587<br />

(3.1.1)


50 CAPITOLO 3. LO STANDARD <strong>JPEG</strong> PER LA COMPRESSIONE DI IMMAGINI FISSE<br />

3.2 Modalità Sequenziale<br />

blocco 8x8<br />

Immagine<br />

Originale<br />

xn [ , n ]<br />

DCT<br />

1 2 X k1 k2<br />

DCT<br />

( ) [ , ]<br />

Quantizzatore<br />

( DCT)<br />

X [ k , k ]<br />

1 2<br />

Co<strong>di</strong>ficatore<br />

Entropico<br />

Tavole Tavole<br />

Figura 3.2: Schema del Co<strong>di</strong>ficatore <strong>JPEG</strong><br />

Dati Immagine<br />

Compressa<br />

La struttura essenziale <strong>di</strong> un co<strong>di</strong>ficatore <strong>JPEG</strong> è mostrata nel<strong>la</strong> Fig.3.2. Ogni componente dell’immagine da co<strong>di</strong>ficare<br />

è sud<strong>di</strong>visa in blocchetti da 8x8 pixel. Secondo una scansione lessicografica, ciascuno <strong>di</strong> questi blocchetti è e<strong>la</strong>borato<br />

dal<strong>la</strong> trasformazioni in<strong>di</strong>cate come DCT, Quantizzatore, Co<strong>di</strong>ficatore Entropico.<br />

3.2.1 Trasformata Dicreta del Coseno (DCT)<br />

Questa trasformazione o<strong>per</strong>a il calcolo del<strong>la</strong> DCT. <strong>Lo</strong> standard non specifica un partico<strong>la</strong>re algoritmo <strong>di</strong> calcolo,<br />

<strong>la</strong>sciando così a chi sviluppa il co<strong>di</strong>ficatore <strong>la</strong> libertà <strong>di</strong> implementare un partico<strong>la</strong>re proce<strong>di</strong>mento. Ciò <strong>di</strong>pende dal<br />

fatto che <strong>di</strong>verse applicazioni possono richiedere <strong>di</strong>fferenti realizzazioni del calco<strong>la</strong>tore <strong>di</strong> DCT, e.g. realizzazioni<br />

hardware VLSI rispetto a realizzazioni software o ibride come un DSP de<strong>di</strong>cato, implementazioni in artimetica a<br />

virgo<strong>la</strong> fissa o mobile, etc., ciascuna con <strong>di</strong>fferenti compromessi fra velocità e precisione.<br />

Tale flessibilità può <strong>per</strong>ò presentare qualche svantaggio. In effetti, idealmente, <strong>la</strong> cascata <strong>di</strong> una trasformazione<br />

DCT e <strong>di</strong> una trasformazione DCT inversa (IDCT) non comporta alcuna <strong>per</strong><strong>di</strong>ta <strong>di</strong> informazione. In realtà, <strong>la</strong><br />

presenza <strong>di</strong> funzioni sinusoidali nell’espressione del<strong>la</strong> trasformata, rende impossibile <strong>di</strong> fatto realizzare i calcoli con<br />

accuratezza <strong>per</strong>fetta. Dunque potremmo trovarci <strong>di</strong> fronte al problema che co<strong>di</strong>ficatori e deco<strong>di</strong>ficatori <strong>di</strong>versi, in<br />

linea <strong>di</strong> principio, potrebbero produrre risultati anche abbastanza <strong>di</strong>versi fra loro. Per evitare tale problema, nello<br />

standard <strong>JPEG</strong> sono specificati dei test <strong>di</strong> conformità rispetto all’accuratezza cui si devono adeguare il co<strong>di</strong>ficatore<br />

e il deco<strong>di</strong>ficatore.<br />

In ogni caso, ricor<strong>di</strong>amo le definizioni del<strong>la</strong> DCT <strong>di</strong> un’immagine x[n1,n2] <strong>di</strong> <strong>di</strong>mensioni N ×N.<br />

• Trasformata DCT (analisi):<br />

X DCT N−1 X<br />

[k1,k2] =α(k1)α(k2)<br />

con α(0) def<br />

q<br />

1 = N e α(k) =<br />

• Trasformata IDCT (sintesi):<br />

x[n1,n2] =<br />

N−1 X<br />

N−1 X<br />

k1=0 k2=0<br />

N−1 X<br />

n1=0 n2=0<br />

q<br />

2<br />

N<br />

µ µ <br />

π(2n1 +1)k1 π(2n2 +1)k2<br />

x[n1,n2]cos<br />

cos<br />

2N<br />

2N<br />

<strong>per</strong> 1 ≤ k ≥ N − 1;<br />

α(k1)α(k2)X (DCT) µ µ <br />

π(2n1 +1)k1 π(2n2 +1)k2<br />

[k1,k2]cos<br />

cos<br />

2N<br />

2N<br />

0 ≤ k1,k2 ≤ N − 1<br />

0 ≤ n1,n2 ≤ N − 1<br />

Dalle Figg. 3.3, 3.4, e 3.5 è possibile apprezzare come <strong>la</strong> DCT compatti l’energia me<strong>di</strong>a nelle componenti a bassa<br />

frequenza. In tali figure, l’ampiezza dei coefficienti DCT é rappresentato come livelli <strong>di</strong> grigio, dal nero verso il<br />

bianco.<br />

Tale compattazione è ancora più evidente <strong>per</strong> blocchetti <strong>di</strong> <strong>di</strong>mensione contenuta (ve<strong>di</strong> Figg. 3.4 e 3.5), dove<br />

<strong>la</strong> corre<strong>la</strong>zione tra i pixel cresce, e l’approssimazione DCT → KLT è sufficientemente accurata. Si osservi come,<br />

bastano pochissimi coefficienti DCT <strong>per</strong> “spiegare” blocchetti con scarse variazioni del livello <strong>di</strong> grigio.


3.2. MODALITÀ SEQUENZIALE 51<br />

Figura 3.3: Immagine e re<strong>la</strong>tiva DCT<br />

Figura 3.4: Immagine blocchettizzata (32x32) e re<strong>la</strong>tiva DCT<br />

Figura 3.5: Immagine blocchettizzata (8x8) e re<strong>la</strong>tiva DCT


52 CAPITOLO 3. LO STANDARD <strong>JPEG</strong> PER LA COMPRESSIONE DI IMMAGINI FISSE<br />

3.2.2 Quantizzatore<br />

All’ingresso del quantizzatore si presentano dunque i 64 coefficienti estratti me<strong>di</strong>ante DCT. Occorre ricordare che<br />

fino all’ingresso del quantizzatore non vi è stata ancora alcuna <strong>per</strong><strong>di</strong>ta <strong>di</strong> informazione.<br />

L’o<strong>per</strong>azione <strong>di</strong> quantizzazione è definita nel modo seguente, <strong>per</strong> k1,k2 =0, ··· , 7:<br />

˙X (DCT) µ <br />

(DCT) X [k1,k2]<br />

[k1,k2] =round<br />

(3.2.1)<br />

Q[k1,k2]<br />

dove Q[k1,k2] sono i valori dei passi <strong>di</strong> quantizzazione associati a ciascun coefficiente DCT. La strategia adottata è<br />

infatti quel<strong>la</strong> <strong>di</strong> quantizzare ciascun coefficiente con uno specifico passo <strong>di</strong> quantizzazione, <strong>di</strong>pendente dall’importanza<br />

psicovisiva che tale coefficiente possiede.<br />

Le immagini naturali hanno un contenuto frequenziale rilevante che si situa nel<strong>la</strong> massima parte alle basse<br />

frequenze; conseguentemente, tra i 64 coefficienti DCT assumono valore significativamente <strong>di</strong>verso da zero solo<br />

quelli concentrati intorno alle basse frequenze spaziali.<br />

Poichè il sistema visivo umano è molto meno sensibile alle alte frequenze (che contengono l’informazione re<strong>la</strong>tiva<br />

ai dettagli fini, al<strong>la</strong> tessitura, etc.) che alle basse; fra queste ultime, il coefficiente del<strong>la</strong> componente continua (DC)<br />

X (DCT) [0, 0], che rappresenta in sostanza il livello me<strong>di</strong>o <strong>di</strong> grigio presente nel blocchetto 8x8, è quello che riveste<br />

<strong>la</strong> maggiore importanza visuale. Per tali motivi, <strong>la</strong> quantizzazione è stu<strong>di</strong>ata <strong>per</strong> cercare <strong>di</strong> preservare (quantizzando<br />

meno) il coefficiente DC, e in generale tutti quelli <strong>per</strong>tinenti alle basse frequenze, e invece quantizzare più duramente i<br />

coefficienti corrispondenti alle alte frequenze. In pratica, i coefficienti corrispondenti alle alte frequenze spaziali, che<br />

assumono valori re<strong>la</strong>tivamente piccoli, sono <strong>di</strong>visi <strong>per</strong> un valore <strong>di</strong> quantizzazione re<strong>la</strong>tivamente grande, tipicamente<br />

compreso fra 80 e 100, e poi arrotondati all’intero più vicino, risultando così in un valore nullo. L’o<strong>per</strong>azione <strong>di</strong><br />

quantizzazione, o<strong>per</strong>azione irreversibile, provoca <strong>la</strong> <strong>per</strong><strong>di</strong>ta <strong>di</strong> informazione.<br />

Le tabelle che contengono gli 8x8 valori dei passi <strong>di</strong> quantizzazione sono specificate dallo standard e sono state<br />

ottenute in base ai risultati <strong>di</strong> numerosissime prove soggettive effettuate negli anni, ma viene in ogni caso <strong>la</strong>sciata <strong>la</strong><br />

possibilità al progettista del co<strong>di</strong>ficatore <strong>di</strong> specificarne <strong>di</strong> proprie, in quanto lo standard stesso prevede che le tabelle<br />

debbano in ogni caso essere inserite nei dati co<strong>di</strong>ficati <strong>per</strong> essere comunicate al deco<strong>di</strong>ficatore.<br />

Luminanza (Y )<br />

16 11 10 16 24 40 51 61<br />

12 12 14 19 26 58 60 55<br />

14 13 16 24 40 57 69 56<br />

14 17 22 29 51 87 80 62<br />

18 22 37 56 68 109 103 77<br />

24 35 55 64 81 104 113 92<br />

49 64 78 87 103 121 120 101<br />

72 92 95 98 112 100 103 99<br />

Crominanza (CRCB)<br />

17 18 24 47 66 99 99 99<br />

18 21 26 66 99 99 99 99<br />

24 26 56 99 99 99 99 99<br />

47 66 99 99 99 99 99 99<br />

66 99 99 99 99 99 99 99<br />

99 99 99 99 99 99 99 99<br />

99 99 99 99 99 99 99 99<br />

99 99 99 99 99 99 99 99<br />

Tabel<strong>la</strong> 3.1: Tabelle dei passi <strong>di</strong> quantizzazione Q[k1,k2] suggerite nello standard <strong>JPEG</strong>.<br />

Una ultima considerazione riguarda i parametri resi <strong>di</strong>sponibili all’utente <strong>per</strong> adattare il livello <strong>di</strong> compressione, e<br />

quin<strong>di</strong> <strong>di</strong> qualità, al<strong>la</strong> partico<strong>la</strong>re applicazione. In sostanza tale adattamento viene effettuato me<strong>di</strong>ante <strong>la</strong> sca<strong>la</strong>tura<br />

tramite un coefficiente moltiplicativo dell’intera tabel<strong>la</strong> <strong>di</strong> quantizzazione.<br />

Prima <strong>di</strong> <strong>per</strong>venire al co<strong>di</strong>ficatore entropico, i dati vengono rior<strong>di</strong>nati nel seguente modo: i coefficienti DC <strong>di</strong><br />

ciascun blocchetto, essendo i livelli me<strong>di</strong> <strong>di</strong> grigio <strong>di</strong> ciascun blocchetto abbastanza corre<strong>la</strong>ti fra loro <strong>per</strong> immagini<br />

naturali, saranno co<strong>di</strong>ficati come <strong>di</strong>fferenza fra il coefficiente DC del blocchetto corrente e quello del blocchetto<br />

def<br />

precedente, i.e. sarà co<strong>di</strong>ficata <strong>la</strong> <strong>di</strong>fferenza ∆DCi = DCi − DCi−1, inizializzata con DC0 =0.


3.2. MODALITÀ SEQUENZIALE 53<br />

I restanti coefficienti, detti coefficienti AC <strong>per</strong> contrasto al coefficiente DC, sono poi scan<strong>di</strong>ti a “zig-zag”, come<br />

mostrato in Fig.3.6.<br />

Figura 3.6: Coefficienti DC ed AC, preparazione al<strong>la</strong> co<strong>di</strong>fica<br />

Questa scansione trasforma i dati da matrici 8x8 in stringhe caratterizzate dall’avere i valori più significativi nelle<br />

prime posizioni, <strong>per</strong> poi proseguire con lunghe corse <strong>di</strong> zeri.<br />

3.2.3 Co<strong>di</strong>ficatore Entropico<br />

Le stringhe <strong>di</strong> dati provenienti dal quantizzatore sono sottoposte ad un processo <strong>di</strong> co<strong>di</strong>fica entropica, senza <strong>per</strong><strong>di</strong>te.<br />

Il processo <strong>di</strong> co<strong>di</strong>fica è strutturato in 2 passi. Nel primo passo si converte <strong>la</strong> sequenza <strong>di</strong> coefficienti quantizzati<br />

in una sequenza interme<strong>di</strong>a <strong>di</strong> simboli. Nel secondo passo si co<strong>di</strong>ficano i simboli interme<strong>di</strong> in stringhe <strong>di</strong> cifre binarie<br />

che costituiscono il vero e proprio “data stream”.<br />

Primo passo: rappresentazione interme<strong>di</strong>a dei simboli<br />

La sequenza <strong>di</strong> simboli interme<strong>di</strong> è costruita nel seguente modo: ogni coefficiente AC non nullo è co<strong>di</strong>ficato<br />

congiuntamente con <strong>la</strong> lunghezza del<strong>la</strong> corsa <strong>di</strong> coefficienti nulli che lo precedono nel<strong>la</strong> sequenza.<br />

Ogni combinazione corsa/coefficiente non nullo è rappresentata me<strong>di</strong>ante una coppia <strong>di</strong> simboli secondo lo schema<br />

<strong>di</strong> Fig.3.7.<br />

Simbolo-1 (8 cifre binarie) Simbolo-2 (SIZE cifre binarie)<br />

RUNLEGTH SIZE<br />

AMPLITUDE<br />

4<br />

4<br />

Figura 3.7: Struttura del<strong>la</strong> co<strong>di</strong>fica entropica delle corse dei coefficienti AC: Simbolo-1 e Simbolo-2.<br />

Il primo simbolo co<strong>di</strong>fica due <strong>di</strong>stinte informazioni, RUNLENGTH e SIZE; il secondo ne co<strong>di</strong>fica una so<strong>la</strong>, AM-<br />

PLITUDE, che rappresenta proprio il valore del coefficiente AC, non nullo, che termina <strong>la</strong> corsa. Poichè i valori dei<br />

pixel dell’immagine x[n1,n2] sono rappresentati in virgo<strong>la</strong> fissa con 8 cifre binarie, dal<strong>la</strong> re<strong>la</strong>zione <strong>di</strong> trasformata<br />

SIZE


54 CAPITOLO 3. LO STANDARD <strong>JPEG</strong> PER LA COMPRESSIONE DI IMMAGINI FISSE<br />

DCT si vede che sono necessari 11 cifre binarie <strong>per</strong> rappresentare il valore del generico coefficente AC, sia prima<br />

che dopo <strong>la</strong> quantizzazione.<br />

Il campo SIZE rappresenta il numero <strong>di</strong> cifre binarie utilizzato <strong>per</strong> co<strong>di</strong>ficare il campo AMPLITUDE, cioè <strong>per</strong><br />

co<strong>di</strong>ficare il Simbolo-2, secondo lo schema <strong>di</strong> Tab.3.2.<br />

SIZE AMPLITUDE<br />

1 1, -1<br />

2 -3, -2, 2, 3<br />

3 -7, -6, -5, -4, 4, 5, 6, 7<br />

4 -15, ···, -8, 8, ···,15<br />

5 -31, ···, -16, 16, ···,31<br />

6 -63, ···, -32, 32, ···,63<br />

7 -127, ···, -64, 64, ···, 127<br />

8 -255, ···, -128, 128, ···,255<br />

9 -511, ···, -256, 256, ···,511<br />

10 -1023, ···, -512, 512, ···,1023<br />

11 -2047, ···, -1024, 1024, ···, 2047<br />

Tabel<strong>la</strong> 3.2: Co<strong>di</strong>fica del Simbolo-2<br />

<strong>Lo</strong> schema comprende anche il valore SIZE=11, necessario <strong>per</strong> rappresentare <strong>la</strong> <strong>di</strong>fferenza ∆DCi = DCi − DCi−1.<br />

Il campo RUNLENGTH rappresenta corse <strong>di</strong> zeri <strong>di</strong> lunghezze comprese fra 0 e 15, <strong>per</strong> cui occorrono 4 cifre<br />

binarie <strong>per</strong> <strong>la</strong> sua translitterazione. Poichè <strong>la</strong> lunghezza delle corse può, e s<strong>per</strong>abilmente deve, su<strong>per</strong>are il valore 15,<br />

il valore speciale (15, 0) <strong>di</strong> Simbolo-1 è utilizzato come simbolo estensione del<strong>la</strong> lunghezza <strong>di</strong> corsa (corsa lunga<br />

almeno 16). Poiché abbiamo 63 coefficienti AC, si possono incontrare fno ad un massimo <strong>di</strong> tre simboli estensione,<br />

oltre ad un Simbolo-1 detto terminatore, il cui campo RUNLENGTH completa <strong>la</strong> lunghezza totale del<strong>la</strong> corsa. Per<br />

esempio, i tre Simboli-1 consecutivi, con re<strong>la</strong>tivo Simbolo-2, (15, 0)(15, 0)(3, 4)(11) rappresentano una corsa lunga<br />

16+16+3=35 coefficienti AC nulli, terminata da un Simbolo2 <strong>di</strong> SIZE=4 cifre binarie, con AMPLITUDE=6.<br />

Il Simbolo-1 terminatore è sempre seguito da un singolo Simbolo-2, eccetto il caso nel quale oltre un certo<br />

coefficiente vi siano solo zeri: in tale caso, il valore speciale (0, 0) <strong>di</strong> Simbolo-1 viene specificato <strong>per</strong> rappresentare<br />

<strong>la</strong> fine dei dati <strong>per</strong>tinenti al blocchetto considerato.<br />

Per quanto riguarda il valore <strong>di</strong>fferenziale del coefficiente DC, <strong>la</strong> rappresentazione interme<strong>di</strong>a è simile al caso<br />

AC, con <strong>la</strong> <strong>di</strong>fferenza che Simbolo-1 comprende solo il campo SIZE con valori fra 1 e 11, come mostrato in Fig.3.8.<br />

Simbolo-1 (4 cifre binarie) Simbolo-2 (SIZE cifre binarie)<br />

SIZE<br />

4<br />

AMPLITUDE<br />

Figura 3.8: Struttura del<strong>la</strong> co<strong>di</strong>fica entropica dei coefficienti ∆DCi: Simbolo-1 e Simbolo-2.<br />

Un possibile esempio <strong>di</strong> stringa co<strong>di</strong>ficata interme<strong>di</strong>a è dunque il seguente:<br />

SIZE<br />

(2)(3),(0, 8)(116),(0, 6)(37),···,(12, 4)(12),(15, 0)(15, 0)(2, 2)(3),(0, 0)<br />

La struttura <strong>di</strong> Simbolo-1 è riassunta nel<strong>la</strong> Tab.3.3


3.2. MODALITÀ SEQUENZIALE 55<br />

RUNLENGTH/SIZE 0 1 2 ... 10 11<br />

0 EOB ...<br />

1 X ...<br />

. X valori legali <strong>di</strong> SIZE<br />

. X ...<br />

15 ZRL ...<br />

Tabel<strong>la</strong> 3.3: Struttura del Simbolo-1 con i simboli speciali <strong>di</strong> fine blocchetto (EOB) ed estensione <strong>di</strong> corsa (ZRL).<br />

Secondo passo: co<strong>di</strong>fica a lunghezza <strong>di</strong> paro<strong>la</strong> variabile<br />

Una volta creata <strong>la</strong> sequenza interme<strong>di</strong>a, a essa vengono associate le effettive parole <strong>di</strong> co<strong>di</strong>ce.<br />

Ogni Simbolo-1 è co<strong>di</strong>ficato me<strong>di</strong>ante una paro<strong>la</strong> <strong>di</strong> co<strong>di</strong>ce a lunghezza variabile (Variable Length Code, VLC)<br />

ottenuta me<strong>di</strong>ante co<strong>di</strong>fica <strong>di</strong> Huffman. Il re<strong>la</strong>tivo Simbolo-2 è co<strong>di</strong>ficato me<strong>di</strong>ante un cosiddetto intero <strong>di</strong> lunghezza<br />

variabile (Variable Length Integer, VLI) <strong>la</strong> cui lunghezza è specificata dal campo SIZE del Simbolo-1. La paro<strong>la</strong> VLI<br />

si ottiene come segue: <strong>per</strong> ogni “piano” in<strong>di</strong>viduato dal valore <strong>di</strong> SIZE, si effettua una translitterazione con parole <strong>di</strong><br />

co<strong>di</strong>ce <strong>di</strong> lughezza pari proprio a SIZE. Un esempio re<strong>la</strong>tivo a SIZE=3 é riportato in Tab.3.4.<br />

AMPLITUDE -7 -6 -5 -4 4 5 6 7<br />

Paro<strong>la</strong> <strong>di</strong> Co<strong>di</strong>ce 000 001 010 011 100 101 110 111<br />

Tabel<strong>la</strong> 3.4: Translitterazione del campo AMPLITUDE (SIZE=3).<br />

Sia i VLC che i VLI sono co<strong>di</strong>ci a lunghezza <strong>di</strong> paro<strong>la</strong> variabile, ma solo i VLC sono co<strong>di</strong>ci <strong>di</strong> Huffman. Un fatto<br />

notevole è che <strong>la</strong> lunghezza <strong>di</strong> un VLC non è nota finchè <strong>la</strong> paro<strong>la</strong> non è stata deco<strong>di</strong>ficata, mentre <strong>la</strong> lunghezza <strong>di</strong><br />

un VLI è contenuta nel VLC precedente: <strong>la</strong> coppia VLC e VLI costituisce una paro<strong>la</strong> <strong>di</strong> un co<strong>di</strong>ce concatenato.<br />

3.2.4 Deco<strong>di</strong>ficatore<br />

Il deco<strong>di</strong>ficatore, come mostrato nello schema qui <strong>di</strong> seguito riportato, è cosituito da blocchi analoghi a quelli del<br />

co<strong>di</strong>ficatore.<br />

Dati Immagine<br />

Compressa<br />

Deco<strong>di</strong>ficatore<br />

Entropico<br />

Tavole<br />

( DCT)<br />

X [ k , k ]<br />

1 2<br />

De-Quantizzatore<br />

Tavole<br />

( DCT)<br />

X [ k , k ]<br />

1 2<br />

IDCT<br />

Figura 3.9: Schema del Deco<strong>di</strong>ficatore <strong>JPEG</strong><br />

xn [ 1, n2]<br />

Immagine<br />

Ricostruita<br />

Il deco<strong>di</strong>ficatore entropico rimappa, me<strong>di</strong>ante le tavole comunicate con i dati, lo stream <strong>di</strong> cifre binarie in simboli<br />

interme<strong>di</strong> e da questi in valori quantizzati.<br />

Dopo aver calco<strong>la</strong>to i coefficienti DC, i.e.<br />

DCi = DCi−1 + ∆DCi


56 CAPITOLO 3. LO STANDARD <strong>JPEG</strong> PER LA COMPRESSIONE DI IMMAGINI FISSE<br />

il de-quantizzatore ripristina <strong>la</strong> <strong>di</strong>namica moltiplicando ciascun coefficiente DCT <strong>per</strong> il re<strong>la</strong>tivo coefficiente <strong>di</strong><br />

quantizzazione, comunicato con i dati, i.e.<br />

ˆX (DCT) [k1,k2] = ˙X (DCT) [k1,k2] · Q[k1,k2]<br />

La trasformazione IDCT o<strong>per</strong>a il calcolo del<strong>la</strong> Trasformata Coseno Discreta Inversa, ottenendo i campioni del<br />

blocchetto ˆx[n1,n2], affetti dal<strong>la</strong> <strong>di</strong>storsione introdotta nel<strong>la</strong> co<strong>di</strong>fica.<br />

Infine, l’immagine completa si ottiene posizionando correttamente, secondo un or<strong>di</strong>ne lessicografico, tutti i<br />

blocchetti 8x8.<br />

3.3 Modalità Progressiva<br />

Tale modalità è impiegata quando si voglia trasferire una immagine co<strong>di</strong>ficata su un canale a basso bit-rate, in<br />

quanto consente <strong>di</strong> trasferire rapidamente una versione a bassa qualità dell’immagine, e.g. <strong>per</strong> render<strong>la</strong> subito visibile<br />

all’utente, e <strong>di</strong> raffinar<strong>la</strong> <strong>per</strong> passi successivi.<br />

Sostanzialmente, in fase <strong>di</strong> co<strong>di</strong>fica, i coefficienti DCT vengono co<strong>di</strong>ficati in gruppi successivi, e tali gruppi<br />

sono poi inviati in successione attraverso il canale; tipicamente i gruppi <strong>di</strong> coefficienti sono selezionati in base al<strong>la</strong><br />

loro importanza psicovisiva, e dunque il primo gruppo comprende il coefficiente DC (livello me<strong>di</strong>o <strong>di</strong> grigio del<br />

blocchetto) e alcuni coefficienti AC.<br />

L’immagine deco<strong>di</strong>ficata dal<strong>la</strong> ricezione <strong>di</strong> (solo) tale gruppo si presenterà come un insieme <strong>di</strong> blocchi uniformi;<br />

aggiungendo un secondo gruppo <strong>di</strong> coefficienti AC, il dettaglio dell’immagine aumenterà, e così via fino a raggiungere<br />

il livello corrispondente a quello ottenibile me<strong>di</strong>ante <strong>la</strong> modalità sequenziale.<br />

La modalità progressiva si artico<strong>la</strong> in due meto<strong>di</strong> complementari:<br />

• selezione spettrale;<br />

• approssimazioni successive.<br />

DCT<br />

0<br />

1<br />

2<br />

62<br />

63<br />

MSB<br />

BLOCCHI<br />

LSB<br />

Figura 3.10: Rappresentazione numerica dei coefficienti DCT <strong>per</strong> i vari blocchetti <strong>di</strong> un’immagine.<br />

Con riferimento al<strong>la</strong> Fig.3.10, dove <strong>la</strong> rappresentazione numerica dei coefficienti DCT dei vari blocchetti è illustrata<br />

in modo tri<strong>di</strong>mensionale, i meto<strong>di</strong> <strong>di</strong> selezione spettrale e approssimazioni successive sono illustrati in Fig.3.11.


3.3. MODALITÀ PROGRESSIVA 57<br />

0<br />

1<br />

2<br />

3<br />

4<br />

5<br />

61<br />

62<br />

63<br />

BLOCCHI<br />

prima scansione<br />

seconda scansione<br />

ultima scansione<br />

SELEZIONE SPETTRALE<br />

11 10<br />

BLOCCHI<br />

prima scansione<br />

9 8<br />

seconda scansione<br />

1<br />

ultima scansione<br />

APPROSSIMAZIONI SUCCESSIVE<br />

Figura 3.11: Rappresentazione numerica dei coefficienti DCT <strong>per</strong> i vari blocchetti <strong>di</strong> un’immagine nelle modalità progressive<br />

selezione spettrale e approssimazioni successive.


58 CAPITOLO 3. LO STANDARD <strong>JPEG</strong> PER LA COMPRESSIONE DI IMMAGINI FISSE<br />

3.4 Modalità Gerarchica<br />

Tale modalità rappresenta una alternativa al<strong>la</strong> realizzazione del<strong>la</strong> modalità progressiva, e si basa sul<strong>la</strong> co<strong>di</strong>fica <strong>di</strong> una<br />

immagine come successione <strong>di</strong> immagini a risoluzione via via crescente.<br />

M:1 =<br />

2 / M<br />

2<br />

2 / M<br />

b g F H G I K J F H G I K J<br />

j j<br />

<br />

1 2 1mod 2<br />

2mod<br />

2<br />

He , e rect<br />

rect<br />

2M<br />

2M<br />

Figura 3.12: Sottocampionamento bi<strong>di</strong>mensionale.<br />

Il termine risoluzione si riferisce al contenuto <strong>di</strong> frequenze spaziali dell’immagine. L’o<strong>per</strong>azione <strong>di</strong> sottocampionamento,<br />

ottenuta <strong>per</strong> filtraggio e decimazione3.3 come illustrato in Fig.3.12 definisce il contenuto <strong>di</strong> frequenze spaziali<br />

dell’immagine da co<strong>di</strong>ficare. Il filtraggio è necessario <strong>per</strong> evitare l’introduzione <strong>di</strong> <strong>di</strong>storsione da aliasing nel<strong>la</strong><br />

successiva o<strong>per</strong>azione <strong>di</strong> decimazione.<br />

1:P =<br />

PB<br />

1<br />

2 / P<br />

MB<br />

b g F H G I K J F H G I K J<br />

j j<br />

<br />

1 2 2 1mod 2<br />

2mod<br />

2<br />

He , e P rect<br />

rect<br />

2P<br />

2P<br />

Figura 3.13: Interpo<strong>la</strong>zione bi<strong>di</strong>mensionale.<br />

L’o<strong>per</strong>azione <strong>di</strong> interpo<strong>la</strong>zione, ottenuta <strong>per</strong> espansione3.4 e filtraggio come illustrato in Fig.3.13, ripristina soltanto<br />

le corrette <strong>di</strong>mensioni dell’immagine, che risulta comunque a banda limitata (non pienamente risoluta). Il guadagno<br />

del filtro recu<strong>per</strong>a lo sca<strong>la</strong>mento introdotto da precedenti o<strong>per</strong>azioni <strong>di</strong> sottocampionamento.<br />

3.3 L’o<strong>per</strong>azione <strong>di</strong> decimazione <strong>di</strong> un fattore M in entrambe le <strong>di</strong>mensioni è definita come segue:<br />

xd[n1,n2] def<br />

= x[n1 · M, n2 · M]<br />

3.4L’o<strong>per</strong>azione <strong>di</strong> espansione <strong>di</strong> un fattore P in entrambe le <strong>di</strong>mensioni è definita come segue:<br />

xe[n1,n2] def<br />

⎧<br />

⎨x[n1/P,<br />

n2/P ] <strong>per</strong> n1,n2 =0 modP (n1 e n2 multipli <strong>di</strong> P )<br />

=<br />

⎩0<br />

<strong>per</strong> n1,n2 = 0 modP (n1 e n2 non multipli <strong>di</strong> P )<br />

2<br />

2 / P<br />

1


3.4. MODALITÀ GERARCHICA 59<br />

La Fig.3.14 mostra un esempio <strong>di</strong> funzionamento dove co<strong>di</strong>ficatori con <strong>di</strong>verso bit-rate (qualità) sono impiegati<br />

<strong>per</strong> le <strong>di</strong>verse “trasmissioni”.<br />

xn [ , n ] 1.2 bit/pixel<br />

prima trasmissione<br />

1 2<br />

1.2/16 = 0.075 bit/pixel<br />

4:1 Cod-1<br />

Decod-1<br />

1:4<br />

2:1<br />

Decod-1<br />

_<br />

1:2<br />

+<br />

r42 , n1n2 [ , ]<br />

[ n1, n2]<br />

_<br />

+<br />

r , n n [ , ]<br />

21 1 2<br />

[ n1, n2]<br />

_<br />

+<br />

Cod-1<br />

Cod-2<br />

seconda trasmissione<br />

1.2/4 = 0.3 bit/pixel<br />

Decod-1<br />

+<br />

+<br />

1:2<br />

Decod-2<br />

+<br />

+<br />

Decod-1<br />

terza trasmissione<br />

0.5 bit/pixel<br />

Decod-2<br />

1:2<br />

[ n1, n2]<br />

rn [ , n ] xn [ , n ] xn<br />

[ , n ]<br />

1 2 1 2 1 2<br />

+<br />

+<br />

+<br />

+<br />

[ n1, n2]<br />

Figura 3.14: Funzionamento del<strong>la</strong> modalità gerarchica.<br />

1:2<br />

0.075 bit/pixel<br />

x 4[ n1, n2]<br />

2<br />

2<br />

2<br />

1<br />

0.075+0.3=0.375 bit/pixel<br />

x 2[ n1, n2]<br />

1<br />

0.5+0.375=0.875 bit/pixel<br />

xn [ 1, n2]<br />

La prima trasmissione ottiene un’immagine con risoluzione 1/4. Il risultato delle trasmissione successive al<strong>la</strong> prima<br />

è quello <strong>di</strong> incrementare <strong>la</strong> risuluzione, portando<strong>la</strong> prima a 1/2, e ottenendo infine <strong>la</strong> piena risoluzione.<br />

Occorre notare che nel <strong>la</strong>to trasmissione sono riprodotte le immagini α[n1,n2] e β[n)1,n2] ricostruite al ricevitore.<br />

Questo <strong>per</strong>mette <strong>di</strong> costruire al ricevitore gli incrementi, o residui r4,2[n1,n2] e r2,2[n1,n2], necessari al ricevitore<br />

<strong>per</strong> aumentare <strong>la</strong> risoluzione a partire da un’immagine a risoluzione minore.<br />

Al ricevitore, <strong>la</strong> prima immagine deco<strong>di</strong>ficata ˆx4[n1,n2] contiene solo un quarto delle frequenze spaziali dell’immagine<br />

originale x[n1,n2], e precisamente nel quadrato <strong>di</strong> banda |ω1| ≤ π/4, |ω2| ≤ π/4. Essa appare come una<br />

versione fortemente sfocata dell’immagine originale, ed è affetta dalle <strong>per</strong><strong>di</strong>te introdotte nel co<strong>di</strong>ficatore-1.<br />

La seconda immagine deco<strong>di</strong>ficata ˆx2[n1,n2] contiene metà delle frequenze spaziali dell’immagine originale<br />

x[n1,n2], nel quadrato <strong>di</strong> banda |ω1|≤π/2, |ω2|≤π/2. Essa è stata ottenuta sommando all’immagine meno risoluta<br />

ˆx4[n1,n2] il residuo ˆr4,2[n1,n2], tenendo conto delle necessarie interpo<strong>la</strong>zioni <strong>per</strong> riportare le immagini ad avere le<br />

stesse <strong>di</strong>mensioni, e appare come una versione me<strong>di</strong>amente sfocata dell’immagine originale. Le <strong>per</strong><strong>di</strong>te sono dovute<br />

solo al co<strong>di</strong>ficatore-1 impiegato <strong>per</strong> trasmettere r4,2[n1,n2].<br />

La terza immagine deco<strong>di</strong>ficata ˆx[n1,n2] ha banda piena (nessun effetto <strong>di</strong> sfocamento), ed è stata ottenuta<br />

sommando all’immagine meno risoluta ˆxe[n1,n2] il residuo ˆr2,1[n1,n2], tenendo conto delle necessarie interpo<strong>la</strong>zioni<br />

<strong>per</strong> riportare le immagini ad avere le stesse <strong>di</strong>mensioni. Le <strong>per</strong><strong>di</strong>te sono dovute solo al co<strong>di</strong>ficatore-2 impiegato <strong>per</strong><br />

trasmettere r2,1[n1,n2].<br />

Si noti che trasmettendo il residuo finale r[n1,n2] me<strong>di</strong>ante co<strong>di</strong>fica senza <strong>per</strong><strong>di</strong>te, anche lo schema complessivo<br />

risulta senza <strong>per</strong><strong>di</strong>te.<br />

Per quanto riguarda il calcolo del bit-rate, occorre <strong>di</strong>re che il parametro 1.2 bit/pixel che caratterizza il co<strong>di</strong>ficatore-<br />

1 si riferisce al risultato che tale co<strong>di</strong>ficatore ottiene sull’immagine a piena risoluzione; o<strong>per</strong>ando sull’immagine<br />

sottocampionata, il bit-rate si abbatte <strong>di</strong> 1/16 nel<strong>la</strong> prima trasmissione, e <strong>di</strong> 1/4 nel<strong>la</strong> seconda trasmissione.<br />

1


Capitolo 4<br />

Elementi <strong>di</strong> Co<strong>di</strong>fica Video<br />

Contenuto<br />

4.1 Riduzione del<strong>la</strong> Ridondanza Temporale: Motocompensazione . . . . . . . . . . . . . . . . . . . 60<br />

4.1.1 Motocompensazione in Avanti . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

4.1.2 Motocompensazione Bi<strong>di</strong>rezionale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

4.2 Successione <strong>di</strong> quadri con motocompensazione . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

4.3 Gli <strong>Standard</strong> H.261 ed H.263 <strong>per</strong> <strong>la</strong> <strong>Compressione</strong> <strong>di</strong> Sequenze Video . . . . . . . . . . . . . . 64<br />

4.3.1 Mo<strong>di</strong> <strong>di</strong> co<strong>di</strong>fica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

4.3.2 Stima del moto e motocompensazione . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

4.3.3 Co<strong>di</strong>fica dei Vettori <strong>di</strong> Spostamento . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

4.3.4 Trasformazione DCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

4.3.5 Quantizzazione . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

4.3.6 Co<strong>di</strong>fica Entropica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

4.3.7 Controllo <strong>di</strong> Co<strong>di</strong>fica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

4.4 <strong>Standard</strong> H.262 (MPEG-2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70<br />

4.1 Riduzione del<strong>la</strong> Ridondanza Temporale: Motocompensazione<br />

Consideriamo una tipica sequenza video: essa è costituita dal<strong>la</strong> rapida successione <strong>di</strong> quadri (frames) ciascuno dei<br />

quali è una immagine fissa.<br />

Tali quadri si susseguono ad uno specifico frame-rate, tipicamente compreso fra 25 e 30 frames/s. Ciò implica<br />

che <strong>la</strong> durata <strong>di</strong> presentazione <strong>di</strong> ogni singolo quadro sia compresa fra 33 e 40 ms/frame. Possiamo ragionevolmente<br />

supporre che, in generale, due frame successivi presentino una alta corre<strong>la</strong>zione fra loro: pensando infatti <strong>di</strong> riprendere<br />

un soggetto in movimento, e.g. un presentatore del telegiornale, ci si rende imme<strong>di</strong>atamente conto che tale soggetto<br />

non potrà compiere movimenti troppo bruschi nel breve tempo occorrente fra due frame successivi. L’idea base da<br />

cui partire è quin<strong>di</strong> che, in me<strong>di</strong>a, frame successivi siano molto simili fra loro.<br />

La motocompensazione è, in essenza, un proce<strong>di</strong>mento me<strong>di</strong>ante il quale è possibile, in base a quanto detto sopra,<br />

ottenere una riduzione del<strong>la</strong> ridondanza temporale presente in una sequenza video. Considerando una coppia <strong>di</strong> quadri<br />

a<strong>di</strong>acenti, infatti, se il quadro corrente è molto simile al quadro precedente, in fase <strong>di</strong> co<strong>di</strong>fica dell’informazione<br />

apportata dal quadro corrente potremo co<strong>di</strong>ficare solo <strong>la</strong> <strong>di</strong>fferenza, auspicabilmente picco<strong>la</strong>, fra i dati presenti nel<br />

quadro corrente e quelli del quadro precedente, quest’ultimo detto <strong>di</strong> riferimento. Sarà inoltre necessario inviare<br />

anche alcune informazioni re<strong>la</strong>tive al movimento intercorso fra i due quadri.<br />

60


4.1. RIDUZIONE DELLA RIDONDANZA TEMPORALE: MOTOCOMPENSAZIONE 61<br />

L’assunto <strong>di</strong> quadri molto corre<strong>la</strong>ti fra loro non è sempre corretto, basti pensare al<strong>la</strong> ripresa <strong>di</strong> un soggetto molto<br />

veloce (una vettura <strong>di</strong> Formu<strong>la</strong> 1, un pallone, etc.), o a caratteristiche tipiche delle pellicole cinematografiche, quali<br />

i bruschi cambi <strong>di</strong> scena tipici del montaggio, o ancora ai cambi <strong>di</strong> scena dovuti ad un repentino cambiamento<br />

dell’inquadratura. In tutti questi casi <strong>la</strong> motocompensazione non è in grado <strong>di</strong> o<strong>per</strong>are in modo efficiente, e dunque<br />

tali casi richiedono l’utlizzo <strong>di</strong> stratagemmi partico<strong>la</strong>ri, sempre che non sia possibile accettare il deca<strong>di</strong>mento del<br />

grado <strong>di</strong> compressione da essi causato. Peraltro, occorre sottolineare che, in generale, tali eventi sono ben tollerati e<br />

solo in applicazioni critiche possono creare realmente problemi.<br />

Entriamo ora più in dettaglio nel processo <strong>di</strong> motocompensazione. Come accadeva <strong>per</strong> <strong>la</strong> co<strong>di</strong>fica <strong>per</strong> trasformate,<br />

ciascun quadro viene sud<strong>di</strong>viso in blocchi da 8x8 pixel; inoltre, tali blocchi sono raggruppati a quattro a quattro nei<br />

cosiddetti macroblocchi (MB) da 16x16 pixel.<br />

4.1.1 Motocompensazione in Avanti<br />

Tale caso prevede che ogni MB del quadro corrente sia confrontato (matched) con un sequenza bi<strong>di</strong>mensionale <strong>di</strong><br />

64x64 pixel presenti nel quadro precedente, posizionati in genere nell’imme<strong>di</strong>ato intorno, cosiddetto Search Window,<br />

del MB in esame; <strong>la</strong> sequenza che meglio rappresenta il MB in co<strong>di</strong>fica è utilizzato come pre<strong>di</strong>ttore <strong>di</strong> quest’ultimo<br />

(best match), con ciò intendendo che il MB ottenuto dal<strong>la</strong> <strong>di</strong>fferenza fra i due è considerato come errore <strong>di</strong> pre<strong>di</strong>zione.<br />

Sono inoltre calco<strong>la</strong>ti i valori (in pixel) dello spostamento orizzontale e verticale del best-match MB rispetto a quello<br />

corrente; tali informazioni costituiscono il cosiddetto Vettore <strong>di</strong> Spostamento (Motion Vector, MV).<br />

Figura 4.1: Motocompensazione in Avanti


62 CAPITOLO 4. ELEMENTI DI CODIFICA VIDEO<br />

Il calcolo del vettore spostamento si effettua come descritto nel seguito. Sia MBc i,j [0, 0] il pixel <strong>di</strong> riferimento<br />

(in basso a sinistra), del macroblocco (i, j) del quadro corrente. I 64x64 pixel dell’intero macroblocco si ottengono<br />

dal<strong>la</strong> sequenza bi<strong>di</strong>mensionale MB (c)<br />

i,j [n1,n2], 0 ≤ n1,n2 ≤ 15. In<strong>di</strong>cando con MB (p)<br />

i,j [0, 0] il pixel <strong>di</strong> riferimento del<br />

macroblocco (i, j) del quadro precedente, le componenti (dMV 1 ,dMV 2 ) del vettore spostamento sono determinate come<br />

segue<br />

(d MV<br />

1 ,d MV<br />

15X<br />

15X<br />

2 )=arg min<br />

(d1,d2)∈SW<br />

n1=0 n2=0<br />

³<br />

Φ MB (c)<br />

i,j [n1,n2] − MB (p)<br />

i,j [n1<br />

´<br />

− d1,n2 − d2]<br />

(4.1.1)<br />

avendo in<strong>di</strong>cato con SW l’insieme dei pixel costituenti <strong>la</strong> Search Window, e con Φ(·) una opportuna funzione che<br />

misura il costo associato al<strong>la</strong> <strong>di</strong>fferenza tra i macroblocchi del quadro corrente e del quadro <strong>di</strong> riferimento. Tipicamente<br />

ΦSSD(·) =(·) 2 , costo che corrisponde al<strong>la</strong> minimizzazione del<strong>la</strong> somma dei quadrati delle <strong>di</strong>fferenze (Sum of Squared<br />

Differences, SSD), o ΦSAD(·) =|·|, costo che corrisponde al<strong>la</strong> minimizzazione del<strong>la</strong> somma dei valori assoluti delle<br />

<strong>di</strong>fferenze (Sum of Absolute Differences, SAD, oppure Mean Square Error, MSE).<br />

La determinazione del vettore spostamento effettuata me<strong>di</strong>ante <strong>la</strong> (4.1.1) è ottenuta me<strong>di</strong>ante una ricerca esaustiva<br />

sull’intera Search Window. Una Search Window utilizzata tipicamente nelle applicazioni, 15 ≤ d1,d2 ≤ 15, é<br />

costituita da 31x31 pixel. Naturalmente, il vettore spostamento è vinco<strong>la</strong>to in modo tale che tutti i pixel da esso<br />

puntati siano entro l’area del quadro <strong>di</strong> riferimento.<br />

Algoritmi <strong>di</strong> ricerca meno onerosi dal punto <strong>di</strong> vista computazionale, e.g. ricerca logaritmica, si applicano quando<br />

è ragionevole assumere che <strong>la</strong> funzione da minimizzare nel<strong>la</strong> (4.1.1) risulti convessa nell’intorno del suo minimo. In<br />

generale, l’unica tecnica che assicura <strong>la</strong> determinazione del minimo del<strong>la</strong> funzione <strong>di</strong> costo è <strong>la</strong> ricerca esaustiva;<br />

tuttavia, il guadagno ottenuto in termini <strong>di</strong> tempi <strong>di</strong> calcolo da tecniche veloci spesso giustifica <strong>la</strong> loro adozione<br />

poichè il prezzo da pagare in termini <strong>di</strong> pre<strong>di</strong>zione meno accurata è quasi sempre trascurabile.<br />

4.1.2 Motocompensazione Bi<strong>di</strong>rezionale<br />

Figura 4.2: Motocompensazione Bi<strong>di</strong>rezionale


4.2. SUCCESSIONE DI QUADRI CON MOTOCOMPENSAZIONE 63<br />

Tale modalità costituisce una evoluzione del<strong>la</strong> motocompensazione in avanti, in quanto consente <strong>di</strong> utilizzare sia un<br />

quadro precedente che uno successivo a quello in co<strong>di</strong>fica come pre<strong>di</strong>ttori <strong>di</strong> quest’ultimo. Più in dettaglio, <strong>per</strong> ogni<br />

MB in co<strong>di</strong>fica è possibile utilizzare come riferimento o un best-matching MB appartenente al quadro precedente, o<br />

un best-matching MB appartenente al quadro successivo, o <strong>la</strong> me<strong>di</strong>a fra tali due MB. In questo ultimo caso al MB<br />

corrente competono due MV (MV1, MV2), ciascuno re<strong>la</strong>tivo ad uno dei due MB <strong>di</strong> riferimento.<br />

In<strong>di</strong>cando con MB (f)<br />

i,j [0, 0] il pixel <strong>di</strong> riferimento del macroblocco (i, j) del quadro successivo, le componenti<br />

d MV1 =(d MV1<br />

1<br />

i.e.<br />

,d MV1<br />

2<br />

) e d MV2 =(d MV2<br />

1<br />

d MV1 =argmin<br />

d MV2 =argmin<br />

,d MV2<br />

2 ) dei due vettori spostamento sono determinante in modo in<strong>di</strong>pendente,<br />

15X<br />

15X<br />

d∈SW<br />

n1=0 n2=0<br />

15X<br />

15X<br />

d∈SW<br />

n1=0 n2=0<br />

³<br />

Φ<br />

³<br />

Φ<br />

MB (c)<br />

i,j<br />

MB (c)<br />

i,j<br />

[n] − MB(p)<br />

i,j<br />

[n] − MB(f)<br />

i,j<br />

´<br />

[n − d]<br />

´<br />

[n − d]<br />

(4.1.2)<br />

La motocompensazione bi<strong>di</strong>rezionale raggiunge più alti rapporti <strong>di</strong> compressione, ma ha una serie <strong>di</strong> svantaggi che ne<br />

rendono non sempre conveniente l’impiego: richiede il doppio del<strong>la</strong> memoria <strong>per</strong> immagazzinare i quadri, aumenta il<br />

ritardo <strong>di</strong> co<strong>di</strong>fica, porta un generale aumento del<strong>la</strong> complessità del co<strong>di</strong>ficatore in quanto <strong>la</strong> fase <strong>di</strong> block-matching,<br />

<strong>la</strong> più onerosa dal punto <strong>di</strong> vista computazionale <strong>di</strong> tutto il processo <strong>di</strong> co<strong>di</strong>fica, deve essere eseguita due volte <strong>per</strong><br />

ogni MB.<br />

4.2 Successione <strong>di</strong> quadri con motocompensazione<br />

Con riferimento a un cosiddetto “Group of Pictures” (GOP), il primo quadro è sempre co<strong>di</strong>ficato senza motocompensazione<br />

(INTRA), gli altri sono co<strong>di</strong>ficati con motocompensazione (INTER), con pre<strong>di</strong>zione in avanti (P), o<br />

bi<strong>di</strong>rezionale (B). I quadri <strong>di</strong> riferimento nel<strong>la</strong> pre<strong>di</strong>zione bi<strong>di</strong>rezionale possono essere I o P, ma non B. La <strong>di</strong>mensione<br />

e <strong>la</strong> composizione <strong>di</strong> un GOP non sono fissati dai vari standard, <strong>di</strong>pendono piuttosto dalle esigenze maturate<br />

nel corso del<strong>la</strong> co<strong>di</strong>fica. Un esempio è mostrato in Fig.4.3.<br />

0 1 2 3 4 5 6 7 8<br />

I<br />

B B B P B B B<br />

Figura 4.3: Un tipico GOP.<br />

Con riferimento al<strong>la</strong> Fig.4.3, l’or<strong>di</strong>ne con il quale il decoder riceverà i quadri sarà:<br />

0 I , 4 P , 1 B , 2 B , 3 B , 8 I , 5 B , 6 B , 7 B<br />

con conseguente aumento del ritardo complessivo <strong>di</strong> co<strong>di</strong>fica.<br />

I


64 CAPITOLO 4. ELEMENTI DI CODIFICA VIDEO<br />

4.3 Gli <strong>Standard</strong> H.261 ed H.263 <strong>per</strong> <strong>la</strong> <strong>Compressione</strong> <strong>di</strong> Sequenze Video<br />

Le raccomandazioni internazionali ITU riguardanti gli standard H.261 (Video Codec for Au<strong>di</strong>ovisual Services at px64<br />

kbit/s) e H.263 (Video Codec for Narrow Telecomunication Channels at < px64 kbit/s) specificano completamente<br />

<strong>la</strong> struttura e il comportamento del co<strong>di</strong>ficatore, <strong>la</strong> sintassi e l’organizzazione del bitstream.<br />

La sequenza video in ingresso è costituita da una sequenza <strong>di</strong> quadri YCBCR <strong>di</strong> luminanza/crominanza, 4.1 <strong>di</strong><br />

<strong>di</strong>mensioni CIF (288x360) o QCIF (144x180). 4.2 L’uso del CIF è opzionale, il QCIF è mandatorio.<br />

Formato Dimensioni (Y )<br />

CODEC<br />

H.261 H.263<br />

SQCIF 128x96 opzionale richiesto<br />

QCIF 176x144 richiesto richiesto<br />

CIF 352x288 opzionale opzionale<br />

4CIF 704x576 non definito opzionale<br />

16CIF 1408x1152 non definito opzionale<br />

Tabel<strong>la</strong> 4.1: Formati negli standard H.261 e H.263.<br />

Il massimo frame-rate è 30000/1001 ' 29.97 fps, con <strong>la</strong> possibilità <strong>di</strong> saltare 1, 2 o 3 quadri.<br />

Si noti che occorrono 36.45 Mbit/s <strong>per</strong> trasmettere, senza compressione, un video CIF al<strong>la</strong> massima velocità <strong>di</strong><br />

quadro, mentre <strong>per</strong> un video QCIF occorrono 9.115 Mbit/s .<br />

Le componenti <strong>di</strong> crominanza sono sottocampionate in modalità 4:2:0, i.e. sottocampionate <strong>di</strong> un fattore 2 in<br />

entrambe le <strong>di</strong>rezioni, quattro pixel con<strong>di</strong>vidono <strong>la</strong> stessa crominanza (ve<strong>di</strong> Fig.4.4).<br />

Figura 4.4: Sottocampionamento del<strong>la</strong> crominanza 4:2:2 (sinistra) e 4:2:0 (destra). Il simbolo X rappresenta un generico<br />

campione <strong>di</strong> luminanza, i due semi-quadrati rappresentano una coppia <strong>di</strong> campioni CRCB<br />

luminanza (4:2:2), o da quattro campioni <strong>di</strong> luminanza (4:2:0).<br />

con<strong>di</strong>visa da due campioni <strong>di</strong><br />

4.1 Dai coefficienti tricromatici del sistema <strong>di</strong> riferimento colorimentrico NTSC RN ,GN ,BN , <strong>la</strong> trasformazione in luminanza/crominanza si<br />

ottiene nel modo seguente:<br />

Y =0.299 · RN +0.587 · GN +0.114 · BN<br />

CR = RN − Y<br />

CB = BN − Y<br />

4.2 Common Interme<strong>di</strong>ate Format (CIF) e Quarter-CIF (QCIF), formati standard ITU.<br />

;<br />

RN = CR + Y<br />

BN = CB + Y<br />

GN = Y − 0.299 · RN − 0.114 · BN<br />

0.587


4.3. GLI STANDARD H.261 ED H.263 PER LA COMPRESSIONE DI SEQUENZE VIDEO 65<br />

Ogni quadro è <strong>di</strong>viso in gruppi <strong>di</strong> macroblocchi (GOB). A un macroblocco <strong>di</strong> 16x16 pixel <strong>di</strong> luminanza restano<br />

associati due corrispondenti insiemi <strong>di</strong> 8x8 pixel <strong>di</strong> crominanza. In termini <strong>di</strong> blocchetti 8x8, un macroblocco consta<br />

ad essere costituito da 6 blocchetti: 4 <strong>di</strong> luminanza, e i corrispondenti 2 <strong>di</strong> crominanza.<br />

Tale struttura gerarchica è mostrata nel<strong>la</strong> Fig.4.5.<br />

Figura 4.5: Struttura gerarchica <strong>di</strong> Quadro<br />

Il co<strong>di</strong>ficatore utilizza congiuntamente tecniche <strong>di</strong> pre<strong>di</strong>zione Inter-frame (<strong>per</strong> ridurre <strong>la</strong> ridondanza temporale me<strong>di</strong>ante<br />

motocompensazione) e tecniche <strong>di</strong> co<strong>di</strong>fica a trasformata Intra-frame (<strong>per</strong> ridurre <strong>la</strong> ridondanza spaziale). La<br />

struttura generale del co<strong>di</strong>ficatore è mostrata nel<strong>la</strong> Fig.4.6.


66 CAPITOLO 4. ELEMENTI DI CODIFICA VIDEO<br />

4.3.1 Mo<strong>di</strong> <strong>di</strong> co<strong>di</strong>fica<br />

Figura 4.6: Schema semplificato del Co<strong>di</strong>ficatore H.263<br />

I possibili mo<strong>di</strong> <strong>di</strong> co<strong>di</strong>fica sono essenzialmente due: INTER ed INTRA.<br />

Il modo <strong>di</strong> co<strong>di</strong>fica INTRA non prevede pre<strong>di</strong>zione interquadro. I frame co<strong>di</strong>ficati INTRA sono detti “frame-I”.<br />

Il modo <strong>di</strong> co<strong>di</strong>fica INTER, invece, prevede pre<strong>di</strong>zione interquadro con eventuale motocompensazione: in tale<br />

modalità, <strong>per</strong> ciascun quadro, è co<strong>di</strong>ficato il cosiddetto “quadro errore <strong>di</strong> pre<strong>di</strong>zione”, ossia <strong>la</strong> <strong>di</strong>fferenza fra il quadro<br />

corrente e quello predetto e motocompensato. I quadri co<strong>di</strong>ficati INTER con pre<strong>di</strong>zione in avanti sono detti “frame-P”.<br />

Il modo <strong>di</strong> co<strong>di</strong>fica può essere segna<strong>la</strong>to su base quadro (quadri I/P), o su base macroblocco nei quadri P.<br />

Nello standard H.263 è possibile avere dei quadri co<strong>di</strong>ficati INTER con pre<strong>di</strong>zione bi<strong>di</strong>rezionale (“frame-B”).<br />

Un frame-B è sempre associato al successivo frame-P <strong>di</strong> riferimento in un cosiddetto frame-PB. Un esempio <strong>di</strong> GOP<br />

con frame-FB é mostrato in Fig.4.7.<br />

0 1 2 3 4<br />

I<br />

B<br />

P B<br />

PB PB<br />

Figura 4.7: Un esempio <strong>di</strong> GOP nello standard H.263.<br />

P


4.3. GLI STANDARD H.261 ED H.263 PER LA COMPRESSIONE DI SEQUENZE VIDEO 67<br />

4.3.2 Stima del moto e motocompensazione<br />

La valutazione del vettore spostamento si effettua solo su macroblocchi <strong>di</strong> luminanza. La motocompensazione sul<strong>la</strong><br />

crominanza si effettua utilizzando il vettore spostamento misurato dal<strong>la</strong> luminanza.<br />

Nello standard H.261 <strong>la</strong> Search Window è limitata ai valori interi −15 ≤ d1,d2 ≤ 15.<br />

Nello standard H.263, si considerano anche valori semi-interi, e.g. d1 =3.5,d2 =7.5, e <strong>la</strong> Search Window è<br />

−16 ≤ d1,d2 ≤ 15.5. Per i valori semi-interi è necessario interpo<strong>la</strong>re sul quadro precedente. Inoltre, è possibile<br />

valutare il vettore spostamento su blocchetti 8x8.<br />

4.3.3 Co<strong>di</strong>fica dei Vettori <strong>di</strong> Spostamento<br />

Nello standard H.263, il vettore <strong>di</strong> spostamento MV è co<strong>di</strong>ficato pre<strong>di</strong>ttivamente, ossia è co<strong>di</strong>ficata <strong>la</strong> <strong>di</strong>fferenza<br />

MVD fra tale vettore ed un opportuno vettore <strong>di</strong> spostamento “pre<strong>di</strong>ttore” MVP, ottenuto come il valore me<strong>di</strong>ano <strong>di</strong><br />

tre vettori opportunamente scelti fra quelli appartenenti a tre macroblocchi a<strong>di</strong>acenti, secondo quanto mostrato dal<strong>la</strong><br />

figura seguente. Le due componenti del vettore MVD sono poi co<strong>di</strong>ficate entropicamente utilizzando un co<strong>di</strong>ce a<br />

lunghezza variabile specificato nello standard.<br />

4.3.4 Trasformazione DCT<br />

Figura 4.8: Vettori <strong>di</strong> Spostamento<br />

La trasformazione DCT si applica ai blocchetti <strong>di</strong> 8x8 pixel, sia <strong>per</strong> i quadri co<strong>di</strong>ficati INTRA che <strong>per</strong> quelli co<strong>di</strong>ficati<br />

INTER. Come nello standard <strong>JPEG</strong>, non é specificato un metodo specifico <strong>per</strong> calco<strong>la</strong>re <strong>la</strong> DCT.


68 CAPITOLO 4. ELEMENTI DI CODIFICA VIDEO<br />

4.3.5 Quantizzazione<br />

Per quanto riguarda il coefficiente DC, abbiamo sempre Q[0, 0] = 8. Per i restanti coefficienti (AC) abbiamo<br />

Q[k1,k2] = 2·QP, con valori compresi fra 1 ≤ QP ≤ 31 (ve<strong>di</strong> Tab.4.2). Occorre sottolineare che il valore QP<br />

è tenuto fissato <strong>per</strong> un intero macroblocco, i.e. non varia <strong>per</strong> blocchetti appartenenti allo stesso macroblocco. La<br />

modalità <strong>di</strong> scelta non è specificata nello standard.<br />

Naturalmente, il valore QP può variare a seconda del tipo <strong>di</strong> co<strong>di</strong>fica (INTRA, INTER-P, INTER-B).<br />

8 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP 2·QP<br />

Tabel<strong>la</strong> 4.2: Tabelle dei passi <strong>di</strong> quantizzazione <strong>per</strong> quadri co<strong>di</strong>ficati INTRA nello standard H.263, con 1 ≤ QP ≤ 31. Per i<br />

macroblocchi e quadri co<strong>di</strong>ficati INTER abbiamo ˙ X (DCT)<br />

<br />

X<br />

INTER [k1,k2] =round<br />

(DCT)<br />

INTER [k1,k2]<br />

<br />

− QP/2<br />

.<br />

2·QP<br />

4.3.6 Co<strong>di</strong>fica Entropica<br />

Dopo quantizzazione, come detto in precedenza, i blocchi si presentano come un insieme <strong>di</strong> valori interval<strong>la</strong>ti da un<br />

gran numero <strong>di</strong> zeri, e dunque ben si prestano ad una co<strong>di</strong>faca delle corse. Innanzitutto, i coefficienti quantizzati<br />

vengono scan<strong>di</strong>ti a “zig-zag”, come in <strong>JPEG</strong>.<br />

La co<strong>di</strong>fica delle corse si effettua me<strong>di</strong>ante tre campi:<br />

• LAST: in<strong>di</strong>ca se il coefficiente corrente sia o meno l’ultimo coefficiente <strong>di</strong>verso da zero nel blocco;<br />

• RUN: il numero <strong>di</strong> zeri consecutivi che precedono il coefficiente da co<strong>di</strong>ficare;<br />

• LEVEL : il valore non nullo del coefficiente da co<strong>di</strong>ficare.<br />

I tre campi sono poi co<strong>di</strong>ficati me<strong>di</strong>ante un co<strong>di</strong>ce <strong>di</strong> lunghezza variabile che <strong>per</strong>ò co<strong>di</strong>cifica solo le terne più<br />

frequentemente ricorrenti. Per le altre si ricorre a una opportuna sequenza cosiddetta <strong>di</strong> ESCAPE.<br />

4.3.7 Controllo <strong>di</strong> Co<strong>di</strong>fica<br />

Essenzialmente, il controllo <strong>di</strong> co<strong>di</strong>fica svolge due funzioni:<br />

1. selezione del modo <strong>di</strong> co<strong>di</strong>fica INTRA/INTER.;<br />

2. assegnazione del parametro QP al quantizzatore.<br />

Per comprendere <strong>la</strong> presenza del controllo <strong>di</strong> co<strong>di</strong>fica, occorre sottolineare che il multiplexer a valle del co<strong>di</strong>ficatore<br />

video deve erogare al<strong>la</strong> sua uscita un flusso <strong>di</strong> cifre binarie a velocità costante, sebbene al suo ingresso sia presente<br />

un flusso con velocità non costante. A questo scopo provvede un’apposita memoria tampone (buffer), <strong>di</strong> <strong>di</strong>mensioni<br />

limitate. Il controllo <strong>di</strong> co<strong>di</strong>fica, quin<strong>di</strong>, <strong>di</strong>pende dallo stato <strong>di</strong> riempimento del buffer. Ad esempio, vicino al<strong>la</strong>


4.3. GLI STANDARD H.261 ED H.263 PER LA COMPRESSIONE DI SEQUENZE VIDEO 69<br />

saturazione del buffer é necessario imporre una quantizzazione più dura (alto QP), evitare una co<strong>di</strong>fica INTRA se<br />

non arrivare a saltare il quadro.<br />

In ogni caso, <strong>la</strong> selezione del modo <strong>di</strong> co<strong>di</strong>fica avviene preventivamente confrontando il minimo del<strong>la</strong> funzione <strong>di</strong><br />

costo del<strong>la</strong> <strong>di</strong>fferanza tra macroblocco corrente e il suo best-match con opportune soglie. Ad esempio, con riferimento<br />

al caso <strong>di</strong> motocompensazione in avanti (ve<strong>di</strong> <strong>la</strong> (4.1.1)), detto<br />

C(d MV )=<br />

15X<br />

15X<br />

n1=0 n2=0<br />

³<br />

Φ<br />

MB (c)<br />

i,j<br />

£ MV<br />

[n] − MB(p) i,j n − d ¤´<br />

il costo associato al<strong>la</strong> scelta del vettore spostamento d MV , <strong>la</strong> selezione si effettua come illustrato in Fig.4.9.<br />

0<br />

SKIP INTER INTRA<br />

t 1<br />

Figura 4.9: Selezione del modo <strong>di</strong> co<strong>di</strong>fica.<br />

t 2<br />

C d MV b g<br />

Come già detto, si può decidere <strong>di</strong> non co<strong>di</strong>ficare affatto il quadro corrente, <strong>la</strong>sciando al deco<strong>di</strong>ficatore il semplice<br />

compito <strong>di</strong> ricopiatura dal quadro <strong>di</strong> riferimento.


70 CAPITOLO 4. ELEMENTI DI CODIFICA VIDEO<br />

4.4 <strong>Standard</strong> H.262 (MPEG-2)<br />

<strong>Lo</strong> standard H.262 (MPEG-2) estende lo standard MPEG-14.3 <strong>per</strong> includere <strong>la</strong> co<strong>di</strong>fica <strong>di</strong> sequenze video con qualità<br />

televisiva, anche con <strong>la</strong> possibilità <strong>di</strong> interal<strong>la</strong>cciamento <strong>di</strong> semiquadri.<br />

Il para<strong>di</strong>gma del<strong>la</strong> co<strong>di</strong>fica è mutuato dallo standard H.261: blocchettizzazione, DCT, motocompensazione, e<br />

co<strong>di</strong>fica entropica.<br />

Occorre notare che lo standard definisce solo il deco<strong>di</strong>ficatore e, conseguentemente, <strong>la</strong> sintassi del bit-stream dei<br />

dati co<strong>di</strong>ficati. Naturalmente, il co<strong>di</strong>ficatore è costretto a generare un bit-stream sintatticamente corretto.<br />

Un tipico GOP è illustrato in Fig.4.10, dove riconosciamo <strong>la</strong> presenza <strong>di</strong> quadri I,P, e B.<br />

0 1 2 3 4 5 6 7 8<br />

I<br />

B B B P B B B<br />

Figura 4.10: Un tipico GOP in MPEG-2.<br />

I formati video sono specificati nei cosiddetti “livelli”, ve<strong>di</strong> Tab.4.3. 4.4<br />

Livello Formato Massimo Rapporto d’Aspetto<br />

<strong>Lo</strong>w 352x288 4/3<br />

Main 720x576 (ITU-601) 4/3<br />

High 1440 1440x1152 (HDTV) 4/3<br />

High 1920x1152 (HDTV) 16/9<br />

Tabel<strong>la</strong> 4.3: Livelli MPEG-2.<br />

Si noti che il rapporto d’aspetto può essere fissato in<strong>di</strong>pendentemente dall’effettivo numero <strong>di</strong> pixel/linea e linee/quadro.<br />

Altre informazioni sul<strong>la</strong> co<strong>di</strong>fica sono collezionate nei cosiddetti “profili”, ve<strong>di</strong> Tab.4.4.<br />

Profilo Caratteristiche<br />

Simple come Main, senza frame B<br />

Main Sottocampionamento 4:2:0, non sca<strong>la</strong>bile<br />

SNR Sca<strong>la</strong>ble Main con qualità sca<strong>la</strong>bile<br />

Spatial Sca<strong>la</strong>ble Main con <strong>di</strong>mensioni sca<strong>la</strong>bili<br />

4:2:2 Sottocampionamento 4:2:2 (produzione TV)<br />

High Sottocampionamento 4:2:0, 4:2:2, pienamente sca<strong>la</strong>bile<br />

Multiview Stereo (un canale <strong>per</strong> occhio)<br />

Tabel<strong>la</strong> 4.4: Profili MPEG-2.<br />

4.3 Moving Pictures Ex<strong>per</strong>ts Group, ufficialmente ISO-IEC/JTC1/SC2/WG11.<br />

4.4 Ve<strong>di</strong> anche http://www.dvb.org/dvb technology/dvb levels.htm.<br />

I


4.4. STANDARD H.262 (MPEG-2) 71<br />

Esempi <strong>di</strong> bit-rate ottenuti <strong>per</strong> coppia livello/profilo sono riportati in Tab.4.5.<br />

Profilo/Livello Simple Main SNR<br />

sca<strong>la</strong>ble<br />

<strong>Lo</strong>w 352x288<br />

4Mb/s<br />

Main 720x576<br />

15 Mb/s<br />

720x576<br />

15 Mb/s<br />

High 1440 1440x1152<br />

60 Mb/s<br />

High 1920x1152<br />

80 Mb/s<br />

352x288<br />

4 Mb/s<br />

760x576<br />

15 Mb/s<br />

Tabel<strong>la</strong> 4.5: Bit-rate in MPEG-2.<br />

Spatial<br />

sca<strong>la</strong>ble<br />

720x576<br />

(1440x1152)<br />

60 Mb/s<br />

4:2:2 High<br />

720x576<br />

50 Mb/s<br />

1920x1152<br />

300 Mb/s<br />

352x288<br />

(720x576)<br />

20 Mb/s<br />

720x576<br />

(1440x1152)<br />

80 Mb/s<br />

960x576<br />

(1920x1152)<br />

100 Mb/s


In<strong>di</strong>ce Analitico<br />

Symbols<br />

YCRCB .......................................49<br />

C<br />

CIF........................................... 64<br />

co<strong>di</strong>ci......................................... 26<br />

co<strong>di</strong>fica<strong>di</strong>sorgente.............................27 corse, co<strong>di</strong>fica..................................28<br />

D<br />

DCT..........................................42<br />

DFT...........................................38<br />

E<br />

entropia........................................25<br />

G<br />

GOP..........................................63<br />

H<br />

H.261.........................................64<br />

H.262.........................................70<br />

H.263.........................................64<br />

H.263, co<strong>di</strong>fica entropica........................68<br />

H263, co<strong>di</strong>fica dei vettori spostamento ...........67<br />

H263, controllo <strong>di</strong> co<strong>di</strong>fica ......................68<br />

H263, GOB ....................................65<br />

H263, mo<strong>di</strong> <strong>di</strong> co<strong>di</strong>fica .........................66<br />

H263, quantizzazione . . . ........................68<br />

Huffman, co<strong>di</strong>fica..............................28<br />

I<br />

informazione, teoria.............................24<br />

J<br />

<strong>JPEG</strong>..........................................48<br />

<strong>JPEG</strong>, co<strong>di</strong>ficaentropica........................53 <strong>JPEG</strong>, modalitàgerarchica......................58 <strong>JPEG</strong>, modalitàprogressiva......................56 <strong>JPEG</strong>, modalitàsequenziale.....................50 72<br />

<strong>JPEG</strong>, quantizzazione...........................52<br />

K<br />

KLT...........................................36<br />

L<br />

livelliMPEG-2.................................70 M<br />

motocompensazione.............................60<br />

motocompensazionebi<strong>di</strong>rezionale................62 motocompensazioneinavanti....................61 MPEG-2.......................................70<br />

MSE..........................................62<br />

P<br />

profiliMPEG-2................................70 Q<br />

QCIF..........................................64<br />

QP............................................68<br />

S<br />

SAD..........................................62<br />

SSD...........................................62<br />

T<br />

tasso-<strong>di</strong>storsione, funzione.......................30<br />

Trasformata <strong>di</strong> Karhunen-<strong>Lo</strong>eve .................36<br />

TrasformataDiscretadelCoseno.................42 TrasformataDiscreta<strong>di</strong>Fourier..................38 trasformateunitarie, co<strong>di</strong>fica....................35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!