神龙卡sdk的一段说明说得很明白:
播放时候FMP driver 将搜索以下标志确定媒体类型
MPEG pack header (0x000001BA)
MPEG2 transport syncbyte (0x47)
sequence header (0x000001B3)
an audio syncword (0xFFF).
当发现第一个包头时driver立即确定此文件所属mpeg1 还是mpeg2
对于MPEG2 transport stream还要搜索 至少10个MPEG2 transport packets(188bytes,以 0x47开头)
File type analysis
The following rules are only information on reader’s discretion and are subject to changes:
· The extension is not used to determine the file type.
· After opening the input file and reading MPEG data, the FMP driver will search for a MPEG pack header (0x000001BA), for a MPEG2 transport syncbyte (0x47), for a sequence header (0x000001B3) or for an audio syncword (0xFFF). The driver will consider immediately the file as a MPEG1 system file or a MPEG2 program file when a pack header is found. In the case of a MPEG2 transport stream, the driver will try to find at least 10 MPEG2 transport packets (188 bytes length, begin
ning with 0x47). In the last two cases, the diver will keep on searching for a header in order to verify the sequence header or the audio syncword is not inside a packet. When a minimum number of bytes has been looked (around 3000 bytes), the driver will decide whether the file is a video file (first choice) or an audio file (no sequence header has been found).
· When the file is considered as a MPEG1 system file or MPEG2 program system , the driver will start searching for information on the different video and audio streams. When a sequence header is found (there can be more than one to describe the streams), the driver will use it to calculate the number of video and audio streams. then
, the driver will try to retrieve information for those streams in the first 20 packets. If some streams remain not initialized (i.e. declare inside a sequence header, but no matching packets) the driver will keep on looking in the next 80 packets or until the first matching packet is found. If some streams are unknown (i.e. not declare in a sequence header), they will be treated the same way. Note that the driver will stop searching for streams when an invalid packet is found (i.e. the next packet headerdo
es not match with the previous packet header after adding the position of the previous packet and its size).
· When the file is considered as a MPEG2 transport stream, the driver will start searching for a program association table, then
for the program map tables to get the elementary streams. The, the driver will try to retrieve information for the elementary streams by using the random_access_indicator bit.
· When the file is considered as an audio file, the first audio syncword found will be considered as the begin
ning of an audio frame (which may not be true: audio syncword are allowed inside audio data).
· The first packet of a stream is used to determine some of its characteristics. Thus, the first video packet needs to have a sequence header fully contained inside the packet (itdo
es not have to be at the begin
ning of the packet). Same thing for the audio: the first audio syncword found in the packet - there must be at least one - will be considered as the begin
ning of a valid audio frame.