技術貼:解碼時AVC1和H264的區別

我一直疑問爲什麼有些視頻解碼時顯示格式是:H264,大部分又是:AVC1
我在搜索編程資料時在微軟的msdn上發現的:
原文:http://msdn.microsoft.com/en-us/library/dd757808(v=vs.85).aspx
FOURCC:AVC1   描述:H.264 bitstream without start codes.
FOURCC:H264   描述:H.264 bitstream with start codes.


H.264 Bitstream with Start Codes

H.264 bitstreams that are transmitted over the air, or contained in MPEG-2 program or transport streams, or recorded on HD-DVD, are formatted as described in Annex B of ITU-T Rec. H.264. According to this specification, the bitstream consists of a sequence of network abstraction layer units (NALUs), each of which is prefixed with a start code equal to 0x000001 or 0x00000001.
這段話的大致意思是:帶有開始碼的H.264視頻一般是用於無線發射、有線廣播或者HD-DVD中的。這些數據流的開始都有一個開始碼:0x000001 或者 0x00000001.


H.264 Bitstream Without Start Codes

The MP4 container format stores H.264 data without start codes. Instead, each NALU is prefixed by a length field, which gives the length of the NALU in bytes. The size of the length field can vary, but is typically 1, 2, or 4 bytes.
這段話的大致意思是:沒有開始碼的H.264視頻主要是存儲在MP4格式的文件中的。它的數據流的開始是1、2或者4個字節表示長度數據。

原文中的"NALU"簡單說是H.264格式中的最基本的單元,是一個數據包。


H.264 Video Types

The following media subtypes are defined for H.264 video.

Subtype FOURCC Description
MEDIASUBTYPE_AVC1 'AVC1' H.264 bitstream without start codes.
MEDIASUBTYPE_H264 'H264' H.264 bitstream with start codes.
MEDIASUBTYPE_h264 'h264' Equivalent to MEDIASUBTYPE_H264, with a different FOURCC.
MEDIASUBTYPE_X264 'X264' Equivalent to MEDIASUBTYPE_H264, with a different FOURCC.
MEDIASUBTYPE_x264 'x264' Equivalent to MEDIASUBTYPE_H264, with a different FOURCC.

The main difference between these media types is the presence of startcodes in the bitstream. If the subtype is MEDIASUBTYPE_AVC1, thebitstream does not contain start codes.

H.264 Bitstream Without Start Codes

The MP4 container format stores H.264 data without start codes.Instead, each NALU is prefixed by a length field, which gives thelength of the NALU in bytes. The size of the length field can vary, butis typically 1, 2, or 4 bytes.

When start codes are not present in the bitstream, the following media type is used.

Major type MEDIATYPE_Video
Subtype MEDIASUBTYPE_AVC1
Format type FORMAT_MPEG2Video

 

The format block is an MPEG2VIDEOINFO structure. This structure should be filled in as follows:

  • hdr: A VIDEOINFOHEADER2 structure that describes the bitstream. No color table is present after theBITMAPINFOHEADER portion of the structure, and biClrUsed must be zero.
  • dwStartTimeCode: Not used. Set to zero.
  • cbSequenceHeader: The length of the dwSequenceHeader array in bytes.
  • dwProfile: Specifies the H.264 profile.
  • dwLevel: Specifies the H.264 level.
  • dwFlags: The number of bytes used for the length field that appears before each NALU. The length field indicates the size of the following NALU in bytes. For example, if dwFlags is 4, each NALU is preceded by a 4-byte length field. The valid values are 1, 2, and 4.
  • dwSequenceHeader: A byte array that may contain sequence parameter set (SPS) and picture parameter set (PPS) NALUs.

The MP4 container might contain sequence parameter sets (SPS) orpicture parameter sets (PPS) as special NAL units in file headers or ina separate stream (distinct from the video stream). When the format isestablished, the media type can specify SPS and PPS NAL units in the dwSequenceHeader array. IfcbSequenceHeader is greater than zero, dwSequenceHeaderis the start of a byte array containing SPS and PPS NALUs, delimited by2-byte length fields, all in network byte order (big-endian). It ispossible to have both SPS and PPS, only one of these types, or none.The actual type of each NALU can be determined by examining thenal_unit_type field of the NALU itself.

When this media type is used, each media sample starts at thebeginning of a NALU, and NAL units do not span samples. This enablesthe decoder to recover from data corruption or dropped samples.

H.264的視頻類型

以下媒體亞型定義的H.264視頻。

亞型fourcc值描述
MEDIASUBTYPE_AVC1“AVC1”H.264比特流沒有啓動代碼。
MEDIASUBTYPE_H264“H264”開始編碼的H.264比特流。
MEDIASUBTYPE_h264'H264'的相當於到MEDIASUBTYPE_H264,與不同的fourcc值。
“X264的'MEDIASUBTYPE_X264的相當於到MEDIASUBTYPE_H264,與不同的fourcc值。
“X264”MEDIASUBTYPE_x264相當於到MEDIASUBTYPE_H264,用不同的fourcc值。
這些媒體類型之間的主要區別是存在的比特流中的startcodes。如果亞型是MEDIASUBTYPE_AVC1,thebitstream不包含啓動代碼。

H.264的碼流沒有啓動代碼
MP4容器格式存儲H.264沒有開始codes.Instead的數據,每個的NALU是由前綴長度字段,從而使字節的NALU thelength。長度字段的大小可以有所不同,butis通常爲1,2,或4個字節。

當啓動代碼是在比特流中不存在,下面的介質類型。

主要類型MEDIATYPE_Video的
亞型MEDIASUBTYPE_AVC1
格式類型FORMAT_MPEG2Video
 

格式塊是MPEG2VIDEOINFO結構。這種結構應填寫如下:

HDR:一個VIDEOINFOHEADER2的結構描述的比特流。沒有顏色表是存在的BITMAPINFOHEADER結構部分後,biClrUsed必須是零。
dwStartTimeCode:未使用。設置爲零。
cbSequenceHeader的在字節dwSequenceHeader數組的長度。
dwProfile:指定H.264的個人資料。
dwLevel:指定H.264水平。
的dwFlags:用於長度字段出現在每次的NALU的字節數。長度字段表示在字節以下的NALU的大小。例如,如果dwFlags是4個,每個的NALU之前由4個字節的長度字段。有效的值是1,2和4。
dwSequenceHeader:一個字節數組可能包含序列參數集(SPS)和圖像參數集(PPS)NALUs。
MP4容器可能含有序列參數集(SPS)orpicture參數集(PPS)的文件頭或INA單獨的流(從視頻流中不同)的特殊NAL單元。當isestablished的格式,媒體類型可以指定在dwSequenceHeader陣列SPS和PPS NAL單元。如果cbSequenceHeader大於零,dwSequenceHeaderis含SPS和PPS的NALUs,分隔BY2字節長度字段,所有在網絡字節順序(大端)字節數組開始。它ispossible SPS和PPS,只有這些類型之一,或可以通過審查的NALU本身thenal_unit_type領域確定每個的NALU none.The實際類型。

當使用這種媒體類型,每個媒體樣本的NALU的thebeginning開始,NAL單元不跨越樣本。這enablesthe解碼器來恢復數據損壞或丟棄的樣品。


發佈了20 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章