Concepts
========


How the Screen Machine II works
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                         |~~~~~~~~~~~~~~~|
                         | I/O INTERFACE |
                         |_______________|
                                /\
                                ||
                                \/
Video --black->|~~~~~~~|   |~~~~~~~~~~~|   |~~~~~~~~|
Video --red--->| INPUT |-->| PROCESSOR |-->| OUTPUT |--RGB-> Monitor
Video -yellow->|_______|   |___________|   |________|
                                /\             ^
                                ||             |
                                \/             |
                           |~~~~~~~~~~|       VGA
                           |  MEMORY  |
                           |__________|

In the input stage the video signal is converted into the digital YUV 4:2:2 format. Video is transmitted in YUV, a format in which Y (the brightness) and UV (the color) are separated, unlike in the RGB or CMYK formats. The final conversion for grabbed images from YUV to RGB is not handled by the board. For a description of the YUV format see "The YUV Color Model" later this chapter or refer to Chapter FileFormat.
The conversion from the video signal to 4:2:2 YUV takes place at the rate of the incoming video, for PAL/SECAM at 50 fields and for NTSC at 60 fields per second. The type of conversion depends on the settings of the input converter. The processor then applies any scaling and filtering to the data and transfers it into memory of the board.
The video processor also transfers the data from memory to the output stage, which mixes the video data with the graphics signal. The output stages handles features like brightness, saturation and contrast. This is why these settings will have no affect on the image in memory, and hence the grabbed images. To retrieve data from the board the processor has a fourth interface to the I/O bus of the PC and this is the only bottleneck. It allows a maximum of 2-3 MB/s to be transferred, which is a far cry from the 20.8 MB/s needed for full frame rate of PAL, or the 17.6 MB/s for NTSC. The 2-3 MB are only possible when using a system that supports memory mapping. 
The I/O interface supports two modes for transferring images to and from the Screen Machine II board. One is the so called I/O port access and is only 8 bit. The other is memory mapping (only supported by some chipsets when the system has more than 16 MB). Memory mapping is 16 bit and suffers from a lot less overhead, increasing performance by a factor of 2 to 3.


The Display Details
~~~~~~~~~~~~~~~~~~~
Here is an overview of the three frames that can be set and how they determine the appearance on screen.

      Video          Screen Machine           Screen
  0                                      0
0|~~~~~~~~~~~~~~|     0                0|~~~~~~~~~~~~~~~|
 | |~~~~~~~~~~|~|~~~0|~~~~~~~~~~~~~|    |               |
 | |          | |    | |~~~~~~~~~|~|~~~~|~|~~~~~~~~~~~| |
 | |VideoFrame| |    | |ZoomFrame| |    | |WindowFrame| |
 | |          | |    | |_________|_|____|_|___________| |
 | |__________|_|____|_____________|    |               |
 |              |                100%   |_______________| max
 |______________|max                               screen res 
           video res
           PAL/NTSC

The video frame determines what portion of the digitized video gets written into the SM memory. The maximum values depend on what system the input source is. Theoretically it is possible to set a selection of video to be displayed, although for this purpose it is better to use the zoom frame, unless SM memory usage is a problem. There are presets for the video frame according to the specified system. If it is desired to digitize more or less of the bandwidth of the video, it is possible to change it with the smSetVideoFrame call. Although the theoretical maximum for PAL is 768 by 576, the default settings are 736 by 552 as most video sources do not have more bandwidth.
Here are the default values used for certain systems:
NTSC
   x         =    5 
   y         =   11 
   width     =  640    // max video res
   height    =  480    // max video res
   horizontal range:  0 - 650
   vertical range:    0 - 500
PAL/SECAM 
   x         =   19    // Offset to skip noise at beginning
   y         =   24    // Offset to skip videotext lines
   width     =  736    // max video res
   height    =  560    // max video res
   horizontal range:  0 - 774
   vertical range:    0 - 590
The window frame sets the size at which the video is displayed on screen. The maximum size and position depend on the screen size. If only a part of the video should be visible, there is the possibility to specify a zoom frame.
The zoom frame changes the portion of the video displayed on screen without having to change what is kept in memory. It is specified in percent of the window or video frame (doesn't make a difference). The portion of the video specified by the zoom frame is then mapped to the screen to the coordinates specified by the window frame.
To recap, the video frame is how much is digitized into SM memory, the zoom frame is how much of that is displayed, and the window frame is where and how big it is displayed.


Clipping
~~~~~~~~
Clipping is the process of masking out areas of the live video. This is usually used to make it possible to use a live overlay in a multi window environment. It is desirable to mask out the video where something (like another window) obscures the live overlay. All this is necessary since an overlay card does actually not write anything into the VRAM of a graphics card, but rather mixes in its video signal after the graphics card and before it gets to the screen.
Unfortunately this is one of the part that is dependant on the window system used, so we could only implement a set of general routines to facilitate clipping. These routines let you specify up to 64 rectangular regions in screen coordinates and assign them a number. As long as such a region is set now, video will be clipped out at those coordinates.


Multiple Screen Machines
~~~~~~~~~~~~~~~~~~~~~~~~
Up to 4 Screen Machine II are supported in a system. 4 Screen Machines produce a considerable amount of heat, some extra cooling might be required. Also you may notice a decrease of brightness in the looped thru signal.


The YUV Color Model
~~~~~~~~~~~~~~~~~~~
The YUV format predominates in the TV technology. As a result, the brightness information and color information are separated. To save bandwidth and also, therefore, data amount, the color information will be transmitted with less depth in relation to the brightness information. The reason for this is that the human eye can distinguish slighter variations in brightness than it can in color. Screen Machine also uses this format by fully digitizing the brightness for every picture point, but including more points per value in the color information. In this context, the format is 4:2:2.
The YUV color space is more "extensive" as that from computers which employ RGB color space. This means that color values can only be shown in approximation. The color space is therefore not completely conveyed, which is, for example, distinct in the chroma keying.
Formula:
  R  =  Y  +  1.370705 V
  G  =  Y  -  0.698001 V  -  0.337633 U
  B  =  Y                 +  1.732446 U

See also chapter FileFormat for documentation of the FLM/YUV file format.
