The description of the language itself in Chapter 5, “Native Compiler Language,” is a starting point for learning about the language of video formats. The examples in this chapter will help solidify your understanding.
Read the next section, “Using Examples”, before proceeding to read the examples. Each of these examples is presented in source form and has brief remarks describing the important points:
“Interlaced Format” shows a two-field interlaced format.
“Stereo Format” shows a stereoscopic video format.
“Color Field Sequential” shows a video format for a color field sequential monitor.
You may also be able to find examples on the Silicon Surf web site and on the developer's CDs. There is not a lot of interest in the general developer community (sniff!), but we get space from time to time.
You will rarely need to write a format completely from scratch. Most people who write formats find a format similar to what they are writing and modify it to suit their needs. If you can, you should do the same.
Many of the examples that accompany this book (provided as part of the vfc installation) and are in the directory /usr/gfx/ucode/common/vfc/vfs/. Refer to those files when writing your own format.
This format is similar to the PAL-I timing format. Its two fields interlace spatially, as described in “Interlaced Formats”.
Note the following features of the format shown in Example 6-1:
The skip and offset attributes describe the monitor's interlacing pattern.
The skip = 1; of the first field is the same as skip = 1; of the second. Both fields interlace similarly by drawing every other line, as described in “Interlaced Formats”. You can find information on the skip attribute in Table 5-3.
The starting line at which each field begins differs. The first field uses the attribute offset = 0; to indicate that drawing should begin on the first line of the monitor. The second field uses offset = 1; to indicate that the first line of the field is offset one line into the display of the monitor. Table 5-3 describes the offset attribute.
The attributes are only part of the story and tell the graphics pipe how pixels should be fetched from the frame buffer. The synchronizing pulses of the vertical sync components of the field tell the monitor which frame is first.
This format permits motion between the two fields. This motion is enabled with the swap = true; attribute of the first field, echoed by the swap = true; attribute of the second field. Were the second field to have its swap value set to false, no swaps would be permitted between fields. See the swap attribute in Table 5-3.
This format describes a two-field stereo format, close to the size of VGA. Monitors showing field-based stereo display slightly different views in two successive fields. In one field, only one eye is permitted to view the image (usually by special glasses); the succeeding field is shown only to the other eye.
The format shown here is known as new-style stereo (also known as per-window stereo). It differs from old-style stereo (or full-screen stereo) in that the new style fetches pixels of both fields from the same location in the frame buffer; this is described in “Stereo Formats”. The old-style stereo formats used pixels in different portions of the frame buffer for each eye's field. The new-style stereo format is shown in Example 6-2.
Note these features of the format shown in Example 6-2:
The format has two fields, both of which have similar structure. The significant difference in timing of the two fields is the length of vertical sync: to allow monitor hardware to discriminate between the two fields, the second field's vertical sync pulse is somewhat longer than that of the first (note the difference in the repeat count).
How different do the sync signals of the two fields need to be? This is just an example; unfortunately, monitor manufacturers have not adopted a common standard for recognition of sync signals of the two fields. Check with the documentation that accompanies your monitor for details; because this information is often sketchy, you may need to contact the monitor manufacturer directly. If the monitor is distributed by Silicon Graphics with your system, the company will provide you with whatever information is available.
The statements eye = {Left}; in the first field and eye = {Right}; in the second field are the significant features in the example. They use the eye attribute described in Table 5-3.
Stereo displays should not have motion between the two fields; this would have an unsettling effect on the viewer, potentially destroying the stereo effect. To inhibit swap, the second field uses the statement swap = false;. Table 5-3 describes the swap attribute.
It is also useful to reduce the swap interval to reduce demand on the rendering hardware of the graphics pipe. If swap were set to true for both fields, the pipe would swap at 120 Hz instead of 60 Hz, halving the time between potential swaps.
Field sequential monitors have special hardware. Instead of displaying all three colors (red, green, and blue) simultaneously, these monitors display only one color at a time. The monitor displays the entire picture once showing only the red pixels, another field only with green, another blue. Each color field is shown at three times the normal rate so thateach frame passes at the normal speed. When the fields pass rapidly, the eye merges the sequential fields successfully. See Example 6-3.
Note these salient features of the format shown in Example 6-3:
The three fields are similar in timing except for the length of vertical sync (note the difference in the repeat count). In the first field, vertical sync is longer. This allows hardware to discriminate between color fields and the beginning of the frame.
The attribute of importance is that of color. This format differs because the different fields specify Color = {red};, Color = {green};, and Color = {blue};. You can find the description of this attribute in Table 5-3.
Swaps are enabled only for the first field (swap = true;), disabled for the second (swap = false;) and third (swap = false;). This inhibits motion between the two fields. Table 5-3 describes this attribute.
You may find it necessary to produce a segment of time in your video format where the synchronization signal makes no transitions at all. In Example 6-4, you can see a portion of code extracted from the standard high-resolution format originally introduced in Example 5-1.
Vertical Sync = { { /* * Sync goes low here (at beginning of the * line, time = 0.0) but does not recover to the * high state until the first line of Vertical * Back Porch. */ Length = 1.0H; Low = 0.0 usec; } repeat 2 { /* Two lines with no transitions */ Length = 1.0H; } } |
In this example:
The first sync transition set executes only once (no explicit repeat statement) and contains only a transition to the low state.
The second sync transition set executes twice. This set has only a length associated with it. Because no transitions are specified, the time passes without transitions. At the end of this sync transition set, the synchronization signal is still set to the low state.