Every extension starts with the start code 00 00 01 B5 and a 4-bit
identifier. MPEG-2 adds these to the MPEG-1 syntax, and their presence is what marks a
stream as MPEG-2. Each extension ends with zero bits up to the next start code. Fields are
big-endian bit fields; uimsbf is unsigned and simsbf signed
two’s complement, most significant bit first. Source: ITU-T H.262, clause 6.2 (syntax),
6.3 (semantics) and clause 8 (profiles and levels), as consolidated in the third edition
(02/2012).
Extension identifiers
Table 6-2. Only some extensions may appear at each point: after the sequence extension, the sequence display and sequence scalable extensions; after the picture coding extension, the picture-level ones. Each type may appear at most once at each point. An extension with a reserved identifier is skipped up to the next start code.
| Value | Extension | Where |
|---|---|---|
| 0 | reserved | |
| 1 | Sequence extension | directly after every sequence header |
| 2 | Sequence display extension | after the sequence extension |
| 3 | Quant matrix extension | after a picture coding extension |
| 4 | Copyright extension | after a picture coding extension |
| 5 | Sequence scalable extension | after the sequence extension |
| 6 | reserved | |
| 7 | Picture display extension | after a picture coding extension |
| 8 | Picture coding extension | directly after every picture header |
| 9 | Picture spatial scalable extension | after a picture coding extension |
| 10 | Picture temporal scalable extension | after a picture coding extension |
| 11 | Camera parameters extension | after a picture coding extension |
| 12 | ITU-T extension | after a picture coding extension |
| 13–15 | reserved |
Sequence extension
Identifier 1, directly after the sequence header (clauses 6.2.2.3 and 6.3.5). Bits follow the 4-bit identifier.
| Bits | Name | Description |
|---|---|---|
| 8 | profile_and_level_indication | see profiles and levels |
| 1 | progressive_sequence | 1 if the sequence holds only progressive frame pictures |
| 2 | chroma_format | see the table below |
| 2 | horizontal_size_extension | top 2 bits of the 14-bit width |
| 2 | vertical_size_extension | top 2 bits of the 14-bit height |
| 12 | bit_rate_extension | top 12 bits of the 30-bit bit rate |
| 1 | marker_bit | 1 |
| 8 | vbv_buffer_size_extension | top 8 bits of the 18-bit buffer size |
| 1 | low_delay | 1: no B pictures, no reordering delay, and “big pictures” that take several buffer checks may occur |
| 2 | frame_rate_extension_n | frame rate = frame_rate_value × (n + 1) ÷ (d + 1) |
| 5 | frame_rate_extension_d | both 0 when the rate is in the frame rate table; n + 1 and d + 1 have no common divisor |
| chroma_format | Meaning | Blocks per macroblock |
|---|---|---|
| 0 | reserved | |
| 1 | 4:2:0 | 6 |
| 2 | 4:2:2 | 8 |
| 3 | 4:4:4 | 12 |
Profiles and levels
profile_and_level_indication is one escape bit (bit 7), then 3 bits of
profile (bits 6 to 4), then 4 bits of level (bits 3 to 0) (Table 8-1). With the escape
bit clear, a larger profile or level number is a subset of a smaller one. Profile
identification (Table 8-2):
| Profile bits | Profile |
|---|---|
| 0 | reserved |
| 1 | High |
| 2 | Spatially Scalable |
| 3 | SNR Scalable |
| 4 | Main |
| 5 | Simple |
| 6, 7 | reserved |
Level identification (Table 8-3, as replaced by Amendment 3 of 2009, which added HighP for 1080-line progressive video at 50 and 60 frames a second):
| Level bits | Level |
|---|---|
| 0, 1 | reserved |
| 2 | HighP |
| 3 | reserved |
| 4 | High |
| 5 | reserved |
| 6 | High 1440 |
| 7 | reserved |
| 8 | Main |
| 9 | reserved |
| 10 | Low |
| 11–15 | reserved |
Limits for the Main profile at each level (Tables 8-8, 8-11 to 8-14). The HighP level
is defined for the Main profile only (Annex E, Table E.25bis), allows frame pictures
only and requires frame_pred_frame_dct = 1.
| Level | Samples × lines × frames/s | Luma samples/s | Max bit rate | VBV buffer (bits) | frame_rate_code |
|---|---|---|---|---|---|
| Low | 352 × 288 × 30 | 3 041 280 | 4 Mbit/s | 475 136 | 1 to 5 |
| Main | 720 × 576 × 30 | 10 368 000 | 15 Mbit/s | 1 835 008 | 1 to 5 |
| High 1440 | 1440 × 1088 × 60 | 47 001 600 | 60 Mbit/s | 7 340 032 | 1 to 8 |
| High | 1920 × 1088 × 60 | 62 668 800 | 80 Mbit/s | 9 781 248 | 1 to 8 |
| HighP | 1920 × 1088 × 60 | 125 337 600 | 80 Mbit/s | 9 781 248 | 1 to 8 |
The sixth amendment (2000) lowered the line limit of the High 1440 and High levels from 1152 to 1088. The Simple profile exists only at Main level. With the escape bit set, the whole byte is one code (Table 8-4); these profiles are not part of the hierarchy:
| Byte | Bits | Meaning |
|---|---|---|
| 0x80, 0x81 | 1000 000x | reserved |
| 0x82 | 1000 0010 | 4:2:2 profile at High level (1920 × 1088 × 60, 300 Mbit/s, VBV 47 185 920 bits) |
| 0x83, 0x84 | reserved | |
| 0x85 | 1000 0101 | 4:2:2 profile at Main level (720 × 608 × 30, 50 Mbit/s, VBV 9 437 184 bits; 512 lines for 525/60 video) |
| 0x86–0x89 | reserved | |
| 0x8A | 1000 1010 | Multi-view profile at High level |
| 0x8B | 1000 1011 | Multi-view profile at High 1440 level |
| 0x8C | 1000 1100 | reserved |
| 0x8D | 1000 1101 | Multi-view profile at Main level |
| 0x8E | 1000 1110 | Multi-view profile at Low level |
| 0x8F–0xFF | reserved |
The Multi-view profile codes stereoscopic video in two layers: the base layer is the left view, coded with Main profile tools, and the enhancement layer is the right view, coded with temporal scalability tools and predicted from both layers. A Main profile decoder can decode the base layer.
Sequence display extension
Identifier 2 (clauses 6.2.2.4 and 6.3.6). Nothing in it affects decoding.
| Bits | Name | Description |
|---|---|---|
| 3 | video_format | the source before coding: see below |
| 1 | colour_description | 1 if the three colour fields follow |
| 8 | colour_primaries | only if colour_description is 1; Table 6-7 |
| 8 | transfer_characteristics | only if colour_description is 1; Table 6-8 |
| 8 | matrix_coefficients | only if colour_description is 1; Table 6-9 |
| 14 | display_horizontal_size | width of the intended display rectangle, in samples of the coded frame |
| 1 | marker_bit | 1 |
| 14 | display_vertical_size | height of the display rectangle, in lines of the coded frame |
| video_format | Meaning (Table 6-6) |
|---|---|
| 0 | component |
| 1 | PAL |
| 2 | NTSC |
| 3 | SECAM |
| 4 | MAC |
| 5 | unspecified video format |
| 6, 7 | reserved |
Without the extension, the format may be taken as unspecified. Without the extension
or with colour_description 0, the colour values are left to the
application. The colour tables, as updated by Amendment 2 (2007):
| Code | colour_primaries (Table 6-7) |
|---|---|
| 0 | forbidden |
| 1 | BT.709-5: green 0.300, 0.600; blue 0.150, 0.060; red 0.640, 0.330; white D65 0.3127, 0.3290 (also BT.1361, IEC 61966-2-4, SMPTE RP 177 Annex B) |
| 2 | unspecified |
| 3 | reserved |
| 4 | BT.470-6 System M (NTSC 1953, FCC): green 0.21, 0.71; blue 0.14, 0.08; red 0.67, 0.33; white C 0.310, 0.316 |
| 5 | BT.470-6 System B, G, BT.601-6 625, BT.1358 625, BT.1700 625 PAL and SECAM: green 0.29, 0.60; blue 0.15, 0.06; red 0.64, 0.33; white D65 |
| 6 | SMPTE 170M, BT.601-6 525, BT.1358 525, BT.1700 NTSC: green 0.310, 0.595; blue 0.155, 0.070; red 0.630, 0.340; white D65 |
| 7 | SMPTE 240M: the same primaries as 6 |
| 8–255 | reserved |
| Code | transfer_characteristics (Table 6-8) |
|---|---|
| 0 | forbidden |
| 1 | BT.709-5, BT.1361 conventional gamut: V = 1.099 Lc0.45 − 0.099 for Lc ≥ 0.018, else 4.500 Lc |
| 2 | unspecified |
| 3 | reserved |
| 4 | assumed display gamma 2.2: BT.470-6 System M, NTSC 1953, FCC |
| 5 | assumed display gamma 2.8: BT.470-6 System B, G, BT.1700 625 PAL and SECAM |
| 6 | SMPTE 170M, BT.601-6, BT.1358, BT.1700 NTSC: the same curve as 1 |
| 7 | SMPTE 240M: V = 1.1115 Lc0.45 − 0.1115 for Lc ≥ 0.0228, else 4.0 Lc |
| 8 | linear: V = Lc |
| 9 | logarithmic, 100:1 range: V = 1.0 − log10(Lc) ÷ 2 for Lc ≥ 0.01, else 0 |
| 10 | logarithmic, 316.22777:1 range: V = 1.0 − log10(Lc) ÷ 2.5 for Lc ≥ 0.0031622777, else 0 |
| 11 | IEC 61966-2-4 (xvYCC): the curve of 1 extended to negative Lc by symmetry |
| 12 | BT.1361 extended colour gamut: the curve of 1 for 0.018 ≤ Lc < 1.33, 4.5 Lc down to −0.0045, and −(1.099 (−4 Lc)0.45 − 0.099) ÷ 4 down to −0.25 |
| 13–255 | reserved |
| Code | matrix_coefficients (Table 6-9) |
|---|---|
| 0 | forbidden |
| 1 | BT.709-5, BT.1361, IEC 61966-2-4 xvYCC709, SMPTE RP 177: E′Y = 0.2126 R + 0.7152 G + 0.0722 B |
| 2 | unspecified |
| 3 | reserved |
| 4 | NTSC 1953, FCC: E′Y = 0.30 R + 0.59 G + 0.11 B |
| 5 | BT.470-6 System B, G, BT.601-6 625, BT.1358 625, BT.1700 625, xvYCC601: E′Y = 0.2990 R + 0.5870 G + 0.1140 B |
| 6 | SMPTE 170M, BT.601-6 525, BT.1358 525, BT.1700 NTSC, xvYCC601: the same as 5 |
| 7 | SMPTE 240M: E′Y = 0.212 R + 0.701 G + 0.087 B |
| 8 | YCgCo: Y = 0.5 G + 0.25 (R + B), Cb (Cg) = 0.5 G − 0.25 (R + B) + 128, Cr (Co) = 0.5 (R − B) + 128, on 8-bit R, G, B scaled to 16 to 235 |
| 9–255 | reserved |
For codes other than 8, Y = 219 E′Y + 16 and Cb, Cr = 224 E′P + 128, each rounded and clipped to 0 to 255.
Quant matrix extension
Identifier 3 (clauses 6.2.3.2 and 6.3.11). Each load flag is 1 bit, followed by 64 bytes in zig-zag order when set. All matrices return to their defaults at every sequence header. With 4:2:0 only the first two are used; the chroma flags must be 0. A matrix loaded into the luma slot is also used for chroma until a chroma matrix is loaded. No entry may be 0, and the first entry of an intra matrix must be 8.
| Bits | Name |
|---|---|
| 1, then 8 × 64 | load_intra_quantiser_matrix, intra_quantiser_matrix |
| 1, then 8 × 64 | load_non_intra_quantiser_matrix, non_intra_quantiser_matrix |
| 1, then 8 × 64 | load_chroma_intra_quantiser_matrix, chroma_intra_quantiser_matrix |
| 1, then 8 × 64 | load_chroma_non_intra_quantiser_matrix, chroma_non_intra_quantiser_matrix |
Copyright extension
Identifier 4 (clauses 6.2.3.6 and 6.3.15). It applies to every picture that follows, in coding order, up to the next copyright extension or the end of the sequence.
| Bits | Name | Description |
|---|---|---|
| 1 | copyright_flag | 1: the following material is copyrighted. 0 says nothing either way |
| 8 | copyright_identifier | the registration authority, assigned by a Registration Authority designated by ISO/IEC JTC1/SC29; 0 not available |
| 1 | original_or_copy | 1 for an original, 0 for a copy |
| 7 | reserved | 0 |
| 1 | marker_bit | 1 |
| 20 | copyright_number_1 | bits 44 to 63 of copyright_number |
| 1 | marker_bit | 1 |
| 22 | copyright_number_2 | bits 22 to 43 |
| 1 | marker_bit | 1 |
| 22 | copyright_number_3 | bits 0 to 21 |
copyright_number = (n1 << 44) + (n2 << 22) + n3, a 64-bit number
identifying the work; 0 means not available. With copyright_flag 0, the
identifier and number must be 0.
Sequence scalable extension
Identifier 5 (clauses 6.2.2.5 and 6.3.7). If it follows one sequence extension it must follow all of them: a stream is scalable throughout or not at all. The base layer carries none, except with data partitioning.
| Bits | Name | Condition | Description |
|---|---|---|---|
| 2 | scalable_mode | see below | |
| 4 | layer_id | this layer’s number: one more than the layer it enhances; 0 and 1 for the two data partitions | |
| 14 | lower_layer_prediction_horizontal_size | mode 1 | the lower layer’s horizontal_size |
| 1 | marker_bit | mode 1 | 1 |
| 14 | lower_layer_prediction_vertical_size | mode 1 | the lower layer’s vertical_size |
| 5 | horizontal_subsampling_factor_m | mode 1 | upsampling factors (clause 7.7.2); 0 forbidden |
| 5 | horizontal_subsampling_factor_n | mode 1 | 0 forbidden |
| 5 | vertical_subsampling_factor_m | mode 1 | 0 forbidden |
| 5 | vertical_subsampling_factor_n | mode 1 | 0 forbidden |
| 1 | picture_mux_enable | mode 3 | 1: the next two fields are used to re-multiplex the layers for display |
| 1 | mux_to_progressive_sequence | mode 3, mux enabled | 1: the two layers interleave into a progressive sequence; 0 interlaced |
| 3 | picture_mux_order | mode 3 | enhancement pictures before the first base picture |
| 3 | picture_mux_factor | mode 3 | enhancement pictures between base pictures; 0 reserved |
| scalable_mode | Meaning (Table 6-10) | macroblock_type tables |
|---|---|---|
| 0 | data partitioning | B.2 to B.4 |
| 1 | spatial scalability | B.5 to B.7 when the picture has a spatial scalable extension, otherwise B.2 to B.4 |
| 2 | SNR scalability | B.8 |
| 3 | temporal scalability | B.2 to B.4 |
Picture display extension
Identifier 7 (clauses 6.2.3.3 and 6.3.12), used for pan-scan. It may appear only if a sequence display extension followed the last sequence header. For each of 1 to 3 frame centre offsets:
| Bits | Name | Description |
|---|---|---|
| 16 | frame_centre_horizontal_offset | signed, in 1/16 sample: positive when the centre of the coded frame is right of the centre of the display rectangle |
| 1 | marker_bit | 1 |
| 16 | frame_centre_vertical_offset | signed, in 1/16 frame line (also in field pictures): positive when the frame centre is below the display centre |
| 1 | marker_bit | 1 |
number_of_frame_centre_offsets: in a progressive sequence, 3 if
repeat_first_field and top_field_first are both 1, 2 if only
repeat_first_field is, otherwise 1. Otherwise, 1 for a field picture, and
for a frame picture 3 if repeat_first_field is 1, else 2. A picture without
the extension reuses the last offset; after a sequence header the offsets are 0.
Picture coding extension
Identifier 8, following every picture header (clauses 6.2.3.1 and 6.3.10).
| Bits | Name | Description |
|---|---|---|
| 4 × 4 | f_code[0][0], f_code[0][1], f_code[1][0], f_code[1][1] | motion vector ranges: forward horizontal, forward vertical, backward horizontal, backward vertical. 1 to 9 in use, 15 not used, 0 forbidden, 10 to 14 reserved; see the macroblocks page |
| 2 | intra_dc_precision | 0 to 3 for 8 to 11 bits of intra DC precision |
| 2 | picture_structure | 1 top field, 2 bottom field, 3 frame picture; 0 reserved |
| 1 | top_field_first | interlaced: in a frame picture, 1 if the top field is output first; 0 in a field picture. Progressive sequence: with repeat_first_field, the frame is output three times (1) or twice (0) |
| 1 | frame_pred_frame_dct | 1: frame prediction and frame DCT only. 0 in field pictures, 1 in progressive sequences |
| 1 | concealment_motion_vectors | 1 if intra macroblocks carry motion vectors for hiding errors |
| 1 | q_scale_type | which column of the quantiser scale table is used (linear or non-linear) |
| 1 | intra_vlc_format | 1: intra blocks use DCT coefficient Table B.15 instead of B.14 |
| 1 | alternate_scan | 1 for the alternate scan order instead of zig-zag |
| 1 | repeat_first_field | frame pictures only: 1 outputs three fields (3:2 pulldown), or two or three frames in a progressive sequence. Must be 0 when progressive_frame is 0 |
| 1 | chroma_420_type | equal to progressive_frame for 4:2:0, otherwise 0; kept for historical reasons |
| 1 | progressive_frame | 1 if the two fields were sampled at the same instant; then the picture must be a frame picture |
| 1 | composite_display_flag | 1 if the five fields below follow, for material that was analogue composite video |
| 1 | v_axis | PAL only: 1 on a positive sign |
| 3 | field_sequence | the field’s place in the PAL eight-field or NTSC four-field sequence: see below |
| 1 | sub_carrier | 0: the sub-carrier to line frequency relationship is correct; 1 it is not |
| 7 | burst_amplitude | PAL and NTSC: burst amplitude, quantised as a BT.601 luma value without its top bit |
| 8 | sub_carrier_phase | phase of the sub-carrier at the field synchronisation datum: value × 360° ÷ 256 |
| field_sequence | Frame | Field |
|---|---|---|
| 0 | 1 | 1 |
| 1 | 1 | 2 |
| 2 | 2 | 3 |
| 3 | 2 | 4 |
| 4 | 3 | 5 |
| 5 | 3 | 6 |
| 6 | 4 | 7 |
| 7 | 4 | 8 |
When a frame is coded as two field pictures, both have the same picture type, except
that an I first field may be followed by a P second field, and the second field has the
opposite parity. The f codes, intra_dc_precision,
concealment_motion_vectors, q_scale_type,
intra_vlc_format, alternate_scan, vbv_delay and
temporal_reference may differ between the two fields.
Picture spatial scalable extension
Identifier 9 (clauses 6.2.3.5 and 6.3.14).
| Bits | Name | Description |
|---|---|---|
| 10 | lower_layer_temporal_reference | temporal reference of the lower-layer frame used for prediction (its low 10 bits) |
| 1 | marker_bit | 1 |
| 15 | lower_layer_horizontal_offset | signed: horizontal position of the upsampled lower layer’s top-left corner, in enhancement-layer samples; even for 4:2:0 and 4:2:2 |
| 1 | marker_bit | 1 |
| 15 | lower_layer_vertical_offset | signed: vertical position, in enhancement-layer lines; even for 4:2:0 |
| 2 | spatial_temporal_weight_code_table_index | which table of spatial and temporal weights the macroblocks use (clause 7.7, Tables 7-20 and 7-21) |
| 1 | lower_layer_progressive_frame | 1 if the lower-layer frame is progressive, 0 if interlaced |
| 1 | lower_layer_deinterlaced_field_select | which lower-layer field the upsampling uses (clause 7.7) |
Intended values of the table index (Table 7-20): 0 for a progressive enhancement layer; 2 when a progressive lower layer matches the enhancement layer’s top fields; 1 when it matches from the bottom fields; 0 or 3 for an interlaced lower layer coded as frame pictures; 0 for an interlaced lower layer coded as field pictures.
Picture temporal scalable extension
Identifier 10 (clauses 6.2.3.4, 6.3.13 and 7.9). Used in the enhancement layer of temporal scalability, and so in the Multi-view profile.
| Bits | Name | Description |
|---|---|---|
| 2 | reference_select_code | which pictures are used as references: see below |
| 10 | forward_temporal_reference | temporal reference of the lower-layer frame used for forward prediction (its low 10 bits) |
| 1 | marker_bit | 1 |
| 10 | backward_temporal_reference | temporal reference of the lower-layer frame used for backward prediction |
| Code | P picture: forward reference (Table 7-28) |
|---|---|
| 0 | the most recent decoded enhancement picture or pictures |
| 1 | the most recent lower-layer frame in display order |
| 2 | the next lower-layer frame in display order |
| 3 | forbidden |
| Code | B picture: forward reference (Table 7-29) | Backward reference |
|---|---|---|
| 0 | forbidden | forbidden |
| 1 | most recent decoded enhancement picture or pictures | most recent lower-layer picture in display order |
| 2 | most recent decoded enhancement picture or pictures | next lower-layer picture in display order |
| 3 | most recent lower-layer picture in display order | next lower-layer picture in display order |
Camera parameters extension
Identifier 11 (clauses 6.2.3.7.1 and 6.3.19), added with the Multi-view profile in 1998. Lengths are in units of 0.001 mm. The reserved fields must be 0.
| Bits | Name | Description |
|---|---|---|
| 1 | reserved | 0 |
| 7 | camera_id | signed: identifies the camera |
| 1 | marker_bit | 1 |
| 22 | height_of_image_device | height of the image sensor, 0 to 4 194.303 mm |
| 1 | marker_bit | 1 |
| 22 | focal_length | 0 to 4 194.303 mm |
| 1 | marker_bit | 1 |
| 22 | f_number | focal length ÷ effective aperture, in units of 0.001 |
| 1 | marker_bit | 1 |
| 22 | vertical_angle_of_view | between the top and bottom edges of the sensor, in units of 0.0001°, 0 to 180° |
| 1 | marker_bit | 1 |
| 16 + 1 + 16 | camera_position_x_upper, marker_bit, camera_position_x_lower | 32-bit signed x of the optical principal point in a user-defined world coordinate system, upper 16 bits first |
| 1 | marker_bit | 1 |
| 16 + 1 + 16 | camera_position_y_upper, marker_bit, camera_position_y_lower | y, likewise |
| 1 | marker_bit | 1 |
| 16 + 1 + 16 | camera_position_z_upper, marker_bit, camera_position_z_lower | z, likewise |
| 1 | marker_bit | 1 |
| 22 each, with a marker bit after each | camera_direction_x, _y, _z | signed vector from the principal point along the optical axis, −2 097 152 to 2 097 151 |
| 22 each, with a marker bit after each | image_plane_vertical_x, _y, _z | signed vector giving the camera’s up direction, parallel to the sensor’s side edge from bottom to top |
| 32 | reserved | 0 |
Camera position ranges from −2 147 483.648 mm to +2 147 483.647 mm.
ITU-T extension
Identifier 12 (clauses 6.2.3.7.2 and 6.3.20). After the identifier come
ITU-T_data bits, one at a time, until the next start code prefix. Its use is
defined in Annex A of ITU-T H.320, not in H.262.