PGS (Presentation Graphic Stream) is defined in the Blu-ray Disc Association’s specifications, which are not public. This page rests on public reverse-engineering work, chiefly The Scorpius’s description and FFmpeg’s PGS decoder. All numbers are big-endian.
Segment header
A file is a run of segments with no file header. Each segment has a 13-byte header.
| Offset | Size | Name | Meaning |
|---|---|---|---|
0 | 2 | Magic | PG (50 47). |
2 | 4 | PTS | Presentation time on a 90 kHz clock. Divide by 90 for milliseconds. |
6 | 4 | DTS | Decoding time, in practice always 0. |
10 | 1 | Type | See below. |
11 | 2 | Size | Bytes of segment data that follow. |
The magic and the timestamps exist only in .sup files. When PGS is carried
in a Blu-ray transport stream or Matroska, a segment is only the type, size and data.
Segment types
| Type | Name | Purpose |
|---|---|---|
14 | PDS | Palette definition |
15 | ODS | Object definition: a run-length encoded image |
16 | PCS | Presentation composition: what to show and when |
17 | WDS | Window definition: screen areas |
80 | END | End of the display set. Its size is 0. |
Display sets and epochs
A display set runs from a PCS to an END segment, and it describes one change to the screen. A normal set is PCS, WDS, then palette and object segments, then END. A display set with no composition objects clears the screen, and there is no separate end time; a subtitle stays until the next set replaces it.
An epoch is a run of display sets that share a graphics memory. It starts with a set whose composition state is Epoch Start. FFmpeg discards all stored objects and palettes when it reads a PCS in any state other than Normal.
FFmpeg’s limits are 8 palettes and 64 objects per epoch, and 2 objects composed at once. These match what discs use.
Worked example
50 47 PG
05 88 FD EC PTS 92,863,980 (÷ 90 = 17:11.822)
00 00 00 00 DTS
16 type PCS
00 13 19 bytes of data