从PAT部分(MPEG-TS)读取信息 [英] Reading information from PAT section (MPEG-TS)

查看:128
本文介绍了从PAT部分(MPEG-TS)读取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写MPEG-TS文件解析器,但我一直想从PAT部分获取program_numbers和PID.我正在使用数据包分析器来比较我的结果.

I'm writing a MPEG-TS file parser and I'm stuck on getting program_numbers and PIDs from the PAT section. I'm using a packet analyser to compare my results.

例如,这是一个PAT数据包

For example, here's a PAT packet

47 40 00 16 00 00 B0 31 00 14 D7 00 00 00 00 E0
10 00 01 E0 24 00 02 E0 25 00 03 E0 30 00 04 E0
31 00 1A E0 67 00 1C E0 6F 43 9D E3 F1 43 A3 E3
F7 43 AC E4 00 C3 69 A6 D8 FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF 

首先,我开始将分析器的结果与字节进行比较,以查看连接.它以以下方式配对字节:[00 10] [01 24] [02 25] [03 30]等.我注意到一个模式(对于i = 14; i< end; i + = 4),但是很快就出错了.因为在"0x6F"字节之后,它开始读取16位而不是8位,所以program_number为0x439D.

First I began comparing the analyser's results to the bytes to see the connection. It paired bytes in the following way: [00 10][01 24][02 25][03 30] etc. I noticed a pattern (for i = 14; i < end; i+=4) but that quickly turned wrong because after the "0x6F" byte it started reading 16 bits, not 8, so the program_number was 0x439D.

我很困惑,希望有人可以向我解释如何从上方解析示例PAT.

I'm seriously confused and I hope that someone can explain to me how to parse the example PAT from above.

推荐答案

每个program_number是16位,后跟16位,由3 x'1'位和13位program_map_pid(或network_pid if program_number` = 0)

Each program_number is 16 bits and is followed by 16 bits consisting of 3 x '1' bits and a 13 bit program_map_pid (or network_pid ifprogram_number`=0)

从转储的偏移量13开始,读取成对的16位字,从而掩盖了第二个字的前3位.

Start at offset 13 in your dump and read pairs of 16-bit words, masking out the top 3 bits of the second word.

例如

offset   bytes          words        program_number pid
======   ===========    =========    ============== ======================
000D:    00 00 E0 10 => 0000 E010 => 0000           0010 (network_pid)
0011:    00 01 E0 24 => 0001 E024 => 0001           0024 (program_map_pid)
0015:    00 02 E0 25 => 0002 E025 => 0002           0025 (program_map_pid)
0019:    etc..
001D:    etc..
0021:    etc..
0025:    00 1C E0 6F => 001C E06F => 001C           006F (program_map_pid)
0029:    43 9D E3 F1 => 439D E3F1 => 439D           03F1 (program_map_pid)
002D:    etc..
etc..

从理论上讲,这比这要复杂得多,因为PAT中可能有多个程序关联部分,而以上内容仅对第一部分有所帮助.

In theory it is more complicated than this as there can be multiple program association sections in a PAT and the above will only help with the 1st section.

有关更多详细信息,请参见ISO/IEC 13818-1的2.4.4.3节,尤其是表2-25.

For more details see section 2.4.4.3 of ISO/IEC 13818-1, specifically table 2-25.

这篇关于从PAT部分(MPEG-TS)读取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆