技术贴:解码时AVC1和H264的区别

来源:互联网 发布:js调用微信扫一扫接口 编辑:程序博客网 时间:2024/05/18 01:23
我一直疑问为什么有些视频解码时显示格式是: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.

SubtypeFOURCCDescriptionMEDIASUBTYPE_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 typeMEDIATYPE_VideoSubtypeMEDIASUBTYPE_AVC1Format typeFORMAT_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解码器来恢复数据损坏或丢弃的样品。

翻译:



原创粉丝点击