The X video extension , often abbreviated to XVideo or Xv, provides a video output mechanism in the X Window System . The protocol was originally developed by David Carver, and its current version (second) was written in July 1991 . To this day, its main purpose remains hardware scaling ( video cards are referred to as equipment) of the video being played to watch it in full screen mode. Without XVideo, this work would have to be entirely performed by the central processor , which would require more resources and could in some cases lead to slower playback or image degradation. In addition, the X video extension uses a video card to convert color space . With it, you can hardware-adjust the brightness, contrast and tone of the displayed video stream.
In order to use this extension, three things are necessary and sufficient:
- The video card must support the necessary functions;
- Its driver and X-server supports the XVideo interface;
- The video playback program is written with the ability to use this interface.
Most modern graphics cards provide the necessary features for XVideo. Usually they are called hardware support for scaling and acceleration of YUV conversion, or simply hardware acceleration of 2D graphics . X server XFree86 (operating systems UNIX, Linux, and partially on Mac OS X) supports the XVideo extension since version 4.0.2. To make sure that your X server supports this extension, you can use the xdpyinfo utility. And to check that the current video card supports the necessary functions, you can use the xvinfo program.
Content
Play and
Popular video playback programs used in X Window, such as MPlayer , MythTV or xine, usually already have support for outputting video through XVideo. Therefore, it is reasonable to use this extension wherever the installed video card allows it and supports drivers. Acceleration will be noticeable even on computers with fast processors.
Despite the fact that the protocol provides the ability to read and write video from and to video cards, by far the most popular functions remain XvPutImage and XvShmPutImage . Clients decode frames one by one and transfer them to the video card for hardware scaling, conversion, and display.
Display
After the image has been scaled and prepared, it remains only to display it. There are several ways to speed up video output at this point. And since full acceleration implies that the video card is responsible for scaling, converting and outputting the video, the specific method will depend on where exactly the image will be displayed.
Composite Window Manager Role
On Linux, the specific display method is highly dependent on the window manager used . With correctly installed GPU drivers, Intel , ATI, or nVidia graphics cards can be used by some window managers, called composite window managers , to process each displayed window independently. This is achieved by displaying the contents of each window in a special buffer and then combining them into a single image. At the moment when individual windows are processed in their own buffer, the video processed by the video card can be added to them at this stage by means of a texture filter, until the window is finally drawn. XVideo can be used to speed up video output through the OpenGL Framebuffer Object or pbuffer extensions.
The Metacity window manager implements this method. Mixing is implemented using the 3D graphics hardware acceleration function, for example GLX_EXT_texture_from_pixmap. In addition, it allows you to independently display multiple streams of video on one screen. Other composite managers Beryl , Compiz, and Compiz Fusion do the same. Compiz Fusion is included in Ubuntu Linux 7.10 and later. It automatically activates if the system detects its supporting equipment.
However, on computers with limited OpenGL hardware support, with no support for Framebuffer Object or pbuffer, as on systems using XGL , the Xv extension will not be available.
Color Key Issues
The reason window managers do not support mixing directly is because it is very difficult to determine where to output the video stream, because during the acceleration, the contents of the screen turn into a single image. The only way to ensure video output is using a hardware overlay using a color key . After all the windows are drawn, the only available information about the windows is their size and coordinates. But to display the video, information is also needed on how and which windows overlap each other. For this, programs that play videos fill the output area with solid color (for example, green). Then, when all the windows are displayed, overlapping windows can close part of the video player window, but the video card will only need to scan certain screen coordinates and if there are green dots there, then you need to display the video stream in this place. A similar method was used to output video with hardware acceleration in the Microsoft Windows XP operating system (and earlier versions), because its window manager was so integrated with the operating system that it was not possible to speed it up itself.
Thus, if the window manager is not composite, then a hardware overlay with a color key is used to output the video, as described in the paragraph above. However, using this method may make it impossible to obtain the correct screenshot with Xvideo-based applications. It may also be impossible to output video to a second monitor if only one hardware overlay is supported.
Problems with New Graphics
Due to the release of DirectX 10, a number of modern graphics cards have trimmed or changed support for texture overlay. This also affected the nVidia GeForce 8 Series graphics cards. All GeForce 8800 graphics cards, including 8800GT and 8800GTS now support only one texture overlay on the main monitor. Due to this, they cannot properly provide output of more than one video stream using hardware acceleration, regardless of platform.
The result was poor video playback on operating systems that do not support DirectX 10, including Windows XP and Linux using XVideo. These changes also hurt many composite managers, including Compiz and partly Metacity .
See also
- XvMC - X-Video Motion Compensation
- MIT-SHM - Shared Memory Extension
Links
- Play Video Chapter from the FreeBSD Handbook
- Official XVideo Specification, Version 2.0 (English)
- XVideo Specification Supplements, Version 2.2
- Xv manual page
- testxv.c is an example program (on most distributions it is compiled with the command β gcc -o testxv testxv.c -L / usr / X11R6 / lib -lX11 -lXext -lXv β )
- testxv2.cc is another sample c ++ program .