Below the sequence level a stream is organised into optional groups of pictures, then pictures, then slices. All fields are big-endian bit fields, straight after the start code. Source: ITU-T H.262 (third edition, 02/2012), clauses 6.2.2.6 to 6.2.4 and 6.3.8 to 6.3.21, and Annex L.
Group of pictures header
Start code 00 00 01 B8. It is optional in MPEG-2. The first coded frame
after it must be an I frame.
| Bits | Name | Description |
|---|---|---|
| 1 | drop_frame_flag | part of the time code: 1 for drop-frame counting, allowed only at 29.97 Hz, where picture numbers 0 and 1 are skipped at the start of each minute except minutes 0, 10, 20, 30, 40 and 50 |
| 5 | time_code_hours | 0 to 23 |
| 6 | time_code_minutes | 0 to 59 |
| 1 | marker_bit | 1 |
| 6 | time_code_seconds | 0 to 59 |
| 6 | time_code_pictures | the picture number within the second, 0 to 59 |
| 1 | closed_gop | 1 if the B pictures straight after the first I frame use only backward prediction or intra coding |
| 1 | broken_link | 0 when encoded; set to 1 by an editor when those B pictures cannot be decoded because their reference was removed |
The 25-bit time_code (Table 6-11) follows IEC 60461 and refers to the first
picture after the header with temporal_reference 0. It plays no part in
decoding. The header ends with zero bits to the byte boundary, so it takes 8 bytes
including the start code.
Picture header
Start code 00 00 01 00. In MPEG-2 a
picture coding extension
follows every picture header and holds the real motion vector ranges.
| Bits | Name | Condition | Description |
|---|---|---|---|
| 10 | temporal_reference | display position modulo 1024: 0 for the first frame shown after a GOP header, then +1 per frame; both fields of a frame share it | |
| 3 | picture_coding_type | see below | |
| 16 | vbv_delay | 90 kHz ticks the decoder buffer waits after the picture start code; FFFF in every picture means variable bit rate input (C.3.2) | |
| 1 | full_pel_forward_vector | type 2 or 3 | MPEG-1 field; must be 0 in MPEG-2 |
| 3 | forward_f_code | type 2 or 3 | MPEG-1 field; must be 7 (111) in MPEG-2 |
| 1 | full_pel_backward_vector | type 3 | must be 0 in MPEG-2 |
| 3 | backward_f_code | type 3 | must be 7 in MPEG-2 |
| 1 | extra_bit_picture | repeated | 1: a content description data structure follows, and then another flag; 0 ends the header |
| Code | Picture type (Table 6-12) |
|---|---|
| 0 | forbidden |
| 1 | I, intra coded |
| 2 | P, predictive coded |
| 3 | B, bidirectionally predictive coded |
| 4 | D, DC coefficients only: MPEG-1 only, must not be used in MPEG-2 |
| 5–7 | reserved |
In MPEG-1 an extra_bit_picture of 1 was followed by 8 bits of
extra_information_picture; H.262 reserves that element, forbids it in its own
streams and tells decoders to discard it. With low_delay set, a big
picture that takes K extra buffer checks advances the next temporal reference by K as
well.
Content description data
Added by Amendment 1 (2000), clause 6.2.3.7.3. It sits inside the picture header after
each extra_bit_picture of 1, and every ninth bit is a marker bit of 1, so
the data is carried as 8-bit values each preceded by a 1.
| Bits | Name | Description |
|---|---|---|
| 8 | data_type_upper | high byte of the 16-bit data_type |
| 1 | marker_bit | 1 |
| 8 | data_type_lower | low byte |
| 1 | marker_bit | 1 |
| 8 | data_length | the rest of the structure in 9-bit units |
| payload | by type, below; for a reserved type, data_length pairs of a marker bit and a reserved byte, which a decoder discards |
data_type | Meaning (Table 6-21) |
|---|---|
| 0 | reserved |
| 1 | padding bytes: data_length × (marker bit, byte 0); counted in buffer calculations |
| 2 | capture timecode |
| 3 | additional pan-scan parameters |
| 4 | active region window |
| 5 | coded picture length |
| 6–65535 | reserved |
A reserved_bit inside these structures is written as 0; decoders accept 0
or 1.
Capture timecode (2)
When the field or frame was captured or created. At most one per picture; it never overrides the system layer’s time stamps.
| Bits | Name | Condition | Description |
|---|---|---|---|
| 1 | marker_bit | 1 | |
| 2 | timecode_type | 0 one stamp for the frame; 1 one for the first or only field; 2 one for the second field; 3 two stamps, one per field. 0, 2 and 3 only in frame pictures | |
| 3 | counting_type | see below | |
| 3 × 1 | reserved_bit | 0 | |
| 1 | marker_bit | counting type not 0 | 1 |
| 1 | nframes_conversion_code | counting type not 0 | conversion factor 1000 + this bit |
| 7 | clock_divisor | counting type not 0 | divisions of the 27 MHz clock |
| 1 + 8 + 1 + 8 | marker_bit, nframes_multiplier_upper, marker_bit, nframes_multiplier_lower | counting type not 0 | 16-bit nframes_multiplier |
frame_or_field_capture_timestamp() | once, or twice when timecode_type is 3 |
counting_type | Meaning (Table 6-23) |
|---|---|
| 0 | nframes not used |
| 1 | no dropping of nframes values |
| 2 | dropping of individual zero values |
| 3 | dropping of individual max_nframes values |
| 4 | dropping of the two lowest values (0 and 1) when the seconds are zero and the units of minutes are not |
| 5 | dropping of unspecified individual values |
| 6 | dropping of unspecified numbers of unspecified values |
| 7 | reserved |
Each timestamp (clause 6.2.3.7.3.2.1):
| Bits | Name | Description |
|---|---|---|
| 1 + 8 | marker_bit, nframes | only when the counting type is not 0: frame increments to add, at most max_nframes = 26 999 999 ÷ (multiplier × (1000 + conversion code) × divisor) |
| 1 | marker_bit | 1 |
| 1 | time_discontinuity | 1: the difference from the previous stamp has no meaning (after an edit, or no previous stamp) |
| 1 | prior_count_dropped | 1: one or more nframes values were dropped before this one |
| 6, 1, 8, 1, 8, 1, 8 | time_offset_part_a to _d with marker bits | 30-bit signed time_offset in clock cycles |
| 1 | marker_bit | 1 |
| 4 + 4 | units_of_seconds, tens_of_seconds | 0 to 9 and 0 to 5; higher values forbidden |
| 1 | marker_bit | 1 |
| 4 + 4 | units_of_minutes, tens_of_minutes | 0 to 9 and 0 to 5 |
| 1 | marker_bit | 1 |
| 4 + 4 | units_of_hours, tens_of_hours | 0 to 9 and 0 to 2; units at most 3 when tens is 2 |
In 27 MHz cycles, the stamp is ((hours × 60 + minutes) × 60 + seconds) × 27 000 000
+ time_offset with counting type 0, and the same seconds term + (nframes ×
multiplier × (1000 + conversion code) + time_offset) × divisor otherwise.
Additional pan-scan parameters (3)
Pan-scan for a second display shape, beside the one given by the sequence display and picture display extensions.
| Bits | Name | Description |
|---|---|---|
| 1 | marker_bit | 1 |
| 4 | aspect_ratio_information | the display shape these values are for (sequence header codes); never the sequence header’s own value |
| 3 × 1 | reserved_bit | 0 |
| 1 | display_size_present | 1: a new display size follows; 0: keep the last one for this shape |
| 1, 1, 1, 6, 1, 8 | marker_bit, 2 × reserved_bit, display_horizontal_size_upper, marker_bit, _lower | if present: the 14-bit display width |
| 1, 1, 1, 6, 1, 8 | the same for display_vertical_size | if present: the 14-bit display height |
| (1 + 8) × 4 | frame_centre_horizontal_offset_upper, _lower, frame_centre_vertical_offset_upper, _lower, each after a marker bit | repeated for each of number_of_frame_centre_offsets: signed 16-bit offsets in 1/16 sample, as in the picture display extension |
Active region window (4)
The rectangle of the decoded frame meant to be shown. At most one per picture, never in the second field of a frame. Each value is 16 bits sent as a marker bit and an upper byte, then a marker bit and a lower byte.
| Bits | Name | Description |
|---|---|---|
| 18 | top_left_x | first luma sample of the window in a line |
| 18 | top_left_y | first luma line of the window |
| 18 | active_region_horizontal_size | width, at most horizontal_size; 0 unknown |
| 18 | active_region_vertical_size | height, at most vertical_size; 0 unknown |
A frame without a window keeps the last one; a sequence header resets it to the whole frame.
Coded picture length (5)
Four marker bits and bytes, picture_byte_count_part_a to
_d, most significant first, giving the 32-bit
picture_byte_count: the bytes from the first byte of the picture’s first
slice start code up to the start code prefix after its last macroblock. 0 means
unknown. At most one per picture.
User data
Start code 00 00 01 B2, then bytes up to the next start code. It may
follow the sequence extension, a GOP header or the picture coding extension. Its
meaning is up to the application, except that it must not contain 23 or more zero bits
in a row, and must not start with 4A 50 33 44 (“JP3D”) unless it is frame
packing data.
Frame packing arrangement (Annex L)
Added by Amendment 4 (2012) for stereoscopic 3D: user data after a picture coding extension, recommended in every picture of a 3D stream.
| Bits | Name | Description |
|---|---|---|
| 32 | frame_packing_user_data_identifier | 4A 50 33 44 |
| 8 | remaining_data_length | 3; other values reserved |
| 1 | reserved_bit | 1; ignored by decoders |
| 7 | arrangement_type | see below |
| 16 | reserved_data | 04 FF; ignored by decoders |
| 8 each | additional_reserved_data_byte | remaining_data_length − 3 of them |
arrangement_type | Meaning (Table L.1) |
|---|---|
| 3 | side by side: left view in the left half, right view in the right half, each at half horizontal resolution |
| 4 | top and bottom: left view in the top half, right view in the bottom half, each at half vertical resolution |
| 8 | 2D video: one view filling the picture |
| others | reserved |
The halves split the displayable part of the picture, not the coded macroblock area. A change of arrangement should be signalled in the picture where the content changes.
Slice header
Start codes 00 00 01 01 to 00 00 01 AF. The last byte,
slice_vertical_position, is the macroblock row plus 1. When the height is
over 2800 lines a 3-bit extension gives the high bits: row =
(extension << 7) + position − 1, with the position then 1 to 128.
| Bits | Name | Condition | Description |
|---|---|---|---|
| 3 | slice_vertical_position_extension | height over 2800 | high bits of the row number |
| 7 | priority_breakpoint | data partitioning | where the slice splits between partitions: see the macroblocks page; 0 in partition 1 |
| 5 | quantiser_scale_code | the quantiser for this slice, 1 to 31; 0 forbidden | |
| 1 | slice_extension_flag | next bit is 1 | 1: the next three fields follow |
| 1 | intra_slice | extension flag 1 | may be 1 only if every macroblock in the slice is intra; for trick play, not used in decoding |
| 1 | slice_picture_id_enable | extension flag 1 | 1: slice_picture_id carries a value; the same in all slices of a picture |
| 6 | slice_picture_id | extension flag 1 | application-defined, the same in all slices of a picture, to help recovery from burst errors; 0 when not enabled |
| 1 | extra_bit_slice | repeated | must be 0; 1 (followed by 8 bits of extra_information_slice) is reserved, and decoders discard such bytes |
The macroblocks follow, running to the next start code.