Each NAL unit follows its start code and starts with a one-byte header. Its first three fields are the same in every NAL unit; types 14, 20 and 21 add a further three-byte extension.
NAL unit header
| Bit | Size | Name | Description |
|---|---|---|---|
| 7 | 1 | forbidden_zero_bit | always 0; 1 is a syntax violation |
| 6–5 | 2 | nal_ref_idc | 0 means the unit is not needed to reconstruct reference pictures and can be discarded; a non-zero value means it is |
| 4–0 | 5 | nal_unit_type | see NAL unit types |
So the first byte of an SPS is often 67: type 7 with a
nal_ref_idc of 3.
NAL unit types
| Type | Name | Contents |
|---|---|---|
| 0 | unspecified | |
| 1 | coded slice of a non-IDR picture | a slice, see the slice header |
| 2 | slice data partition A | headers and motion data of a partitioned slice |
| 3 | slice data partition B | intra residual data |
| 4 | slice data partition C | inter residual data |
| 5 | coded slice of an IDR picture | a slice of an instantaneous decoding refresh picture, where decoding can start |
| 6 | SEI | supplemental enhancement information |
| 7 | SPS | sequence parameter set |
| 8 | PPS | picture parameter set |
| 9 | AUD | access unit delimiter |
| 10 | end of sequence | no payload |
| 11 | end of stream | no payload |
| 12 | filler data | FF bytes |
| 13 | SPS extension | alpha plane information, see the SPS page |
| 14 | prefix NAL unit | carries SVC or MVC information for the unit after it |
| 15 | subset SPS | parameters for SVC and MVC layers |
| 16 | depth parameter set | |
| 17, 18 | reserved | |
| 19 | auxiliary slice | a slice of an auxiliary coded picture, such as alpha |
| 20 | coded slice extension | SVC or MVC slice |
| 21 | depth or 3D-AVC slice | coded slice extension for depth or 3D-AVC texture views |
| 22, 23 | reserved | |
| 24–31 | unspecified | free for system use. RTP uses them for aggregation and fragmentation packets (24 STAP-A, 25 STAP-B, 26 MTAP16, 27 MTAP24, 28 FU-A, 29 FU-B), which do not appear in a plain Annex B file |
NAL unit header extension
When nal_unit_type is 14 or 20, a further three bytes follow the header.
In the bit order given by RFC 6190, for SVC streams:
| Bits | Name | Description |
|---|---|---|
| 1 | svc_extension_flag | 1 for SVC; 0 selects the MVC layout. RFC 6190 calls this bit reserved |
| 1 | idr_flag | 1 for an IDR layer representation |
| 6 | priority_id | lower values mean higher priority |
| 1 | no_inter_layer_pred_flag | 1 means inter-layer prediction is not used |
| 3 | dependency_id | the inter-layer coding dependency level |
| 4 | quality_id | the quality level |
| 3 | temporal_id | the temporal layer |
| 1 | use_ref_base_pic_flag | 1 means only reference base pictures are used |
| 1 | discardable_flag | 1 means the unit is not used to decode higher dependency layers |
| 1 | output_flag | affects decoded picture output |
| 2 | reserved_three_2bits | binary 11 |
The MVC layout holds non_idr_flag (0 for an IDR access unit),
priority_id, view_id, temporal_id,
anchor_pic_flag, inter_view_flag and a reserved bit. Its exact
field widths are not given here, because they could not be confirmed from a public
source. Type 21 has its own flag for 3D-AVC.
Access unit delimiter
A type 9 unit marks the start of an access unit, the set of NAL units for one picture. Its payload is one field and the trailing bits:
| Name | Coding | Description |
|---|---|---|
primary_pic_type | u(3) | which slice types the picture may contain |
| Value | Slice types allowed |
|---|---|
| 0 | I |
| 1 | I, P |
| 2 | I, P, B |
| 3 | SI |
| 4 | SI, SP |
| 5 | I, SI |
| 6 | I, SI, P, SP |
| 7 | I, SI, P, SP, B |
The meanings of these values are from the standard’s table as commonly reproduced; they could not be confirmed from a public page while writing this.
Order of NAL units in an access unit
In an access unit an AUD comes first, when present. Any SPS, PPS and SEI units follow before the first slice of the primary coded picture. Then come the slices, and after them any redundant slices, auxiliary slices and filler. End of sequence and end of stream units come last.