PS stream format

Source: Internet
Author: User

Concept:

A single data stream composed of one or more pes with a common time benchmark is called a program stream ).

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.

Composition:

The PS package consists of three parts: Baotou, system header, and PES package.Header starting from PS package,Basic Part of the SCR-system clock reference,SCR ExtensionAndPS multiplexing RateConsists of four parts.

 

Charts corresponding to Wikipedia (headers and system headers ):

 

The byte order is as follows:

 

The package start code of 4b:

Byte 0

Byte 1

Byte 2

Byte 3

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

0000 0000 0000 0000 0000 0001
Start code

1011 1010
Pack identifier

Pack identifier -- 0xba

 

Basic Part of the SCR-system clock reference,SCR Extension:

Byte 4

Byte 5

Byte 6

Byte 7

Byte 8

Byte 9

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

01

SCR 32 .. 30

1

SCR 29 .. 15

1

SCR 14 .. 00

1

Scr_ext

1

 

PS multiplexing rate:

Byte 10

Byte 11

Byte 12

Byte 13

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

7

6

5

4

3

2

1

0

Program_mux_rate

1

1

Reserved

Pack_stuffing_length

 

    • SCR and scr_ext together areSystem clock reference, A counter driven at 27 MHz, used as a reference to synchronize streams. the clock is divided by 300 (to match the 90 kHz clocks such as pts/DTS), the quotient is SCR
      (33 bits), the remainder is scr_ext (9 bits)
    • Program_mux_rate -- this is a 22 bit integer specifying the rate at which the program stream target decoder has es the Program Stream during the pack in which it is wrongly ded. the value of program_mux_rate is measured in units of 50 bytes/second. the Value
      0 is forbidden.
    • Pack_stuffing_length -- A 3 bit integer specifying the number of stuffing bytes which follow this field.
    • Stuffing byte -- this is a fixed 8-bit value equal to '000000' that can be inserted by the encoder, for example to meet the requirements of the channel. it is discarded by the decoder.

 

The PES package (Payload):

Reference SectionCodeUnderstanding:Http://read.pudn.com/downloads104/sourcecode/multimedia/mpeg/427188/PESdecode/pesdecode.cpp__.htm

You can see that PTS/DTS (Stream ID, used to distinguish es of different nature) Is in the PES package, the two parameters areSynchronous audio displayTo prevent the input cache overflow or underflow of the 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.

Audio and Video Synchronization:

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.

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.