After the slice header comes the slice
data: the macroblocks of the slice, 16 × 16 luma samples each, in order. When the PPS sets
entropy_coding_mode_flag the elements are CABAC coded (ae(v));
otherwise they use Exp-Golomb codes and CAVLC. This page gives the syntax and the meaning
of every element, from the H.264 text (June 2026). The code tables of the entropy coders
themselves (the CAVLC tables 9-5 to 9-10 and the CABAC context tables of clause 9.3) are
not reproduced; the coded block pattern mapping is given below.
Extra descriptors
| Coding | Meaning |
|---|---|
me(v) | mapped Exp-Golomb: a ue(v) code number turned into a value through a table (used for coded_block_pattern) |
te(v) | truncated Exp-Golomb: when the largest possible value is 1, a single bit with the meaning inverted (0 means 1); otherwise ue(v) |
ce(v) | context-adaptive variable-length code (CAVLC) |
ae(v) | context-adaptive binary arithmetic code (CABAC) |
Where the coding column gives two forms, such as ue(v) | ae(v), the first
is used with CAVLC and the second with CABAC.
Slice data
| Name | Coding | Condition | Description |
|---|---|---|---|
cabac_alignment_one_bit | f(1) | CABAC, until byte aligned | 1 |
mb_skip_run | ue(v) | CAVLC, not I or SI | number of skipped macroblocks (P_Skip or B_Skip) before the next coded one |
mb_skip_flag | ae(v) | CABAC, not I or SI | 1: this macroblock is skipped |
mb_field_decoding_flag | u(1) | ae(v) | MBAFF frame, top macroblock of a pair (or the bottom one when the top was skipped) | 1: the macroblock pair is coded as two fields |
macroblock_layer() | not skipped | see below | |
end_of_slice_flag | ae(v) | CABAC, after each macroblock (each pair in MBAFF) | 1: last macroblock of the slice |
With CAVLC the slice ends when the RBSP data runs out. The macroblock address starts at
first_mb_in_slice (doubled in MBAFF frames) and moves to the next macroblock
of the same slice group each time. After the data come the trailing bits and, with CABAC,
any cabac_zero_word padding.
Data partitions
In the Extended profile a slice can be split into three NAL units by importance. Each element of the slice data belongs to a category: 2 for headers, macroblock types and motion, 3 for intra residual, 4 for inter residual.
| NAL type | Partition | Contents |
|---|---|---|
| 2 | A | slice header, slice_id (ue(v)), then the category 2 elements |
| 3 | B | slice_id, colour_plane_id (separate planes), redundant_pic_cnt (when enabled), then the category 3 elements |
| 4 | C | the same leading fields, then the category 4 elements |
Macroblock layer
| Name | Coding | Condition | Description |
|---|---|---|---|
mb_type | ue(v) | ae(v) | see macroblock types | |
pcm_alignment_zero_bit | f(1) | I_PCM, to the byte boundary | 0 |
pcm_sample_luma[i] | u(v) | I_PCM, 256 times | raw luma samples in raster order, luma bit depth each |
pcm_sample_chroma[i] | u(v) | I_PCM, 2 × chroma block size | all Cb samples then all Cr, chroma bit depth each |
sub_mb_pred() | four-partition inter types (P_8x8, P_8x8ref0, B_8x8) | see sub-macroblocks | |
transform_size_8x8_flag | u(1) | ae(v) | 8 × 8 transform enabled in the PPS, I_NxN | 1: Intra_8x8 prediction and 8 × 8 transform; 0: Intra_4x4 |
mb_pred() | other types | see macroblock prediction | |
coded_block_pattern | me(v) | ae(v) | not Intra_16x16 | low 4 bits: which 8 × 8 luma blocks have coefficients; high bits ÷ 16: chroma, see coded block pattern |
transform_size_8x8_flag | u(1) | ae(v) | inter, luma coefficients present, 8 × 8 transform enabled, no partition smaller than 8 × 8 | 1: 8 × 8 transform for the luma residual |
mb_qp_delta | se(v) | ae(v) | any coefficients, or Intra_16x16 | change of QPY; −(26 + QpBdOffsetY ÷ 2) to +(25 + QpBdOffsetY ÷ 2), wrapping round the 52 values |
residual(0, 15) | the same | see residual data |
Macroblock types
Each slice type has its own numbering; the intra types follow on after the slice’s own types. In I slices the intra types are 0 to 25; in SI slices 0 is SI and 1 to 26 are the intra types; in P and SP slices 0 to 4 are inter and 5 to 30 intra; in B slices 0 to 22 are inter and 23 to 48 intra.
| I type | Name | Prediction | Description |
|---|---|---|---|
| 0 | I_NxN | Intra_4x4 or Intra_8x8 | sixteen 4 × 4 or four 8 × 8 blocks, chosen by transform_size_8x8_flag |
| 1–24 | I_16x16_m_c_a | Intra_16x16 | whole-macroblock prediction. Type − 1 = m + 4 × c + 12 × a, where m is the prediction mode (0 vertical, 1 horizontal, 2 DC, 3 plane), c is CodedBlockPatternChroma (0 to 2) and a is 1 when CodedBlockPatternLuma is 15 (AC coefficients present) |
| 25 | I_PCM | raw samples |
| P type | Name | Partitions | Description |
|---|---|---|---|
| 0 | P_L0_16x16 | one 16 × 16 | list 0 |
| 1 | P_L0_L0_16x8 | two 16 × 8 | list 0 for both |
| 2 | P_L0_L0_8x16 | two 8 × 16 | list 0 for both |
| 3 | P_8x8 | four 8 × 8 | each with its own sub-macroblock type |
| 4 | P_8x8ref0 | four 8 × 8 | as P_8x8, with every reference index 0 and not sent |
| inferred | P_Skip | one 16 × 16 | no data: predicted motion, reference 0, no residual |
| B type | Name | Partitions | Prediction |
|---|---|---|---|
| 0 | B_Direct_16x16 | — | direct: motion derived, none sent; residual may follow |
| 1 | B_L0_16x16 | one 16 × 16 | list 0 |
| 2 | B_L1_16x16 | one 16 × 16 | list 1 |
| 3 | B_Bi_16x16 | one 16 × 16 | both lists |
| 4–21 | B_X0_X1_16x8, …_8x16 | two 16 × 8 (even types) or 8 × 16 (odd types) | 4, 5 L0 L0; 6, 7 L1 L1; 8, 9 L0 L1; 10, 11 L1 L0; 12, 13 L0 Bi; 14, 15 L1 Bi; 16, 17 Bi L0; 18, 19 Bi L1; 20, 21 Bi Bi |
| 22 | B_8x8 | four 8 × 8 | each with its own sub-macroblock type |
| inferred | B_Skip | — | direct, with no residual |
In SI slices, type 0 (SI) is an Intra_4x4 macroblock for switching pictures.
Macroblock prediction
| Name | Coding | Condition | Description |
|---|---|---|---|
prev_intra4x4_pred_mode_flag[i] | u(1) | ae(v) | Intra_4x4, 16 blocks | 1: use the predicted (most probable) mode |
rem_intra4x4_pred_mode[i] | u(3) | ae(v) | flag above is 0 | one of the other eight modes |
prev_intra8x8_pred_mode_flag[i], rem_intra8x8_pred_mode[i] | u(1), u(3) | ae(v) | Intra_8x8, 4 blocks | the same for 8 × 8 blocks |
intra_chroma_pred_mode | ue(v) | ae(v) | intra, 4:2:0 or 4:2:2 | 0 DC, 1 horizontal, 2 vertical, 3 plane |
ref_idx_l0[i] | te(v) | ae(v) | per partition using list 0, when the list has more than one entry (or field and frame differ) | reference index |
ref_idx_l1[i] | te(v) | ae(v) | the same for list 1 | |
mvd_l0[i][0][c] | se(v) | ae(v) | per partition using list 0, horizontal then vertical | motion vector difference in quarter samples; −8192 to 8191.75 |
mvd_l1[i][0][c] | se(v) | ae(v) | the same for list 1 |
All reference indices of the macroblock come first, then all motion vector differences. Intra 4 × 4 and 8 × 8 modes: 0 vertical, 1 horizontal, 2 DC, 3 diagonal down left, 4 diagonal down right, 5 vertical right, 6 horizontal down, 7 vertical left, 8 horizontal up. In 4:4:4 the luma modes are used for Cb and Cr too.
Sub-macroblocks
sub_mb_pred() sends four sub_mb_type values
(ue(v) | ae(v)), then the reference indices of the four 8 × 8 blocks, then
their motion vector differences, one per sub-partition.
| P sub type | Name | Sub-partitions |
|---|---|---|
| 0 | P_L0_8x8 | one 8 × 8 |
| 1 | P_L0_8x4 | two 8 × 4 |
| 2 | P_L0_4x8 | two 4 × 8 |
| 3 | P_L0_4x4 | four 4 × 4 |
| B sub type | Name | Sub-partitions | Prediction |
|---|---|---|---|
| 0 | B_Direct_8x8 | four 4 × 4 | direct |
| 1 | B_L0_8x8 | one 8 × 8 | list 0 |
| 2 | B_L1_8x8 | one 8 × 8 | list 1 |
| 3 | B_Bi_8x8 | one 8 × 8 | both |
| 4 | B_L0_8x4 | two 8 × 4 | list 0 |
| 5 | B_L0_4x8 | two 4 × 8 | list 0 |
| 6 | B_L1_8x4 | two 8 × 4 | list 1 |
| 7 | B_L1_4x8 | two 4 × 8 | list 1 |
| 8 | B_Bi_8x4 | two 8 × 4 | both |
| 9 | B_Bi_4x8 | two 4 × 8 | both |
| 10 | B_L0_4x4 | four 4 × 4 | list 0 |
| 11 | B_L1_4x4 | four 4 × 4 | list 1 |
| 12 | B_Bi_4x4 | four 4 × 4 | both |
Coded block pattern
CodedBlockPatternLuma = coded_block_pattern mod 16: bit
n set means 8 × 8 luma block n has coefficients (in 4:4:4, the Cb and
Cr blocks at the same place too). CodedBlockPatternChroma =
coded_block_pattern ÷ 16, for 4:2:0 and 4:2:2:
| Value | Chroma coefficients |
|---|---|
| 0 | none |
| 1 | DC only (some DC non-zero, all AC zero) |
| 2 | DC and AC (some AC non-zero) |
For monochrome and 4:4:4 the chroma value is always 0. With CAVLC the value is sent as a
code number (me(v)) and mapped through Table 9-4 of H.264, which has separate
columns for intra (Intra_4x4, Intra_8x8) and inter macroblocks. For 4:2:0 and 4:2:2,
code numbers 0 to 47 give these patterns:
| Code numbers | Intra | Inter |
|---|---|---|
| 0–7 | 47, 31, 15, 0, 23, 27, 29, 30 | 0, 16, 1, 2, 4, 8, 32, 3 |
| 8–15 | 7, 11, 13, 14, 39, 43, 45, 46 | 5, 10, 12, 15, 47, 7, 11, 13 |
| 16–23 | 16, 3, 5, 10, 12, 19, 21, 26 | 14, 6, 9, 31, 35, 37, 42, 44 |
| 24–31 | 28, 35, 37, 42, 44, 1, 2, 4 | 33, 34, 36, 40, 39, 43, 45, 46 |
| 32–39 | 8, 17, 18, 20, 24, 6, 9, 22 | 17, 18, 20, 24, 19, 21, 26, 28 |
| 40–47 | 25, 32, 33, 34, 36, 40, 38, 41 | 23, 27, 29, 30, 22, 25, 38, 41 |
For monochrome and 4:4:4, code numbers 0 to 15:
| Code numbers | Intra | Inter |
|---|---|---|
| 0–7 | 15, 0, 7, 11, 13, 14, 3, 5 | 0, 1, 2, 4, 8, 3, 5, 10 |
| 8–15 | 10, 12, 1, 2, 4, 8, 6, 9 | 12, 15, 7, 11, 13, 14, 6, 9 |
Residual data
Residual blocks come in this order: for Intra_16x16 the 16 luma DC coefficients first; then each of the four 8 × 8 luma blocks whose pattern bit is set, as four 4 × 4 blocks (15 AC coefficients each for Intra_16x16, otherwise 16) or one 8 × 8 block of 64; then for 4:2:0 and 4:2:2 the chroma DC of Cb and Cr (4 or 8 coefficients), then the chroma AC blocks of 15 coefficients. In 4:4:4 the Cb and Cr components are coded like luma, after it.
With CAVLC (residual_block_cavlc), each block is:
| Name | Coding | Description |
|---|---|---|
coeff_token | ce(v) | the number of non-zero coefficients (TotalCoeff) and of trailing ±1 values (TrailingOnes, up to 3), from a table chosen by the neighbouring blocks |
trailing_ones_sign_flag | u(1) | sign of each trailing ±1; 1 negative |
level_prefix | ce(v) | leading zeros then a 1; with the suffix gives each other level, highest frequency first |
level_suffix | u(v) | low bits of the level; its length adapts as levels grow |
total_zeros | ce(v) | zeros before the last non-zero coefficient, when fewer than all coefficients are non-zero |
run_before | ce(v) | zeros before each coefficient in turn, while zeros remain |
With CAVLC an 8 × 8 block is sent as four interleaved 4 × 4 blocks. With CABAC
(residual_block_cabac):
| Name | Coding | Description |
|---|---|---|
coded_block_flag | ae(v) | 1: the block has non-zero coefficients; not sent for 8 × 8 blocks except in 4:4:4 |
significant_coeff_flag[i] | ae(v) | 1: coefficient i is not zero |
last_significant_coeff_flag[i] | ae(v) | 1: coefficient i is the last non-zero one |
coeff_abs_level_minus1[i] | ae(v) | magnitude minus 1, sent from the last coefficient backwards |
coeff_sign_flag[i] | ae(v) | 1: negative |