H264 Nal互转RBSP常见小问题

      一般来说也不会去解析nal,直接扔给解码器完事,但有时候可能需要解析sps之类的获取一些信息,比如想
 不解码就获取视频分辨率等等。
      常见错误是从Nal提取RBSP时,忘了过滤掉0x3. 就是说在Nal中遇到 00 00 03 的时候,没有移除掉03.
   
   具体请看 Nal Unit语法:
   
   nal_unit( NumBytesInNALunit ) {                C Descriptor
         forbidden_zero_bit                               All f(1)
         nal_ref_idc                                            All u(2)
         nal_unit_type                                        All u(5)
         NumBytesInRBSP = 0
         for( i = 1; i < NumBytesInNALunit; i++ ) {
         if( i + 2 < NumBytesInNALunit && next_bits( 24 ) = = 0x000003 ) {
            rbsp_byte[ NumBytesInRBSP++ ]          All b(8)
            rbsp_byte[ NumBytesInRBSP++ ]          All b(8)
            i += 2
            emulation_prevention_three_byte /* equal to 0x03 */ All f(8)
         } else
        rbsp_byte[ NumBytesInRBSP++ ]              All b(8)
       }
    }
   
   
   反过来,有时候要自己生成NAL,常见应用比如生成自己的Sei等等.那么生成NAL时,当遇到:
   0x000000, 0x000001, 0x000002, 0x000003时,要再最后一个字节之前插入0x03.
   举个例子,比如遇到0x000001时,插入0x03就变成0x00000301.
   
   原文如下:
     The encoder can produce a NAL unit from an RBSP by the following procedure:
  The RBSP data is searched for byte-aligned bits of the following binary patterns:
  '00000000 00000000 000000xx' (where xx represents any 2 bit pattern: 00, 01, 10, or 11),
  and a byte equal to 0x03 is inserted to replace these bit patterns with the patterns
 '00000000 00000000 00000011 000000xx'.
 
  相关测试播放推送测试demo:  点击打开链接 或加群:294891451
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值