Transport stream packet
The MPEG-2 transport stream is a series of 188-byte packets with each packet consisting of a header and a payload. The payload carries data belonging to different PES packets from the various components of one of a number of programmes. This process is subject to two constraints. The first is that only data from one PES packet may be carried in any one transport packet. The second is that a PES packet should always start at the beginning of the payload part of a transport packet and end at the end of a transport packet. The PES packet itself, typically 2048 KB in length, is larger than the transport packet and will thus be spread across a large number of transport packets. Furthermore, since it is unlikely that a single PES packet will fill the payloads of an integer number of transport packets, the last transport packet that carries the residue of the PES will only be partially occupied. To avoid breaking the two con- straints mentioned earlier, the excess space is deliberately ‘wasted’ by filling it with an adaptation field; the field length is the difference between 184 bytes and the PES residue (Figure 7.5). The adaptation field is never completely wasted. It is structured so it can carry some useful data such as the PCR.
Null transport packets
When all the PESs are converted into transport packets, these packets are then sent out sequentially at a constant bit rate to form the MPEG-2 trans- port stream. The bit rate of the transport stream is determined by the num- ber of transport packets produced by the multiplexer. If the number of programmes is few with fewer packets, the bit rate may fall below the value set by the broadcaster. In such a situation, service information and
MPEG-2 ‘null’ transport packets are used to soak up any spare multiplex capacity and ensure a constant bit rate.
Transport packet header
Each transport packet comprises a 4-byte header followed by a 184-byte payload of actual video, audio or other coded data, and a total of 188 bytes (Figure 7.6). The header provides the information needed by the receiver
to unpack the various programmes to generate the ES of the selected pro- gramme. The structure of the transport packet header is illustrated in Figure 7.7 and listed in Table 7.2.
The header commences with a 1-byte sync word, 01000111 binary (47 hex), which provides a run-in clock sequence for the packet. This sequence is not unique and it can quite naturally occur in other fields of the transport packet. However, the fact that a sync word will occur every 188 bytes within the transport stream enables the decoder to lock onto it. This is another reason for making sure that all payloads are fully filled with actual data or stuffed with useless data. The payload_unit_start_indicator is a 1-bit flag which when set to 1 indicates that the first byte of the payload part of the transport packet is also the first byte of the PES packet. The 13-bit packet identifier (PID) is used to indicate the ES its payload belongs to. There may be many ESs comprising many different programmes. With 13 bits there are 213 = 8192 possible values or codes (0–8191) available to be allocated. Of these, 17 are reserved for special purposes. The remaining 8175 codes may be allocated to ESs as necessary. MPEG does not specify any constraints on which PID code of the available 8175 is assigned to which ES, except that ESs must be allocated unique PID values. This allocation of PID codes is carried out by the broadcaster at the system layer multiplexer stage. The continuity counter keeps track of how a single PES packet is spread across transport packets. It is incremented between successive transport packets belonging to the same ES.