Rud*_*lis 4 rtp video-encoding video-streaming h.264
我需要对H264 NAL单元分隔符前缀(00 00 00 01和00 00 01)做一些澄清,我使用Intel Media SDK生成H264并将其打包到RTP中.问题是,到目前为止,我只关注00 00 00 01单位分隔符,基本上只能在比特流中找到AUD,SPS,PPS和SEI单位.看看内存,我看到在SEI之后有一个字节序列00 00 01 25可能是IDR单元的开始,但是由于缺少零字节,我的搜索算法没有检测到它.任何人都可以澄清00 00 00 01和00 00 01前缀之间的区别吗?看看Chromium代码,看起来第一个单元以及AUD,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;
}
Run Code Online (Sandbox Code Playgroud)
1)我会假设我应该寻找两个前缀,但后来我明白我需要检查下一个NAL单元的类型,以便知道当前的长度(知道前缀是3还是4字节)并且不消耗可能是前一个NAL单元的末尾作为前缀的零字节.
2)PPS,SPS和SEI尺寸是否固定?如果是这样,我可以在寻找下一个前缀时跳到单元的末尾.
我希望有更多经验的人可以对上述问题发表评论.