Inside DVD-Video/Subpicture Streams

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Subpictures are used to display subtitles as well as menu buttons, overlaid on the video. These are stored in an MPEG stream (private stream 1) as a sequence of Sub-Picture Units (SPUs). SPUs may be broken across multiple MPEG stream packets.

Each SPU contains an image bitmap with 2 bits per pixel, split into odd and even fields, stored using a run-length-encoded (RLE) compression format. This is accompanied by a sequence of commands that control the actual display of the bitmap, including the choice of which four colours from the PGC colour table to use. There is also a time delay that can be specified before executing the commands.

(see here for more details for now)

A complete SPU cannot exceed 65535 bytes, because the length header field is only 16 bits. However, an uncompressed full-screen subpicture image can be as large as 103680 bytes (= 720 * 576 / 4) for PAL, or 84600 bytes (= 720 * 480 / 4) for NTSC, and RLE compression performs poorly when there are only short runs of identical pixels. Any image which cannot be RLE-compressed to fit within the limit is simply not allowed.

Subpictures may be turned off or on under user control, or their display may be forced so they are always visible. User-controllable subpicture display is useful for showing subtitles, while forced subpictures are useful for buttons in menus—you don’t want the user wondering where the buttons have gone!

At most one subpicture stream can be visible at a time, overlaid on the video image, which will show through wherever the subpicture pixels are not fully opaque.

Widescreen Considerations[edit | edit source]

One subtlety to keep in mind with widescreen video is that in this case subpictures are scaled to fit the screen, not the video. Specifically, if widescreen video is being shown “letterboxed” on a narrowscreen TV, the subpicture display area will still include the parts occupied by the black bars above and below the video image. As they say, “this is a feature, not a bug”; presumably, the point is to allow you to use the black area to show subtitles, leaving the video image untouched. The PGC header allows you to specify up to four alternative subpicture streams to be substituted as appropriate, depending on the following situations:

  • narrowscreen footage (“normal”) being viewed on all TVs
  • widescreen footage being viewed on a widescreen TV
  • widescreen footage being letterboxed on a narrowscreen TV
  • widescreen footage being shown in “pan-and-scan” mode on a narrowscreen TV

(Though of course narrowscreen video will only use the first one, and widescreen will not use the first one.)