1. PES:
1.1 Introduction to PES:
PES--Packetized Elementary Streams (packeted ES), the packets formed by ES are called PES packets, which are a data structure used to transmit ES . The PES stream is a data stream formed by the ES stream after being processed by the PES packetizer. In this process, operations such as grouping, packaging, and adding header information to the ES stream are completed (the first packaging of the ES stream). The basic unit of a PES stream is a PES packet. A PES packet consists of a header and a payload .
1.2. PES syntax syntax diagram:
2. Analyze the PES package:
2.1 PES packet data:
2.2 Header:
The TS packet header has only 4 bytes (47 48 14 10). After removing the first byte 0x47, there are only 3 left. The regrouping is as follows:
0 1 0 0100000010100 00 01 0000
sync_byte |
sync byte |
0x47: |
transport_error_indicator |
transmission error flag |
0: |
payload_unit_start_indicator |
Load cell start identification |
1: It can be seen that the payload part of this packet has a PES headshot, in other words, where the frame header is located. From the analysis of the second TS packet, we can see that the TS packet with the PID of 814 stores data in MP3 format. It can be seen that this package stores a frame of partial data in MP3 format. |
transport_priority |
Transmission priority |
0: |
pid |
PID |
0x814: Because finding audio in PMT is program_map_PID is 0x814.
|
transport_scrambling_control |
transmission jamming control |
00: |
adaptation_field_control |
Adaptive Zone Control |
01: It is known that the payload contains only payload units, that is, PES packets. without adaptive fields. 00:是保留值。 |
continuity_counter |
连续计数器 |
0x0:0000 0000 00000000 |
10:默认规定
00:PES加扰控制
0:PES优先级
0:数据定位指示符
0:版权
0:原始的或复制的
|
10:PTS_DTS_flags,10代表后面将会有PTS信息。
000000:分别代表其他6个标志,0表示后面没有对应的信息。
|
PES头数据长度,表示后面还有0x05个字节,之后就是一帧的数据内容。 PES头数据具体包含哪些内容有前面的标志位来确定,哪些信息得标志位1,就包含哪些信息。排列顺序分别是PTS DTS ESCR ES速率 DSM特技方式 附件的复制信息 前PES的CRC PES 扩展,如果还有多余的字节没用,就用填充字节0xFF填充。 本例子中,PES头数据只包含PTS数据。 |
If(PTS_DTS_flags == ‘10’){ |
|
‘0010’ |
4 |
PTS[32..30] |
3 |
marker_bit |
1 |
PTS[29..15] |
15 |
marker_bit |
1 |
PTS[14..0] |
15 |
marker_bit |
1 |
} |
|
0010:默认规定,4位
000:PTS[32..30] 3位
1:marker_bit:1位
0000 0000 0000 000:PTS[29..15] 15位
1:market_bit 占1位
1001 0110 0000 011:PTS[14..0] 15位
1:marker_bit 1位
|
packet_start_code_prefix |
0x00 00 01 |
stream_id |
0xC0:流ID |
PES_packet_length |
0x01 88:PES包长度 |
‘10’ |
2b:10 |
PES_scrambling_control |
2b:0 |
PES_priority |
1b:0 |
Data_alignment_indicator |
1b:0 |
copyright |
1b:0 |
Original_or_copy |
1b:0 |
PTS_DTS_flags |
2b:10 |
ESCR_flag |
1b:0 |
ES_rate_flag |
1b:0 |
DSM_trick_mode_flag |
1b:0 |
Additional_copy_info_flag |
1b:0 |
PES_CRC_flag |
1b:0 |
PES_extension_flag |
1b:0 |
PES_header_data_length |
8b:0x05 |
PTS_DTS data |
40b:0x21 00 01 96 07 |
3. PES第二个数据包:
3.1 PES包数据:
3.2 包头:
S包头只有4个字节(47 08 14 11),除掉第一个字节0x47,剩下就3个,重新分组如下:
0 0 0 0100000010100 00 01 0001
sync_byte |
同步字节 |
0x47: |
transport_error_indicator |
传输错误标识 |
0: |
payload_unit_start_indicator |
负载单元开始标识 |
0:有效载荷单元起始符为0,表示不是帧头,不含PES包头数据,只有PES负载(PES负载就是一帧数据) |
transport_priority |
传输优先级 |
0: |
pid |
PID |
0x814:因为在PMT中查找音频是program_map_PID为0x814。
|
transport_scrambling_control |
传输扰乱控制 |
00: |
adaptation_field_control |
自适应区域控制 |
01:可知负载只含有有效载荷单元,也就是PES包。而不含自适应字段。 00:是保留值。 |
continuity_counter |
连续计数器 |
0x0001:0000 0000 00000001 |
3.3 TS数据:
去除包头都是MP3数据的有效荷载。
4. PES语法解析: