0%

MPEG-TS adaptation field 分析

分析 MPEG-TS 格式,涉及协议 ISO13818-1

data

47 40 8E 17 00 3C BF FD 02 00 C1 F7 FF 11 03 10
47 00 8E 18 48 7B 71 A1 AA DF F0 17 C5 70 16 78

Transport Stream packet layer

Table 2-2 – Transport packet of this Recommendation | International Standard

transport_packet(){
    sync_byte                                   8bits
    transport_error_indicator                   1bit
    payload_unit_start_indicator                1bit
    transport_priority                          1bit
    PID                                         13bits
    transport_scrambling_control                2bits
    adaptation_field_control                    2bits
    continuity_counter                          4bits
    if(adaptation_field_control = = '10' || adaptation_field_control = = '11'){
        adaptation_field()
    }
    if(adaptation_field_control = = '01' || adaptation_field_control = = '11') {
        for (i = 0; i < N; i++){
            data_byte                           8bits
        }
    }
}
  • sync_byte 0x47
  • transport_error_indicator When set to ‘1’ it indicates that at least 1 uncorrectable bit error exists in the associated Transport Stream packet.
  • payload_unit_start_indicator which has normative meaning for Transport Stream packets that carry PES packets (refer to 2.4.3.6) or PSI data (refer to 2.4.4).
  • transport_priority

payload unit start indicator

ts 中携带的 payloadPSI or PES 是由如下规则来判断

TS 根据 payload unit start indicator 来判断这个包中是否有 PES、PSI 分组

然后再去看 data_byte 前 24 位,是否为 0x000001pes_packet_start_code_prefix,如果不是,那就是 psi 包

PSI

payload_unit_start_indicator

  • 1 表示这个 ts 包携带 psi section 头,表明这个传输流数据包的有效载荷的第一个字节携带 pointer_field
  • 0

When the payload of the Transport Stream packet contains PSI data, the payload_unit_start_indicator has the following
significance: if the Transport Stream packet carries the first byte of a PSI section, the payload_unit_start_indicator value
shall be ‘1’, indicating that the first byte of the payload of this Transport Stream packet carries the pointer_field. If the
Transport Stream packet does not carry the first byte of a PSI section, the payload_unit_start_indicator value shall be ‘0’,
indicating that there is no pointer_field in the payload. Refer to 2.4.4.1 and 2.4.4.2. This also applies to private streams of
stream_type 5 (refer to Table 2-29).

pointer_field

pointer_field – This is an 8-bit field whose value shall be the number of bytes, immediately following the pointer_field
until the first byte of the first section that is present in the payload of the Transport Stream packet (so a value of 0x00 in
the pointer_field indicates that the section starts immediately after the pointer_field).

PES

2.4.3.6 PES packet

packet_start_code_prefix 0x000001

payload_unit_start_indicator

  • 1 指示该传输流数据包的有效载荷将从第一个字节开始一个 PES 数据包
  • 0 表示在该传输流分组中不应该开始 PES 分组

When the payload of the Transport Stream packet contains PES packet data, the payload_unit_start_indicator has the
following significance: a ‘1’ indicates that the payload of this Transport Stream packet will commence with the first byte
of a PES packet and a ‘0’ indicates no PES packet shall start in this Transport Stream packet. If the
payload_unit_start_indicator is set to ‘1’, then one and only one PES packet starts in this Transport Stream packet. This
also applies to private streams of stream_type 6 (refer to Table 2-29).

Analyser

47 40 8E 17 00 3C BF FD 02 00 C1 F7 FF 11 03 10
47 00 8E 18 48 7B 71 A1 AA DF F0 17 C5 70 16 78

第一个 ts, payload_unit_start_indicator 为 1, 判断为 PSIadaptation_field_control0x1data_bytes 第一个字节为 pointer_field

第二个 ts, payload_unit_start_indicator 为 0