H264 NAL单位前缀 [英] H264 NAL unit prefixes

查看:285
本文介绍了H264 NAL单位前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对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前缀之间的区别?查看铬代码,似乎第一个单元以及AUD,SPS,PPS和SEI还有一个额外的零:

I need some clarification on H264 NAL unit delimiter prefixes (00 00 00 01 and 00 00 01), I am using Intel Media SDK to generate a H264 and pack it into RTP. The issue is that so far I was looking only for 00 00 00 01 as a unit separator and basically was able to find only AUD,SPS,PPS and SEI units in the bitstream. Looking at the memory I saw that after the SEI there was a byte sequence 00 00 01 25 that could be a start of an IDR unit, but my search algorithm did not detect it because of a missing zero byte. Can anyone clarify the difference between 00 00 00 01 and 00 00 01 prefixes? Looking at Chromium code it seems that first unit as well as AUD, SPS, PPS, and SEI have an extra zero:

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单元的类型,以便知道当前NAL单元的长度(要知道前缀是否为3)或4个字节,并且不消耗零字节,该字节可能是前一个NAL单元的结尾作为前缀.)

1) I would assume I should look for both prefixes, but then I understand that I need to check the type of the next NAL unit in order to know the length of the current one (to know if the the prefix is 3 or 4 bytes and not consume a zero byte that could be an end of a previous NAL unit as the prefix).

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

2) Are PPS, SPS, and SEI sizes fixed? If so I could just jump to the end of the unit when looking for the next prefix.

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

I hope that someone who has had more experience with this can comment on the questions above.

推荐答案

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

From H.264 spec, B.1.2 Byte stream NAL unit semantics:

zero_byte是等于0x00的单个字节.

zero_byte is a single byte equal to 0x00.

满足以下任何条件时,将出现zero_byte语法元素.

When any of the following conditions are fulfilled, the zero_byte syntax element shall be present.

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

这篇关于H264 NAL单位前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆