技术贴:解码时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 anMPEG2VIDEOINFOstructure. This structure should be filled in as follows:
hdr: AVIDEOINFOHEADER2structure that describes the bitstream. No color table is present
after theBITMAPINFOHEADERportion of the structure, andbiClrUsedmust be zero.dwStartTimeCode: Not used. Set to zero.cbSequenceHeader: The length of thedwSequenceHeaderarray 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 eachNALU. The length field indicates the size of the following NALU in bytes. For example, ifdwFlagsis 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 thedwSequenceHeaderarray. IfcbSequenceHeaderis 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解碼器來恢復數據損壞或丟棄的樣品。
翻譯:
總結
以上是生活随笔為你收集整理的技术贴:解码时AVC1和H264的差别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 菩提子手链(正品菩提一般多少钱)
- 下一篇: 超人电熨斗哪个是好的超人电熨斗价格