XvMC (hardware accelerated video decoding)
DISCLAIMER
This page was written by external contributors, and not by nouveau project developers. Consequently, nouveau developers do not officially endorse what's written on this page and wish to remind readers that what is expressed is not necessarily of their own opinion, but rather are the opinions of others.
About XvMC
X-Video Motion Compensation (XvMC), is an extension of the X video extension (Xv) for the X Window System. The XvMC API allows video programs to offload portions of the video decoding process to the GPU hardware, it does this by executing specific code algorithms on the GPU. In theory this process should also reduce bus bandwidth requirements.
nouveau and XvMC support
The nouveau driver does not currently feature XvMC support.
As can be read on the nouveau driver's Feature Support Page, after considering the limited benefit that XvMC support would bring against the necessary expenditure (both in terms of development time & effort) required to provide such, the nouveau project developers have opted not to pursue the task of implementing XvMC support. However, they certainly remain open to the possibility of its inclusion into the driver through the means of acceptable contributions from outside efforts (i.e. XvMC support for nouveau via 3rd party development).
Note that one individual has already begun investigation towards that end (see jb17bsome's page here).
Developers wanted!
If a programmer volunteered to implement XvMC support into Nouveau then probably the best way to start would be to start a fork of libxvmc from the openChrome project. openChrome is an open source device drivers for VIA S3 GPU and contains a updated XvMC library (with MPEG-2 and MPEG-4 acceleration support), the openChrome project in turn original forked their version of libxvmc from the uniChrome project. libxvmc is a wrapper library to provide universal access to native video hardware acceleration libraries designed for many new graphics chipsets. Thanks to libXvMCW library developers of video players no more have to write hardware dependent code to support video hardware acceleration on every graphics chipset on the market.
FFmpeg (plus MPlayer) should probably be the reference and test platform for XvMC. Plenty of technical information can also be found in MythTV wiki which possible makes it a good alternative reference and test platform, other video players with XvMC support include Xine and VLC (VideoLAN Client).
Note that implementing one method of hardware accelerated video decoding does not automaticly rule out a other, best would be to combine more than one method, (probably all through XvMC).
1. Video decoding processes that could be accelerated
Even though NVIDIA closed source binary device driver for Linux currently only XvMC support hardware acceleration of motion compensation|motion compensation (mo comp), and inverse discrete cosine transform (iDCT). The closed source binary device driver for Microsoft Windows from NVIDIA features many more additional video decoding processes which can be passed on to modern GPU (such as NVIDIA's GeForce 6-series, from 6150 and on ) which on Microsoft Windows can accelerate many more via Microsoft's DxVA (DirectX Video Acceleration) API. XvMC for Linux could possible be extended in the future to support the same processes:
- Motion compensation (mo comp)
- Inverse Discrete Cosine Transform (iDCT)
- * Inverse Telecine 3:2 and 2:2 pull-down correction
- Inverse modified discrete cosine transform (iMDCT)
- In-loop deblocking filter
- Intra-frame prediction
- Inverse quantization (IQ)
- Variable Length Decoding (VLD), more commonly known as slice level acceleration
- Spatial-Temporal De-Interlacing, (plus automatic interlace/progressive source detection)
- Bitstream processing (CAVLC/CABAC)
- * CABAC entropy decoding is probably not possible to offload on GPU via pixel shader.
- * NVIDIA (and ATI/AMD GPUs) use dedicated hardware blocks for such entropy decoding.
PureVideo
NVIDIA's GeForce 6-series (from GeForce 6150 and on) features a video acceleration engine is called "PureVideo", G8X (with the exception of GeForce 8800) features an updated version of the PureVideo technology which NVIDIA calls "PureVideo HD", (also refered to as "PureVideo 2"). PureVideo is a true discrete programmable processing core inside the NVIDIA GPU (note by ahuillet : this is what nvidia pretends ! no one is sure about this). PureVideo is a combination of a hardware video processor and video decoding software, meaning it only offloads parts of the video decoding process to the GPU (but since those are the 'heavy' and processor intensive parts it can make a large diffrence on CPU usage). Source: http://www.bit-tech.net/news/2006/01/07/nvidia_decode_h264/
Windows driver has since version 85 featured PureVideo Technology support for accelerated hardware video decoding of MPEG-2, MPEG-4 AVC (H.264), VC-1, and WMV9, (plus it also Spatial-Temporal De-Interlacing), via DXVA (which is Microsoft's equivalent of the XvMC API).
Alternative methods of hardware accelerated video decoding
Video decoding processes could possible also be accelerated under Linux/UNIX by using other methods than PureVideo, (or in combination with PureVideo to run video decoding processes that PureVideo do not support). By writting (programming) a shaders (Pixel Shader or Vertex Shader), with one shader for each video deoding processes that one would wish to accelerate. GPGPU (General-Purpose Computing on Graphics Processing Units) is another method.
1. GLSL (OpenGL Shading Language)
OpenGL Shading Language (GLSL, a.k.a. GLslang) is a high-level shader programming-language (based on the C programming-language)which offers such possibilities, (GLSL Owas originally introduced as an extension to OpenGL 1.5 but the OpenGL ARB only formally included GLSL into the OpenGL 2.0 core). http://en.wikipedia.org/wiki/OpenGL_Shading_Language
2. Cg (C for Graphics)
Cg (or "C for Graphics") is a another high-level shading programming-language created by NVIDIA for programming vertex and pixel shaders. Cg is also based on the C programming language, and although they share the same syntax, some features of C were modified and new data types were added to make Cg more suitable for programming graphics processing units. http://en.wikipedia.org/wiki/Cg_programming_language
3. GPGPU (General-Purpose Computing on Graphics Processing Units)
General-Purpose Computing on Graphics Processing Units (GPGPU, also referred to as GPGP and to a lesser extent GP²) is a recent trend in computer science that uses the Graphics Processing Unit to perform the computations rather than the CPU. The addition of programmable stages and higher precision arithmetic to the GPU rendering pipeline have allowed software developers to use the GPU for non graphics related applications. Because of the extremely parallel nature of the graphics pipeline the GPU is especially useful for programs that can be cast as stream processing and real-time computing problems. Simplest way to enable GPGPU support is by using a library such as BrookGPU or Lib Sh (both GPGPU library for C++), (since Sh has been abandoned BrookGPU would probably be the better choise, but that does not mean that one should not look at both for reference). http://en.wikipedia.org/wiki/GPGPU
4. CUDA (Compute Unified Device Architecture)
CUDA (Compute Unified Device Architecture) is an new GPGPU technology and API that just recently introduced in NVIDIA's GeForce 8-series (G8X based) GPUs. CUDA allows a programmer to use the C programming-language to code algorithms for execution on the GPU. A video decoding process could be a such code algorithms that is executed on the GPU via CUDA. Since CUDA is limited to GeForce 8-series (G8X based) GPUs it makes it an unlikly candidate for hardware accelerated video decoding. http://en.wikipedia.org/wiki/CUDA
Alternatives to XvMC
1. VAAPI (Video Acceleration API)
A new video acceleration API called VAAPI (Video Acceleration API) is currently being developed, in an effort lead by Intel. This new API supports more complete offload (like VLD) as well as iDCT and MC, and can support acceleration of MPEG-4 ASP (H.264), MPEG-4 AVC (H.264), VC-1/VMW3, as well as MPEG-2. (Extending XvMC was considered, but due to its original design for MPEG-2 MoComp only, it made more sense to design an interface from scratch that can fully expose the video decode capabilities in today's GPUs). The website for this new API effort is: http://www.freedesktop.org/wiki/Software/vaapi
Possible XvMC source code resources
openChrome Project - open source device drivers for VIA S3 (has updated XvMC with MPEG-4 acceleration support)
intellinuxgraphics.org open source Linux Graphics Device Drivers from Intel (with XvMC for MPEG-2 acceleration support)