一般来说也不会去解析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
不解码就获取视频分辨率等等。
常见错误是从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