Http://blog.lmtw.com/ B /moreframe/archives/2006/40865.html
It should be said that after truly understanding TS and reading the book "digital TV business information and coding" recommended by friends, MPEG2 TS and digital TV are closely inseparable, it is worth summarizing some of these relationships.
ISO/IEC-13818-1: System Section; ISO/IEC-13818-2: Video; ISO/IEC-13818-3: audio; ISO/IEC-13818-4: conformance testing; ISO/IEC-13818-5: Software section; ISO/IEC-13818-6: digital Storage media commands and control; ISO/IEC-13818-7: Advanced Audio Coding; ISO/IEC-13818-8: Real-time interface for system decoding;
MPEG2 system tasks include: 1. protocol for data transmission in packages; 2. the protocol that specifies the synchronization of data streams between the two ends; 3. provides multiplexing and multiplexing protocols for multiple data streams. 3. provides data stream encryption protocols. Storing and transmitting data streams in the form of packets is the key point of MPEG2 systems.
ES is a data stream directly from the encoder. It can be a collectively referred to as an encoded video data stream, audio data stream, or other encoded data streams. The es stream is converted to the PES package after it passes through the PES package. The PES package consists of a packet header and payload. The specific format is as follows:
We can see that PTS/DTS is in the PES package, and the two parameters are the key to solving synchronous display of video and audio and preventing the input cache overflow or underflow of decoder. PTS indicates the time when the unit appears in the system target Decoder (STD: system target decoder). DTS indicates the time when all the bytes of the access unit are removed from the es decoder cache of STD. Each packet header of I, P, and B has a PTS and DTS, but PTS and DTs are the same for B frames and do not need to mark the data transmission of B frames. For frames I and P, it must be stored in the re-Sort cache of the Video Decoder before display. After delay (re-sorting), it must be marked with PTS and DTS respectively.
As described in the previous section, es needs to be packaged as a PES stream package, and PES needs to be packaged as a PS or TS package for storage or transmission as needed. Each elasticsearch contains only the encoded data streams of one source. Therefore, each PES contains only the data streams of the corresponding source.
For PS streams, each PES header contains pts, DTS, and stream identification code to distinguish es of different properties. The PES package is then reused as a PS package through the PS multiplexing. Actually, the PES package is decomposed into smaller PS packages. During decoding, The demutor splits the PS into PES packages. The package is split into video and audio es and input to the respective decoder for decoding. One question is: how can we ensure the synchronization of video and audio during decoding by es? In addition to the combination of PTS and DTS, an important parameter is SCR (system clock reference ). During encoding, PTS, DTS, and SCR are both generated by system time clock. During decoding, STC will regenerate, the PLL-Phase Lock Loop is used to compare the local SCR phase with the input instantaneous SCR Phase Lock to determine whether the decoding process is synchronized, the instantaneous SCR is used to adjust the local clock frequency of 27 MHz. Finally, PTS, DTS, and SCR work together to solve the problem of Synchronous Video/audio playback. The PS format is excerpted as follows:
The length of the PS package is long and variable. It is mainly used in an error-free environment, because the longer the package, the more difficult the synchronization is, and the more difficult the reorganization is in the case of packet loss. Therefore, PS is suitable for editing program information and application of local content applications.