H265封装成RTP流(一)
H265封装成RTP流是比较复杂的一件事情,需要一些基础知识才行,首先需要了解一些H265的知识,这里介绍的H265的头信息识识,主要来源于官方的文档《T-REC-H.265-201410-I!!PDF-E.pdf》,主要内容为第7章的内容。
H265码流开头,为00 00 00 01 ,后面跟两个字节的nal_unit_header。Nal_unit_header头的结构为:
+------------------+------------------+
|0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F| Type | LayerId | TID |
+-----------------+-------------------+
对字段的解释,还是用英文吧,
forbidden_zero_bit shall be equal to 0 nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
nal_unit_type Name of nal_unit_type Content of NAL unit and RBSP syntax structure NAL unit type class
0 TRAIL_N Coded slice segment of a non-TSA, non-STSA trailing picture VCL
1 TRAIL_R slice_segment_layer_rbsp( )
2 TSA_N Coded slice segment of a TSA picture VCL
3 TSA_R slice_segment_layer_rbsp( )
4 STSA_N Coded slice segment of an STSA picture VCL
5 STSA_R slice_segment_layer_rbsp( )
6 RADL_N Coded slice segment of a RADL picture VCL
7 RADL_R slice_segment_layer_rbsp( )
8 RASL_N Coded slice segment of a RASL picture VCL
9 RASL_R slice_segment_layer_rbsp( )
10 RSV_VCL_N10 Reserved non-IRAP SLNR VCL NAL unit types VCL
12 RSV_VCL_N12
14 RSV_VCL_N14
11 RSV_VCL_R11 Reserved non-IRAP sub-layer reference VCL NAL unit types VCL
13 RSV_VCL_R13
15 RSV_VCL_R15
16 BLA_W_L Coded slice segment of a BLA picture VCL
17 P BLA_W_RADL slice_segment_layer_rbsp( )
18 BLA_N_LP
19 IDR_W_RADL Coded slice segment of an IDR picture VCL
20 IDR_N_LP slice_segment_layer_rbsp( )
21 CRA_NUT Coded slice segment of a CRA picture VCL
slice_segment_layer_rbsp( )
22 RSV_IRAP_VCL22 Reserved IRAP VCL NAL unit types VCL
23 RSV_IRAP_VCL23
24..31 RSV_VCL24.. Reserved non-IRAP VCL NAL unit types VCL
RSV_VCL31
32 VPS_NUT Video parameter set video_parameter_set_rbsp( ) non-VCL
33 SPS_NUT Sequence parameter set seq_parameter_set_rbsp( ) non-VCL
34 PPS_NUT Picture parameter set pic_parameter_set_rbsp( ) non-VCL
35 AUD_NUT Access unit delimiter access_unit_delimiter_rbsp( ) non-VCL
36 EOS_NUT End of sequence end_of_seq_rbsp( ) non-VCL
37 EOB_NUT End of bitstream end_of_bitstream_rbsp( ) non-VCL
38 FD_NUT Filler data filler_data_rbsp( ) non-VCL
39 PREFIX_SEI_NUT Supplemental enhancement information sei_rbsp( ) non-VCL
40 SUFFIX_SEI_NUT
41..47 RSV_NVCL41.. Reserved non-VCL
RSV_NVCL47
48..63 UNSPEC48.. Unspecified non-VCL
UNSPEC63
LayerId:6 bits
nuh_layer_id:Required to be equal to zero in [HEVC]. It isanticipatedthat in future scalable or 3D video codingextensionsof this specification, this syntax element will be used toidentify additional layers that may be present in the codedvideo sequence, wherein a layer may be, e.g. a spatial scalablelayer, a quality scalable layer, a texture view, or a depthview.
TID: 3bits
nuh_temporal_id_plus1.This field specifies the temporal identifierof the NAL unit plus 1. The value of TemporalId is equal toTID minus 1. A TID value of 0 is illegal to ensure thatthere is at least one bit in the NAL unit header equal to 1, so toenable independent considerations of start code emulationsin the NAL unit header and in the NAL unit payload data.