H264编解码 分析六 FU-A 分片单元

FU-A

NON IDR 属于 [RTP header] + 拆分的NAL单元 ,所以RTP包结构如下

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X|  CC   |M|     PT      |       sequence number         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           timestamp                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           synchronization source (SSRC) identifier            |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
|            contributing source (CSRC) identifiers             |
|                             ....                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FU indicator  |   FU header   |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
|                                                               |
|                         FU payload                            |
|                                                               |
|                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               :...OPTIONAL RTP padding        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                            +---------------+
+-+-+-+-+-+-+-+-+           |0|1|2|3|4|5|6|7|
| FU indicator  |  < == >   +-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+           |F|NRI|  Type   |
                            +---------------+

                            +---------------+
+-+-+-+-+-+-+-+-+           |0|1|2|3|4|5|6|7|
| FU header     |   < == >  +-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+           |S|E|R|  Type   |
                            +---------------+

FU-A Start

先看 抓到的 dump

0000   80 60 e2 51 ff 70 7f 99 c6 0a 3f ef 5c 81 9a dd   .Qÿp..Æ.?ï\..Ý
0010   11 5a 82 05 b5 b5 b5 a2 65 30 00 02 3e 73 ff fa   .Z..µµµ¢e0..>sÿú
0020   58 00 00 1d fd 39 0c 62 cb 80 17 ff 7f ff 0f b3   X...ý9.bË..ÿ.ÿ.³
0030   02 d5 63 c8 3b 0c c5 4a a3 e7 15 6a 7a f7 54 b1   .ÕcÈ;.ÅJ£ç.jz÷T±
0040   a3 69 b0 d2 7f 06 ab 02 ce 2d 19 2f bd 40 83 a8   £i°Ò..«.Î-./½@.¨
0050   0e f9 72 05 b1 d9 f9 e9 d3 b3 ......                                                

在上面12个byte是 [RTP Header]

80 60 e2 51 
ff 70 7f 99 
c6 0a 3f ef
====>转化 二进制
1000 0000 0110 0000 1110 0010 0101 0001 v=2 p=0 x=0 CC=0 M=0 PT=96 SN=57937 
1111 1111 0111 0000 0111 1111 1001 1001 timestamp 
1100 0110 0000 1010 0011 1111 1110 1111 ssrc 

对应wireshark 解析

Real-Time Transport Protocol
    10.. .... = Version: RFC 1889 Version (2)
    ..0. .... = Padding: False
    ...0 .... = Extension: False
    .... 0000 = Contributing source identifiers count: 0
    0... .... = Marker: False
    Payload type: DynamicRTP-Type-96 (96)
    Sequence number: 57937
    Timestamp: 4285562777
    Synchronization Source identifier: 0xc60a3fef (3322560495)

分片NALU 地一个字节 [FU indicator] 第二个字节 [FU Header]

0000   5c 81 9a dd 11 5a 82 05 b5 b5 b5 a2 65 30 00 02   \..Ý.Z..µµµ¢e0..
0010   3e 73 ff fa 58 00 00 1d fd 39 0c 62 cb 80 17 ff   >sÿúX...ý9...ÿ
0020   7f ff 0f b3 02 d5 63 c8 .......

===> 转化 第一个字节 5c 第二个字节 81
0101 1100  F=0 NRI=10  type=28 说明是 FU-A
1000 0001  S=1 E=0 R=0  type=1 非参考帧

wireshark 解析

FU identifier
    0... .... = F bit: No bit errors or other syntax violations
    .10. .... = Nal_ref_idc (NRI): 2
    ...1 1100 = Type: Fragmentation unit A (FU-A) (28)
FU Header
    1... .... = Start bit: the first packet of FU-A picture
    .0.. .... = End bit: Not the last packet of FU-A picture
    ..0. .... = Forbidden bit: 0
    ...0 0001 = Nal_unit_type: Coded slice of a non-IDR picture (1)

剩下的就看下H264 分片 NAL Unit Payload NALU的负载

0000   9a dd 11 5a 82 05 b5 b5 b5 a2 65 30 00 02 3e 73   .Ý.Z..µµµ¢e0..>s
0010   ff fa 58 00 00 1d fd 39 0c 62 cb 80 17 ff 7f ff   ÿúX...ý9.bË..ÿ.ÿ
0020   0f b3 02 d5 63 c8 3b 0c c5 ....

FU-A

先看 抓到的 dump

0000   80 60 e2 52 ff 70 7f 99 c6 0a 3f ef 5c 01 9f 95   .`âRÿp..Æ.?ï\...
0010   71 c6 30 d3 cd e7 7d a6 19 00 04 c4 00 83 59 cc   qÆ0ÓÍç}¦...Ä..YÌ
0020   48 ab c1 23 51 12 48 f8 83 e5 5e a9 ce 19 ec 1d   H«Á#Q.Hø.å^©Î.ì.
0030   e3 ea 43 f9 14 2c 6f 90 .......                                            

在上面12个byte是 [RTP Header]

80 60 e2 52 
ff 70 7f 99 
c6 0a 3f ef
====>转化 二进制
1000 0000 0110 0000 1110 0010 0101 0010 v=2 p=0 x=0 CC=0 M=0 PT=96 SN=57938 
1111 1111 0111 0000 0111 1111 1001 1001 timestamp 
1100 0110 0000 1010 0011 1111 1110 1111 ssrc 

对应wireshark 解析

Real-Time Transport Protocol
    10.. .... = Version: RFC 1889 Version (2)
    ..0. .... = Padding: False
    ...0 .... = Extension: False
    .... 0000 = Contributing source identifiers count: 0
    0... .... = Marker: False
    Payload type: DynamicRTP-Type-96 (96)
    Sequence number: 57938
    Timestamp: 4285562777
    Synchronization Source identifier: 0xc60a3fef (3322560495)

分片NALU 地一个字节 [FU indicator] 第二个字节 [FU Header]

0000   5c 01 9f 95 71 c6 30 d3 cd e7 7d a6 19 00 04 c4   \...qÆ0ÓÍç}¦...Ä
0010   00 83 59 cc 48 ab c1 23 51 12 48 f8 83 e5 5e a9   ..YÌH«Á#Q.Hø.å^©
0020   ce 19 ec 1d e3 ea 43 f9 14 2c 6f 90 4a 1d eb f1   Î.ì.ãêCù.,o.J.ëñ
0030   5d b8 53 b3 62 07 7e c1 ......

===> 转化 第一个字节 5c 第二个字节 01
0101 1100  F=0 NRI=10  type=28 说明是 FU-A
0000 0001  S=0 E=0 R=0  type=1 非参考帧

wireshark 解析

FU identifier
    0... .... = F bit: No bit errors or other syntax violations
    .10. .... = Nal_ref_idc (NRI): 2
    ...1 1100 = Type: Fragmentation unit A (FU-A) (28)
FU Header
    0... .... = Start bit: Not the first packet of FU-A picture
    .0.. .... = End bit: Not the last packet of FU-A picture
    ..0. .... = Forbidden bit: 0
    ...0 0001 = Nal_unit_type: Coded slice of a non-IDR picture (1)

剩下的就看下H264 分片 NAL Unit Payload NALU的负载

0000   9f 95 71 c6 30 d3 cd e7 7d a6 19 00 04 c4 00 83 .Ý.Z..µµµ¢e0..>s
0010   59 cc 48 .....

FU-A End

先看 抓到的 dump

0000   80 e0 e2 53 ff 70 7f 99 c6 0a 3f ef 5c 41 7c cb   .àâSÿp..Æ.?ï\A0010   df 35 ba 73 4a ae d7 94 b6 17 04 7d 50 e0 94 65   ß5ºsJ®×.¶..}Pà.e
0020   b5 26 f5 1c 3a 61 ca 92 ba ed 3c d7 c4 a2 35 d3   µ&õ.:aÊ.ºí<×Ä¢5Ó
0030   15 a4 72 f4 9c fe fc .....                             

在上面12个byte是 [RTP Header]

80 e0 e2 53 
ff 70 7f 99 
c6 0a 3f ef
====>转化 二进制
1000 0000 1100 0000 1110 0010 0101 0011 v=2 p=0 x=0 CC=0 M=0 PT=96 SN=57939 
1111 1111 0111 0000 0111 1111 1001 1001 timestamp 
1100 0110 0000 1010 0011 1111 1110 1111 ssrc 

对应wireshark 解析

Real-Time Transport Protocol
    10.. .... = Version: RFC 1889 Version (2)
    ..0. .... = Padding: False
    ...0 .... = Extension: False
    .... 0000 = Contributing source identifiers count: 0
    1... .... = Marker: True
    Payload type: DynamicRTP-Type-96 (96)
    Sequence number: 57939
    Timestamp: 4285562777
    Synchronization Source identifier: 0xc60a3fef (3322560495)

分片NALU 地一个字节 [FU indicator] 第二个字节 [FU Header]

0000   5c 41 7c cb df 35 ba 73 4a ae d7 94 b6 17 04 7d   \A|Ëß5ºsJ®×.¶..}
0010   50 e0 94 65 b5 26 f5 1c 3a 61 ca 92 ba ed 3c d7   Pà.eµ&õ.:aÊ.ºí<×
0020   c4 a2 35 d3 15 a4 72 f4 .....

===> 转化 第一个字节 5c 第二个字节 41
0101 1100  F=0 NRI=10  type=28 说明是 FU-A
0100 0001  S=0 E=1 分片帧结束 R=0  type=1 非参考一帧

wireshark 解析

FU identifier
    0... .... = F bit: No bit errors or other syntax violations
    .10. .... = Nal_ref_idc (NRI): 2
    ...1 1100 = Type: Fragmentation unit A (FU-A) (28)
FU Header
    0... .... = Start bit: Not the first packet of FU-A picture
    .1.. .... = End bit: the last packet of FU-A picture
    ..0. .... = Forbidden bit: 0
    ...0 0001 = Nal_unit_type: Coded slice of a non-IDR picture (1)

剩下的就看下H264 分片 NAL Unit Payload NALU的负载

0000   7c cb df 35 ba 73 4a ae d7 94 b6 17 04 7d 50 e0   ...Ëß5ºsJ®×.¶..}
0010   94 65 b5 26 f5 1c 3a 61 ca 92 ba ed 3c d7 ...  

上面的分析,总结如下,FU-A 中时间戳一样的,只是序列号一次增加
能理解多少,记多少,为后面学习编码和解码打基础

猜你喜欢

转载自blog.csdn.net/engineer_james/article/details/81783517