After the slice header come the macroblocks, one after another up to the next start code. A macroblock covers 16 × 16 luma samples and holds 6, 8 or 12 blocks of 8 × 8 samples for 4:2:0, 4:2:2 and 4:4:4. Most fields are variable-length codes (VLCs), written here as bit strings with spaces every four bits for reading; there are no byte boundaries inside slice data. Source: ITU-T H.262 (third edition, 02/2012), clauses 6.2.5, 6.2.6, 6.3.17, 7.2 to 7.6 and Annex B.
Macroblock syntax
| Field | Bits | Condition | Description |
|---|---|---|---|
macroblock_escape | 11 | repeated while the next bits are 0000 0001 000 | adds 33 to the address increment |
macroblock_address_increment | 1–11, VLC | Table B.1: 1 to 33 | |
macroblock_type | 1–9, VLC | Tables B.2 to B.8; gives the flags below | |
spatial_temporal_weight_code | 2 | type’s weight-code flag is 1 and the picture’s weight table index is not 0 | spatial scalability: how spatial and temporal predictions combine (Table 7-21) |
frame_motion_type | 2 | forward or backward motion, frame picture, frame_pred_frame_dct 0 | Table 6-17 |
field_motion_type | 2 | forward or backward motion, field picture | Table 6-18 |
dct_type | 1 | frame picture, frame_pred_frame_dct 0, intra or pattern | 1: field DCT; 0: frame DCT |
quantiser_scale_code | 5 | macroblock_quant | new quantiser, 1 to 31: Table 7-6 |
motion_vectors(0) | forward motion, or intra with concealment vectors | forward vectors: below | |
motion_vectors(1) | backward motion | backward vectors | |
marker_bit | 1 | intra with concealment vectors | 1 |
coded_block_pattern_420 | 3–9, VLC | macroblock_pattern | Table B.9: which of the first six blocks are coded |
coded_block_pattern_1 | 2 | pattern, 4:2:2 | blocks 6 and 7 |
coded_block_pattern_2 | 6 | pattern, 4:4:4 | blocks 6 to 11 |
block(i) | for each block, if coded | block syntax |
The first macroblock of a slice has address mb_row × mb_width − 1 plus the
increment; a jump of more than one skips macroblocks. I pictures may not skip, except in
spatial or SNR scalable enhancement layers; a B picture may not skip straight after an
intra macroblock; and the first and last macroblocks of a slice are never skipped.
macroblock_stuffing from MPEG-1 is not allowed.
Macroblock address increment
Table B.1.
| Code | Increment | Code | Increment |
|---|---|---|---|
1 | 1 | 0000 0101 01 | 18 |
011 | 2 | 0000 0101 00 | 19 |
010 | 3 | 0000 0100 11 | 20 |
0011 | 4 | 0000 0100 10 | 21 |
0010 | 5 | 0000 0100 011 | 22 |
0001 1 | 6 | 0000 0100 010 | 23 |
0001 0 | 7 | 0000 0100 001 | 24 |
0000 111 | 8 | 0000 0100 000 | 25 |
0000 110 | 9 | 0000 0011 111 | 26 |
0000 1011 | 10 | 0000 0011 110 | 27 |
0000 1010 | 11 | 0000 0011 101 | 28 |
0000 1001 | 12 | 0000 0011 100 | 29 |
0000 1000 | 13 | 0000 0011 011 | 30 |
0000 0111 | 14 | 0000 0011 010 | 31 |
0000 0110 | 15 | 0000 0011 001 | 32 |
0000 0101 11 | 16 | 0000 0011 000 | 33 |
0000 0101 10 | 17 | 0000 0001 000 | macroblock_escape |
Macroblock types
The table depends on the picture type and the scalable mode.
Each code sets six flags: Q macroblock_quant, F
macroblock_motion_forward, B macroblock_motion_backward, P
macroblock_pattern, I macroblock_intra and W
spatial_temporal_weight_code_flag, and allows certain spatial-temporal
weight classes (class 0 temporal prediction only, 4 spatial only, 1 to 3 a mix; clause
7.7.4).
I pictures (Table B.2)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
01 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
P pictures (Table B.3)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | MC, Coded |
01 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | No MC, Coded |
001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | MC, Not Coded |
0001 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
0001 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | MC, Coded, Quant |
0000 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | No MC, Coded, Quant |
0000 01 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
B pictures (Table B.4)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
10 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | Interp, Not Coded |
11 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | Interp, Coded |
010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | Bwd, Not Coded |
011 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | Bwd, Coded |
0010 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | Fwd, Not Coded |
0011 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | Fwd, Coded |
0001 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
0001 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | Interp, Coded, Quant |
0000 11 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | Fwd, Coded, Quant |
0000 10 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | Bwd, Coded, Quant |
0000 01 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
I pictures with spatial scalability (Table B.5)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible |
01 | 1 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible, Quant |
0011 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
0010 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
0001 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | Not Coded, Compatible |
P pictures with spatial scalability (Table B.6)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
10 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | MC, Coded |
011 | 0 | 1 | 0 | 1 | 0 | 1 | 1, 2, 3 | MC, Coded, Compatible |
0000 100 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | No MC, Coded |
0001 11 | 0 | 0 | 0 | 1 | 0 | 1 | 1, 2, 3 | No MC, Coded, Compatible |
0010 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | MC, Not Coded |
0000 111 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
0011 | 0 | 1 | 0 | 0 | 0 | 1 | 1, 2, 3 | MC, Not Coded, Compatible |
010 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | MC, Coded, Quant |
0001 00 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | No MC, Coded, Quant |
0000 110 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
11 | 1 | 1 | 0 | 1 | 0 | 1 | 1, 2, 3 | MC, Coded, Compatible, Quant |
0001 01 | 1 | 0 | 0 | 1 | 0 | 1 | 1, 2, 3 | No MC, Coded, Compatible, Quant |
0001 10 | 0 | 0 | 0 | 0 | 0 | 1 | 1, 2, 3 | No MC, Not Coded, Compatible |
0000 101 | 0 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible |
0000 010 | 1 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible, Quant |
0000 011 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | Not Coded, Compatible |
B pictures with spatial scalability (Table B.7)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
10 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | Interp, Not Coded |
11 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | Interp, Coded |
010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | Back, Not Coded |
011 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | Back, Coded |
0010 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | For, Not Coded |
0011 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | For, Coded |
0001 10 | 0 | 0 | 1 | 0 | 0 | 1 | 1, 2, 3 | Back, Not Coded, Compatible |
0001 11 | 0 | 0 | 1 | 1 | 0 | 1 | 1, 2, 3 | Back, Coded, Compatible |
0001 00 | 0 | 1 | 0 | 0 | 0 | 1 | 1, 2, 3 | For, Not Coded, Compatible |
0001 01 | 0 | 1 | 0 | 1 | 0 | 1 | 1, 2, 3 | For, Coded, Compatible |
0000 110 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | Intra |
0000 111 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | Interp, Coded, Quant |
0000 100 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | For, Coded, Quant |
0000 101 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | Back, Coded, Quant |
0000 0100 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | Intra, Quant |
0000 0101 | 1 | 1 | 0 | 1 | 0 | 1 | 1, 2, 3 | For, Coded, Compatible, Quant |
0000 0110 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1, 2, 3 | Back, Coded, Compatible, Quant |
0000 0111 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | Not Coded, Compatible |
0000 0110 1 | 1 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible, Quant |
0000 0111 1 | 0 | 0 | 0 | 1 | 0 | 0 | 4 | Coded, Compatible |
SNR scalability, all picture types (Table B.8)
| Code | Q | F | B | P | I | W | Classes | Description |
|---|---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Coded |
01 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | Coded, Quant |
001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | Not Coded |
The SNR enhancement layer needs a “Not Coded” type because the first and last macroblocks of a slice cannot be skipped.
Motion types and DCT type
frame_motion_type | Weight classes | Prediction | Vectors | Vector format | Dual prime |
|---|---|---|---|---|---|
| 0 | reserved | ||||
| 1 | 0, 1 | field-based | 2 | field | 0 |
| 1 | 2, 3 | field-based | 1 | field | 0 |
| 2 | 0 to 3 | frame-based | 1 | frame | 0 |
| 3 | 0, 2, 3 | dual-prime | 1 | field | 1 |
field_motion_type | Weight classes | Prediction | Vectors | Vector format | Dual prime |
|---|---|---|---|---|---|
| 0 | reserved | ||||
| 1 | 0, 1 | field-based | 1 | field | 0 |
| 2 | 0, 1 | 16 × 8 motion compensation | 2 | field | 0 |
| 3 | 0 | dual-prime | 1 | field | 1 |
Tables 6-17 and 6-18. When frame_pred_frame_dct is 1 the frame motion type
is absent and frame-based prediction is used. Intra macroblocks with concealment vectors
have no motion type and use frame-based (frame pictures) or field-based (field
pictures) vectors. When dct_type is absent it is unused in field pictures
and uncoded or skipped macroblocks, and 0 (frame DCT) when
frame_pred_frame_dct is 1 (Table 6-19).
Quantiser scale
Table 7-6. q_scale_type in the picture coding extension picks the
column. Code 0 is forbidden.
| Code | Type 0 | Type 1 | Code | Type 0 | Type 1 |
|---|---|---|---|---|---|
| 1 | 2 | 1 | 17 | 34 | 28 |
| 2 | 4 | 2 | 18 | 36 | 32 |
| 3 | 6 | 3 | 19 | 38 | 36 |
| 4 | 8 | 4 | 20 | 40 | 40 |
| 5 | 10 | 5 | 21 | 42 | 44 |
| 6 | 12 | 6 | 22 | 44 | 48 |
| 7 | 14 | 7 | 23 | 46 | 52 |
| 8 | 16 | 8 | 24 | 48 | 56 |
| 9 | 18 | 10 | 25 | 50 | 64 |
| 10 | 20 | 12 | 26 | 52 | 72 |
| 11 | 22 | 14 | 27 | 54 | 80 |
| 12 | 24 | 16 | 28 | 56 | 88 |
| 13 | 26 | 18 | 29 | 58 | 96 |
| 14 | 28 | 20 | 30 | 60 | 104 |
| 15 | 30 | 22 | 31 | 62 | 112 |
| 16 | 32 | 24 |
Motion vectors
With one vector, motion_vertical_field_select[0][s] (1 bit: 0 top
reference field, 1 bottom) comes first only for field-format vectors that are not dual
prime; with two vectors each has its own select bit. Each vector is:
| Field | Bits | Condition |
|---|---|---|
motion_code[r][s][0] | 1–11, VLC (Table B.10) | |
motion_residual[r][s][0] | f_code[s][0] − 1 | f_code[s][0] ≠ 1 and the motion code ≠ 0 |
dmvector[0] | 1–2, VLC (Table B.11) | dual prime |
motion_code[r][s][1] | 1–11, VLC | |
motion_residual[r][s][1] | f_code[s][1] − 1 | f_code[s][1] ≠ 1 and the motion code ≠ 0 |
dmvector[1] | 1–2, VLC | dual prime |
Indices (Table 7-7): r is the first (0) or second (1) vector, s forward (0) or backward (1), t horizontal (0) or vertical (1).
| Code | motion_code | Code | motion_code |
|---|---|---|---|
0000 0011 001 | −16 | 010 | 1 |
0000 0011 011 | −15 | 0010 | 2 |
0000 0011 101 | −14 | 0001 0 | 3 |
0000 0011 111 | −13 | 0000 110 | 4 |
0000 0100 001 | −12 | 0000 1010 | 5 |
0000 0100 011 | −11 | 0000 1000 | 6 |
0000 0100 11 | −10 | 0000 0110 | 7 |
0000 0101 01 | −9 | 0000 0101 10 | 8 |
0000 0101 11 | −8 | 0000 0101 00 | 9 |
0000 0111 | −7 | 0000 0100 10 | 10 |
0000 1001 | −6 | 0000 0100 010 | 11 |
0000 1011 | −5 | 0000 0100 000 | 12 |
0000 111 | −4 | 0000 0011 110 | 13 |
0001 1 | −3 | 0000 0011 100 | 14 |
0011 | −2 | 0000 0011 010 | 15 |
011 | −1 | 0000 0011 000 | 16 |
1 | 0 |
| Code | dmvector (Table B.11) |
|---|---|
11 | −1 |
0 | 0 |
10 | 1 |
Range of a decoded vector component in half samples, by f_code
(Table 7-8). The first column applies to the vertical component of field vectors in
frame pictures.
f_code | Field vectors in frame pictures, vertical | All other cases |
|---|---|---|
| 0 | forbidden | |
| 1 | −4 to +3.5 | −8 to +7.5 |
| 2 | −8 to +7.5 | −16 to +15.5 |
| 3 | −16 to +15.5 | −32 to +31.5 |
| 4 | −32 to +31.5 | −64 to +63.5 |
| 5 | −64 to +63.5 | −128 to +127.5 |
| 6 | −128 to +127.5 | −256 to +255.5 |
| 7 | −256 to +255.5 | −512 to +511.5 |
| 8 | −512 to +511.5 | −1024 to +1023.5 |
| 9 | −1024 to +1023.5 | −2048 to +2047.5 |
| 10–14 | reserved | |
| 15 | this vector is not used | |
The levels cap f_code: horizontal 1 to 7 at Low level, 1 to 8 at Main
and 1 to 9 above; vertical 1 to 4, 5, 5, 5 in frame pictures and 1 to 3, 4, 4, 4 in field
pictures (Table 8-8).
Coded block pattern
Table B.9 gives cbp, a 6-bit pattern for blocks 0 to 5 (bit 5 is block 0,
the top-left luma block; blocks 4 and 5 are Cb and Cr). For 4:2:2 the 2 extra bits cover
blocks 6 and 7, and for 4:4:4 the 6 extra bits cover blocks 6 to 11, again most
significant bit first. Luma blocks are 0 to 3; in 4:2:2 blocks 4 and 6 are Cb and 5 and
7 Cr; in 4:4:4 the even-numbered blocks from 4 are Cb and the odd ones Cr (Table 7-1).
In intra macroblocks every block is coded.
| Code | cbp | Code | cbp |
|---|---|---|---|
111 | 60 | 0001 1100 | 35 |
1101 | 4 | 0001 1011 | 13 |
1100 | 8 | 0001 1010 | 49 |
1011 | 16 | 0001 1001 | 21 |
1010 | 32 | 0001 1000 | 41 |
1001 1 | 12 | 0001 0111 | 14 |
1001 0 | 48 | 0001 0110 | 50 |
1000 1 | 20 | 0001 0101 | 22 |
1000 0 | 40 | 0001 0100 | 42 |
0111 1 | 28 | 0001 0011 | 15 |
0111 0 | 44 | 0001 0010 | 51 |
0110 1 | 52 | 0001 0001 | 23 |
0110 0 | 56 | 0001 0000 | 43 |
0101 1 | 1 | 0000 1111 | 25 |
0101 0 | 61 | 0000 1110 | 37 |
0100 1 | 2 | 0000 1101 | 26 |
0100 0 | 62 | 0000 1100 | 38 |
0011 11 | 24 | 0000 1011 | 29 |
0011 10 | 36 | 0000 1010 | 45 |
0011 01 | 3 | 0000 1001 | 53 |
0011 00 | 63 | 0000 1000 | 57 |
0010 111 | 5 | 0000 0111 | 30 |
0010 110 | 9 | 0000 0110 | 46 |
0010 101 | 17 | 0000 0101 | 54 |
0010 100 | 33 | 0000 0100 | 58 |
0010 011 | 6 | 0000 0011 1 | 31 |
0010 010 | 10 | 0000 0011 0 | 47 |
0010 001 | 18 | 0000 0010 1 | 55 |
0010 000 | 34 | 0000 0010 0 | 59 |
0001 1111 | 7 | 0000 0001 1 | 27 |
0001 1110 | 11 | 0000 0001 0 | 39 |
0001 1101 | 19 | 0000 0000 1 | 0 (not with 4:2:0) |
Block syntax
| Field | Bits | Condition |
|---|---|---|
dct_dc_size_luminance | 2–9, VLC (Table B.12) | intra, blocks 0 to 3 |
dct_dc_size_chrominance | 2–10, VLC (Table B.13) | intra, chroma blocks |
dct_dc_differential | dct_dc_size bits | intra, size not 0 |
| first DCT coefficient | 2–24, VLC | non-intra blocks |
| subsequent DCT coefficients | 3–24, VLC, repeated | until end of block |
| end of block | 2 or 4, VLC |
The DC differential is added to a predictor per colour component, which is reset at
the start of each slice, at each non-intra macroblock and at each skip, to 128, 256, 512
or 1024 for intra_dc_precision 0 to 3 (Table 7-2). Coefficients are then
placed by the scan order and inverse quantised. Data partitioning changes the block
layer; see clause 7.10.
| Code | dct_dc_size_luminance |
|---|---|
100 | 0 |
00 | 1 |
01 | 2 |
101 | 3 |
110 | 4 |
1110 | 5 |
1111 0 | 6 |
1111 10 | 7 |
1111 110 | 8 |
1111 1110 | 9 |
1111 1111 0 | 10 |
1111 1111 1 | 11 |
| Code | dct_dc_size_chrominance |
|---|---|
00 | 0 |
01 | 1 |
10 | 2 |
110 | 3 |
1110 | 4 |
1111 0 | 5 |
1111 10 | 6 |
1111 110 | 7 |
1111 1110 | 8 |
1111 1111 0 | 9 |
1111 1111 10 | 10 |
1111 1111 11 | 11 |
DCT coefficients
Each code gives a run of zero coefficients and a level; the final bit
s is the sign of the level (0 positive, 1 negative). Table B.14 (table zero)
is used for non-intra blocks, and for intra blocks when intra_vlc_format is
0; Table B.15 (table one) for intra blocks when it is 1 (Table 7-3). In table zero, run 0
level 1 is 1s for the first coefficient of a non-intra block and
11s otherwise, so end of block 10 cannot be the first code. An
intra block’s AC coefficients start after the DC value.
After the escape code come 6 bits of run (0 to 63) and 12 bits of signed level in two’s
complement: −2047 to +2047, with 0 forbidden and 1000 0000 0000 reserved
(Table B.16). This escape differs from MPEG-1’s.
| Code | Run | Level |
|---|---|---|
10 | end of block | |
1s | 0 | 1 (first coefficient) |
11s | 0 | 1 (others) |
011s | 1 | 1 |
0100 s | 0 | 2 |
0101 s | 2 | 1 |
0010 1s | 0 | 3 |
0011 1s | 3 | 1 |
0011 0s | 4 | 1 |
0001 10s | 1 | 2 |
0001 11s | 5 | 1 |
0001 01s | 6 | 1 |
0001 00s | 7 | 1 |
0000 110s | 0 | 4 |
0000 100s | 2 | 2 |
0000 111s | 8 | 1 |
0000 101s | 9 | 1 |
0000 01 | escape | |
0010 0110 s | 0 | 5 |
0010 0001 s | 0 | 6 |
0010 0101 s | 1 | 3 |
0010 0100 s | 3 | 2 |
0010 0111 s | 10 | 1 |
0010 0011 s | 11 | 1 |
0010 0010 s | 12 | 1 |
0010 0000 s | 13 | 1 |
0000 0010 10s | 0 | 7 |
0000 0011 00s | 1 | 4 |
0000 0010 11s | 2 | 3 |
0000 0011 11s | 4 | 2 |
0000 0010 01s | 5 | 2 |
0000 0011 10s | 14 | 1 |
0000 0011 01s | 15 | 1 |
0000 0010 00s | 16 | 1 |
0000 0001 1101 s | 0 | 8 |
0000 0001 1000 s | 0 | 9 |
0000 0001 0011 s | 0 | 10 |
0000 0001 0000 s | 0 | 11 |
0000 0001 1011 s | 1 | 5 |
0000 0001 0100 s | 2 | 4 |
0000 0001 1100 s | 3 | 3 |
0000 0001 0010 s | 4 | 3 |
0000 0001 1110 s | 6 | 2 |
0000 0001 0101 s | 7 | 2 |
0000 0001 0001 s | 8 | 2 |
0000 0001 1111 s | 17 | 1 |
0000 0001 1010 s | 18 | 1 |
0000 0001 1001 s | 19 | 1 |
0000 0001 0111 s | 20 | 1 |
0000 0001 0110 s | 21 | 1 |
| Code | Run | Level |
|---|---|---|
0110 | end of block | |
10s | 0 | 1 |
010s | 1 | 1 |
110s | 0 | 2 |
0010 1s | 2 | 1 |
0111 s | 0 | 3 |
0011 1s | 3 | 1 |
0001 10s | 4 | 1 |
0011 0s | 1 | 2 |
0001 11s | 5 | 1 |
0000 110s | 6 | 1 |
0000 100s | 7 | 1 |
1110 0s | 0 | 4 |
0000 111s | 2 | 2 |
0000 101s | 8 | 1 |
1111 000s | 9 | 1 |
0000 01 | escape | |
1110 1s | 0 | 5 |
0001 01s | 0 | 6 |
1111 001s | 1 | 3 |
0010 0110 s | 3 | 2 |
1111 010s | 10 | 1 |
0010 0001 s | 11 | 1 |
0010 0101 s | 12 | 1 |
0010 0100 s | 13 | 1 |
0001 00s | 0 | 7 |
0010 0111 s | 1 | 4 |
1111 1100 s | 2 | 3 |
1111 1101 s | 4 | 2 |
0000 0010 0s | 5 | 2 |
0000 0010 1s | 14 | 1 |
0000 0011 1s | 15 | 1 |
0000 0011 01s | 16 | 1 |
1111 011s | 0 | 8 |
1111 100s | 0 | 9 |
0010 0011 s | 0 | 10 |
0010 0010 s | 0 | 11 |
0010 0000 s | 1 | 5 |
0000 0011 00s | 2 | 4 |
0000 0001 1100 s | 3 | 3 |
0000 0001 0010 s | 4 | 3 |
0000 0001 1110 s | 6 | 2 |
0000 0001 0101 s | 7 | 2 |
0000 0001 0001 s | 8 | 2 |
0000 0001 1111 s | 17 | 1 |
0000 0001 1010 s | 18 | 1 |
0000 0001 1001 s | 19 | 1 |
0000 0001 0111 s | 20 | 1 |
0000 0001 0110 s | 21 | 1 |
1111 1010 s | 0 | 12 |
1111 1011 s | 0 | 13 |
1111 1110 s | 0 | 14 |
1111 1111 s | 0 | 15 |
The longer codes, from 13 to 17 bits including the sign, are the same in both
tables, except that the first four (run 0, levels 12 to 15) exist only in table zero;
table one codes those with 1111 1010 s to 1111 1111 s
above:
| Code | Run | Level | Code | Run | Level |
|---|---|---|---|---|---|
0000 0000 1101 0s | 0 | 12 | 0000 0000 0010 101s | 0 | 35 |
0000 0000 1100 1s | 0 | 13 | 0000 0000 0010 100s | 0 | 36 |
0000 0000 1100 0s | 0 | 14 | 0000 0000 0010 011s | 0 | 37 |
0000 0000 1011 1s | 0 | 15 | 0000 0000 0010 010s | 0 | 38 |
0000 0000 1011 0s | 1 | 6 | 0000 0000 0010 001s | 0 | 39 |
0000 0000 1010 1s | 1 | 7 | 0000 0000 0010 000s | 0 | 40 |
0000 0000 1010 0s | 2 | 5 | 0000 0000 0011 111s | 1 | 8 |
0000 0000 1001 1s | 3 | 4 | 0000 0000 0011 110s | 1 | 9 |
0000 0000 1001 0s | 5 | 3 | 0000 0000 0011 101s | 1 | 10 |
0000 0000 1000 1s | 9 | 2 | 0000 0000 0011 100s | 1 | 11 |
0000 0000 1000 0s | 10 | 2 | 0000 0000 0011 011s | 1 | 12 |
0000 0000 1111 1s | 22 | 1 | 0000 0000 0011 010s | 1 | 13 |
0000 0000 1111 0s | 23 | 1 | 0000 0000 0011 001s | 1 | 14 |
0000 0000 1110 1s | 24 | 1 | 0000 0000 0001 0011 s | 1 | 15 |
0000 0000 1110 0s | 25 | 1 | 0000 0000 0001 0010 s | 1 | 16 |
0000 0000 1101 1s | 26 | 1 | 0000 0000 0001 0001 s | 1 | 17 |
0000 0000 0111 11s | 0 | 16 | 0000 0000 0001 0000 s | 1 | 18 |
0000 0000 0111 10s | 0 | 17 | 0000 0000 0001 0100 s | 6 | 3 |
0000 0000 0111 01s | 0 | 18 | 0000 0000 0001 1010 s | 11 | 2 |
0000 0000 0111 00s | 0 | 19 | 0000 0000 0001 1001 s | 12 | 2 |
0000 0000 0110 11s | 0 | 20 | 0000 0000 0001 1000 s | 13 | 2 |
0000 0000 0110 10s | 0 | 21 | 0000 0000 0001 0111 s | 14 | 2 |
0000 0000 0110 01s | 0 | 22 | 0000 0000 0001 0110 s | 15 | 2 |
0000 0000 0110 00s | 0 | 23 | 0000 0000 0001 0101 s | 16 | 2 |
0000 0000 0101 11s | 0 | 24 | 0000 0000 0001 1111 s | 27 | 1 |
0000 0000 0101 10s | 0 | 25 | 0000 0000 0001 1110 s | 28 | 1 |
0000 0000 0101 01s | 0 | 26 | 0000 0000 0001 1101 s | 29 | 1 |
0000 0000 0101 00s | 0 | 27 | 0000 0000 0001 1100 s | 30 | 1 |
0000 0000 0100 11s | 0 | 28 | 0000 0000 0001 1011 s | 31 | 1 |
0000 0000 0100 10s | 0 | 29 | |||
0000 0000 0100 01s | 0 | 30 | |||
0000 0000 0100 00s | 0 | 31 | |||
0000 0000 0011 000s | 0 | 32 | |||
0000 0000 0010 111s | 0 | 33 | |||
0000 0000 0010 110s | 0 | 34 |
Scan orders
Coefficients are read in one of two orders, chosen by alternate_scan.
Each grid shows, at each position of the 8 × 8 block (row v, column u), the index of the
coefficient that lands there (Figures 7-2 and 7-3). Quantiser matrices are always sent in
the zig-zag order.
zig-zag (alternate_scan 0)
0 1 5 6 14 15 27 28
2 4 7 13 16 26 29 42
3 8 12 17 25 30 41 43
9 11 18 24 31 40 44 53
10 19 23 32 39 45 52 54
20 22 33 38 46 51 55 60
21 34 37 47 50 56 59 61
35 36 48 49 57 58 62 63
alternate (alternate_scan 1)
0 4 6 20 22 36 38 52
1 5 7 21 23 37 39 53
2 8 19 24 34 40 50 54
3 9 18 25 35 41 51 55
10 17 26 30 42 46 56 60
11 16 27 31 43 47 57 61
12 15 28 32 44 48 58 62
13 14 29 33 45 49 59 63
Data partitioning
With scalable_mode 0, each slice of partition 0 carries a
priority_breakpoint that says where the data moves to partition 1
(Table 7-30):
priority_breakpoint | Syntax elements kept in partition 0 |
|---|---|
| 0 | reserved for partition 1, where every slice has this value |
| 1 | all sequence, GOP, picture and slice data down to extra_bit_slice |
| 2 | also the macroblock fields up to and including macroblock_address_increment |
| 3 | also the macroblock fields up to but not including coded_block_pattern() |
| 4–63 | reserved |
| 64 | everything up to and including the coded block pattern or DC coefficient, and the first run and level pair (or end of block) |
| 63 + j | as 64, with up to j run and level pairs, for j up to 64 (value 127) |
Partition 1 repeats the sequence, GOP and picture headers and the sequence end code; its only extensions are the sequence, picture coding and sequence scalable extensions.