TS Intro - PES Header


https://en.wikipedia.org/wiki/Packetized_elementary_stream


Packetized elementary stream

From Wikipedia, the free encyclopedia

Packetized Elementary Stream (PES) is a specification in the MPEG-2 Part 1 (Systems) (ISO/IEC 13818-1) and ITU-T H.222.0[1][2] that defines carrying of elementary streams (usually the output of an audio or video encoder) in packets withinMPEG program streams andMPEG transport streams.[3] The elementary stream ispacketized by encapsulating sequential data bytes from the elementary stream inside PES packet headers.

A typical method of transmitting elementary stream data from a video or audio encoder is to first create PES packets from the elementary stream data and then to encapsulate these PES packets inside Transport Stream (TS) packets or Program Stream (PS) packets. The TS packets can then be multiplexed and transmitted using broadcasting techniques, such as those used in anATSC andDVB.

Transport Streams and Program Streams are each logically constructed from PES packets. PES packets shall be used to convert between Transport Streams and Program Streams. In some cases the PES packets need not be modified when performing such conversions. PES packets may be much larger than the size of a Transport Stream packet.[3]

PES packet header[edit]

NameSizeDescription
Packet start code prefix3 bytes0x000001
Stream id1 byteExamples: Audio streams (0xC0-0xDF), Video streams (0xE0-0xEF) [4][5][6][7]
  Note: The above 4 bytes is called the 32 bit start code.
PES Packet length2 bytesSpecifies the number of bytes remaining in the packet after this field. Can be zero. If the PES packet length is set to zero, the PES packet can be of any length. A value of zero for the PES packet length can be used only when the PES packet payload is a video elementary stream.[8]
Optional PES headervariable length (length >= 9)not present in case of Padding stream & Private stream 2 (navigation data)
Stuffing bytesvariable length 
Data See elementary stream. In the case of private streams the first byte of the payload is the sub-stream number.

Optional PES header[edit]

NameNumber of BitsDescription
Marker bits210 binary or 0x2 hex
Scrambling control200 implies not scrambled
Priority1 
Data alignment indicator11 indicates that the PES packet header is immediately followed by the video start code or audiosyncword
Copyright11 implies copyrighted
Original or Copy11 implies original
PTS DTS indicator211 = both present, 01 is forbidden, 10 = only PTS, 00 = no PTS or DTS
ESCR flag1 
ES rate flag1 
DSM trick mode flag1 
Additional copy info flag1 
CRC flag1 
extension flag1 
PES header length8gives the length of the remainder of the PES header in bytes
Optional fieldsvariable lengthpresence is determined by flag bits above
Stuffing Bytesvariable length0xff

While above flags indicate that values are appended into variable length optional fields, they are not just simply written out. For example, PTS (and DTS) is expanded from 33 bits to 5 bytes (40 bits). If only PTS is present, this is done by catenating 0010b, most significant 3 bits from PTS, 1, following next 15 bits, 1, rest 15 bits and 1. If both PTS and DTS are present, first 4 bits are 0011 and first 4 bits for DTS are 0001. Other appended bytes have similar but different encoding.

References[edit]

External links[edit]







http://dvd.sourceforge.net/dvdinfo/pes-hdr.html

MPEG Headers Quick Reference

This is a quick reference to the various headers and streams found in MPEG/DVD. For a complete description you should get a copy of ISO/IEC 13818.
This is an incomplete work-in-progress

The header

Every stream or table begins with a 32-bit start code, codes 00 through B8 are video stream start codes (fully defined in 13818-2), and codes B9-FF are stream-id's
byte 0byte 1byte 2byte 3
0000 0000 0000 0000 0000 0001
Start code prefix
Stream ID
Start codeused for
0x00Picture
0x01 - 0xAFslice
0xB0reserved
0xB1reserved
0xB2user data
0xB3Sequence header
0xB4sequence error
0xB5extension
0xB6reserved
0xB7sequence end
0xB8Group of Pictures
Stream IDused for
0xB9Program end (terminates a program stream)
0xBAPack header
0xBBSystem Header
0xBCProgram Stream Map
0xBDPrivate stream 1
0xBEPadding stream
0xBFPrivate stream 2
0xC0 - 0xDFMPEG-1 or MPEG-2 audio stream
0xE0 - 0xEFMPEG-1 or MPEG-2 video stream
0xF0ECM Stream
0xF1EMM Stream
0xF2ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or ISO/IEC 13818-6_DSMCC_stream
0xF3ISO/IEC_13522_stream
0xF4ITU-T Rec. H.222.1 type A
0xF5ITU-T Rec. H.222.1 type B
0xF6ITU-T Rec. H.222.1 type C
0xF7ITU-T Rec. H.222.1 type D
0xF8ITU-T Rec. H.222.1 type E
0xF9ancillary_stream
0xFA - 0xFEreserved
0xFFProgram Stream Directory

Picture header (0100)

Variable length.
byte 4byte 5byte 6byte 7
76543210765432107654321076543210
temperal sequence numberframe type
1=I, 2=P
3=B, 4=D
VBV delay---

additional fields appended beginning at byte 7 bit 2:
If frame type = 2 (P) or 3 (B) the following 4 bits are appended to the header:

3210
full_pel_forward_vectorforward_f_code

This field is used by MPEG-1 only, for MPEG-2 it should be set to 0 1 1 1

If frame type = 3 (B) the following 4 bits are appended to the header:

3210
full_pel_backward_vectorbackward_f_code

This field is used by MPEG-1 only, for MPEG-2 it should be set to 0 1 1 1

additionally if the next bit is "1" (extra_bit_picture) it is followed by 8 bits of "extra" data (discarded by decoders). This continues until a "0" bit is encountered.


Sequence header (01B3)

Variable length.
byte 4byte 5byte 6byte 7
76543210765432107654321076543210
horizontal sizevertical sizeaspect ratioframe rate
byte 8byte 9byte 10byte 11
76543210765432107654321076543210
bit rate1VBV buffer sizeconstrained parameters flagload intra quantiser matrix(load non-intra quantiser matrix)
If either load quantiser matrix flag is =1, it is immediately followed by the 64 byte table (moving the "load non-intra quantiser matrix" flag, in the case of "load intra quantiser matrix")
CodeAspect RatioFrame Rate
0forbiddenforbidden
11:124000/1001 (23.976)
24:324
316:925
42.21:1(not used in DVD)30000/1001 (29.97)
5reserved30
6reserved50
7reserved60000/1001 (59.94)
8reserved60
9reservedreserved
:
15reservedreserved

extension header (01B5)

There are a variety of extensions, denoted by the first 4 bits.
Sequence_Extension
Fixed length.
byte 4byte 5byte 6byte 7byte 8byte 9
765432107654321076543210765432107654321076543210
0001profile and levelprogressive_sequencechroma_formathorizontal size extensionvertical size extensionbit rate extension1vbv buffer size extensionlow delayframe rate extension nframe rate extension d
Sequence_Display_Extension
Variable length.
byte 4byte 5byte 6byte 7
76543210765432107654321076543210
0010video formatcolor description flag =0
(not present)
=1color primariestransfer characteristicsmatrix coefficients
byte 5
byte 8
byte 6
byte 9
byte 7
byte 10
byte 8
byte 11
76543210765432107654321076543210
display horizontal size1display vertical size0 0 0
Picture_Coding_Extension
Variable length.
byte 4byte 5byte 6
765432107654321076543210
1000f_code[0][0] (forward horizontal)f_code[0][1] (forward vertical)f_code[1][0] (backward horizontal)f_code[1][1] (backward vertical)intra_DC_precisionpicture_structure
byte 7
76543210
Top_Field_Firstframe_pred_frame_dctconcealment_motion_vectorsq_scale_typeintra_vlc_formatalternate_scanRepeat_First_Fieldchroma_420_type
byte 8byte 9byte 10
765432107654321076543210
progressive_framecomposite_display =00 0 0 0 0 0
(not present)
=1v_axisfield_sequencesub_carrierburst_amplitudesub_carrier_phase0 0

Group Of Pictures (GOP) (01B8)

Fixed length, contains 3 flags and the time stamp for the first frame.
byte 4byte 5byte 6byte 7
76543210765432107654321076543210
drop frame flaghour (0-23)minute (0-59)1second (0-59)frame (0-59)closed GOPbroken GOP0 0 0 0 0

DVD-Video home

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值