浅谈RBSP trailing bits syntax

来源:互联网 发布:orbslam2 kitti数据集 编辑:程序博客网 时间:2024/06/07 01:33

H.264码流的RBSP级别,是由SODB和RBSP trailing bits构成的,由于编码后的数据要精确到位(bit)组装起来,而码流又是以字节为单位的,这样就需要补齐到字节。

参考ISO IEC 14496-10文档

7.3.2.11 RBSP trailing bits syntax

rbsp_trailing_bits( ) {
    rbsp_stop_one_bit /* equal to 1 */
    while( !byte_aligned( ) )
        rbsp_alignment_zero_bit /* equal to 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 contains 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.

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恰好占到8的倍数个bits,这时候还是需要RBSP trailing bits,即二进制的‘10000000’

如果SODB按8位字节占据,多余7个bits,这时候的RBSP trailing bits,即二进制的‘1’,后面不用再添0了

普通的情况是后面补齐二进制1和(1-6个)0

还有一种情况是,有的RBSP最后还会出现1个或多个cabac_zero_word,即16位的0





原创粉丝点击