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
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
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>