How SubPictures Work - Part 2

Compression and Colors

Just a 2-bit RLE

Before I get into where the colors come from, let's talk about how the subpicture image is compressed. The method chosen allows each pixel to be assigned one of four values. By convention the pixel values are called:
0   background (B)
1   pattern (P)
2   emphasis 1 (E1)
3   emphasis 2 (E2)
The compression method is run length encoded (RLE), which, simply stated, means each compressed code conveys 2 pieces of information, the pixel value (code) and the number of pixels in succesion having the same value (run). RLE works well when large areas have the same value, and so is a good choice for subpictures.

The encoding

The
compressed codes are multiples of 4 bits (called nibbles) long. In all encodings the last 2 bits (least significant) contain the pixel value. To encode from 1 to 3 pixels a single nibble is used, with the run length in the first 2 bits. 4 to 15 pixels use 2 nibbles (one byte), and the run length is in the first 6 bits. Notice 2 things, though.This same scheme is used for the next 2 codes lengths (12 and 16) as well, giving a simple way to determine the code length.
Run lengths from 16 to 63 use 12 bits, and 64 to 255 use the longest code, the 16-bit code.

Special Cases and Considerations

So, where do the 4 colors get defined?

The colors are defined in another layer of indirection. Within the commands for each subpicture are 2 commands,
Set Color and Set Contr. The Set Color command specifies a 4-bit value for each of the 4 pixel values. This 4-bit value is an index into the Color LookUp Table (CLUT) with the currently executing PGC.
This allows each subpicture to act as a template, with the PGC specifying the actual colors. This is the same method that Windows or most forums (including our own) use to apply color "themes" to page templates.
The Set Contrast command specifies the contrast, or alpha blending, of each pixel value directly.

But is 4 colors per subpicture the max?

NO! Another command,
Chg_ColCon (Change Color and Contrast) allows you to divide the subpicture area up into smaller areas, each with its own color and contrast values. There is no arbitrary limit on the number of areas you may define, so it is possible to use all 256 combinations of CLUT colors and contrast values in one subpicture.

It is through the use of this command, coupled with the timing ability of subpictures, that wipes and fades of all kinds are performed.
More on this command later.
More articles
DVD-Video info home Copyright © 2003 - 2024 MPUCoder, all rights reserved.