[Gentoo] G45/GM45 h264 VA-API video decoding

On May 2011 Intel released G45/GM45 h264 VA-API in their g45-h264 branch. More then one year later they still didn’t merge it to master and no one touched that code in the meantime.

Fortunately if you tweak your system a bit that code is good enough to play a 1080p video with a generous bitrate, unfortunately it will not work out of the box.

After putting the vaapi use flag in your /etc/make.conf you will need to modify the x11-libs/libva-9999 and x11-libs/libva-intel-driver-9999 ebuilds to checkout from the g45-h264 branch instead of master. Of course if you use the ebuilds from my overlay you will have to do nothing.

Then you will have to emerge a player which takes advantage of vaapi, you have three alternatives:

  • VLC: the media-video/vlc ebuild in gentoo already supports vaapi, unfortunately I didn’t get good performances with vlc so I discourage using it. I didn’t waste lot of time trying to tweak it anyway because I don’t like vlc too much.
  • media-plugins/gst-plugins-vaapi and your favorite gstreamer player (for example kde-base/dragonplayer if you use KDE). Unfortunately gst-plugins-vaapi isn’t in portage, you can find it the openoffice-geki overlay but it is broken so I suggest you to use the one in my overlay. Also you will need media-libs/gstreamer-0.10.36, gst-plugins-bad-0.10.23 and gst-plugins-* 0.10.36, they aren’t in portage of course so I suggest you to do a version bump or using the ebuilds in my overlay. Unfortunately gst-plugins-vaapi is currently broken with G45/GM45 so you should skip to the next alternative until it gets fixed. EDIT: it works now https://bugs.freedesktop.org/show_bug.cgi?id=50390

 

  • media-video/mplayer with the SMPlayer frontend.

There isn’t any mplayer ebuild with vaapi support, so I suggest you to take it from my overlay. I made the ebuild using the latest git snapshot of mplayer-vappi. You can find a live ebuild of media-video/smplayer in the multimedia overlay.

You can check if everything works as expected with:

mplayer -vo vaapi -va vaapi file.mkv

but you will seriously need some tweaks until it gets usable.

  • First of all you will have to disable the desktop compositing, you can temporarily do it with ALT+SHIT+F12 if you use kde.
  • Then you will have to disable SwapbuffersWait:

# cat << EOF >> /usr/share/X11/xorg.conf.d/99-intel.conf
Section “Device”
Identifier “intel”
Driver “intel”
Option “SwapbuffersWait” “off”
EndSection
EOF

  • In SMPlayer go to Options –> Preferences and in the General section disable Screenshots. In the video tab select vaapi as Output driver. If you use pulseaudio or jack set it in the audio tab. In the Performance section disable Frame drop and set Threads to 1. Go to the Advanced section and then in the Options for mplayer tab, add -va vaapi in Options. If you have IPv6 connectivity set IPv6 in the Network tab.

Done, you can finally enjoy hardware accelerated VA-API video decoding. With vaapi I can even watch 1080p videos while emerging @world with my 1.4GHz cpu :)

Edit: I forgot to say you should not use SNA (Sandy Bridge New Acceleration) because VA-API becomes slower. (FIXED)

Anyway you will probably want to emerge mplayer2 and smplayer2 too, so if you want to use the cpu instead of the gpu to decode a particular video you will be able to do it without having to unset smplayer. If you have a slow cpu I suggest using:

mplayer2 -vc ffh264 -lavdopts threads=4:fast:skiploopfilter=all -vo gl file.mkv

14 comments to [Gentoo] G45/GM45 h264 VA-API video decoding

  • darkbasic

    I forgot to say you should not use SNA (Sandy Bridge New Acceleration) because VA-API becomes slower.

  • godlike

    Current trunk for libva-intel-driver (g45-h264 branch) is throwing errors related to some VA*BufferJPEGBaseline (see http://pastebin.com/1wzYPHxy). Any idea how to fix this?

  • darkbasic

    With latest graphic stack from git and my latest mplayer-vaapi ebuild hardware video decoding is really quick on my laptop, well done Intel!

  • godlike

    Error persists with 9999 from your overlay. See http://pastebin.com/5AJrCdMz
    Are there any other packages that need to be updated too?

  • godlike

    And updating xf86 intel driver to latest version does not help.

    • godlike

      Neither does updating mesa to 9.0

      • Hugo

        It seems that if you use only x11-libs/libva-intel-driver-9999 from the overlay and the “regular” x11-libs/libva-1.1.0 from portage it works fine (i’m using vlc). So the problem is with the libva in this overlay.

        # vainfo output:
        libva info: VA-API version 0.33.0
        libva info: va_getDriverName() returns 0
        libva info: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
        libva info: Found init function __vaDriverInit_0_33
        libva info: va_openDriver() returns 0
        vainfo: VA-API version: 0.33 (libva 1.1.0)
        vainfo: Driver version: Intel i965 driver – 1.0.19.pre1
        vainfo: Supported profile and entrypoints
        VAProfileMPEG2Simple : VAEntrypointVLD
        VAProfileMPEG2Main : VAEntrypointVLD
        VAProfileH264Baseline : VAEntrypointVLD
        VAProfileH264Main : VAEntrypointVLD
        VAProfileH264High : VAEntrypointVLD

        • darkbasic

          I use both from my overlay:

          laptop ~ # emerge -pv x11-libs/libva x11-libs/libva-intel-driver

          These are the packages that would be merged, in order:

          Calculating dependencies… done!
          [ebuild R *] x11-libs/libva-9999::darkbasic USE=”opengl” VIDEO_CARDS=”intel -dummy -fglrx -nvidia” 0 kB
          [ebuild R *] x11-libs/libva-intel-driver-9999::darkbasic 0 kB

          Total: 2 packages (2 reinstalls), Size of downloads: 0 kB

          Anyway I think x11-libs/libva-intel-driver-9999::darkbasic *may* be enough (x11-libs/libva is similar to the ebuild in portage but pulls from g45-h264), I should ask an Intel developer to be sure anyway.

        • darkbasic

          laptop ~ # vainfo
          libva: libva version 0.32.0
          libva: va_getDriverName() returns 0
          libva: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
          libva: va_openDriver() returns 0
          vainfo: VA API version: 0.32
          vainfo: Driver version: Intel i965 driver – 1.0.14
          vainfo: Supported profile and entrypoints
          VAProfileMPEG2Simple : VAEntrypointVLD
          VAProfileMPEG2Main : VAEntrypointVLD
          VAProfileH264Baseline : VAEntrypointVLD
          VAProfileH264Main : VAEntrypointVLD
          VAProfileH264High : VAEntrypointVLD

  • darkbasic

    I noticed the ebuilds didn’t work anymore so I updated them, the following works flawlessly for me:

    [ebuild R *] x11-libs/libva-9999 USE=”X opengl -egl -wayland” VIDEO_CARDS=”intel -dummy -fglrx -nvidia” 0 kB
    [ebuild R *] x11-libs/libva-intel-driver-9999::linuxsystems USE=”X -wayland” 0 kB
    [ebuild R ~] media-plugins/gst-plugins-vaapi-0.4.2:0.10::linuxsystems USE=”X opengl -wayland” 0 kB

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>