XBMC will be renamed to Kodi for v14. Read here for more details

HOW-TO:Compile XBMC for Linux, Archive:Hardware Accelerated Video Decoding Development

From Kodi
(Difference between pages)
Jump to: navigation, search
 
(corrected language & spelling. (???) = eh)
 
Line 1: Line 1:
<div class="messagebox merge">[[Image:Merge-arrow.gif|left]] It has been suggested that the ''[[:{{NAMESPACE}}HOW-TO compile XBMC for Linux on Fedora Red Hat Enterprise Linux CentOS]]'' article should be merged into this article ([[{{{2|:{{NAMESPACE}} Talk:HOW-TO compile XBMC for Linux on Fedora Red Hat Enterprise Linux CentOS}}}|discuss]]).</div>
+
This article will cover potential methods of and the '''development''' around Hardware Accelerated Video Decoding.
<div class="messagebox merge">[[Image:Merge-arrow.gif|left]] It has been suggested that the ''[[:{{NAMESPACE}}HOW-TO compile XBMC for Linux on Debian/Ubuntu]]'' article should be merged into this article ([[{{{2|:{{NAMESPACE}} Talk:HOW-TO compile XBMC for Linux on Debian/Ubuntu}}}|discuss]]).</div>
+
<div class="messagebox merge">[[Image:Merge-arrow.gif|left]] It has been suggested that the ''[[:{{NAMESPACE}}HOW-TO compile XBMC for Linux on openSUSE Linux]]'' article should be merged into this article ([[{{{2|:{{NAMESPACE}} Talk:HOW-TO compile XBMC for Linux on openSUSE Linux}}}|discuss]]).</div>
+
<div class="messagebox merge">[[Image:Merge-arrow.gif|left]] It has been suggested that the ''[[:{{NAMESPACE}}HOW-TO compile XBMC for Linux on Moblin v2]]'' article should be merged into this article ([[{{{2|:{{NAMESPACE}} Talk:HOW-TO compile XBMC for Linux on Moblin v2}}}|discuss]]).</div>
+
  
 +
'''Note!''' XBMC does not yet support any methods of hardware accelereated video decoding. Developers wanted!
  
{{Current event}}
+
=Hardware Accelerated Video Decoding=
{{GoToParent|Parent=Installing XBMC for Linux}}
+
"Hardware Accelerated Video Decoding" is the when a video-playback software-application offload portions of the [http://en.wikipedia.org/wiki/Video_decoding video decoding process] to the [http://en.wikipedia.org/wiki/Graphics_processing_unit GPU (Graphic) hardware], it does this by executing specific code algorithms on the GPU. In theory this process should also reduce bus bandwidth requirements.
__NOTOC__
+
''This is only a copy and paste from the [http://xbmc.svn.sourceforge.net/viewvc/*checkout*/xbmc/branches/linuxport/XBMC/README.linux README.linux] just to get this article started. Please refer to the SVN version of [http://xbmc.svn.sourceforge.net/viewvc/*checkout*/xbmc/branches/linuxport/XBMC/README.linux README.linux] to be sure you got the latest edition!''
+
----
+
;'''Note:''' This is an initial Linux port. It does not yet include all the features of XBMC. Don't expect too much. For more information read the [[XBMC for Linux port project]] article in this wiki.
+
;'''Note:''' XBMC is open source (GPL) software and as so the source code is available for anyone to modify and/or compile (under the rules of the GPL).
+
  
 +
[http://ffmpeg.mplayerhq.hu FFmpeg] (and [http://www.mplayerhq.hu MPlayer]) should probably be the reference and test platform for all hardware accelerated video decoding development. The reason for this is that XBMC used FFmpeg as the base for its [[DVDPlayer|DVDPlayer-playback-core]] core, and FFmpeg is used as the codec-suit inside XBMC [[MPlayer|MPlayer-playback-core]]. Also, since both [http://ffmpeg.mplayerhq.hu FFmpeg] and [http://www.mplayerhq.hu MPlayer] are cross-platform code we can get help from non-XBMC developers.
  
==Prerequisites==
+
==Hardware Accelerated Video Decoding under Linux==
*Supported Linux Operating-System installed on a supported computer, currently the officially supported OS are:
+
Developers wanted!, for more information on XBMC and Linux please see the [[Linux port project]] article in this WIKI.
**[http://www.ubuntu.com/products/WhatIsUbuntu/desktopedition Ubuntu Desktop Edition 8.04 (Hardy Heron) 32-bit for x86]
+
===Video decoding processes which could be accelerated===
**[http://www.ubuntu.com/products/WhatIsUbuntu/desktopedition Ubuntu Desktop Edition 8.10 (Intrepid Ibex) 32-bit for x86]
+
XvMC for Linux could possible be extended in the future to support the same processes:
**[http://www.ubuntu.com/products/WhatIsUbuntu/desktopedition Ubuntu Desktop Edition 9.04 (Jaunty Jackalope) 32-bit for x86]
+
* Motion compensation (mo comp)
**[http://www.ubuntu.com/products/WhatIsUbuntu/serveredition Ubuntu Server Edition 8.04 (Hardy Heron) 32-bit for x86]
+
* Inverse Discrete Cosine Transform (iDCT)
**[http://www.ubuntu.com/products/WhatIsUbuntu/serveredition Ubuntu Server Edition 8.10 (Intrepid Ibex) 32-bit for x86]
+
* Inverse Telecine 3:2 and 2:2 pull-down correction
**[http://www.ubuntu.com/products/WhatIsUbuntu/serveredition Ubuntu Server Edition 9.04 (Jaunty Jackalope) 32-bit for x86]
+
* Bitstream processing (CAVLC/CABAC)
**[http://www.ubuntu.com/products/mobile Ubuntu Mobile and Embedded Edition 8.04 (UME) 32-bit for x86]
+
* in-loop deblocking
**[http://www.ubuntu.com/products/mobile Ubuntu Mobile and Embedded Edition 8.10 (UME) 32-bit for x86]
+
* inverse quantization (IQ)
**[http://www.ubuntu.com/products/mobile Ubuntu Mobile and Embedded Edition 9.04 (UME) 32-bit for x86]
+
* Variable-Length Decoding (VLD), more commonly known as slice level acceleration
***Note that it is also possible to compile and run 32-bit XBMC under 64-bit (AMD64/EMT64) Ubuntu if you run it in a 32bit chroot.
+
* Spatial-Temporal De-Interlacing, (plus automatic interlace/progressive source detection)
  
* Other working distributions (but officially unsupported) are:
+
===XvMC===
**[[HOW-TO compile XBMC for Linux on Fedora Red Hat Enterprise Linux CentOS|Fedora RedHat Enterprise Linux, and CentOS]]
+
[http://en.wikipedia.org/wiki/X-Video_Motion_Compensation X-Video Motion Compensation (XvMC)], is an extension of the [http://en.wikipedia.org/wiki/X_video_extension X video extension (Xv)] for the [http://en.wikipedia.org/wiki/X_Window_System X Window System]. The XvMC [http://en.wikipedia.org/wiki/API API] allows a simple way to add hardware accelerated video decoding to video-playback software-application
**[[HOW-TO compile XBMC for Linux on openSUSE Linux|OpenSUSE]]
+
**[[HOW-TO compile XBMC for Linux on Debian/Ubuntu|Debian]]
+
**[[HOW-TO compile XBMC for Linux on Moblin v2|Moblin]]
+
  
*[http://en.wikipedia.org/wiki/X86 x86-based computer]. No other special hardware is required for development, as developers can compile using the "''make sdl_2d option''" (see [http://xbmc.svn.sourceforge.net/viewvc/*checkout*/xbmc/branches/linuxport/XBMC/README.linux|README.linux]). However for end-users the minimum requirement is a [http://en.wikipedia.org/wiki/Graphics_Processing_Unit 3D GPU (Graphics Processing Unit)] that at least supports [http://en.wikipedia.org/wiki/Shader_model Shader Model 3.0] and [http://en.wikipedia.org/wiki/OpenGL OpenGL 2.0] (that features 24bpp or 32bpp for 3D hardware-acceleration support, which XBMC GUI need to run smootly at an acceptable frame-rate). Graphic adapters that support [http://en.wikipedia.org/wiki/DirectX DirectX version 9.0c] or later usually meet all of those mentioned requirements, ([[Team-XBMC]] recommends [http://en.wikipedia.org/wiki/Nvidia NVIDIA GeForce 6150 or later] as NVIDIA are currently the manufacturer that offers [http://en.wikipedia.org/wiki/Graphics_hardware_and_FOSS good device-drivers for Linux] (and [http://en.wikipedia.org/wiki/Nvidia NVIDIA GeForce 6150 or later] supports OpenGL 2.0).
+
====NVIDIA====
 +
Even though NVIDIA closed source binary device driver for Linux currently only support XvMC hardware acceleration of motion compensation (mo comp), and inverse discrete cosine transform (iDCT) for MPEG-2, 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 video decoding processes via [http://en.wikipedia.org/wiki/DirectX_Video_Acceleration Microsoft's DxVA (DirectX Video Acceleration) API], (the Microsoft Windows equivalent to XvMC).
  
*Correctly installed graphics device-drivers which supports 24bpp or 32bpp for 3D hardware-acceleration, ([[Team-XBMC]] recommends that you run [http://www.albertomilone.com/nvidia_scripts1.html Envy] which is a application that automaticly downloads and installs the correct proprietary device-driver for your ATI or NVIDIA graphic chip).
+
=====NVIDIA PureVideo Technology=====
 +
NVIDIA's GeForce 6-series (from GeForce 6150 and on) features a video acceleration engine called "PureVideo", NVIDIA's GeForce 8-series (with the exception of GeForce 8800) features an updated version of the PureVideo technology which NVIDIA calls "PureVideo HD". NVIDIA PureVideo Technology is a true discrete programmable processing core inside the NVIDIA GPU. The NVIDIA PureVideo technology is a combination of a hardware video processor and video decode software, meaning it only offloads parts of the video decoding to the GPU (but since those are the 'heavy' and processor intensive parts it results in a [http://www.bit-tech.net/news/2006/01/07/nvidia_decode_h264/ huge diffrence on CPU usage when using PureVideo vs. not using PureVideo]).
  
==Getting the source code==
+
NVIDIA closed source binary device driver for Microsoft Windows has since ForceWare 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 [http://en.wikipedia.org/wiki/DirectX_Video_Acceleration DXVA] (which is Microsoft's equivalent of the XvMC API).
For the first time:<br>
+
<source lang="bash">
+
$ sudo apt-get install subversion
+
$ cd $HOME
+
$ svn checkout {{svn}}
+
</source>
+
  
In order to update the source code (and clean old make files):<br>
+
====Intel (GMA)====
<source lang="bash">
+
Intel's open source device drivers for Linux supports motion compensation (mo comp), and inverse discrete cosine transform (iDCT), and de-interlacing for MPEG-2.
$ cd $HOME/XBMC
+
$ svn up
+
$ make clean
+
</source>
+
  
==Installing required Ubuntu packages==
+
=====Intel Clear Video Technology=====
The current list of required packages for each supported version is located in the [http://xbmc.svn.sourceforge.net/viewvc/*checkout*/xbmc/branches/linuxport/XBMC/README.linux README.linux] file in the SVN
+
[http://www.intel.com/products/chipsets/clear_video/index.htm Intel® Clear Video Technology] is a combination of video processing hardware and software technologies for a wide range of digital displays. This technology is available on all Intel® G965 Express Chipset-based hardware platforms. According to Intel, Clear Video Technology enables; ''Enhanced high-definition video playback, Sharper images, Precise color control, and Advanced display capability''.
  
'''''Use a single command to get all build dependencies'''''
+
'''Intel Clear Video Technology Features and benefits;'''
 +
*MPEG-2 decode iDCT + motion compensation. Up to 2 stream support (1 HD and 1 SD)
 +
*De-interlacing Advanced pixel adaptive (SD/HD-1080i)
 +
*Color control ProcAmp: brightness, hue, saturation, contrast.
 +
*Video scaling 4x4 scaling
 +
*Digital Display Support (through SDVO) Digital Video Interface (DVI), High-Definition Multimedia Interface (HDMI)
 +
*Display support RGB (QXGA), HDMI, UDI, DVI, HDTV (1080i/p, 720p), Composite, Component, S-Video (via Intel Serial Digital Video Out), TV-out, CRT
 +
*Aspect ratio 16:9, 4:3, letterbox
 +
*Maximum resolution support 2048 x 1536 at 75 Hz, RGB (QXGA)
  
For this, you need to specify the PPA in your apt sources. Please find them [http://forum.xbmc.org/showthread.php?t=33327 on the forum].
+
===Alternative methods of hardware accelerated video decoding===
 +
Video decoding processes could possible also be accelerated under Linux/UNIX (and Microsoft Windows) by using other methods than the previously mentioned PureVideo Technology from NVIDIA (alternative methods could also be used in combination with PureVideo to run video decoding processes that PureVideo do not support). Programming [http://en.wikipedia.org/wiki/Shader shaders (Pixel Shader or Vertex Shader)], with one shader for each video decoding process that one would wish to accelerate is one such method. GPGPU (General-Purpose Computing on Graphics Processing Units) is another possible method. All these alternative methods requires [http://en.wikipedia.org/wiki/Shader Shader Model 3.0] support by the GPU, (which is one of the reasons why we made [http://en.wikipedia.org/wiki/Shader Shader Model 3.0] a minimum end-user requirement for the [[Linux port project|XBMC Linux port]]).
  
Update apt :
+
=== GLSL (OpenGL Shading Language) ===
<source lang="bash">
+
[http://en.wikipedia.org/wiki/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 was originally introduced as an extension to OpenGL 1.5 but the OpenGL ARB only formally included GLSL into the OpenGL 2.0 core).
$ sudo apt-get update
+
http://en.wikipedia.org/wiki/OpenGL_Shading_Language
</source>
+
=== Cg (C for Graphics) ===
 +
[http://en.wikipedia.org/wiki/Cg_programming_language Cg (or "C for Graphics")] is a another high-level shading programming-language, created by NVIDIA for programming vertex and pixel shaders it is compatible with other GPU hardware manufactures as well. Like GLSL, 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. The Cg programming-language seems to have survived the introduction of the newer shading languages very well, mainly (???) of its established momentum in the digital content creation area, although the language is seldom used in final products.
  
Here is the magic command to get the build dependencies (used to compile the version on the PPA).
+
=== GPGPU (General-Purpose Computing on Graphics Processing Units) ===
<source lang="bash">
+
[http://en.wikipedia.org/wiki/GPGPU 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 [http://en.wikipedia.org/wiki/Lib_Sh Lib Sh (GPGPU library for C++)], or [http://en.wikipedia.org/wiki/BrookGPU BrookGPU] (the latter, BrookGPU is probably the better of the two for XBMC video decoding purposes).
$ sudo apt-get build-dep xbmc
+
</source>
+
  
==How to compile==
+
=== CUDA (Compute Unified Device Architecture) ===
===Default compile and install===
+
[http://en.wikipedia.org/wiki/CUDA CUDA (Compute Unified Device Architecture)] is an [http://en.wikipedia.org/wiki/GPGPU GPGPU technology] and API that NVIDIA introduced in the 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.
Requires 3D GPU that has supported OpenGL 3D hardware acceleration, set bitdepth to 24bpp or 32bpp<br>
+
<source lang="bash">
+
$ cd $HOME/XBMC
+
$ ./bootstrap
+
$ ./configure
+
$ make
+
$ sudo make install
+
</source>
+
  
===./configure command line switches===
+
==Possible development tools and resources==
These switches are possible when running configure:
+
Tools and resources that could possible help in the development. Note that GLSL shaders will need to be created and tested in a development tool prior to the injection in the video-playback software-application that will use them, (to do so, GLSL developer tools exists, see "Development Tools" below).
 +
===Development Tools===
 +
* [http://sourceforge.net/projects/lumina/ Lumina] -  GLSL development tool (IDE). It is platform independent and the interface uses the [http://en.wikipedia.org/wiki/Qt_%28toolkit%29 Qt (toolkit)].
 +
*NVIDIA [http://developer.nvidia.com/object/nvshaderperf_1_8_home.html ShaderPerf1.8] and [http://developer.nvidia.com/object/nvshaderperf_home.html ShaderPerf 2.0 Alpha] - handy utility that reports detailed shader performance metrics for a wide range of inputs. It is available both as a command line utility and with a user interface in [http://developer.nvidia.com/object/fx_composer_home.html FX Composer]. Please note that ShaderPerf 2.0 Alpha only supports DirectX shaders written in HLSL or assembly, (so either use version 1.8 or use [http://en.wikipedia.org/wiki/HLSL2GLSL HLSL2GLSL] which can be used to convert a HLSL shader into a GLSL shader).
 +
* [http://developer.nvidia.com/object/fx_composer_home.html FX Composer] - provides an IDE interface to create, compile and debug GLSL (as well as DirectX) shaders.
 +
* [http://www.ati.com/developer/rendermonkey/ RenderMonkey] - provides an IDE interface to create, compile and debug GLSL (as well as DirectX) shaders.
 +
* [http://www.blender.org/ Blender] - This popular opensource 3D modeling and animation package can now use GLSL materials, thus allowing any shader developer to use it as a developement tool.
 +
* [http://en.wikipedia.org/wiki/OpenSceneGraph OpenSceneGraph] - open source multiplatform graphics and shader IDE (also see [http://developer.3dlabs.com/documents/presentations/osg_glsl_july2005.zip GLSL Shading with OSG — 1.20MB zipped PDF])
 +
* [http://en.wikipedia.org/wiki/HLSL2GLSL HLSL2GLSL] - library and tool that converts HLSL (High Level Shader Language) shaders to GLSL (OpenGL Shading Language)
 +
* [http://sourceforge.net/projects/dxglwrap/ DirectX OpenGL Wrapper] - emulates API calls thru OpenGL commands and other platform specific commands in order to run DirectX 8 application running on other platform than Windows.
  
* '''--prefix=/path'''
+
===Open Source Device Drivers===
** Install XBMC to /path rather than default (/usr/local)
+
* [http://intellinuxgraphics.org intellinuxgraphics.org] open source Linux Graphics Device Drivers from Intel (with XvMC for MPEG-2 acceleration support)
* '''--disable-gl'''
+
* [http://www.openchrome.org openChrome Project] - open source device drivers for VIA (has updated XvMC with MPEG-2/MPEG-4 acceleration support)
** Much much slower GUI rendering but works on all adapters and bitdepths. For development purposes only.
+
* [http://nouveau.freedesktop.org/wiki/XvMC Nouveau] - open source device driver for NVIDIA-based graphic controllers (does not yet feature any XvMC support)
* '''--disable-debug'''
+
** <nowiki>No debug information (smaller executable, no FreeMem text in screens)</nowiki>
+
** <nowiki>open issue: FreeMem is still shown even with --disable-debug</nowiki>
+
  
It is also possible to combine these options, for example:
+
===Source Code and Libraries===
 +
* [http://en.wikipedia.org/wiki/BrookGPU BrookGPU] - GPGPU library in ANSI C for general purpose computations on GPU (OpenGL and DirectX compatible)
 +
* [http://en.wikipedia.org/wiki/Lib_Sh Lib Sh] - GPGPU library in metaprogramming language and C++ for general purpose computations on GPU
 +
* [http://www.shadertech.com/shaders/stsummer04/JianqingWang-src.zip Discrete Wavelet Transform (DWT) of JPEG 2000 (JasPer) on GPU written in Cg shader]
 +
* [http://sourceforge.net/projects/opencvlibrary OpenCV (Open Computer Vision Library)] - a collection of algorithms and sample code for various computer vision problems. The library is compatible with [http://www.intel.com/cd/software/products/asmo-na/eng/perflib/ipp/302910.htm Intel Image Processing Library (IPL) and utilizes Intel Integrated Performance Primitives] for better performance. Features a bi-linear interpolation and color space conversion functions in IPL, (I also read that motion estimation with block matching and Hough transform is on the roadmap so you might want to check out their CVS).
 +
* [http://www.antigrain.com Anti-Grain Geometry] - A High Quality Rendering Engine (High Fidelity 2D Graphics Renderer) for C++ (GPL licensced)
 +
*[http://www.crusaderky.altervista.org//?s=downloads SDL_buffer] - a SDL extension library that is useful when you have to resize an image multiple times.
 +
* [http://members.cox.net/dolsen6/resize.zip SDL_Resize] - basic image resizing library, high quality output suited for prerendering images.
 +
*[http://sdl-cfg.sourceforge.net SDL_Config] - Library designed for reading and writing configuration (.ini) files in an easy, cross-platform way.
 +
* [http://www.ferzkopp.net/~aschiffler/Software/SDL_bgrab/index.html SDL_bgrab] - SDL convertion of libbgrab (a framegrabber lib from the same author).
 +
* [http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html NVIDIA Shader Library] (color space conversions, blurring, interpolation, anti-aliasing, etc.)
  
<source lang="bash">
+
===Other developer resources===
$ ./configure --disable-debug --disable-gl
+
====Online Documentation and Tutorials====
</source>
+
* [http://www.lighthouse3d.com/opengl/glsl/ GLSL (OpenGL Shader Language) Tutorial @ Lighthouse 3D]
 +
*[http://developer.3dlabs.com/documents/index.htm OpenGL specification and OpenGL Shading Language reference documents (3DLabs)]
  
===Quicker compilation===
+
====Books (hard-copy)====
By adding -j<number> to the make command, you describe how many cores will be used. So for dualcore the commands are:<br>
+
*[http://developer.nvidia.com/object/gpu_gems_2_home.html GPU Gems 2 (published by NVIDIA)] for and by developers
<source lang="bash">
+
**there is also [http://developer.nvidia.com/object/gpu_gems_home.html GPU Gems 1] but it does not cover GPCPU
$ make -j2
+
</source>
+
or
+
<source lang="bash">
+
$ make -j2 sdl_2d
+
</source>
+
  
Exprimental: You could add [http://distcc.samba.org/ distcc] if you have more than one computer networked. This will run make on several computers sharing the workload between them.
+
== External links ==
 +
====XvMC====
 +
* [http://en.wikipedia.org/wiki/X-Video_Motion_Compensation Wikipedia.org article on XvMC (X-Video_Motion_Compensation)]
 +
* [http://www.mythtv.org/wiki/index.php/XvMC MythTV WIKI article on XvMC under Linux]
 +
* [http://www.bit-tech.net/news/2006/01/07/nvidia_decode_h264/ bit-tech.net article on NVIDIA PureVideo Technology]
 +
====GLSL====
 +
* [http://en.wikipedia.org/wiki/GLSL Wikipedia.org article on GLSL (OpenGL Shading Language)]
 +
* [http://www.shadertech.com shadertech.com] -  Shader development news, forums, tools, code, and links.
  
==How to run==
+
[[category:Inner Workings]]
Everything is now taken care of by the install script. Simply run the xbmc command from anywhere:
+
[[category:Development]]
<source lang="bash">
+
$ xbmc
+
</source>
+
 
+
==Fullscreen==
+
Toggle FS with \ key while XBMC is running.
+
 
+
==Multi-monitor Fullscreen==
+
If you have a multi-monitor setup and you want to use fullscreen, make sure to set the env variable
+
SDL_VIDEO_FULLSCREEN_HEAD to the display no. which you want SDL to use for the fullscreen mode.
+
 
+
For e.g. "SDL_VIDEO_FULLSCREEN_HEAD=1 ./xbmc.bin -fs" to tell SDL to use display no.1
+
 
+
[[category:How To|Linux]]
+
 
[[category:Linux]]
 
[[category:Linux]]
[[category:Development]]
 
[[category:Inner Workings]]
 
[[category:OpenGL]]
 
 
[[category:To-Do]]
 
[[category:To-Do]]

Revision as of 07:10, 31 May 2007

This article will cover potential methods of and the development around Hardware Accelerated Video Decoding.

Note! XBMC does not yet support any methods of hardware accelereated video decoding. Developers wanted!

Contents

1 Hardware Accelerated Video Decoding

"Hardware Accelerated Video Decoding" is the when a video-playback software-application offload portions of the video decoding process to the GPU (Graphic) hardware, it does this by executing specific code algorithms on the GPU. In theory this process should also reduce bus bandwidth requirements.

FFmpeg (and MPlayer) should probably be the reference and test platform for all hardware accelerated video decoding development. The reason for this is that XBMC used FFmpeg as the base for its DVDPlayer-playback-core core, and FFmpeg is used as the codec-suit inside XBMC MPlayer-playback-core. Also, since both FFmpeg and MPlayer are cross-platform code we can get help from non-XBMC developers.

1.1 Hardware Accelerated Video Decoding under Linux

Developers wanted!, for more information on XBMC and Linux please see the Linux port project article in this WIKI.

1.1.1 Video decoding processes which could be accelerated

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
  • Bitstream processing (CAVLC/CABAC)
  • in-loop deblocking
  • inverse quantization (IQ)
  • Variable-Length Decoding (VLD), more commonly known as slice level acceleration
  • Spatial-Temporal De-Interlacing, (plus automatic interlace/progressive source detection)

1.1.2 XvMC

X-Video Motion Compensation (XvMC), is an extension of the X video extension (Xv) for the X Window System. The XvMC API allows a simple way to add hardware accelerated video decoding to video-playback software-application

1.1.2.1 NVIDIA

Even though NVIDIA closed source binary device driver for Linux currently only support XvMC hardware acceleration of motion compensation (mo comp), and inverse discrete cosine transform (iDCT) for MPEG-2, 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 video decoding processes via Microsoft's DxVA (DirectX Video Acceleration) API, (the Microsoft Windows equivalent to XvMC).

1.1.2.1.1 NVIDIA PureVideo Technology

NVIDIA's GeForce 6-series (from GeForce 6150 and on) features a video acceleration engine called "PureVideo", NVIDIA's GeForce 8-series (with the exception of GeForce 8800) features an updated version of the PureVideo technology which NVIDIA calls "PureVideo HD". NVIDIA PureVideo Technology is a true discrete programmable processing core inside the NVIDIA GPU. The NVIDIA PureVideo technology is a combination of a hardware video processor and video decode software, meaning it only offloads parts of the video decoding to the GPU (but since those are the 'heavy' and processor intensive parts it results in a huge diffrence on CPU usage when using PureVideo vs. not using PureVideo).

NVIDIA closed source binary device driver for Microsoft Windows has since ForceWare 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).

1.1.2.2 Intel (GMA)

Intel's open source device drivers for Linux supports motion compensation (mo comp), and inverse discrete cosine transform (iDCT), and de-interlacing for MPEG-2.

1.1.2.2.1 Intel Clear Video Technology

Intel® Clear Video Technology is a combination of video processing hardware and software technologies for a wide range of digital displays. This technology is available on all Intel® G965 Express Chipset-based hardware platforms. According to Intel, Clear Video Technology enables; Enhanced high-definition video playback, Sharper images, Precise color control, and Advanced display capability.

Intel Clear Video Technology Features and benefits;

  • MPEG-2 decode iDCT + motion compensation. Up to 2 stream support (1 HD and 1 SD)
  • De-interlacing Advanced pixel adaptive (SD/HD-1080i)
  • Color control ProcAmp: brightness, hue, saturation, contrast.
  • Video scaling 4x4 scaling
  • Digital Display Support (through SDVO) Digital Video Interface (DVI), High-Definition Multimedia Interface (HDMI)
  • Display support RGB (QXGA), HDMI, UDI, DVI, HDTV (1080i/p, 720p), Composite, Component, S-Video (via Intel Serial Digital Video Out), TV-out, CRT
  • Aspect ratio 16:9, 4:3, letterbox
  • Maximum resolution support 2048 x 1536 at 75 Hz, RGB (QXGA)

1.1.3 Alternative methods of hardware accelerated video decoding

Video decoding processes could possible also be accelerated under Linux/UNIX (and Microsoft Windows) by using other methods than the previously mentioned PureVideo Technology from NVIDIA (alternative methods could also be used in combination with PureVideo to run video decoding processes that PureVideo do not support). Programming shaders (Pixel Shader or Vertex Shader), with one shader for each video decoding process that one would wish to accelerate is one such method. GPGPU (General-Purpose Computing on Graphics Processing Units) is another possible method. All these alternative methods requires Shader Model 3.0 support by the GPU, (which is one of the reasons why we made Shader Model 3.0 a minimum end-user requirement for the XBMC Linux port).

1.1.4 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 was 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

1.1.5 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 it is compatible with other GPU hardware manufactures as well. Like GLSL, 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. The Cg programming-language seems to have survived the introduction of the newer shading languages very well, mainly (???) of its established momentum in the digital content creation area, although the language is seldom used in final products.

1.1.6 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 Lib Sh (GPGPU library for C++), or BrookGPU (the latter, BrookGPU is probably the better of the two for XBMC video decoding purposes).

1.1.7 CUDA (Compute Unified Device Architecture)

CUDA (Compute Unified Device Architecture) is an GPGPU technology and API that NVIDIA introduced in the 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.

1.2 Possible development tools and resources

Tools and resources that could possible help in the development. Note that GLSL shaders will need to be created and tested in a development tool prior to the injection in the video-playback software-application that will use them, (to do so, GLSL developer tools exists, see "Development Tools" below).

1.2.1 Development Tools

  • Lumina - GLSL development tool (IDE). It is platform independent and the interface uses the Qt (toolkit).
  • NVIDIA ShaderPerf1.8 and ShaderPerf 2.0 Alpha - handy utility that reports detailed shader performance metrics for a wide range of inputs. It is available both as a command line utility and with a user interface in FX Composer. Please note that ShaderPerf 2.0 Alpha only supports DirectX shaders written in HLSL or assembly, (so either use version 1.8 or use HLSL2GLSL which can be used to convert a HLSL shader into a GLSL shader).
  • FX Composer - provides an IDE interface to create, compile and debug GLSL (as well as DirectX) shaders.
  • RenderMonkey - provides an IDE interface to create, compile and debug GLSL (as well as DirectX) shaders.
  • Blender - This popular opensource 3D modeling and animation package can now use GLSL materials, thus allowing any shader developer to use it as a developement tool.
  • OpenSceneGraph - open source multiplatform graphics and shader IDE (also see GLSL Shading with OSG — 1.20MB zipped PDF)
  • HLSL2GLSL - library and tool that converts HLSL (High Level Shader Language) shaders to GLSL (OpenGL Shading Language)
  • DirectX OpenGL Wrapper - emulates API calls thru OpenGL commands and other platform specific commands in order to run DirectX 8 application running on other platform than Windows.

1.2.2 Open Source Device Drivers

  • intellinuxgraphics.org open source Linux Graphics Device Drivers from Intel (with XvMC for MPEG-2 acceleration support)
  • openChrome Project - open source device drivers for VIA (has updated XvMC with MPEG-2/MPEG-4 acceleration support)
  • Nouveau - open source device driver for NVIDIA-based graphic controllers (does not yet feature any XvMC support)

1.2.3 Source Code and Libraries

1.2.4 Other developer resources

1.2.4.1 Online Documentation and Tutorials

1.2.4.2 Books (hard-copy)

1.3 External links

1.3.1 XvMC

1.3.2 GLSL

Personal tools
Namespaces

Variants
Actions
Navigation
Wiki help
Toolbox