MEPG2-TS Summary

Source: Internet
Author: User
Tags benchmark

 

Really understandTSAfter reading the book "digital TV business information and coding" recommended by a friend, MPEG2TSIt is closely related to digital TV, and it is worth summing up some of its relationships.

ISO/IEC-13818-1: system part;
ISO/IEC-13818-2: video;
ISO/IEC-13818-3: audio;
ISO/IEC-13818-4: consistency testing;
ISO/IEC-13818-5: software part;
ISO/IEC-13818-6: digital storage media command and control;
ISO/IEC-13818-7: Advanced Audio Encoding;
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 sending and receiving ends;
3. Provides multiplexing and reuse protocols for multiple data streams;
4. 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 mentioned above, ES needs to be packaged into a PES stream package first, and PES needs to be packaged into a PS orTSPackage for storage or transmission. 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 elasticsearch packages and input them 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, use this instantaneous SCR.AdjustmentThe local clock frequency of 27MHz. 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.

TSStreams are also composed of one or more PES. They can have the same time benchmark or different. The basic reuse idea is to reuse programs for multiple pes with the same time benchmark, and transmit and reuse each PS with an independent time benchmark to generateTS.

TSA packet consists of two parts: the packet header and the packet data. The packet header can also include an extended self-applicable zone. The Header Length occupies 4 bytes, and the self-use zone and package data account for 184 bytes.TSThe package length is equivalent to four ATM packets.TSThe packet header consists of the Synchronization Byte, transmission code indicator, start indicator of the payload unit, transmission priority, and packet identification (PID-packet identification) as shown in the excerpt) transmission and Disturbance Control, adaptive Zone Control, and continuous counter.

It can be used to synchronize the automatic characteristics of the byte string, detect packet restrictions in the data stream, and establish packet synchronization. When the transmission error code indicator is available, the error correction decoder can be used to indicate 1 bit codes but cannot be corrected. The start indicator of the payload Unit indicates whether a specified start information exists in the data packet.TSPackage allocation priority. The PID value is determined by the user.TSFrom esTSPackets are differentiated to reconstruct the original elasticsearch. The transmission Disturbance Control can indicate whether the packet content is disturbed, but the packet header and the adaptive area are never disturbed. The adaptive area control, use 2 bits to indicate whether there is an adaptive zone. That is, (01) indicates that there is useful information without an adaptive zone. (10) indicates that no useful information has an adaptive zone. (11) indicates that useful information has an adaptive zone and (00) is not defined. Continuous counters can transmit sequential counts to the PID package, according to counter readings, the receiving end can determine whether there are packet loss and packet transmission order errors. Apparently, BaotouTSThe package supports synchronization, identification, error detection, and encryption.

TSThe packet adaptive area consists of four parts: Adaptive Area chief, various indicator, information related to the inserted flag, and filled data. The marker consists of eight parts: intermittent indicator, random access indicator, es optimized indicator, PCR sign, contact sign, transmission specific data mark, original PCR sign, and adaptive area extension sign.. What is important is the mark part of the PCRFieldTo synchronize data with the 27mhz clock of the decoder. The process is to use the PLL to compare the local PCR phase with the input instantaneous PCR phase lock during decoding to determine whether the decoding process is synchronized. If not, use this instantaneous PCRAdjustmentClock frequency. Because digital images use complex and different compression encoding algorithms, resulting in different data of each image, making it impossible to obtain clock information directly from the beginning of the compressed image data. Therefore, some (not all) are selected)TSPacket adaptive zone to transmit timing information. Therefore, the selectedTSPacket adaptive zone, which can be used to determine the control bit and important control information of packet information. The adaptive area does not need to be sent along with each packet.TSThe specific time-scale parameter for packet transmission is determined. The random access indicator and contact sign in the sign. When the program changes, it provides a random entry point for the data stream that randomly enters the I-frame compression, and also facilitates the insertion of local programs. The padding data in the adaptive zone is because the PES package length cannot be convertedTSThe package is an integer multiple of the finalTSThe package retains a small part of the useful capacity, which is filled by filling in bytes. This prevents the cache from overflow and keeps the total bit rate unchanged.

The previous three sections summarize MPEG2TSIncluding PES, PS, andTSAnd RelatedField. As a transmission stream,TSPackage or reuse the content so that the media content becomesTSTransmission and decoding at the decoding end. To put it simply,TSIt is a transport layer protocol stack that can carry transmission of various content, such as MPEG, WMV, h264, or even IP addresses. How is the transmission specification defined? This is what PSI (Program-specific information) is about to do.

PSI consists of four tables: PAT, PMT, CAT, and NIT.TSThe Transmission Structure of all elasticsearch streams. The first concept is,TSIt is transmitted as a package and must be identified by a certain package ID on the codec end.TSContent in the stream. For example, the PAT table will exist in one or moreTSSo a special package ID is used for representation. In addition, different ES streams also need different package IDs for identification. We have the PAT and PMT tables, and the decoder can use the PIDTSFrom ESTSPackage is differentiated for decoding.

TSThe decoding is divided into two steps. The first step is from PID to 0.TSIn the package, parse the PAT table and find the PID of each program source from the PAT table. Generally, these program sources are composed of several ES streams and described in the PMT table, then, the PID of each ES can be retrieved in the PMT table through the node source PID. Second, the Decoder uses the ES stream PID in the PMT tableTSStreams are differentiated and decoded based on different ES streams. So,TSIt is completed through two layers: program multiplexing and transmission multiplexing. That is, when a program is reused, PMT is added, and PAT is added during transmission replay. Similarly, when the program is resolved, you can obtain the PMT and PAT when the program is resolved. A good overview of its ideas

 

 

 





TSIt supports multiplexing, so it can be used to transmit multi-layer programs after reuse. In the process of multiplexing, we should note the time reference and synchronization problems that need to be faced during decoding. Because the de-multiplexing requires synchronization of various information, during the multiplexing process, you need to insert the relevant time information: PTS, DTS, and PCR.

InTSDuring the formation process, PTS and DTS inject the clock information into the PES package according to the STC reference when ES is packaged into PES, and then cut itTSThen inject the PID and PCR informationTSPackage, when multipleTSWhen reuse is performedTSThe PCR will be extracted, analyzed, and then generated and injected intoTS. Finally, because the original Pat table information is not applicable, the new Pat table needs to be generated and appended to the newTSStreaming. After this multi-layer reuse, the newTSThe stream can enter the modulation and transmission stages. For the process, see:

The decoding process is faced with the following problems: demultiplexing, video and audio synchronization, and the decoding cache never overflows. Demultiplexing meansTSPrograms transmitted in different time sequences in the same channel are separated. Video and audio synchronization is coordinated by DTs, PTS, and PCR, and PCR is the absolute time scale of the reconstruction system time benchmark, DTS and PTS are the relative time points for decoding and reproduction. To solve the problem that the decoder cache is overwhelming, it must be implemented through the system target Decoder (STD) model, the basic idea is as follows:

  1. TSAfter a stream enters the decoder, it first splits various ES streams (including PSI information stream) by the commutator according to a certain time sequence ).
  2. After the decomposition, the ES stream enters its own transmission cache, and its PES stream enters its primary storage. Note that the PSI information stream enters the system cache, it also reaches the primary storage.
  3. Finally, the decoder extracts the media or system information from each primary storage based on the DTS information for decoding, and displays the media content based on the PTS information.

For the process, see:

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.