MPEG2視頻編碼定義在 ISO/IEC13818-2中,MPEG2 video sequence如下圖所示
我們可以借助Elecard Stream Analyer工具來分析MPEG2視頻碼流
MPEG2編碼碼流的起始碼的含義如下
1.Sequence Header
MPEG2視頻裸流的每一個GOP以Sequence Header開頭,Sequence Header的起始碼為00 00 01 B3,它里面保存了如下信息
- horizontal_size_value:視頻幀寬度
- vertical_size_value:視頻幀高度
- aspect_ratio_information:寬高比,各取值的含義如下
- frame_rate_code:幀率,各取值含義如下
- bit_rate_value:碼率
- marker_bit:This is one bit that shall be set to '1'. This bit prevents emulation of start codes
- vbv_buffer_size:定義了VBV (Video Buffering Verifie)的大小
2.Sequence Extention
它的起始碼為 00 00 01 B5,保存了如下信息

- profile_and_level_indication:指明了profile和leve
- progressive_sequence:When set to '1' the coded video sequence contains only progressive frame pictures. Whenprogressive_sequence is set to '0' the coded video sequence may contain both frame pictures and field pictures, and framepicture may be progressive or interlaced frames.
- chroma_format:采樣格式,各取值含義如下
3.Group of picture Header
起始碼為00 00 01 B8,保存了如下信息

- time_code:時碼,占25個字節,包含drop_frame_flag, time_code_hours, time_code_minutes,marker_bit, time_code_seconds 以及 time_code_pictures,各標志取值范圍如下
drop_frame_flag 標志只有在幀率為 29.97 時才有可能被設置為1。如果被設置為0 每秒鍾的幀數被近似到最近的整數,例如29.97的被近似為30. 如果被設置為1,除了 0, 10, 20, 30, 40, 50 分鍾外每分鍾開始的第0和第1幀將被忽略
- closed_gop:指明緊挨着在group of picture header后的I幀的連續的B幀的編碼方式,如果被設置為1,表示該B幀只采用backward prediction 或 intra coding (Close GOP是指幀間的預測都是在GOP中進行的。而使用open GOP,后一個GOP會參考前一個GOP的信息。使用這種方式就大大降低了碼率)
4.Picture Header
Picture Header保存了圖像相關信息,從該頭部信息中可以判斷該幀時IP或B幀。它的起始碼為00 00 01 00

- temporal_reference:指明該幀的參考屬性,各取值含義如下
- vbv_delay:當該值為 0xFFFF 表示VBR編碼
當出現0x0000100,是就表示已經到了圖象層,再越過10位(Temporal_reference占10位),就到了Picture_coding_type(3位),如果Picture_coding_type為001(二進制)就是I幀,為010是P幀,011則就是B幀。
5. Picture coding extension
- f_code[s][t]:4bit的整數,用在解碼時的運動向量中,s和t的取值含義如下圖
- intra_dc_precision: indicates the number of bits for quantized DC,coefficients of intra-coded blocks,The more bits are used, the more precise quantization is achieved,取之含義如下
- picture_structure :圖像掃面方式,各取值含義如下
- frame_pred_frame_dct:If this flag is set to '1', then only frame-DCT and frame prediction are used. In a field picture it shall be '0'. frame_pred_frame_dct shall be '1' if progressive_sequence is '1'. This flag affects the syntax of the bitstream.
- concealment_motion_vectors:This flag has the value '1' to indicate that motion vectors are coded in intra macroblocks. This flag has the value '0' to indicate that no motion vectors are coded in intra macroblocks
參考:ISOIEC13818-2-2013.pdf