XMBC Part IV: Accelerated Video Playback with an ATI HD5450

26 01 2011

I use my HTPC primarily for video playback, watching high definition movies and series. As you can see in one of my previous posts, I have an Ati Graphics Card in my HTPC. This card supports so called Video Acceleration (VA), which is just a fancy name for the ability to decode certain video files, like H264 encoded MKV-files. The advantage of watching video with VA is that the video decoding is entirely done by the GPU, leaving the CPU to do other important things.

Now if you have an NVidea graphics card, enabling VA isn’t that big of a deal. But enabling VA with an Ati card can be quite challenging. So this post is for all those XBMC users whom do not have that much linux experience (like me…) and would like the benefits of VA.

Because of the length of this blog, I have split it into three parts:

  1. Installing the graphics card drivers. You will need to get the latest official drivers from the Ati website and install them.
  2. Installing the Video Acceleration libraries. The actual Video Acceleration libraries are distributed in yet another package.
  3. Recompiling XBMC. The standard XBMC doesn’t support Video Acceleration for Ati card, so we need to manually compile XBMC ourselves.

Now if you are a Windows user like me, you are used to searching the internet for free software, download it, and install the software using the provided installation program. While that is also possible with Ubuntu, there is also another mechanism. In this post we will extensively use the Advanced Packaging Tool, or in short APT. Using apt-commands we can do all the above (search, download, and install) with one simple command. I won’t go into that much detail about the commands as you are used from me, as that will probably lengthen this post even more.

Part 1: Installing the graphics card drivers

  1. Exit XBMC. You can use the most right button on the bottom of the screen to exit XBMC.
    images
  2. Open a command line terminal and update the APT index. You will need an internet connection as this command will instruct APT to retrieve the available package listings and the update its internal package index.
    sudo apt-get update
  3. Now update all currently installed packages.
    sudo apt-get upgrade
  4. Before we download the needed drivers, create a directory to bundle everything together.
    mkdir VAAPI
    cd VAAPI
  5. Ati provides the Catalyst drivers as their recommended drivers for Linux based systems. The current version is the Ati Catalyst 10.12 driver, but you can check the Ati website to find the latest version. Download the latest drivers using the wget command.
    wget https://a248.e.akamai.net/f/674/9206/0/www2.ati.com/drivers/linux/ati-driver-installer-10-12-x86.x86_64.run
  6. As you can see, this command ends with .run. To make sure we can actually run this file change the permissions of this file.
    chmod +x ati-driver-installer-10-12-x86.x86_64.run
  7. The next statement will execute the file. Specifically it will run the file and instruct it to build the needed packages for an Ubuntu/lucid operating system. If you have another (version of) operating system, you might want to change this parameter.
    sudo ./ati-driver-installer-10-12-x86.x86_64.run –-buildpkg Ubuntu/lucid
  8. The packages will be saved in the current directory. Install all these packages. Tip: use the * wildcard.
    sudo dpkg -i *.deb
  9. After the packages are deployed, configure the Ati display drivers.
    sudo aticonfig –initial
  10. Now reboot your system. As soon as XBMC is fully loaded again, switch back to the command line interface (Ctrl+1).
    sudo reboot
  11. The following command will test your driver configuration. The –display 0:0 parameter tells the command what display is used. If you receive an error like “Unable to find display”, play around with the parameter, using various options like 0:1 or 1:1.
    fgl_glxgears -display 0:0
  12. If the above command succeeded a 3D moving cube is present on your display, but you will have to switch back to XBMC to see it (Ctrl+7 ). If your screen is all messed up like mine, you can try another configuration:
    sudo aticonfig –initial –tls=0
    sudo reboot

Part 2: Installing the Video Acceleration libraries

  1. Switch to the command line interface, if you haven’t already done so. Open the directory we created earlier en dowload the VA drivers. As you can see, the VA drivers aren’t supplied by Ati, but a certain enhousiasic called G. Beauchesne.
    cd VAAPI
    wget http://www.splitted-desktop.com/~gbeauchesne/xvba-video/xvba-video-latest.i686.deb
    wget http://www.splitted-desktop.com/~gbeauchesne/libva/libva-latest.tar.gz
  2. Before we can install the VA drivers, we need some other packages, quite al lot of them actually. Luckily you can download and install all of them with one command. The package manager will only download and install missing packages and automatically update any old packages.
    sudo apt-get install cdbs autotools-dev libdrm-dev x11proto-xext-dev libxext-dev libxfixes-dev libgl-dev pkg-config automake1.9 libtool libgl-mesa-dev
  3. The Video Acceleration drivers are bundled together in a Tar-archive. For all those Windows users, just compare it to a .zip or .cab. Untar the packages:
    tar -xvzf libva-latest.tar.gz
  4. The drivers are placed in a subdirectory within your current directory, in my case “libva-0.31.1”. Enter this directory, you can use the ls command if you are unsure about the directory.
    cd libva-0.31.1/
  5. The next step is to build the packages.
    dpkg-buildpackage -rfakeroot -uc -us
  6. The packages are placed one directory up. Don’t ask me why, I have no idea.
    cd ..
  7. The build command generated 4 packages, together with the package we downloaded in step 1, there will be 5 packages in this directory. Install these packages. See note as bottom if you have version 0.31-1 sds5)
    sudo dpkg -i libva1_0.31.1-1+sds4_i386.deb
    sudo dpkg -i libva-dev_0.31.1-1+sds4_i386.deb
    sudo dpkg -i libva1-dbg_0.31.1-1+sds4_i386.deb
    sudo dpkg -i libva-driver-i965_0.31.1-1+sds4_i386.deb
    sudo dpkg -i xvba-video-latest.i686.deb
  8. Now the Video Acceleration drivers are all installed. As a final step, reboot your system.
    sudo reboot

Part 3: Recompiling XBMC

  1. Congratulation, you made it through the most difficult part of this post. These last few steps are all about recompiling XBMC, but before you can compile XBMC you will need to install even more packages. Quit XBMC and install these packages.
    sudo apt-get install git-core make g++ gcc gawk pmount libtool nasm yasm automake cmake gperf zip unzip bison libsdl-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libfribidi-dev liblzo2-dev libfreetype6-dev libsqlite3-dev libogg-dev libasound-dev python-sqlite libglew-dev libcurl3 libcurl4-gnutls-dev libxrandr-dev libxrender-dev libmad0-dev libogg-dev libvorbisenc2 libsmbclient-dev libmysqlclient-dev libpcre3-dev libdbus-1-dev libhal-dev libhal-storage-dev libjasper-dev libfontconfig-dev libbz2-dev libboost-dev libenca-dev libxt-dev libxtst-dev libxmu-dev libpng-dev libjpeg-dev libpulse-dev mesa-utils libcdio-dev libsamplerate-dev libmms-dev libmpeg3-dev libfaad-dev libflac-dev libiso9660-dev libass-dev libssl-dev fp-compiler gdc libwavpack-dev libmpeg2-4-dev libmicrohttpd-dev libmodplug-dev libssh-dev gettext cvs
  2. Now that we have all packages in place, download the very latest source code from git. Git is a source code control repository that the developers of XBMC use to store their source code, track changes, etc. For the convenience, make another directory to store the source code.
    mkdir XBMC-source
    cd XBMC-source
    sudo git clone git://xbmc.git.sourceforge.net/gitroot/xbmc/xbmc
  3. After the download is completed, run the bootstrap script.
    sudo ./bootstrap
  4. The next script will set the compile options. We need the parameter –-prefix=/usr to tell the compiler the location of XBMC so that it will overwrite the current installation of XMBC with our new freshly compiled version. The most important option is the ––enable-vaapi . This tells the compiler to create XBMC with Video Acceleration Application Programming Interface (VAAPI).
    sudo ./configure –prefix=/usr –enable-vaapi
  5. After we configured the compile time options, we can compile our own version of XBMC. My CPU supports hyperthreading, so I use the –j2 option for multi-threaded compilation. If you have a dual-, quad-. hexa-core processor you can also use this option; if unsure just omit this option.
    sudo make -j2
  6. After compilation of XBMC, we can install XBMC.
    sudo make install
  7. The final step in the command line interface is to reboot your system.
    sudo reboot
  8. In XBMC navigate to your video settings and enable VAAPI.
    VAAPI
  9. Start your favourite H264 encoded (full definition) movie. While playing press “o” to see some system information. The video decoder should be something like “ff-h264-vaapi”. As you can see in this screenshot, the video encoding is done by the graphical card, and the processor is almost down to 0%.
    VAAPI h264

I took me quite a few hours to get the hang of this. I hope you enjoyed this rather lengthy post and can now enjoy Video Acceleration playback of your favourite movies.


Read the rest of this entry »