Thursday, July 3, 2008

MPEG-2 System

Introduction

The increasing need for audio and video compression for storage and transmission purpose led to MPEG (Motion Picture Expert Group). MPEG1 (ISO/IEC 11172) is first standard finalized in 1993 by MPEG committee. MPEG1 standard is mainly targeted for digital storage application. MPEG2 (ISO/IEC 13818) is successor to the MPEG1 standard, which got finalized in 1998. MPEG2 standard is mainly targeted for digital broadcast and television application. It addresses video compression up to 15 Mbps, audio compression at 128kbps and method of multiplexing audio-visual data. MPEG2 standard consists of following subparts namely system, audio and video. The audio and video subpart addresses details of respective compression method. The system part covers method of combining one or more audio, video or data streams in to one or more system stream, audio-visual synchronization and buffer management.

MPEG2 system layer enhances the MPEG1 system by introduction of second way to multiplex and addition features to existing one. MPEG2 system defines two ways to multiplex for addressing different kind of applications as follows.
  • Program Stream(PS)
  • Transport Stream(TS)
Program stream is targeted for single program application on error free environment e.g. digital storage media. It is based on MPEG1 system stream. Popular DVD uses MPEG2 program stream for movie. Transport stream is targeted for simultaneous delivery of multiple programs on error-prone network e.g. broadcast environment, DVB etc.

Terms and Definitions

1. Program: - Program used to describe is channel or broadcast service.
2. Presentation Unit: - It is used to denote an uncompressed raw YUV picture frame or a raw
PCM audio frame.
3. Access Unit: - It is compressed presentation unit. E.g. audio access unit stands for encoded audio frame and video access unit stands for encoded video frame.
4. Elementary stream: - It is generic term to define successions of audio or video access units.
5. Audio Elementary stream: - It is used to denote consecutive audio access unit. In other words, it denotes output of audio encoder.
6. Video Elementary stream: - It is used to denote consecutive video access unit. In other words, it denotes output of video encoder.

MPEG-2 System Overview

MPEG2 system layer supports five basic functions.
1. Synchronization of multiple compressed streams on playback side
2. Interleaving of multiple compressed streams in to single or multiple system streams
3. Initialization of buffer for playback buffer for startup
4. Continuous buffer management
5. Time identification.


Similar on lines of audio and video subpart, system subpart does not specify architecture or implementation of encoder or decoder. However standard specifies the bitstream syntax and any implementations has to comply with specification. Even if with bitstream compliance, there exists lots of freedom in design and implementation.


MPEG-2 System Architecture

MPEG 2 system layer consists of two layers. Namely
1. PES Packet Layer
2. Multiplex layer
PES packet layer handles synchronization by means of time stamps, while multiplex layer handles interleaving of data and data continuity. The PES packet layer is common across the transport and program stream. The multiplexing layer is different for transport and program stream. The multiplexing layer for program stream is pack layer, while for transport layer it is transport packets. Transcoding is possible between program stream and transport stream using PES packets. In case of transport stream having multiple programs, user gets multiple program streams.

PES Packet Layer

Presentation time stamp (PTS): - It denotes time instant at which access unit from decoder buffer is removed, decoded and presented for viewer for display. In STD model, decoding process is assumed to be instantaneous without any delay. Any real system must compensate for actual decoding delay.

Decoding time stamp (DTS): - It denotes time instant at which access unit from decoder buffer is removed, decoded, but not presented to viewer to display. It is stored for display at later point of time. DTS is present in case of video sequences having B frame. In this case, there is rearrangement of video frames for encoding. The encoding frame order and display order are different. DTS always comes with PTS for any video access unit. DTS alone cannot exist for any video access unit. DTS value will always lesser then corresponding PTS. In case of audio and video sequence (without B frames) there is only one time stamp i.e. PTS. DTS is not applicable for these kinds of sequences.

Packet layer consists of packet header followed by access units. Packet can be fixed or variable length. Some important fields of packet header are shown below.



Stream_ID identifies audio/video packet data to its audio/video elementary streams. Significance of PTS and DTS is mentioned above.

Transport Packet Layer

Transport stream is mainly targeted for error-prone transmission. Transport packets consist of short fixed length packet. The packet size is always 188 bytes. It consists of 4 bytes header followed by adaptation field or payload or both. A PES a packet is divided into many transport packets with following constraints.

  • The first byte of PES packet must become first byteof the transport packet layer payload
  • Only data from one PES packet may be carried in a transport packet.
A PES packet is unlikely to fill integer number of payload of transport packets. In this case, excessive space in last transport packet is wasted using adaptation field of appropriate length in this transport packet. The resulting transport packets are outputted sequentially to form MPEG2 transport stream. Some of important field for transport packet header are as follows.



Sync_byte gets repeated every 188 bytes, which help in error recovery. Packet Identifier (PID) is used to associate data with corresponding elementary streams. If in a given transport packet, the start of access unit happens, then Payload_unit_start_indicator will be set. Continuity_counter increments for successive packets. This helps in identifying loss of packet. Adaption_field_control is used to fill last transport packet. There are some transport packets with specific PID carrying service information, program specific information and null packets.


No comments: