# Program-specific information

Program-specific information (PSI) is metadata about a program (channel) and part of an MPEG transport stream.
The PSI data as defined by ISO/IEC 13818-1 (MPEG-2 Part 1: Systems) includes four tables:
* PAT (Program Association Table)
* CAT (Conditional Access Table)
* PMT (Program Mapping Table)
* NIT (Network Information Table)
The MPEG-2 specification does not specify the format of the CAT and NIT.
PSI is carried in the form of a table structure. Each table structure is broken into sections, although some tables like a PMT cannot have more than one section. Each section can span multiple transport stream packets. On the other hand, although this is uncommon, a transport stream packet or set of packets under the same PID can contain multiple sections belonging to different tables. Adaptation field also occurs in TS packets carrying PSI data. The PSI data will never be scrambled so that the decoder at the receiving end can easily identify the properties of the stream.
The sections comprising the PAT and CAT tables are associated with predefined PIDs (Packet Identifier) and table IDs as explained in their respective descriptions below. There may be multiple independent PMTs in a stream, one for each program. Each PMT is given a unique user-defined PID and maps a program number to the metadata describing that program and the streams within it. PMT PIDs are defined in the PAT, and are the only PIDs defined there. The streams themselves are contained in PES packets with user-defined PIDs specified in the PMT.

## PSI structure
### Table Sections

Pointer :
| Name | Number of bits | Description |
| Pointer field | 8 | Present at the start of the TS packet payload signaled by the payload_unit_start_indicator bit in the TS header. Used to set packet alignment bytes or content before the start of tabled payload data. |
| Skipped bytes | N*8 | When the pointer field is non-zero, this is the pointer field number of skipped bytes (usually belonging to the previous table section spanning across TS packets). |
Section header :
| Name | Number of bits | Description |
| Table ID | 8 | Table Identifier, that defines the structure of the syntax section and other contained data. As an exception, if this is the byte that immediately follow previous table section and is set to 0xFF, then it indicates that the repeat of table section end here and the rest of TS packet payload shall be stuffed with 0xFF. Consequently, the value 0xFF shall not be used for the Table Identifier. |
| Section syntax indicator | 1 | A flag that indicates if the long section header syntax is used (fields following Section Length are present). The PAT, PMT, and CAT all set this to 1. |
| Private bit | 1 | The PAT, PMT, and CAT all set this to 0. Other tables set this to 1. |
| Reserved bits | 2 | Set to 0x03 (all bits on) |
| Section length unused bits | 2 | Set to 0 (all bits off) |
| Section length | 10 | The number of bytes that follow, including long header, data, and CRC value. Must be <=1021 for PAT, CAT, and PMT, but can be 4093 for private sections and some others. |
Section long header (present if section syntax indicator is 1) :
| Name | Number of bits | Description |
| Table ID extension | 16 | Supplemental identifier. The PAT uses this for the transport stream identifier and the PMT uses this for the Program number. |
| Reserved bits | 2 | Set to 0x03 (all bits on) |
| Version number | 5 | Table version number. Incremented when data is changed and wrapped around on overflow for values greater than 32. |
| Current/next indicator | 1 | Indicates if data is currently in effect or will be made effective in the near future. If the bit is 1, the data is to be used now. If 0, the decoder may begin to prepare for the data to change. |
| Section number | 8 | This is the index of the section within its table. The first section starts from 0. |
| Last section number | 8 | This indicates the total number of sections in the table, minus 1. |
Section data and checksum :
| Name | Number of bits | Description |
| Section data | N*8 | Data as defined by the Table Identifier. |
| CRC32 | 32 | A checksum of the entire section excluding the pointer field, pointer filler bytes and the trailing CRC32. |

### Descriptor

Descriptor :
| Name | Number of bits | Description |
| descriptor tag | 8 | the tag defines the structure of the contained data following the descriptor length. |
| descriptor length | 8 | The number of bytes that are to follow. |
| Descriptor data | N*8 | Data as defined by the Descriptor Tag. |

### PAT (Program Association Table)

The program association table (PAT) lists all programs available in the transport stream. Each of the listed programs is identified by a 16-bit value called program_number. Each of the programs listed in PAT has an associated value of PID for its PMT.
The value 0x0000 for program_number is reserved to specify the PID where to look for network information table. If such a program is not present in PAT the default PID value (0x0010) shall be used for NIT.
TS packets containing PAT information always have PID 0x0000.
PAT specific data repeated until end of section length :
| Name | Number of bits | Description |
| Program num | 16 | Relates to the Table ID extension in the associated PMT. A value of 0 is reserved for a NIT packet identifier. |
| Reserved bits | 3 | Set to 0x07 (all bits on) |
| Program map PID | 13 | The packet identifier that contains the associated PMT |
The PAT is assigned PID 0x0000 and table id of 0x00. The transport stream contains at least one or more TS packets with PID 0x0000. Some of these consecutive packets form the PAT. At the decoder side the PSI section filter listens to the incoming TS packets. After the filter identifies the PAT table they assemble the packet and decode it. A PAT has information about all the programs contained in the TS. The PAT contains information showing the association of Program Map Table PID and Program Number. The PAT should end with a 32-bit CRC

### PMT (Program map specific data)

PMTs contain information about programs. For each program, there is one PMT. While the MPEG-2 standard permits more than one PMT section to be transmitted on a single PID (Single Transport stream PID contains PMT information of more than one program), most MPEG-2 "users" such as ATSC and SCTE require each PMT to be transmitted on a separate PID that is not used for any other packets. The PMTs provide information on each program present in the transport stream, including the program_number, and list the elementary streams that comprise the described MPEG-2 program. There are also locations for optional descriptors that describe the entire MPEG-2 program, as well as an optional descriptor for each elementary stream. Each elementary stream is labeled with a stream_type value.
PMT specific data :
| Name | Number of bits | Description |
| Reserved bits | 3 | Set to 0x07 (all bits on) |
| PCR PID | 13 | The packet identifier that contains the program clock reference used to improve the random access accuracy of the stream's timing that is derived from the program timestamp. If this is unused. then it is set to 0x1FFF (all bits on). |
| Reserved bits | 4 | Set to 0x0F (all bits on) |
| Program info length unused bits | 2 | Set to 0 (all bits off) |
| Program info length | 10 | The number of bytes that follow for the program descriptors. |
| Program descriptors | N*8 | When the program info length is non-zero, this is the program info length number of program descriptor bytes. |
| Elementary stream info data | N*8 | The streams used in this program map. |
Elementary stream specific data repeated until end of section length :
| Name | Number of bits | Description |
| stream type | 8 | This defines the structure of the data contained within the elementary packet identifier. |
| Reserved bits | 3 | Set to 0x07 (all bits on) |
| Elementary PID | 13 | The packet identifier that contains the stream type data. |
| Reserved bits | 4 | Set to 0x0F (all bits on) |
| ES Info length unused bits | 2 | Set to 0 (all bits off) |
| ES Info length | 10 | The number of bytes that follow for the elementary stream descriptors. |
| Elementary stream descriptors | N*8 | When the ES info length is non-zero, this is the ES info length number of elementary stream descriptor bytes. |
This table contains PID numbers of elementary streams associated with the program and it has information about the type of these elementary streams (video, audio, etc.). In addition it may also contain an ECM (entitlement control messages) stream for any other stream that is encrypted. These messages provide the information used in the cipher key selection stage.

### CAT (Conditional access specific data)

* Table ID value is 0x01.
This table is used for conditional access management of the cypher keys used for decryption of restricted streams. This table contains privately defined descriptors of the system used and the associated EMM PID. It is used by a network provider to maintain regular key updates.

### NIT (Network information specific data)

This optional table may group transport stream identifiers into a network, providing access parameters and other details. ITU-T Rec. H.222 and ISO/IEC 13818-1 do not define the NIT structure. The European Broadcasting Union DVB specification ETSI EN 300 468 (DVB-SI) does. The purpose of mentioning but not defining this table in H.222 is that it has reserved program number 0 (zero) in the PAT. The Table ID extension is used to identify the local network together with a directory listing of transport streams. Descriptors are used to list the modulation, source of those streams and programs. The original network identifier is meant to allow transport streams and programs on foreign networks to be included in the local network which allows no remapping of transport and program IDs that may be duplicated between networks. The DVB specification defines the transport packet identifier as 16 and the table identifier of the local network of transports as 64. A table identifier of 65 is for a foreign network of transports. The network identifiers are maintained via DVB Services who have separated the identifiers into two unique, yet unnecessary groupings of Network_ID and Original_Network_ID. The two groupings have a large number of overlapping entries.

## PSI labels
### Table Identifiers

Each table in a transport stream is identified by an 8-bit table identifier.
Identifiers in use :
| Decimal | Hexadecimal | Description |
| 0 | 0x00 | Program Association section contains a directory listing of all Program Map Tables |
| 1 | 0x01 | Conditional Access section contains a directory listing of all EMM streams |
| 2 | 0x02 | Program Map section contains a directory listing of all elementary streams. |
| 3 | 0x03 | Transport Stream Description section. |
| 4 | 0x04 | ISO/IEC 14496 scene description section. |
| 5 | 0x05 | ISO/IEC 14496 object description section. |
| 6 | 0x06 | Metadata section. |
| 7 | 0x07 | ISO/IEC 13818-11 IPMP control information (DRM). |
| 8 - 57 | 0x08 - 0x39 | Reserved. |
| 58 | 0x3A | ISO/IEC 13818-6 DSM CC multiprotocol encapsulated. |
| 59 | 0x3B | ISO/IEC 13818-6 DSM CC U-N messages. |
| 60 | 0x3C | ISO/IEC 13818-6 DSM CC Download Data Messages. |
| 61 | 0x3D | ISO/IEC 13818-6 DSM CC stream descriptor list. |
| 62 | 0x3E | ISO/IEC 13818-6 DSM CC privately defined (used by DVB MAC addressed datagrams). |
| 63 | 0x3F | ISO/IEC 13818-6 DSM CC addressable. |
| 64 - 127 | 0x40 - 0x7F | Used by DVB. |
| 128 - 143 | 0x80 - 0x8F | DVB-CSA and DigiCipher II/ATSC CA message sections used in EMM and ECM streams. |
| 144 - 191 | 0x90 - 0xBF | May be assigned as needed to other data tables. |
| 192 - 254 | 0xC0 - 0xFE | Used by DigiCipher II/ATSC/SCTE. |
| 255 | 0xFF | Forbidden. As is used for null padding. |
SCTE Specific tables: 0xCO table id is used by Programme Information Message 0xC1 table id is used by Programme Name Message It is not necessary that pid of PMT pointed by PAT will contain a table with table id 0x02 Ignoring table id while reading PMT could have bad consequence

### Program and Elementary Stream Descriptor Tags

Each descriptor in a transport stream table is identified by an 8-bit descriptor tag.
Tags in use :
| Decimal | Hexadecimal | Description |
| 0 - 1 | 0x00 - 0x01 | Reserved. |
| 2 | 0x02 | Video stream header parameters for ITU-T Rec. H.262, ISO/IEC 13818-2 and ISO/IEC 11172-2 |
| 3 | 0x03 | Audio stream header parameters for ISO/IEC 13818-3 and ISO/IEC 11172-3 |
| 4 | 0x04 | Hierarchy for stream selection |
| 5 | 0x05 | Registration of private formats |
| 6 | 0x06 | Data stream alignment for packetized video and audio sync point |
| 7 | 0x07 | Target background grid defines total display area size |
| 8 | 0x08 | Video Window defines position in display area |
| 9 | 0x09 | Conditional access system and EMM/ECM PID |
| 10 | 0x0A | ISO 639 language and audio type |
| 11 | 0x0B | System clock external reference |
| 12 | 0x0C | Multiplex buffer utilization bounds |
| 13 | 0x0D | Copyright identification system and reference |
| 14 | 0x0E | Maximum bit rate |
| 15 | 0x0F | Private data indicator |
| 16 | 0x10 | Smoothing buffer |
| 17 | 0x11 | STD video buffer leak control |
| 18 | 0x12 | IBP video I-frame indicator |
| 19 | 0x13 | ISO/IEC13818-6 DSM CC carousel identifier |
| 20 | 0x14 | ISO/IEC13818-6 DSM CC association tag |
| 21 | 0x15 | ISO/IEC13818-6 DSM CC deferred association tag |
| 22 | 0x16 | ISO/IEC13818-6 DSM CC Reserved. |
| 23 | 0x17 | DSM CC NPT reference |
| 24 | 0x18 | DSM CC NPT endpoint |
| 25 | 0x19 | DSM CC stream mode |
| 26 | 0x1A | DSM CC stream event |
| 27 | 0x1B | Video stream header parameters for ISO/IEC 14496-2 (MPEG-4 H.263 based) |
| 28 | 0x1C | Audio stream header parameters for ISO/IEC 14496-3 (MPEG-4 LOAS multi-format framed) |
| 29 | 0x1D | IOD parameters for ISO/IEC 14496-1 |
| 30 | 0x1E | SL parameters for ISO/IEC 14496-1 |
| 31 | 0x1F | FMC parameters for ISO/IEC 14496-1 |
| 32 | 0x20 | External ES identifier for ISO/IEC 14496-1 |
| 33 | 0x21 | MuxCode for ISO/IEC 14496-1 |
| 34 | 0x22 | FMX Buffer Size for ISO/IEC 14496-1 |
| 35 | 0x23 | Multiplex Buffer for ISO/IEC 14496-1 |
| 36 | 0x24 | Content labeling for ISO/IEC 14496-1 |
| 37 | 0x25 | Metadata pointer |
| 38 | 0x26 | Metadata |
| 39 | 0x27 | Metadata STD |
| 40 | 0x28 | Video stream header parameters for ITU-T Rec. H.264 and ISO/IEC 14496-10 |
| 41 | 0x29 | ISO/IEC 13818-11 IPMP (DRM) |
| 42 | 0x2A | Timing and HRD for ITU-T Rec. H.264 and ISO/IEC 14496-10 |
| 43 | 0x2B | Audio stream header parameters for ISO/IEC 13818-7 ADTS AAC |
| 44 | 0x2C | FlexMux Timing for ISO/IEC 14496-1 |
| 45 | 0x2D | Text stream header parameters for ISO/IEC 14496 |
| 46 | 0x2E | Audio extension stream header parameters for ISO/IEC 14496-3 (MPEG-4 LOAS multi-format framed) |
| 47 | 0x2F | Video auxiliary stream header parameters |
| 48 | 0x30 | Video scalable stream header parameters |
| 49 | 0x31 | Video multi stream header parameters |
| 50 | 0x32 | Video stream header parameters for ITU-T Rec. T.800 and ISO/IEC 15444 (JPEG 2000) |
| 51 | 0x33 | Video multi operation point stream header parameters |
| 52 | 0x34 | Video stereoscopic (3D) stream header parameters for ITU-T Rec. H.262, ISO/IEC 13818-2 and ISO/IEC 11172-2 |
| 53 | 0x35 | Program stereoscopic (3D) information |
| 54 | 0x36 | Video stereoscopic (3D) information |
| 55 - 63 | 0x37 - 0x3F | Reserved. |
| 64 - 127 | 0x40 - 0x7F | Used by DVB. |
| 128 - 207 | 0x80 - 0xCF | Used by ATSC. |
| 160 | 0xA0 | VideoLAN FourCC, video size and codec initialization data |
| 208 - 223 | 0xD0 - 0xDF | Used by ISDB. |
| 224 - 233 | 0xE0 - 0xE9 | Used by CableLabs. |
| 234 - 254 | 0xEA - 0xFE | May be assigned as needed to other descriptors. |
| 255 | 0xFF | Forbidden. As is used for null padding. |

### Elementary stream types

Each elementary stream in a transport stream is identified by an 8-bit elementary stream type assignment.
Assignments in use :
| Decimal | Hexadecimal | Description |
| 0 | 0x00 | Reserved |
| 1 | 0x01 | ISO/IEC 11172-2 (MPEG-1 video) in a packetized stream |
| 2 | 0x02 | ITU-T Rec. H.262 and ISO/IEC 13818-2 (MPEG-2 higher rate interlaced video) in a packetized stream |
| 3 | 0x03 | ISO/IEC 11172-3 (MPEG-1 audio) in a packetized stream |
| 4 | 0x04 | ISO/IEC 13818-3 (MPEG-2 halved sample rate audio) in a packetized stream |
| 5 | 0x05 | ITU-T Rec. H.222 and ISO/IEC 13818-1 (MPEG-2 tabled data) privately defined |
| 6 | 0x06 | ITU-T Rec. H.222 and ISO/IEC 13818-1 (MPEG-2 packetized data) privately defined (i.e., DVB subtitles/VBI and AC-3) |
| 7 | 0x07 | ISO/IEC 13522 (MHEG) in a packetized stream |
| 8 | 0x08 | ITU-T Rec. H.222 and ISO/IEC 13818-1 DSM CC in a packetized stream |
| 9 | 0x09 | ITU-T Rec. H.222 and ISO/IEC 13818-1/11172-1 auxiliary data in a packetized stream |
| 10 | 0x0A | ISO/IEC 13818-6 DSM CC multiprotocol encapsulation |
| 11 | 0x0B | ISO/IEC 13818-6 DSM CC U-N messages |
| 12 | 0x0C | ISO/IEC 13818-6 DSM CC stream descriptors |
| 13 | 0x0D | ISO/IEC 13818-6 DSM CC tabled data |
| 14 | 0x0E | ISO/IEC 13818-1 auxiliary data in a packetized stream |
| 15 | 0x0F | ISO/IEC 13818-7 ADTS AAC (MPEG-2 lower bit-rate audio) in a packetized stream |
| 16 | 0x10 | ISO/IEC 14496-2 (MPEG-4 H.263 based video) in a packetized stream |
| 17 | 0x11 | ISO/IEC 14496-3 (MPEG-4 LOAS multi-format framed audio) in a packetized stream |
| 18 | 0x12 | ISO/IEC 14496-1 (MPEG-4 FlexMux) in a packetized stream |
| 19 | 0x13 | ISO/IEC 14496-1 (MPEG-4 FlexMux) in ISO/IEC 14496 tables |
| 20 | 0x14 | ISO/IEC 13818-6 DSM CC synchronized download protocol |
| 21 | 0x15 | Packetized metadata |
| 22 | 0x16 | Sectioned metadata |
| 23 | 0x17 | ISO/IEC 13818-6 DSM CC Data Carousel metadata |
| 24 | 0x18 | ISO/IEC 13818-6 DSM CC Object Carousel metadata |
| 25 | 0x19 | ISO/IEC 13818-6 Synchronized Download Protocol metadata |
| 26 | 0x1A | ISO/IEC 13818-11 IPMP |
| 27 | 0x1B | ITU-T Rec. H.264 and ISO/IEC 14496-10 (lower bit-rate video) in a packetized stream |
| 28 | 0x1C | ISO/IEC 14496-3 (MPEG-4 raw audio) in a packetized stream |
| 29 | 0x1D | ISO/IEC 14496-17 (MPEG-4 text) in a packetized stream |
| 30 | 0x1E | ISO/IEC 23002-3 (MPEG-4 auxiliary video) in a packetized stream |
| 31 | 0x1F | ISO/IEC 14496-10 SVC (MPEG-4 AVC sub-bitstream) in a packetized stream |
| 32 | 0x20 | ISO/IEC 14496-10 MVC (MPEG-4 AVC sub-bitstream) in a packetized stream |
| 33 | 0x21 | ITU-T Rec. T.800 and ISO/IEC 15444 (JPEG 2000 video) in a packetized stream |
| 34 - 35 | 0x22 - 0x23 | Reserved. |
| 36 | 0x24 | ITU-T Rec. H.265 and ISO/IEC 23008-2 (Ultra HD video) in a packetized stream |
| 37 - 65 | 0x25 - 0x41 | Reserved. |
| 66 | 0x42 | Chinese Video Standard in a packetized stream |
| 67 - 126 | 0x43 - 0x7e | Reserved. |
| 127 | 0x7f | ISO/IEC 13818-11 IPMP (DRM) in a packetized stream |
| 128 | 0x80 | ITU-T Rec. H.262 and ISO/IEC 13818-2 with DES-64-CBC encryption for DigiCipher II or PCM audio for Blu-ray in a packetized stream |
| 129 | 0x81 | Dolby Digital (AC-3) up to six channel audio for ATSC and Blu-ray in a packetized stream |
| 130 | 0x82 | SCTE subtitle or DTS 6 channel audio for Blu-ray in a packetized stream |
| 131 | 0x83 | Dolby TrueHD lossless audio for Blu-ray in a packetized stream |
| 132 | 0x84 | Dolby Digital Plus (enhanced AC-3) up to 16 channel audio for Blu-ray in a packetized stream |
| 133 | 0x85 | DTS 8 channel audio for Blu-ray in a packetized stream |
| 134 | 0x86 | SCTE-35 digital program insertion cue message or DTS 8 channel lossless audio for Blu-ray in a packetized stream |
| 135 | 0x87 | Dolby Digital Plus (enhanced AC-3) up to 16 channel audio for ATSC in a packetized stream |
| 136 - 143 | 0x88 - 0x8F | Privately defined. |
| 144 | 0x90 | Blu-ray Presentation Graphic Stream (subtitling) in a packetized stream |
| 145 | 0x91 | ATSC DSM CC Network Resources table |
| 146 - 191 | 0x92 - 0xBF | Privately defined. |
| 192 | 0xC0 | DigiCipher II text in a packetized stream |
| 193 | 0xC1 | Dolby Digital (AC-3) up to six channel audio with AES-128-CBC data encryption in a packetized stream |
| 194 | 0xC2 | ATSC DSM CC synchronous data or Dolby Digital Plus up to 16 channel audio with AES-128-CBC data encryption in a packetized stream |
| 195 - 206 | 0xC3 - 0xCE | Privately defined. |
| 207 | 0xCF | ISO/IEC 13818-7 ADTS AAC with AES-128-CBC frame encryption in a packetized stream |
| 208 | 0xD0 | Privately defined. |
| 209 | 0xD1 | BBC Dirac (Ultra HD video) in a packetized stream |
| 210 | 0xD2 | Audio Video Standard AVS2 (Ultra HD video) in a packetized stream |
| 211 | 0xD3 | Audio Video Standard AVS3 Audio in a packetized stream |
| 212 | 0xD4 | Audio Video Standard AVS3 Video (Ultra HD video) in a packetized stream |
| 213 - 218 | 0xD5 - 0xDA | Privately defined. |
| 219 | 0xDB | ITU-T Rec. H.264 and ISO/IEC 14496-10 with AES-128-CBC slice encryption in a packetized stream |
| 220 - 233 | 0xDC - 0xE9 | Privately defined. |
| 234 | 0xEA | Microsoft Windows Media Video 9 (lower bit-rate video) in a packetized stream |
| 235 - 255 | 0xEB - 0xFF | Privately defined. |