# VAAPI anyone?



## petrus (Jul 26, 2010)

Does anyone have GPU decoding in vlc working on FreeBSD?  It appears that libva doesn't build at the moment on FreeBSD 8.1-RELEASE, and according to videolan.org this is a requirement.


----------



## lily (Jul 27, 2010)

What error you are getting? libva from git compiles fine here on 9-CURRENT with a few tweaks to the build glue.
	
	



```
$ vainfo
libva: libva version 0.31.1
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /home/holo/aaa/lib/dri/dummy_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.31
vainfo: Driver version: Dummy Driver 1.0
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointMoComp
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointMoComp
      VAProfileMPEG4Simple            : VAEntrypointVLD
      VAProfileMPEG4AdvancedSimple    : VAEntrypointVLD
      VAProfileMPEG4Main              : VAEntrypointVLD
      VAProfileH264Baseline           : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
```


```
diff --git a/configure.ac b/configure.ac
index 8792dcc..53369f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,8 @@ AC_PROG_CC
 AC_HEADER_STDC
 AC_SYS_LARGEFILE
 
+AC_CHECK_LIB(dl, dlopen)
+
 PKG_CHECK_MODULES([X11], [x11])
 PKG_CHECK_MODULES([XEXT],[xext])
 PKG_CHECK_MODULES([XFIXES], [xfixes])
diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am
index f458dd5..2932792 100644
--- a/dummy_drv_video/Makefile.am
+++ b/dummy_drv_video/Makefile.am
@@ -22,7 +22,7 @@
 
 dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la
 dummy_drv_video_ladir = @LIBVA_DRIVERS_PATH@
-dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined
+dummy_drv_video_la_LDFLAGS = -module -avoid-version
 dummy_drv_video_la_LIBADD = $(top_builddir)/va/$(libvabackendlib)
 dummy_drv_video_la_DEPENDENCIES = $(top_builddir)/va/$(libvabackendlib)
 
diff --git a/i965_drv_video/Makefile.am b/i965_drv_video/Makefile.am
index 058b525..e88aee0 100644
--- a/i965_drv_video/Makefile.am
+++ b/i965_drv_video/Makefile.am
@@ -26,8 +26,8 @@ AM_CFLAGS = -Wall -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 @DRM
 
 i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
 i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@
-i965_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined @DRM_LIBS@ -ldrm_intel
-i965_drv_video_la_LIBADD = ../va/libva-x11.la -lpthread
+i965_drv_video_la_LDFLAGS = -module -avoid-version @DRM_LIBS@ -ldrm_intel -pthread
+i965_drv_video_la_LIBADD = ../va/libva-x11.la
 
 i965_drv_video_la_SOURCES =	\
 	object_heap.c		\
diff --git a/test/putsurface/Makefile.am b/test/putsurface/Makefile.am
index fe18388..fd084da 100644
--- a/test/putsurface/Makefile.am
+++ b/test/putsurface/Makefile.am
@@ -23,8 +23,9 @@
 bin_PROGRAMS = putsurface
 
 AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/src/x11
+AM_LDFLAGS = -pthread
 
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) -lpthread
+TEST_LIBS = $(top_builddir)/va/$(libvabackendlib)
 
 putsurface_LDADD = $(TEST_LIBS)
 putsurface_SOURCES = putsurface.c
diff --git a/va/Makefile.am b/va/Makefile.am
index 8451a38..1eb64aa 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -30,12 +30,12 @@ LDADD = \
 libva_la_SOURCES = va.c va_trace.c
 libva_ladir = $(libdir)
 libva_la_LDFLAGS = $(LDADD) -no-undefined
-libva_la_LIBADD = $(LIBVA_LIBS) -ldl
+libva_la_LIBADD = $(LIBVA_LIBS)
 
 libva_tpi_la_SOURCES = va_tpi.c
 libva_tpi_ladir = $(libdir)
 libva_tpi_la_LDFLAGS = $(LDADD) -no-undefined
-libva_tpi_la_LIBADD = $(libvacorelib) -ldl
+libva_tpi_la_LIBADD = $(libvacorelib)
 libva_tpi_la_DEPENDENCIES = $(libvacorelib) 
 
 
@@ -43,7 +43,7 @@ libva_x11_backend      = libva-x11.la
 libva_x11_backenddir   = x11
 
 libva_x11_la_SOURCES = 
-libva_x11_la_LIBADD  = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(DRM_LIBS) $(XFIXES_LIBS) -ldl
+libva_x11_la_LIBADD  = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(DRM_LIBS) $(XFIXES_LIBS)
 libva_x11_la_LDFLAGS = $(LDADD)
 libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la
 
@@ -65,7 +65,7 @@ libva_glx_backend      = libva-glx.la
 libva_glx_backenddir   = glx
 
 libva_glx_la_SOURCES =
-libva_glx_la_LIBADD  = $(libvacorelib) glx/libva_glx.la libva-x11.la $(GL_DEPS_LIBS) -ldl
+libva_glx_la_LIBADD  = $(libvacorelib) glx/libva_glx.la libva-x11.la $(GL_DEPS_LIBS)
 libva_glx_la_LDFLAGS = $(LDADD)
 libva_glx_la_DEPENDENCIES = $(libvacorelib) glx/libva_glx.la libva-x11.la
 
diff --git a/va/android/Makefile.am b/va/android/Makefile.am
index d86ea86..95ba154 100644
--- a/va/android/Makefile.am
+++ b/va/android/Makefile.am
@@ -22,7 +22,7 @@ AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 $(DRM_CFLAGS)
 
 noinst_LTLIBRARIES = libva_dummy.la	
 
-libva_dummy_la_LIBADD = $(LIBVA_LIBS) -ldl -ludev
+libva_dummy_la_LIBADD = $(LIBVA_LIBS) -ludev
 
 libva_dummyincludedir = ${includedir}/va
```


----------



## petrus (Jul 27, 2010)

Thanks much for the patch! Installs now, but I get this fairly opaque error:


```
vainfo
libva: libva version 0.31.1
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/local/lib/dri/nvidia_drv_video.so
libva: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
```
Any thoughts?


----------



## lily (Jul 28, 2010)

You need vdpau backend for nvidia blobs. Refer to this guide.


----------



## petrus (Jul 28, 2010)

Thanks,

vdpau-video-0.6.10 is installed.  If, rather than using libva from git, I get it from splitted-desktop.com, and apply the debian/patches as directed, I get:



```
zfs# vainfo
libva: libva version 0.31.1-sds1
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/local/lib/va/drivers/nvidia_drv_video.so
Assertion failed: (vdp_status == VDP_STATUS_OK), function vdpau_do_Initialize, file vdpau_driver.c, line 233.
Abort (core dumped)
zfs#
```
So with this would you say libva is functional to this point and now I am in the realm of VDPAU not working, perhaps?  I'm using NVIDIA-FreeBSD-x86_64-256.35.


----------



## lily (Jul 29, 2010)

```
$ vainfo
libva: libva version 0.31.1-sds1
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /home/holo/aaa/lib/va/drivers/nvidia_drv_video.so
libva: va_openDriver() returns 0
vainfo: VA API version: 0.31
vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA API - 0.6.10
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
```
I'm using same driver as you on /head@r210488. Can you try to apply slightly tweaked patches[1][2] and run inside gdb(1)? Besides, being a bit more verbose about steps you do to build sources may help me reproduce your runtime error.


----------



## petrus (Jul 29, 2010)

Here are the complete build steps I used (including your patches):


```
zfs# C_INCLUDE_PATH=/usr/local/include
zfs# export C_INCLUDE_PATH
zfs# LIBRARY_PATH=/usr/local/lib
zfs# export LIBRARY_PATH
zfs# tar -xf libva-latest.tar
zfs# patch < libva.diff
zfs# cd libva-0.31.1/
zfs# (for p in debian/patches/*.patch; do patch -p1 < $p; done)
zfs# autoreconf
zfs# ./configure
zfs# mv libtool libtool.old
zfs# ln -s /usr/local/bin/libtool libtool
zfs# gmake install
zfs# cd ..
zfs# tar -xf vdpau-video-latest.tar 
zfs# patch < vdpau-video.diff 
zfs# cd vdpau-video-0.6.10
zfs# ./configure
zfs# gmake install
```

I neglected to mention before that the included libtool failed for me.  I needed to use the one I have (version 2.2.6b).  Do you believe this may be an issue?

Here's some gdb output.


```
zfs# gdb vainfo
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) r
Starting program: /usr/local/bin/vainfo 
libva: libva version 0.31.1-sds1
Xlib:  extension "XFree86-DRI" missing on display ":0.0".
libva: va_getDriverName() returns 0
libva: Trying to open /usr/local/lib/va/drivers/nvidia_drv_video.so
[New LWP 100955]
[New Thread 8016401c0 (LWP 100955)]
Assertion failed: (vdp_status == VDP_STATUS_OK), function vdpau_do_Initialize, file vdpau_driver.c, line 233.

Program received signal SIGABRT, Aborted.
[Switching to Thread 8016401c0 (LWP 100955)]
0x00000008013c93cc in kill () from /lib/libc.so.7
(gdb) backtrace
#0  0x00000008013c93cc in kill () from /lib/libc.so.7
#1  0x00000008013c81cb in abort () from /lib/libc.so.7
#2  0x00000008013b15a5 in __assert () from /lib/libc.so.7
#3  0x0000000801804be6 in __vaDriverInit_0_31_1_sds1 (ctx=0x80162e200) at vdpau_driver.c:233
#4  0x000000080064b048 in va_openDriver (dpy=0x80162d040, driver_name=Variable "driver_name" is not available.
) at va.c:232
#5  0x000000080064b672 in vaInitialize (dpy=0x80162d040, major_version=0x7fffffffe7bc, 
    minor_version=0x7fffffffe7b8) at va.c:415
#6  0x0000000000400b98 in main (argc=Variable "argc" is not available.
) at vainfo.c:104
(gdb)
```

Thanks much for the help.  Hope you have some insight.


----------



## lily (Jul 30, 2010)

Hmm, I'm not a coder but can you show more context? Compile with CFLAGS='-O0 -g3', set VDPAU_TRACE=1 in environment and type in gdb
`$ gdb vainfo`
[cmd='(gdb)']b vdpau_driver.c:233[/cmd]
[cmd='(gdb)']r[/cmd]
[cmd='(gdb)']set print pretty[/cmd]
[cmd='(gdb)']p vdp_status[/cmd]
[cmd='(gdb)']p *driver_data[/cmd]

BTW, did you try to play anything in `mplayer -vo vdpau...'? Does vdpau work at all? If yes can you show *vdpauinfo* output?


			
				petrus said:
			
		

> I neglected to mention before that the included libtool failed for me.  I needed to use the one I have (version 2.2.6b).  Do you believe this may be an issue?


I use `$ autoreconf -sif`


----------



## petrus (Jul 30, 2010)

Yeah, so vdpau does not appear to work at all.  The gdb output you asked about is here

I just installed mplayer with vdpau from 8.1-RELEASE ports. Great suggestion.  libvdpau and vdpauinfo are from git today at freedesktop.org. NVIDIA driver is from NVidia's website a week ago.


```
$mplayer -vo help
MPlayer SVN-r30341-snapshot-4.2.1 (C) 2000-2009 MPlayer Team
Available video output drivers:
	vdpau	VDPAU with X11
	xv	X11/Xv
	x11	X11 ( XImage/Shm )
	xover	General X11 driver for overlay capable video output drivers
	gl	X11 (OpenGL)
	gl2	X11 (OpenGL) - multiple textures version
	matrixview	MatrixView (OpenGL)
	dga	DGA ( Direct Graphic Access V2.0 )
	xvidix	X11 (VIDIX)
	cvidix	console VIDIX
	null	Null video output
	mpegpes	MPEG-PES to DVB card
	yuv4mpeg	yuv4mpeg output for mjpegtools
	png	PNG file
	jpeg	JPEG file
	gif89a	animated GIF output
	tga	Targa output
	pnm	PPM/PGM/PGMYUV file
	md5sum	md5sum of each frame
```

And attempting to use it yields:

```
$ mplayer -vo vdpau officespace.mp4
MPlayer SVN-r30341-snapshot-4.2.1 (C) 2000-2009 MPlayer Team

Playing officespace.mp4.
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x807cc7010]max_analyze_duration reached
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO:  [MP4V]  640x480  24bpp  24.000 fps  613.8 kbps (74.9 kbyte/s)
Clip info:
 major_brand: isom
 minor_version: 0
 compatible_brands: mp41
[vdpau] Error when calling vdp_device_create_x11: 1
Error opening/initializing the selected video_out (-vo) device.
```


```
$ vdpauinfo
display: :0.0   screen: 0
Error creating VDPAU device: 1
```

This has to be something simple I'm missing, if it's working for you. An NVidia Quadro FX 1400 should be sufficient, right?


----------



## lily (Jul 31, 2010)

Quadro FX 1400 doesn't have any VDPAU features, cf. supported chips on 256.35.
OTOH, my card, 9600 GT has feature set *A*

```
$ vdpauinfo
display: :0.0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  256.35  Wed Jun 16 18:51:41 PDT 2010

Video surface:

name   width height types
-------------------------------------------
420     4096  4096  NV12 YV12
422     4096  4096  UYVY YUYV

Decoder capabilities:

name               level macbs width height
-------------------------------------------
MPEG1                 0  8192  2048  2048
MPEG2_SIMPLE          3  8192  2048  2048
MPEG2_MAIN            3  8192  2048  2048
H264_MAIN            41  8192  2048  2048
H264_HIGH            41  8192  2048  2048
VC1_SIMPLE            1  8190  2048  2048
VC1_MAIN              2  8190  2048  2048
VC1_ADVANCED          4  8190  2048  2048

Output surface:

name              width height nat types
----------------------------------------------------
B8G8R8A8          8192  8192    y  Y8U8V8A8 V8U8Y8A8
R10G10B10A2       8192  8192    y  Y8U8V8A8 V8U8Y8A8

Bitmap surface:

name              width height
------------------------------
B8G8R8A8          8192  8192
R8G8B8A8          8192  8192
R10G10B10A2       8192  8192
B10G10R10A2       8192  8192
A8                8192  8192

Video mixer:

feature name                    sup
------------------------------------
DEINTERLACE_TEMPORAL             y
DEINTERLACE_TEMPORAL_SPATIAL     y
INVERSE_TELECINE                 y
NOISE_REDUCTION                  y
SHARPNESS                        y
LUMA_KEY                         y
HIGH QUALITY SCALING - L1        -
HIGH QUALITY SCALING - L2        -
HIGH QUALITY SCALING - L3        -
HIGH QUALITY SCALING - L4        -
HIGH QUALITY SCALING - L5        -
HIGH QUALITY SCALING - L6        -
HIGH QUALITY SCALING - L7        -
HIGH QUALITY SCALING - L8        -
HIGH QUALITY SCALING - L9        -

parameter name                  sup      min      max
-----------------------------------------------------
VIDEO_SURFACE_WIDTH              y         1     4096
VIDEO_SURFACE_HEIGHT             y         1     4096
CHROMA_TYPE                      y
LAYERS                           y         0        4

attribute name                  sup      min      max
-----------------------------------------------------
BACKGROUND_COLOR                 y
CSC_MATRIX                       y
NOISE_REDUCTION_LEVEL            y      0.00     1.00
SHARPNESS_LEVEL                  y     -1.00     1.00
LUMA_KEY_MIN_LUMA                y
LUMA_KEY_MAX_LUMA                y
```


----------



## petrus (Jul 31, 2010)

Well I suppose I'll be buying a new video card now :\  You've been more than helpful, thanks again, this has been very educational.  And I may resurrect this thread...


----------

