H264 NAL单位前缀

时间:2014-05-07 11:40:14

标签: video-streaming h.264 rtp video-encoding

我需要对H264 NAL单位分隔符前缀(00 00 00 0100 00 01)做一些澄清,我正在使用Intel Media SDK生成H264并将其打包到RTP中。问题是到目前为止我只关注00 00 00 01作为单位分隔符,并且基本上只能在比特流中找到AUD,SPS,PPS和SEI单位。看看内存,我看到在SEI之后有一个字节序列00 00 01 25可能是IDR单元的开头,但我的搜索算法由于缺少零字节而没有检测到它。任何人都可以澄清00 00 00 0100 00 01前缀之间的区别吗?看Chromium code似乎第一单位以及澳元,SPS,PPS和SEI都有额外的零:

if (first_nal_in_this_access_unit ||
    IsAccessUnitBoundaryNal(nal_unit_type)) {
    output_size += 1;  // Extra zero_byte for these nal units
    first_nal_in_this_access_unit = false;
}

...

static bool IsAccessUnitBoundaryNal(int nal_unit_type) {
    // Check if this packet marks access unit boundary by checking the
    // packet type.
    if (nal_unit_type == 6 ||  // Supplemental enhancement information
        nal_unit_type == 7 ||  // Picture parameter set
        nal_unit_type == 8 ||  // Sequence parameter set
        nal_unit_type == 9 ||  // Access unit delimiter
        (nal_unit_type >= 14 && nal_unit_type <= 18)) {  // Reserved types
            return true;
        }
    return false;
}

1)我认为我应该寻找两个前缀,但后来我明白我需要检查下一个NAL单元的类型,以便知道当前的长度(知道前缀是3或4个字节,并且不消耗可能是前一个NAL单元的末尾作为前缀的零字节。

2)PPS,SPS和SEI尺寸是否固定?如果是这样,我可以在寻找下一个前缀时跳到单元的末尾。

我希望有更多经验的人可以对上述问题发表评论。

1 个答案:

答案 0 :(得分:6)

来自H.264 spec,B.1.2字节流NAL单元语义:

enter image description here

  

zero_byte是一个等于0x00的单字节。

     

当满足以下任何条件时,应存在zero_byte语法元素。

     
      
  • nal_unit()中的nal_unit_type等于7(序列参数集)或8(图片参数集)
  •   
  • 字节流NAL单元语法结构按解码顺序包含访问单元的第一个NAL单元,如子条款7.4.1.2.3所规定。
  •   
相关问题