NALU

NALU

H.264码流在网络中传输时实际是以NALU的形式进行传输的.

NALU结构

每个NALU一个字节HeaderRBSP组成.

NAL Header
NAL Header
  • forbidden_zero_bit

forbidden_zero_bit shall be equal to 0.

  • nal_ref_idc
    用于表示当前NALU的重要性,值越大,越重要.
    解码器在解码处理不过来的时候,可以丢掉重要性为0的NALU.
nal_ref_idc

nal_ref_idc不等于0时, NAL unit的内容可能是SPS/PPS/参考图像的片等.
nal_ref_idc等于0时,NAL unit的内容可能是非参考图像的片等.

nal_ref_idc shall not be equal to 0 for sequence parameter set or picture parameter set NAL units.
When nal_ref_idc is equal to 0 for one slice or slice data partition NAL unit of a particular picture, it shall be equal to 0 for all slice and slice data partition NAL units of the picture.

SPS/PPS时,nal_ref_idc不可为0.
当某个图像的片的nal_ref_id等于0时,该图像的所有片均应等于0.

nal_ref_idc shall not be equal to 0 for IDR NAL units, i.e., NAL units with nal_unit_type equal to 5.
nal_ref_idc shall be equal to 0 for all NAL units having nal_unit_type equal to 6, 9, 10, 11, or 12.

The relationship of nal_unit_type and nal_ref_idc
  • nal_unit_type

nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.

NAL unit type codes

nal_unit_type从是否包含VCL层编码数据分为VCL NAL unitsnon-VCL NAL units.
VCL NAL units中包含VCL层编码输出的数据, 而non-VCL NAL units不包括.

VCL NAL units & non-VCL NAL units

VCL NAL units常用的是nal_unit_type=5nal_unit_type=1.
nal_unit_type=5表明该NALU的类型是IDR的slice, 也表明该NALU所在图像也属于IDR帧.
nal_unit_type=1时一般表示该NALU所在的帧是P帧.

RBSP(Raw Byte Sequence Payload)

A syntax structure containing an integer number of bytes that is
encapsulated in a NAL unit
.
An RBSP is either empty or has the form of a string of data bits containing syntax
elements followed by an RBSP stop bit and followed by zero or more subsequent bits equal to 0.

  • (RBSP) stop bit

A bit equal to 1 present within a raw byte sequence payload
(RBSP) after a string of data bits. The location of the end of the string of data bits within an RBSP can be identified by searching from the end of the RBSP for the RBSP stop bit, which is the last non-zero bit in the
RBSP.

stop bit用于标示RBSP中数据部分的结束. 其后会填充0.

An RBSP is specified as an ordered sequence of bytes as follows.
The RBSP contains an SODB as follows.

  • If the SODB is empty (i.e., zero bits in length), the RBSP is also empty.
  • Otherwise, the RBSP contains the SODB as follows.
  1. The first byte of the RBSP contains the (most significant, left-most) eight bits of the SODB; the next byte of the RBSP shall contain the next eight bits of the SODB, etc., until fewer than eight bits of the SODB remain.
  2. rbsp_trailing_bits( ) are present after the SODB as follows:
    i) The first (most significant, left-most) bits of the final RBSP byte contains the remaining bits of the SODB, (if any)
    ii) The next bit consists of a single rbsp_stop_one_bit equal to 1, and
    iii) When the rbsp_stop_one_bit is not the last bit of a byte-aligned byte, one or more rbsp_alignment_zero_bit is present to result in byte alignment.
  3. One or more cabac_zero_word 16-bit syntax elements equal to 0x0000 may be present in some RBSPs after the rbsp_trailing_bits( ) at the end of the RBSP.

SODB(String Of Data Bits):
最原始的编码数据RBSP, 长度不一定是8的倍数,此时需要对齐. 
RBSP: 在SODB的后面填加了结尾比特(RBSP trailing bits 一个bit“1”)若干比特“0”,以便字节对齐.

RBSP

References:
14496-10.pdf
14496-15.pdf
http://blog.csdn.net/newthinker_wei/article/details/8748442
http://www.360doc.com/content/14/0520/17/17532616_379388909.shtml
http://www.samirchen.com/video-concept/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 年后新房交付,简单装修后高高兴兴入住了。 小区整体环境不错,道路干净,路两旁树木错落有致,生活设施齐全,运动场,儿...
    留逝阅读 288评论 1 2
  • 群里有麻麻私信我,问第一叛逆期…… 不是叛逆啦,是反抗期!这个必须要先说明,对于无论2.3岁还是青春期的孩子,用叛...
    和翊浛阅读 115评论 0 0
  • 翻译《Stack Overflow: The Hardware》 (20160717已完成)技术《About Ga...
    RiboseYim阅读 146评论 0 0
  • ​真琴实在是很喜欢各式各样的花,虽然对园艺和插花技术都有远超同龄人的审美品位和高超技术造诣,真琴却从来不参与学校花...
    GAssembly阅读 228评论 0 0
  • 最近再考虑要不要再买一个外研社的点读笔?拿不定主意是因为,我自己对点读笔的看法,但是音频有时候不好找,看看汪琣珽老...
    木木sani阅读 258评论 0 0