# Architecture

&kdetv; uses a plugin architecture to be portable and flexible. There are several plugin types, &eg; video input, on-screen-display, mixers, and image filters. When you start &kdetv; for the first time, go through the configuration dialog to select the plugins you need for your hardware. Most importantly, you should be aware which video plugin you are using to avoid being unsatisfied with &kdetv;'s performance. Read the sections about the video plugins for details.

## Video Device Names

On most &linux; systems, you will notice two kinds of device names in the device list:

- XVideo: video4linux (port <some_number>)

  These are the devices provided by the &xvideo; plugin. For more information about this plugin's capabilities, refer to &xvideo; Plugin.

- Video4Linux: <Your video card's name>

  These are the devices provided by the &video4linux; plugin. For more information about this plugin's capabilities, refer to &video4linux; Plugin.

- Video4Linux2: <Your video card's name>

  These are the devices provided by the &video4linux2; plugin. For more information about this plugin's capabilities, refer to &video4linux2; Plugin.

## &xvideo; Plugin

To find out whether you are using a &xvideo; plugin device, look here: Video Device Names.

### How does it work?

The plugin uses the X-Server to display video. It cooperates with an X-Server module that provides video playback (the &v4l; module, a &video4linux; to &xvideo; bridge). The &v4l; bridge provides very CPU efficient video playback because the video image is directly copied from the grabber card into the video memory. On most modern hardware, the graphics card will scale the image to the desired size. Some hardware even deinterlaces the image; the author of these lines uses a Radeon 9500 card with the open-source &xfree; drivers, this combination provides deinterlacing. Since the &v4l; bridge works in on the &xfree; server side, it can provide overlay video display without corrupting the screen, as opposed to the &video4linux; plugin overlay mode.

### What features does it provide?

- Low CPU usage.

- Depending on the hardware, a quite good picture quality.

### What features does it not provide? Why?

- Image filtering. The images are directly transferred to the graphics card, there is no possibility to manipulate them in between.

- Snapshots. Reason: see above.

- Overscan. Reason: see above.

- Audio mode selection. This feature is not exposed by the &xvideo; &xfree; interface.

- Channel scanning without having the &vbi; decoder running. The feature to determine signal strength is not exposed by the &xvideo; &xfree; interface.

- Image scaling on some very old hardware (&eg; NVidia Riva 128).

- Can only provide access to the most important picture controls since the &xvideo; API does not expose the others.

## &video4linux; Plugin

To find out whether you are using a &video4linux; plugin device, look here: Video Device Names.

This plugin has two operation modes:

### Overlay

It works in Overlay mode when you check the Prefer overlay if possible checkbox. In this mode, the TV image is directly transferred into the graphics card. Since the video window can only be updated after it has been moved or resized (&kdetv; is an &xfree; client) you will notice display corruption and heavy flicker whenever you move or resize the window. This is necessary to repaint the desktop regions that were corrupted by the video stream. This mode uses almost no CPU resources, but should only be used as a fallback if nothing else works.

#### What features does it provide?

- Low CPU usage.

- Snapshots.

- Audio mode selection.

- Channel scanning without having the &vbi; decoder running.

#### What features does it not provide? Why?

- Image filtering; the images are directly transferred to the graphics card, there is no possibility to manipulate them in between.

- Overscan. Reason: see above.

- Image scaling. Most TV hardware (bt8X8 chips) does not support it.

- Can only provide access to the most important picture controls since the &v4l1; API does not expose the others.

### Grab and Display

This mode is active when the Prefer overlay if possible checkbox is not checked. An image is grabbed from the TV card and stored in a local buffer. This buffer can be manipulated in arbitrary ways (deinterlacing, overscan, other filters) and is then being displayed using different methods (see below). This is the most flexible way, but also the most CPU intensive way &kdetv; offers.

#### Display modes

##### &xvideo; (with or without shared memory)

The image is handed over to the graphics card in &yuv422; format. Depending on the driver, the graphics card or the CPU scale, the image is transformed to RGB with the display's color depth and displayed. This is the fastest and most flexible way &kdetv; provides. It is strongly recommended that you use this mode since it is the only mode that exposes all of &kdetv;'s features. The usage of shared memory may yield a small performance benefit.

##### &opengl;

The image is handed over to the graphics card in RGB format as a texture for a polygon. If you have &opengl; hardware acceleration, the picture is scaled to the desired output size by the graphics card, which causes a very low CPU usage. The drawback of this view mode is that the &opengl; view mode seems to be unstable. Also, all good deinterlacers use the &yuv422; image format, which would cause additional conversions that would nullify the hardware acceleration effect.

##### X11 (with or without shared memory)

The image is displayed using standard &xfree; mechanisms. This is very slow and does not provide image scaling. Use it as a fallback if nothing else works. Since the video image is grabbed in RGB format, all good deinterlacers will not work. The usage of shared memory may yield a small performance benefit.

#### Framerate selection

This plugin provides the option of selecting between full and half framerate. Full framerate is only useful in conjunction with one of the good &dscaler; deinterlacers since they create a new image from the two most recent fields. Full framerate provides smoother movement.

#### What features does it provide (assuming &xvideo; display mode is used)?

- Best picture quality.

- Image filtering in arbitrary ways, &eg; deinterlacing.

- Snapshots.

- Overscan.

- Audio mode selection.

- Channel scanning without having the &vbi; decoder running.

#### What features does it not provide? Why?

- Can only provide access to the most important picture controls since the &v4l1; API does not expose the others.

- There may be limitations due to the selected display mode. See above. When using &xvideo; mode, all &kdetv; features are available.

## &video4linux2; Plugin

To find out whether you are using a &video4linux2; plugin device, look here: Video Device Names.

This plugin only supports one operation mode: Grab and display. Overlay is not supported because of the annoying flickering sideeffects that are impossible to work around when performing overlay under an X-Server.

An image is grabbed from the TV card and stored in a local buffer. This buffer can be manipulated in arbitrary ways (deinterlacing, overscan, other filters) and is then being displayed on the screen.

### Display modes

#### &xvideo; (with or without shared memory)

The image is handed over to the graphics card in &yuv422; format. Depending on the driver, the graphics card or the CPU scale, the image is transformed to RGB with the display's color depth and displayed. The usage of shared memory may yield a small performance benefit.

### Framerate selection

This plugin provides the option of selecting between full and half framerate. Full framerate is only useful in conjunction with one of the good &dscaler; deinterlacers since they create a new image from the two most recent fields. Full framerate provides smoother movement.

### What features does it provide?

- Best picture quality.

- Image filtering in arbitrary ways, &eg; deinterlacing.

- Snapshots (when the hardware supports RGB grabbing.

- Overscan.

- Audio mode selection.

- Channel scanning without having the &vbi; decoder running.

- Provides access to all TV hardware controls the hardware driver provides.

## Mixer Plugins

&kdetv; currently ships two mixer plugins (&oss; and &alsa;). These should work on all platforms &kdetv; supports. Read the FAQ when you have trouble adjusting the volume.