How SubPictures Work - Part 3

Command Sequences and Timing

The SP_DCSQ

A subpicture is not just a simple bitmap presented at its Presentation TimeStamp (PTS) for a certain duration. Instead it has a command structure comprised of eight commands. These commands are grouped into sequences called SubPicture Display Control SeQuences (
SP_DCSQ) which execute after a defined interval of time. For each subpicture unit (SPU) there can be as few as one SP_DCSQ and as many as will fit in the limited (32,000 bytes) space allotted to commands.

The delay

The very first thing each sequence does is wait. This is how timed effects, such as scrolling, wiping, or fading in/out are realized using the same bitmap. The delay is specified in what may look like a strange unit, but when you examine it, it makes sense. The unit of time is the 90KHz clock divided by 1024. All DVD timing is determined by the master clock, which runs at 27MHz, and the 90KHz clock, which is derived from the master clock by dividing it by 300. Since 90KHz provides more precision than we need to determine a frame or field, another divisor of 1024 (210) is used to yield a granularity of approximately 87 per second. This is fine enough to specify a field in either NTSC or PAL standards (see
table). Division by 2048, the next power of two, would be too coarse to specify a single field of NTSC video.

How it gets started

Once the delay has expired (and it may be zero, for immediate action) the
commands execute. The first sequence must contain at least a SET_COLOR, SET_CONTR, SET_DAREA, and SET_DSPXA command. These define the color and contrast of the pixels, the display area, and pixel data pointers, respectively. All sequences must end with the CMD_END command, after which the next sequence, if one is defined in the current sequence's header, begins its delay.

But what turns it on and off?

There are three more commands to deal with just turning the subpicture on and off, these are:

Scrolling

Vertical scrolling is accomplished by changing the pixel data pointers with
SET_DSPXA at timed intervals. Excess lines in the pixel data area are not a problem, once the display area limit is reached, the remaining data is ignored.
Horizontal scrolling is trickier, and usually requires separate images for each step of the scroll. However, the SET_DSPXA command aso allows us to store more than one image per SPU, and use each as needed.

Wipes and Fades

These are performed by using the very versatile and complex
CHG_COLCON command. This command allows you to define areas within the subpicture and assign different color and contrast values to the pixels within each area. The command has a large and variable parameter area made up of segments that describe either a vertically bounded area, or a horizontally bounded area within the current vertically bounded area. Sound difficult? It's really not, the first thing is to define a horizontal band using the LN_CTLI structure. This specifies the starting and ending line numbers, and the number of horizontally bounded areas (1 to 15) within the band. After that you define each area with the PX_CTLI structure, which specifies the starting column number (these work left-to-right, and extend to the next area or the right side of the image), and the new color and contrast values.
As you can see, combined with timing, the areas can be slid around the screen causing the pixels to change colors for a wipe effect. Combined with timing, but not sliding around, changes in contrast values can be used to fade a subpicture in or out (or to mask and unmask the underlying video). The command can also be used statically to add more colors to a subpicture.

Animation

This is accomplished with different images, as many as will fit in each SPU. Despite some claims otherwise, the subpicture stream can be rendered at the full frame rate of the video. What limits subpictures is not the rendering ability of DVD players, but the bitrates and the authoring programs. Subpicture bitrate is limited to 3.36 Mbps, so the animation most likely will not be full screen. And, of course, the overall bitrate for all streams excluding DSI must not exceed 10.08 Mbps. Authoring programs, including DVDMaestro and Scenarist, are not able to pack multiple images into one SPU, making animation difficult without the aid of external programs.
The DVD which accompanies "DVD Demystified" 2nd edition has an excellent example of subpicture animation (as well as all the other effects).
More articles
DVD-Video info home Copyright © 2003 - 2024 MPUCoder, all rights reserved.