summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2011-10-24 13:51:10 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2011-10-24 13:51:10 +0800
commit9a07024a9570459f1c41ed81f5a2db2f96f66ffa (patch)
treec1fb924bf3ce6d88300aa1d7c8334457010a6db2
parentdf732e430001bf71e69d89ebcdb712799c011352 (diff)
parentd457eab70e4bd75ccf6539078eb14d208a30dafc (diff)
Merge branch 'master' into vaapi-ext
Conflicts: configure.ac test/encode/h264encode_common.c test/vainfo/vainfo.c
-rw-r--r--Makefile.am34
-rw-r--r--build/gen_version.sh22
-rw-r--r--config.h81
-rw-r--r--configure.ac99
-rw-r--r--debian.upstream/Makefile.am32
-rw-r--r--debian.upstream/README.Debian (renamed from debian/README.Debian)0
-rw-r--r--debian.upstream/changelog.in5
-rw-r--r--debian.upstream/compat (renamed from debian/compat)0
-rw-r--r--debian.upstream/control.in52
-rw-r--r--debian.upstream/copyright (renamed from debian/copyright)0
-rw-r--r--debian.upstream/libva-dev.dirs (renamed from debian/libva-dev.dirs)0
-rw-r--r--debian.upstream/libva-dev.install3
-rw-r--r--debian.upstream/libva1.dirs (renamed from debian/libva1.dirs)0
-rw-r--r--debian.upstream/libva1.install2
-rwxr-xr-xdebian.upstream/rules15
-rw-r--r--debian/changelog27
-rw-r--r--debian/control36
-rw-r--r--debian/dirs2
-rw-r--r--debian/docs0
-rw-r--r--debian/files2
-rw-r--r--debian/libva-dev.install8
-rw-r--r--debian/libva-dev.substvars1
-rw-r--r--debian/libva1.install2
-rw-r--r--debian/libva1.substvars1
-rwxr-xr-xdebian/rules114
-rw-r--r--dummy_drv_video/Makefile.am2
-rw-r--r--pkgconfig/Makefile.am47
-rw-r--r--pkgconfig/libva-egl.pc.in (renamed from libva-egl.pc.in)2
-rw-r--r--pkgconfig/libva-glx.pc.in (renamed from libva-glx.pc.in)2
-rw-r--r--pkgconfig/libva-tpi.pc.in (renamed from libva-tpi.pc.in)2
-rw-r--r--pkgconfig/libva-x11.pc.in (renamed from libva-x11.pc.in)2
-rw-r--r--pkgconfig/libva.pc.in (renamed from libva.pc.in)2
-rw-r--r--test/basic/test_08.c2
-rw-r--r--test/basic/test_10.c2
-rw-r--r--test/basic/test_11.c2
-rw-r--r--test/basic/test_common.c5
-rw-r--r--test/encode/h264encode_common.c2
-rw-r--r--test/vainfo/Makefile.am7
-rw-r--r--test/vainfo/vainfo.c7
-rwxr-xr-xva/Android.mk18
-rw-r--r--va/Makefile.am1
-rw-r--r--va/android/va_android.cpp15
-rw-r--r--va/va.c225
-rw-r--r--va/va.h4
-rw-r--r--va/va_backend_tpi.h52
-rw-r--r--va/va_fool.c568
-rw-r--r--va/va_fool.h90
-rw-r--r--va/va_fool_getframe.c210
-rw-r--r--va/va_tpi.c32
-rw-r--r--va/va_tpi.h21
-rw-r--r--va/va_trace.c221
-rw-r--r--va/va_trace.h37
-rw-r--r--va/va_version.h87
-rw-r--r--va/va_version.h.in28
-rw-r--r--va/x11/va_fglrx.c43
-rw-r--r--va/x11/va_x11.c13
56 files changed, 907 insertions, 1382 deletions
diff --git a/Makefile.am b/Makefile.am
index f0223e0..331394b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,24 +22,24 @@
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = va test
-if BUILD_DUMMY_DRIVER
-SUBDIRS += dummy_drv_video
-endif
+SUBDIRS = va dummy_drv_video pkgconfig test debian.upstream
-pcfiles = libva.pc libva-tpi.pc
-pcfiles += libva-x11.pc
-if USE_GLX
-pcfiles += libva-glx.pc
-endif
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = \
+ aclocal.m4 compile config.guess config.sub \
+ configure depcomp install-sh ltmain.sh \
+ Makefile.in missing
-if USE_EGL
-pcfiles += libva-egl.pc
-endif
+DEB_BUILDDIR = debian.build
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = $(pcfiles)
+deb:
+ @[ -d debian ] || ln -s debian.upstream debian
+ dpkg-buildpackage -rfakeroot -uc -us
-EXTRA_DIST = libva.pc.in libva-tpi.pc.in libva-x11.pc.in libva-glx.pc.in libva-egl.pc.in
-
-CLEANFILES = $(pcfiles)
+deb.upstream: dist
+ -mkdir -p $(DEB_BUILDDIR)
+ cd $(DEB_BUILDDIR) && \
+ rm -rf $(PACKAGE)-$(VERSION) && \
+ tar zxvf ../$(PACKAGE)-$(VERSION).tar.gz && \
+ cd $(PACKAGE)-$(VERSION) && \
+ $(MAKE) deb -f Makefile.am
diff --git a/build/gen_version.sh b/build/gen_version.sh
index dd01d95..f594ddd 100644
--- a/build/gen_version.sh
+++ b/build/gen_version.sh
@@ -12,21 +12,21 @@ parse_configure() {
}
if test -f "${libva_topdir}/configure.ac"; then
- libva_major_version=`parse_configure_ac libva_major_version`
- libva_minor_version=`parse_configure_ac libva_minor_version`
- libva_micro_version=`parse_configure_ac libva_micro_version`
+ va_api_major_version=`parse_configure_ac va_api_major_version`
+ va_api_minor_version=`parse_configure_ac va_api_minor_version`
+ va_api_micro_version=`parse_configure_ac va_api_micro_version`
elif test -f "${libva_topdir}/configure"; then
- libva_major_version=`parse_configure LIBVA_MAJOR_VERSION`
- libva_minor_version=`parse_configure LIBVA_MINOR_VERSION`
- libva_micro_version=`parse_configure LIBVA_MICRO_VERSION`
+ va_api_major_version=`parse_configure VA_API_MAJOR_VERSION`
+ va_api_minor_version=`parse_configure VA_API_MINOR_VERSION`
+ va_api_micro_version=`parse_configure VA_API_MICRO_VERSION`
else
echo "ERROR: configure or configure.ac file not found in $libva_topdir/"
exit 1
fi
-libva_version="$libva_major_version.$libva_minor_version.$libva_micro_version"
+va_api_version="$va_api_major_version.$va_api_minor_version.$va_api_micro_version"
-sed -e "s/@LIBVA_MAJOR_VERSION@/${libva_major_version}/" \
- -e "s/@LIBVA_MINOR_VERSION@/${libva_minor_version}/" \
- -e "s/@LIBVA_MICRO_VERSION@/${libva_micro_version}/" \
- -e "s/@LIBVA_VERSION@/${libva_version}/" \
+sed -e "s/@VA_API_MAJOR_VERSION@/${va_api_major_version}/" \
+ -e "s/@VA_API_MINOR_VERSION@/${va_api_minor_version}/" \
+ -e "s/@VA_API_MICRO_VERSION@/${va_api_micro_version}/" \
+ -e "s/@VA_API_VERSION@/${va_api_version}/" \
$version_h_in
diff --git a/config.h b/config.h
deleted file mode 100644
index 943469d..0000000
--- a/config.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <GL/glx.h> header file. */
-#define HAVE_GL_GLX_H 1
-
-/* Define to 1 if you have the <GL/gl.h> header file. */
-#define HAVE_GL_GL_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "libva"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "waldo.bastian@intel.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libva"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libva 0.32.0"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libva"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.32.0"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Defined to the versioned __vaDriverInit function name */
-#define VA_DRIVER_INIT_FUNC __vaDriverInit_0_32
-
-/* Defined to the versioned __vaDriverInit function name (in string form) */
-#define VA_DRIVER_INIT_FUNC_S "__vaDriverInit_0_32"
-
-/* Version number of package */
-#define VERSION "0.32.0"
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#define _FILE_OFFSET_BITS 64
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
diff --git a/configure.ac b/configure.ac
index eb886e8..1972cf7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,21 +20,62 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# VA-API version
+# - increment major for any ABI change (which shall not occur!)
+# - increment minor for any interface change (e.g. new/modified function)
+# - increment micro for any other change (new flag, new codec definition, etc.)
+# - reset micro version to zero when minor version is incremented
+# - reset minor version to zero when major version is incremented
+m4_define([va_api_major_version], [0])
+m4_define([va_api_minor_version], [32])
+m4_define([va_api_micro_version], [0])
+
+m4_define([va_api_version],
+ [va_api_major_version.va_api_minor_version.va_api_micro_version])
+
# libva package version number, (as distinct from shared library version)
-m4_define([libva_major_version], [0])
-m4_define([libva_minor_version], [32])
-m4_define([libva_micro_version], [0])
+# XXX: we want the package version to remain at 1.0.x for VA-API 0.32.y
+#
+# - major version is automatically generated from VA-API major version
+# - minor version is automatically generated from VA-API minor version
+# - increment micro for any library release
+# - reset micro version to zero when VA-API major or minor version is changed
+m4_define([libva_major_version], [m4_eval(va_api_major_version + 1)])
+m4_define([libva_minor_version], [m4_eval(va_api_minor_version - 32)])
+m4_define([libva_micro_version], [15])
+m4_define([libva_pre_version], [1])
m4_define([libva_version],
[libva_major_version.libva_minor_version.libva_micro_version])
+m4_if(libva_pre_version, [0], [], [
+m4_append([libva_version], libva_pre_version, [.pre])
+])
-# if the library source code has changed, increment revision
-m4_define([libva_lt_revision], [14])
-# if any interface was added/removed/changed, then inc current, reset revision
-m4_define([libva_lt_current], [1])
-# if any interface was added since last public release, then increment age
-# if any interface was removed since last public release, then set age to 0
-m4_define([libva_lt_age], [0])
+# libva library version number (generated, do not change)
+# XXX: we want the SONAME to remain at libva.so.1 for VA-API major == 0
+#
+# The library name is generated libva.<x>.<y>.0 where
+# <x> = VA-API major version + 1
+# <y> = 100 * VA-API minor version + VA-API micro version
+#
+# For example:
+# VA-API 0.32.0 generates libva.so.1.3200.0
+# VA-API 0.34.1 generates libva.so.1.3401.0
+# VA-API 1.2.13 generates libva.so.2.213.0
+m4_define([libva_interface_bias], [m4_eval(va_api_major_version + 1)])
+m4_define([libva_interface_age], [0])
+m4_define([libva_binary_age],
+ [m4_eval(100 * va_api_minor_version + va_api_micro_version - libva_interface_age)])
+
+m4_define([libva_lt_current],
+ [m4_eval(100 * va_api_minor_version + va_api_micro_version + libva_interface_bias)])
+m4_define([libva_lt_revision],
+ [m4_eval(libva_interface_age)])
+m4_define([libva_lt_age],
+ [m4_eval(libva_binary_age - libva_interface_age)])
+
+# libdrm minimun version requirement
+m4_define([libdrm_version], [2.4])
AC_PREREQ(2.57)
AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva)
@@ -44,6 +85,15 @@ AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER([config.h])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+VA_API_MAJOR_VERSION=va_api_major_version
+VA_API_MINOR_VERSION=va_api_minor_version
+VA_API_MICRO_VERSION=va_api_micro_version
+VA_API_VERSION=va_api_version
+AC_SUBST(VA_API_MAJOR_VERSION)
+AC_SUBST(VA_API_MINOR_VERSION)
+AC_SUBST(VA_API_MICRO_VERSION)
+AC_SUBST(VA_API_VERSION)
+
LIBVA_MAJOR_VERSION=libva_major_version
LIBVA_MINOR_VERSION=libva_minor_version
LIBVA_MICRO_VERSION=libva_micro_version
@@ -95,10 +145,11 @@ AC_SYS_LARGEFILE
PKG_CHECK_MODULES([X11], [x11])
PKG_CHECK_MODULES([XEXT],[xext])
PKG_CHECK_MODULES([XFIXES], [xfixes])
-PKG_CHECK_MODULES([DRM], [libdrm])
-PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.2], [gen4asm=yes], [gen4asm=no])
-AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
+# Check for recent enough DRM
+LIBDRM_VERSION=libdrm_version
+PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION])
+AC_SUBST(LIBDRM_VERSION)
if test x$enable_dummy_backend = xyes; then
PKG_CHECK_MODULES([UDEV], [libudev], [libudev=yes], [libudev=no])
@@ -128,14 +179,6 @@ AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes")
USE_EGL="yes"
AM_CONDITIONAL(USE_EGL, test "$USE_EGL" = "yes")
-
-# Make sure drivers use the correctly versioned __vaDriverInit*() function name
-VA_DRIVER_INIT_FUNC="__vaDriverInit_${LIBVA_MAJOR_VERSION}_${LIBVA_MINOR_VERSION}"
-AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC], [$VA_DRIVER_INIT_FUNC],
- [Defined to the versioned __vaDriverInit function name])
-AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC_S], ["$VA_DRIVER_INIT_FUNC"],
- [Defined to the versioned __vaDriverInit function name (in string form)])
-
# We only need the headers, we don't link against the DRM libraries
LIBVA_CFLAGS="$DRM_CFLAGS"
AC_SUBST(LIBVA_CFLAGS)
@@ -152,6 +195,7 @@ AC_SUBST([libvabackendlib])
AC_OUTPUT([
Makefile
+ debian.upstream/Makefile
va/Makefile
va/va_version.h
va/x11/Makefile
@@ -166,17 +210,18 @@ AC_OUTPUT([
test/encode/Makefile
test/vainfo/Makefile
test/transcode/Makefile
- libva.pc
- libva-x11.pc
- libva-glx.pc
- libva-egl.pc
- libva-tpi.pc
+ pkgconfig/libva-egl.pc
+ pkgconfig/libva-glx.pc
+ pkgconfig/libva-tpi.pc
+ pkgconfig/libva-x11.pc
+ pkgconfig/libva.pc
+ pkgconfig/Makefile
])
# Print a small summary
echo ""
-echo "libva - ${LIBVA_VERSION}"
+echo "libva - ${LIBVA_VERSION} (VA-API ${VA_API_VERSION})"
echo ""
echo " • Global :"
diff --git a/debian.upstream/Makefile.am b/debian.upstream/Makefile.am
new file mode 100644
index 0000000..56dc98a
--- /dev/null
+++ b/debian.upstream/Makefile.am
@@ -0,0 +1,32 @@
+DEBIANFILES = \
+ README.Debian \
+ changelog.in \
+ compat \
+ control.in \
+ copyright \
+ libva-dev.dirs \
+ libva-dev.install \
+ libva1.dirs \
+ libva1.install \
+ rules \
+ $(NULL)
+
+DEBIANGENFILES = \
+ changelog \
+ control \
+ $(NULL)
+
+EXTRA_DIST = $(DEBIANFILES)
+
+dist_noinst_DATA = $(DEBIANGENFILES)
+
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in $(DEBIANGENFILES)
+
+$(DEBIANGENFILES): %: %.in Makefile
+ -sed \
+ -e 's|\@DATE\@|'"`LC_ALL=C date +'%a, %d %b %Y %X %z'`"'|' \
+ -e 's|\@LIBDRM_VERSION\@|$(LIBDRM_VERSION)|' \
+ -e 's|\@LIBVA_PACKAGE_VERSION\@|$(LIBVA_PACKAGE_VERSION)|' \
+ -e 's|\@PACKAGE_VERSION\@|$(PACKAGE_VERSION)|' \
+ $< > $@
diff --git a/debian/README.Debian b/debian.upstream/README.Debian
index d10d702..d10d702 100644
--- a/debian/README.Debian
+++ b/debian.upstream/README.Debian
diff --git a/debian.upstream/changelog.in b/debian.upstream/changelog.in
new file mode 100644
index 0000000..397b5eb
--- /dev/null
+++ b/debian.upstream/changelog.in
@@ -0,0 +1,5 @@
+libva (@PACKAGE_VERSION@-1) unstable; urgency=low
+
+ * Autogenerated package, see NEWS file for ChangeLog.
+
+ -- Gwenole Beauchesne <gwenole.beauchesne@intel.com> @DATE@
diff --git a/debian/compat b/debian.upstream/compat
index 7ed6ff8..7ed6ff8 100644
--- a/debian/compat
+++ b/debian.upstream/compat
diff --git a/debian.upstream/control.in b/debian.upstream/control.in
new file mode 100644
index 0000000..f8291c5
--- /dev/null
+++ b/debian.upstream/control.in
@@ -0,0 +1,52 @@
+Source: libva
+Priority: extra
+Maintainer: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
+Build-Depends: automake,
+ autotools-dev,
+ cdbs,
+ debhelper (>= 5),
+ libdrm-dev (>= @LIBDRM_VERSION@),
+ libgl-dev,
+ libtool,
+ libxext-dev,
+ libxfixes-dev,
+ pkg-config,
+ x11proto-xext-dev
+Standards-Version: 3.7.2
+Section: libs
+
+Package: libva-dev
+Section: libdevel
+Architecture: any
+Depends: libva1 (= ${binary:Version}),
+ libdrm-dev (>= @LIBDRM_VERSION@),
+ libgl-dev,
+ pkg-config
+Conflicts: libva-0.29-dev
+Replaces: libva-0.29-dev
+Description: Video Acceleration (VA) API for Linux -- development files
+ The libva library implements the Video Acceleration (VA) API for Linux.
+ The library loads a hardware dependendent driver.
+ .
+ This package provides the development environment for libva.
+
+Package: libva1
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}
+Conflicts: libva-0.29-0
+Replaces: libva-0.29-0
+Provides: libva-0.29-0
+Description: Video Acceleration (VA) API for Linux -- runtime
+ The libva library implements the Video Acceleration (VA) API for Linux.
+ The library loads a hardware dependendent driver.
+
+Package: libva1-dbg
+Section: libdevel
+Architecture: any
+Depends: libva1 (= ${Source-Version})
+Description: Video Acceleration (VA) API for Linux -- runtime
+ The libva library implements the Video Acceleration (VA) API for Linux.
+ The library loads a hardware dependendent driver.
+ .
+ This package contains the debug files.
diff --git a/debian/copyright b/debian.upstream/copyright
index 38b60ef..38b60ef 100644
--- a/debian/copyright
+++ b/debian.upstream/copyright
diff --git a/debian/libva-dev.dirs b/debian.upstream/libva-dev.dirs
index 4418816..4418816 100644
--- a/debian/libva-dev.dirs
+++ b/debian.upstream/libva-dev.dirs
diff --git a/debian.upstream/libva-dev.install b/debian.upstream/libva-dev.install
new file mode 100644
index 0000000..2611cdb
--- /dev/null
+++ b/debian.upstream/libva-dev.install
@@ -0,0 +1,3 @@
+debian/tmp/usr/include/va/va*.h
+debian/tmp/usr/lib/libva*.so
+debian/tmp/usr/lib/pkgconfig/libva*.pc
diff --git a/debian/libva1.dirs b/debian.upstream/libva1.dirs
index 6845771..6845771 100644
--- a/debian/libva1.dirs
+++ b/debian.upstream/libva1.dirs
diff --git a/debian.upstream/libva1.install b/debian.upstream/libva1.install
new file mode 100644
index 0000000..ddfd8ed
--- /dev/null
+++ b/debian.upstream/libva1.install
@@ -0,0 +1,2 @@
+debian/tmp/usr/lib/libva.so.*
+debian/tmp/usr/lib/libva-*.so.*
diff --git a/debian.upstream/rules b/debian.upstream/rules
new file mode 100755
index 0000000..27b2639
--- /dev/null
+++ b/debian.upstream/rules
@@ -0,0 +1,15 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+include /usr/share/cdbs/1/rules/utils.mk
+
+# Allow SMP build
+ifeq ($(DEBIAN_BUILD_NCPUS),)
+ DEBIAN_BUILD_NCPUS = $(shell /usr/bin/getconf _NPROCESSORS_ONLN)
+endif
+ifneq ($(DEBIAN_BUILD_NCPUS),)
+ EXTRA_MAKE_FLAGS += -j$(DEBIAN_BUILD_NCPUS)
+endif
+MAKE += $(EXTRA_MAKE_FLAGS)
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 1f60620..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,27 +0,0 @@
-libva (0.24-1) unstable; urgency=low
-
- * Updated to v0.24
- * Display attributes added
- * H264 parameter fixes
- * Swapped vaGetConfigAttributes and vaQueryConfigAttributes
-
- -- Waldo Bastian <waldo.bastian@intel.com> Thu, 20 Sep 2007 15:08:04 -0700
-
- * Updated to v0.22
- * VAImage and VASubpicture added
-
- -- Waldo Bastian <waldo.bastian@intel.com> Fri, 07 Sep 2007 04:32:28 -0700
-
- * Updated to v0.20
- * Clean up & exporting DRI interface
-
- -- Waldo Bastian <waldo.bastian@intel.com> Thu, 09 Aug 2007 11:49:43 -0700
-
- * Add VA_INVALID_SURFACE
-
- -- Waldo Bastian <waldo.bastian@intel.com> Wed, 11 Jul 2007 17:24:10 -0700
-
- * Initial release of libva
-
- -- Waldo Bastian <waldo.bastian@intel.com> Mon, 18 Jun 2007 21:35:31 -0700
-
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 7ad39bc..0000000
--- a/debian/control
+++ /dev/null
@@ -1,36 +0,0 @@
-Source: libva
-Priority: extra
-Maintainer: Waldo Bastian <waldo.bastian@intel.com>
-Build-Depends: debhelper (>= 5),
- autotools-dev,
- libdrm-dev (>= 2.3.0),
- mesa-common-dev,
- x11proto-gl-dev,
- x11proto-xext-dev,
- libxext-dev,
- pkg-config
-Standards-Version: 3.7.2
-Section: libs
-
-Package: libva-dev
-Section: libdevel
-Architecture: any
-Depends: libva1 (= ${binary:Version}),
- libdrm-dev (>= 2.3.0),
- pkg-config
-Description: Video Acceleration (VA) API for Linux -- development files
- The libva library implements the Video Acceleration (VA) API for Linux.
- The library loads a hardware dependendent driver.
- .
- This package provides the development environment for libva.
-
-Package: libva1
-Section: libs
-Architecture: any
-Depends: libx11-6,
- libxext6,
- libdrm2 (>= 2.3.0)
-Description: Video Acceleration (VA) API for Linux -- runtime
- The libva library implements the Video Acceleration (VA) API for Linux.
- The library loads a hardware dependendent driver.
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index ca882bb..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/sbin
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index e69de29..0000000
--- a/debian/docs
+++ /dev/null
diff --git a/debian/files b/debian/files
deleted file mode 100644
index bbaff89..0000000
--- a/debian/files
+++ /dev/null
@@ -1,2 +0,0 @@
-libva-dev_0.24-1_i386.deb libdevel extra
-libva1_0.24-1_i386.deb libs extra
diff --git a/debian/libva-dev.install b/debian/libva-dev.install
deleted file mode 100644
index d86b3bf..0000000
--- a/debian/libva-dev.install
+++ /dev/null
@@ -1,8 +0,0 @@
-debian/tmp/usr/include/va.h
-debian/tmp/usr/include/va_x11.h
-debian/tmp/usr/include/va_backend.h
-debian/tmp/usr/include/va_dri.h
-debian/tmp/usr/X11R6/lib/modules/dri/dummy_drv_video.*
-debian/tmp/usr/lib/libva.la
-debian/tmp/usr/lib/libva.so
-debian/tmp/usr/lib/pkgconfig/libva.pc
diff --git a/debian/libva-dev.substvars b/debian/libva-dev.substvars
deleted file mode 100644
index 17c2baa..0000000
--- a/debian/libva-dev.substvars
+++ /dev/null
@@ -1 +0,0 @@
-shlibs:Depends=libc6 (>= 2.6-1)
diff --git a/debian/libva1.install b/debian/libva1.install
deleted file mode 100644
index 499e94b..0000000
--- a/debian/libva1.install
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/tmp/usr/lib/libva.so.*
-debian/tmp/usr/bin/vainfo
diff --git a/debian/libva1.substvars b/debian/libva1.substvars
deleted file mode 100644
index 9e3d1d8..0000000
--- a/debian/libva1.substvars
+++ /dev/null
@@ -1 +0,0 @@
-shlibs:Depends=libc6 (>= 2.6-1), libx11-6, libxext6
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 60fbc95..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-# shared library versions, option 1
-#version=2.0.5
-#major=2
-# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
-version=`ls src/.libs/lib*.so.* | \
- awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
-#major=`ls src/.libs/lib*.so.* | \
-# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
-
-config.status: configure
- dh_testdir
- # Add here commands to configure the package.
-ifneq "$(wildcard /usr/share/misc/config.sub)" ""
- cp -f /usr/share/misc/config.sub config.sub
-endif
-ifneq "$(wildcard /usr/share/misc/config.guess)" ""
- cp -f /usr/share/misc/config.guess config.guess
-endif
- ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
-
-
-build: build-stamp
-build-stamp: config.status
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) distclean
- rm -f config.sub config.guess
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/tmp
- $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_python
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am
index 2ca506c..245e6e8 100644
--- a/dummy_drv_video/Makefile.am
+++ b/dummy_drv_video/Makefile.am
@@ -22,6 +22,7 @@
INCLUDES = -I$(top_srcdir)
+if BUILD_DUMMY_DRIVER
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
@@ -29,3 +30,4 @@ dummy_drv_video_la_LIBADD = $(top_builddir)/va/$(libvabackendlib)
dummy_drv_video_la_DEPENDENCIES = $(top_builddir)/va/$(libvabackendlib)
dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c
noinst_HEADERS = dummy_drv_video.h object_heap.h
+endif
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am
new file mode 100644
index 0000000..f595413
--- /dev/null
+++ b/pkgconfig/Makefile.am
@@ -0,0 +1,47 @@
+# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+pcfiles = libva.pc
+pcfiles += libva-tpi.pc
+pcfiles += libva-x11.pc
+if USE_GLX
+pcfiles += libva-glx.pc
+endif
+if USE_EGL
+pcfiles += libva-egl.pc
+endif
+
+all_pcfiles_in = libva.pc.in
+all_pcfiles_in += libva-tpi.pc.in
+all_pcfiles_in += libva-x11.pc.in
+all_pcfiles_in += libva-glx.pc.in
+all_pcfiles_in += libva-egl.pc.in
+
+pkgconfigdir = @pkgconfigdir@
+pkgconfig_DATA = $(pcfiles)
+
+EXTRA_DIST = $(all_pcfiles_in)
+
+DISTCLEANFILES = $(pcfiles)
+
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/libva-egl.pc.in b/pkgconfig/libva-egl.pc.in
index 3d621b2..d80fcc8 100644
--- a/libva-egl.pc.in
+++ b/pkgconfig/libva-egl.pc.in
@@ -7,7 +7,7 @@ display=egl
Name: libva-${display}
Description: Userspace Video Acceleration (VA) ${display} interface
Requires: libva
-Version: @PACKAGE_VERSION@
+Version: @VA_API_VERSION@
Libs: -L${libdir} -lva-${display}
Cflags: -I${includedir}
diff --git a/libva-glx.pc.in b/pkgconfig/libva-glx.pc.in
index 2019915..8599866 100644
--- a/libva-glx.pc.in
+++ b/pkgconfig/libva-glx.pc.in
@@ -7,6 +7,6 @@ display=glx
Name: libva-${display}
Description: Userspace Video Acceleration (VA) ${display} interface
Requires: libva
-Version: @PACKAGE_VERSION@
+Version: @VA_API_VERSION@
Libs: -L${libdir} -lva-${display}
Cflags: -I${includedir}
diff --git a/libva-tpi.pc.in b/pkgconfig/libva-tpi.pc.in
index 43616c0..bc7fdd7 100644
--- a/libva-tpi.pc.in
+++ b/pkgconfig/libva-tpi.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libva-tpi
Description: Userspace Video Acceleration (VA) 3rd party interface
Requires: libva
-Version: @PACKAGE_VERSION@
+Version: @VA_API_VERSION@
Libs: -L${libdir} -lva-tpi
Cflags: -I${includedir}
diff --git a/libva-x11.pc.in b/pkgconfig/libva-x11.pc.in
index 6dde07f..4e7330c 100644
--- a/libva-x11.pc.in
+++ b/pkgconfig/libva-x11.pc.in
@@ -7,6 +7,6 @@ display=x11
Name: libva-${display}
Description: Userspace Video Acceleration (VA) ${display} interface
Requires: libva
-Version: @PACKAGE_VERSION@
+Version: @VA_API_VERSION@
Libs: -L${libdir} -lva-${display}
Cflags: -I${includedir}
diff --git a/libva.pc.in b/pkgconfig/libva.pc.in
index 60f1483..8b03f98 100644
--- a/libva.pc.in
+++ b/pkgconfig/libva.pc.in
@@ -6,6 +6,6 @@ driverdir=@LIBVA_DRIVERS_PATH@
Name: libva
Description: Userspace Video Acceleration (VA) core interface
-Version: @PACKAGE_VERSION@
+Version: @VA_API_VERSION@
Libs: -L${libdir} -lva
Cflags: -I${includedir}
diff --git a/test/basic/test_08.c b/test/basic/test_08.c
index 8c743b6..ac0c09d 100644
--- a/test/basic/test_08.c
+++ b/test/basic/test_08.c
@@ -66,7 +66,7 @@ test_size_t test_sizes[] = {
void test()
{
VASurfaceID surfaces[NUM_SIZES+1];
- int i;
+ unsigned int i;
memset(surfaces, 0xff, sizeof(surfaces));
diff --git a/test/basic/test_10.c b/test/basic/test_10.c
index 6a7b978..3d6625e 100644
--- a/test/basic/test_10.c
+++ b/test/basic/test_10.c
@@ -103,7 +103,7 @@ unsigned int buffer_sizes[] =
void test()
{
VABufferID buffer_ids[NUM_BUFFER_TYPES+1];
- int i;
+ unsigned int i;
memset(buffer_ids, 0xff, sizeof(buffer_ids));
for(i=0; i < NUM_BUFFER_TYPES; i++)
{
diff --git a/test/basic/test_11.c b/test/basic/test_11.c
index 8f3c4b8..5c20e2b 100644
--- a/test/basic/test_11.c
+++ b/test/basic/test_11.c
@@ -104,7 +104,7 @@ void test()
{
VABufferID buffer_ids[NUM_BUFFER_TYPES+1];
uint32_t *input_data[NUM_BUFFER_TYPES];
- int i, j;
+ unsigned int i, j;
memset(buffer_ids, 0xff, sizeof(buffer_ids));
for(i=0; i < NUM_BUFFER_TYPES; i++)
{
diff --git a/test/basic/test_common.c b/test/basic/test_common.c
index ae730a4..5f93c25 100644
--- a/test/basic/test_common.c
+++ b/test/basic/test_common.c
@@ -96,12 +96,15 @@ const char *profile2string(VAProfile profile)
PROFILE(MPEG4Simple)
PROFILE(MPEG4AdvancedSimple)
PROFILE(MPEG4Main)
+ PROFILE(H263Baseline)
PROFILE(H264Baseline)
PROFILE(H264Main)
PROFILE(H264High)
+ PROFILE(H264ConstrainedBaseline)
PROFILE(VC1Simple)
PROFILE(VC1Main)
PROFILE(VC1Advanced)
+ PROFILE(JPEGBaseline)
}
ASSERT(0);
return "Unknown";
@@ -118,6 +121,8 @@ const char *entrypoint2string(VAEntrypoint entrypoint)
ENTRYPOINT(IDCT)
ENTRYPOINT(MoComp)
ENTRYPOINT(Deblocking)
+ ENTRYPOINT(EncSlice)
+ ENTRYPOINT(EncPicture)
}
ASSERT(0);
return "Unknown";
diff --git a/test/encode/h264encode_common.c b/test/encode/h264encode_common.c
index 1375b36..91b4e3d 100644
--- a/test/encode/h264encode_common.c
+++ b/test/encode/h264encode_common.c
@@ -198,7 +198,7 @@ static int do_h264_encoding(void)
CHECK_VASTATUS(va_status,"vaBeginPicture");
if (i == 0) {
- VAEncSequenceParameterBufferH264Baseline seq_h264 = {0};
+ VAEncSequenceParameterBufferH264Baseline seq_h264;
VABufferID seq_param_buf;
seq_h264.level_idc = SH_LEVEL_3;
diff --git a/test/vainfo/Makefile.am b/test/vainfo/Makefile.am
index 8d9d017..190aa8b 100644
--- a/test/vainfo/Makefile.am
+++ b/test/vainfo/Makefile.am
@@ -23,12 +23,15 @@
bin_PROGRAMS = vainfo
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/test/basic
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/test/basic \
+ -DLIBVA_VERSION_S="\"${LIBVA_VERSION}\"" \
+ $(NULL)
vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) -lX11
vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
-vainfo_SOURCES = vainfo.c
valgrind: vainfo
valgrind --leak-check=full --show-reachable=yes .libs/vainfo;
diff --git a/test/vainfo/vainfo.c b/test/vainfo/vainfo.c
index afa74c3..00b2736 100644
--- a/test/vainfo/vainfo.c
+++ b/test/vainfo/vainfo.c
@@ -59,6 +59,7 @@ static char * profile_string(VAProfile profile)
case VAProfileH263Baseline: return "VAProfileH263Baseline";
case VAProfileJPEGBaseline: return "VAProfileJPEGBaseline";
case VAProfileH264ConstrainedBaseline: return "VAProfileH264ConstrainedBaseline";
+
default:
break;
}
@@ -77,6 +78,7 @@ static char * entrypoint_string(VAEntrypoint entrypoint)
case VAEntrypointEncSlice:return "VAEntrypointEncSlice";
case VAEntrypointEncPicture:return "VAEntrypointEncPicture";
case VAEntrypointVideoProc:return "VAEntrypointVideoProc";
+
default:
break;
}
@@ -102,7 +104,7 @@ int main(int argc, const char* argv[])
name = argv[0];
#ifndef ANDROID
- dpy = XOpenDisplay(":0.0");
+ dpy = XOpenDisplay(NULL);
#else
dpy = (Display*)malloc(sizeof(Display));
#endif
@@ -122,7 +124,8 @@ int main(int argc, const char* argv[])
va_status = vaInitialize(va_dpy, &major_version, &minor_version);
CHECK_VASTATUS(va_status, "vaInitialize", 3);
- printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
+ printf("%s: VA-API version: %d.%d (libva %s)\n",
+ name, major_version, minor_version, LIBVA_VERSION_S);
driver = vaQueryVendorString(va_dpy);
printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
diff --git a/va/Android.mk b/va/Android.mk
index 0f73a3e..6777f6d 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -35,8 +35,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
va.c \
va_trace.c \
- va_fool.c \
- va_fool_getframe.c
+ va_fool.c
LOCAL_CFLAGS += \
-DANDROID \
@@ -51,7 +50,6 @@ LOCAL_COPY_HEADERS := \
va.h \
va_version.h \
va_backend.h \
- va_version.h.in \
x11/va_dricommon.h
LOCAL_COPY_HEADERS_TO := libva/va
@@ -59,18 +57,16 @@ LOCAL_COPY_HEADERS_TO := libva/va
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva
-LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils
+LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils liblog
include $(BUILD_SHARED_LIBRARY)
-intermediates := $(local-intermediates-dir)
-GEN := $(intermediates)/va_version.h
-$(GEN): PRIVATE_GEN_VERSION := $(LOCAL_PATH)/../build/gen_version.sh
-$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/va_version.h.in
-$(GEN): PRIVATE_CUSTOM_TOOL = sh $(PRIVATE_GEN_VERSION) $(LOCAL_PATH)/.. $(PRIVATE_INPUT_FILE) > $@
-$(GEN): $(LOCAL_PATH)/va_version.h
+GEN := $(LOCAL_PATH)/va_version.h
+$(GEN): SCRIPT := $(LOCAL_PATH)/../build/gen_version.sh
+$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
+$(GEN): PRIVATE_CUSTOM_TOOL = sh $(SCRIPT) $(PRIVATE_PATH)/.. $(PRIVATE_PATH)/va_version.h.in > $@
+$(GEN): $(LOCAL_PATH)/%.h : $(LOCAL_PATH)/%.h.in $(SCRIPT) $(LOCAL_PATH)/../configure.ac
$(transform-generated-source)
-
LOCAL_GENERATED_SOURCES += $(GEN)
# For libva-android
diff --git a/va/Makefile.am b/va/Makefile.am
index 2130eb1..16a1e8f 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -34,7 +34,6 @@ LDADD = \
libva_source_c = \
va.c \
va_fool.c \
- va_fool_getframe.c \
va_trace.c \
$(NULL)
diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp
index 869e4af..4d4885a 100644
--- a/va/android/va_android.cpp
+++ b/va/android/va_android.cpp
@@ -25,6 +25,8 @@
#define _GNU_SOURCE 1
#include "va.h"
#include "va_backend.h"
+#include "va_trace.h"
+#include "va_fool.h"
#include "va_android.h"
#include "va_dricommon.h" /* needs some helper functions from this file */
#include <stdio.h>
@@ -123,7 +125,7 @@ static VAStatus va_DisplayContextGetDriverName (
};
memset(dri_state, 0, sizeof(*dri_state));
- dri_state->fd = open_device(DEVICE_NAME);
+ dri_state->fd = open_device((char *)DEVICE_NAME);
if (dri_state->fd < 0) {
fprintf(stderr,"can't open DRM devices\n");
@@ -267,11 +269,6 @@ extern "C" {
);
}
-#define VA_TRACE(trace_func,...) \
- if (trace_flag) { \
- trace_func(__VA_ARGS__); \
- }
-
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
@@ -300,9 +297,9 @@ VAStatus vaPutSurface (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_TRACE(va_TracePutSurface, dpy, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch,
- destx, desty, destw, desth,
- cliprects, number_cliprects, flags );
+ VA_TRACE_LOG(va_TracePutSurface, dpy, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch,
+ destx, desty, destw, desth,
+ cliprects, number_cliprects, flags );
return ctx->vtable->vaPutSurface( ctx, surface, static_cast<void*>(&draw), srcx, srcy, srcw, srch,
destx, desty, destw, desth,
diff --git a/va/va.c b/va/va.c
index 55ce9d2..ee92cb2 100644
--- a/va/va.c
+++ b/va/va.c
@@ -28,7 +28,6 @@
#include "va_backend.h"
#include "va_trace.h"
#include "va_fool.h"
-#include "config.h"
#include <assert.h>
#include <stdarg.h>
@@ -48,18 +47,6 @@
#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
-extern int trace_flag;
-#define VA_TRACE(trace_func,...) \
- if (trace_flag) { \
- trace_func(__VA_ARGS__); \
- }
-
-extern int fool_decode;
-extern int fool_encode;
-#define VA_FOOL(fool_func,...) \
- if (fool_decode || fool_encode) { \
- ret = fool_func(__VA_ARGS__); \
- }
/*
* read a config "env" for libva.conf or from environment setting
@@ -73,7 +60,6 @@ int va_parseConfig(char *env, char *env_value)
char oneline[1024];
FILE *fp=NULL;
-
if (env == NULL)
return 1;
@@ -138,8 +124,7 @@ void va_infoMessage(const char *msg, ...)
static Bool va_checkVtable(void *ptr, char *function)
{
- if (!ptr)
- {
+ if (!ptr) {
va_errorMessage("No valid vtable entry for va%s\n", function);
return False;
}
@@ -148,8 +133,7 @@ static Bool va_checkVtable(void *ptr, char *function)
static Bool va_checkMaximum(int value, char *variable)
{
- if (!value)
- {
+ if (!value) {
va_errorMessage("Failed to define max_%s in init\n", variable);
return False;
}
@@ -158,14 +142,20 @@ static Bool va_checkMaximum(int value, char *variable)
static Bool va_checkString(const char* value, char *variable)
{
- if (!value)
- {
+ if (!value) {
va_errorMessage("Failed to define str_%s in init\n", variable);
return False;
}
return True;
}
+static inline int
+va_getDriverInitName(char *name, int namelen, int major, int minor)
+{
+ int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor);
+ return ret > 0 && ret < namelen;
+}
+
static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
{
VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
@@ -182,19 +172,14 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
char *driver_dir;
if (geteuid() == getuid())
- {
/* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
search_path = getenv("LIBVA_DRIVERS_PATH");
- }
if (!search_path)
- {
search_path = VA_DRIVERS_PATH;
- }
search_path = strdup((const char *)search_path);
- driver_dir = strtok_r((const char *)search_path, ":", &saveptr);
- while(driver_dir)
- {
+ driver_dir = strtok_r(search_path, ":", &saveptr);
+ while (driver_dir) {
void *handle = NULL;
char *driver_path = (char *) malloc( strlen(driver_dir) +
strlen(driver_name) +
@@ -210,25 +195,21 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
#else
handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
#endif
- if (!handle)
- {
+ if (!handle) {
/* Don't give errors for non-existing files */
if (0 == access( driver_path, F_OK))
- {
va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
- }
- }
- else
- {
- VADriverInit init_func;
- init_func = (VADriverInit) dlsym(handle, VA_DRIVER_INIT_FUNC_S);
- if (!init_func)
- {
- va_errorMessage("%s has no function %s\n", driver_path, VA_DRIVER_INIT_FUNC_S);
+ } else {
+ VADriverInit init_func = NULL;
+ char init_func_s[256];
+ if (va_getDriverInitName(init_func_s, sizeof(init_func_s),
+ VA_MAJOR_VERSION, VA_MINOR_VERSION))
+ init_func = (VADriverInit) dlsym(handle, init_func_s);
+ if (!init_func) {
+ va_errorMessage("%s has no function %s\n",
+ driver_path, init_func_s);
dlclose(handle);
- }
- else
- {
+ } else {
struct VADriverVTable *vtable = ctx->vtable;
vaStatus = VA_STATUS_SUCCESS;
@@ -242,8 +223,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
if (VA_STATUS_SUCCESS == vaStatus)
vaStatus = (*init_func)(ctx);
- if (VA_STATUS_SUCCESS == vaStatus)
- {
+ if (VA_STATUS_SUCCESS == vaStatus) {
CHECK_MAXIMUM(vaStatus, ctx, profiles);
CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
CHECK_MAXIMUM(vaStatus, ctx, attributes);
@@ -292,15 +272,12 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
}
- if (VA_STATUS_SUCCESS != vaStatus)
- {
+ if (VA_STATUS_SUCCESS != vaStatus) {
va_errorMessage("%s init failed\n", driver_path);
dlclose(handle);
}
if (VA_STATUS_SUCCESS == vaStatus)
- {
ctx->handle = handle;
- }
free(driver_path);
break;
}
@@ -318,7 +295,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
{
VADriverContextP ctx;
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return NULL;
ctx = CTX(dpy);
@@ -334,8 +311,7 @@ VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
*/
const char *vaErrorStr(VAStatus error_status)
{
- switch(error_status)
- {
+ switch(error_status) {
case VA_STATUS_SUCCESS:
return "success (no error)";
case VA_STATUS_ERROR_OPERATION_FAILED:
@@ -404,24 +380,20 @@ VAStatus vaInitialize (
va_FoolInit(dpy);
- va_infoMessage("libva version %s\n", VA_VERSION_S);
+ va_infoMessage("VA-API version %s\n", VA_VERSION_S);
driver_name_env = getenv("LIBVA_DRIVER_NAME");
- if (driver_name_env && geteuid() == getuid())
- {
+ if (driver_name_env && geteuid() == getuid()) {
/* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
driver_name = strdup(driver_name_env);
vaStatus = VA_STATUS_SUCCESS;
va_infoMessage("User requested driver '%s'\n", driver_name);
- }
- else
- {
+ } else {
vaStatus = va_getDriverName(dpy, &driver_name);
va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
}
- if (VA_STATUS_SUCCESS == vaStatus)
- {
+ if (VA_STATUS_SUCCESS == vaStatus) {
vaStatus = va_openDriver(dpy, driver_name);
va_infoMessage("va_openDriver() returns %d\n", vaStatus);
@@ -432,7 +404,7 @@ VAStatus vaInitialize (
if (driver_name)
free(driver_name);
- VA_TRACE(va_TraceInitialize, dpy, major_version, minor_version);
+ VA_TRACE_LOG(va_TraceInitialize, dpy, major_version, minor_version);
return vaStatus;
}
@@ -463,7 +435,7 @@ VAStatus vaTerminate (
if (VA_STATUS_SUCCESS == vaStatus)
pDisplayContext->vaDestroy(pDisplayContext);
- VA_TRACE(va_TraceTerminate, dpy);
+ VA_TRACE_LOG(va_TraceTerminate, dpy);
va_TraceEnd(dpy);
@@ -484,7 +456,7 @@ const char *vaQueryVendorString (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return NULL;
return CTX(dpy)->str_vendor;
@@ -496,7 +468,7 @@ int vaMaxNumProfiles (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
return CTX(dpy)->max_profiles;
@@ -507,7 +479,7 @@ int vaMaxNumEntrypoints (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
return CTX(dpy)->max_entrypoints;
@@ -519,7 +491,7 @@ int vaMaxNumConfigAttributes (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
return CTX(dpy)->max_attributes;
@@ -583,11 +555,11 @@ VAStatus vaCreateConfig (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
-
- vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
+ vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
- VA_TRACE(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
+ /* record the current entrypoint for further trace/fool determination */
+ VA_TRACE_FUNC(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
+ VA_FOOL_FUNC(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
return vaStatus;
}
@@ -631,16 +603,13 @@ VAStatus vaCreateSurfaces (
{
VADriverContextP ctx;
VAStatus vaStatus;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
vaStatus = ctx->vtable->vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
- VA_TRACE(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
-
- VA_FOOL(va_FoolCreateSurfaces, dpy, width, height, format, num_surfaces, surfaces);
+ VA_TRACE_LOG(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
return vaStatus;
}
@@ -679,7 +648,8 @@ VAStatus vaCreateContext (
vaStatus = ctx->vtable->vaCreateContext( ctx, config_id, picture_width, picture_height,
flag, render_targets, num_render_targets, context );
- VA_TRACE(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
+ /* keep current encode/decode resoluton */
+ VA_TRACE_FUNC(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
return vaStatus;
}
@@ -711,7 +681,7 @@ VAStatus vaCreateBuffer (
ctx = CTX(dpy);
int ret = 0;
- VA_FOOL(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
+ VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
if (ret)
return VA_STATUS_SUCCESS;
@@ -727,7 +697,9 @@ VAStatus vaBufferSetNumElements (
VADriverContextP ctx;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
-
+
+ VA_FOOL_RETURN();
+
return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements );
}
@@ -744,15 +716,14 @@ VAStatus vaMapBuffer (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
-
- VA_FOOL(va_FoolMapBuffer, dpy, buf_id, pbuf);
+
+ VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
if (ret)
return VA_STATUS_SUCCESS;
-
+
va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
- if (va_status == VA_STATUS_SUCCESS)
- VA_TRACE(va_TraceMapBuffer, dpy, buf_id, pbuf);
+ VA_TRACE_LOG(va_TraceMapBuffer, dpy, buf_id, pbuf);
return va_status;
}
@@ -767,7 +738,7 @@ VAStatus vaUnmapBuffer (
ctx = CTX(dpy);
int ret = 0;
- VA_FOOL(va_FoolUnmapBuffer, dpy, buf_id);
+ VA_FOOL_FUNC(va_FoolUnmapBuffer, dpy, buf_id);
if (ret)
return VA_STATUS_SUCCESS;
@@ -783,6 +754,8 @@ VAStatus vaDestroyBuffer (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
+ VA_FOOL_RETURN();
+
return ctx->vtable->vaDestroyBuffer( ctx, buffer_id );
}
@@ -796,9 +769,15 @@ VAStatus vaBufferInfo (
)
{
VADriverContextP ctx;
+ int ret = 0;
+
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
+ VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements);
+ if (ret)
+ return VA_STATUS_SUCCESS;
+
return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements );
}
@@ -809,18 +788,17 @@ VAStatus vaBeginPicture (
)
{
VADriverContextP ctx;
- int ret = 0;
+ VAStatus va_status;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_TRACE(va_TraceBeginPicture, dpy, context, render_target);
-
- VA_FOOL(va_FoolBeginPicture, dpy, context, render_target);
- if (ret)
- return VA_STATUS_SUCCESS;
-
- return ctx->vtable->vaBeginPicture( ctx, context, render_target );
+ VA_TRACE_FUNC(va_TraceBeginPicture, dpy, context, render_target);
+ VA_FOOL_RETURN();
+
+ va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target );
+
+ return va_status;
}
VAStatus vaRenderPicture (
@@ -831,16 +809,12 @@ VAStatus vaRenderPicture (
)
{
VADriverContextP ctx;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL(va_FoolRenderPicture, dpy, context, buffers, num_buffers);
- if (ret)
- return VA_STATUS_SUCCESS;
-
- VA_TRACE(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
+ VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
+ VA_FOOL_RETURN();
return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers );
}
@@ -852,20 +826,18 @@ VAStatus vaEndPicture (
{
VAStatus va_status;
VADriverContextP ctx;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL(va_FoolEndPicture, dpy, context);
- if (ret) {
- VA_TRACE(va_TraceEndPicture, dpy, context);
- return VA_STATUS_SUCCESS;
- }
+ /* dump encode source surface */
+ VA_TRACE_SURFACE(va_TraceEndPicture, dpy, context, 0);
+ /* return directly if do dummy operation */
+ VA_FOOL_RETURN();
va_status = ctx->vtable->vaEndPicture( ctx, context );
-
- VA_TRACE(va_TraceEndPicture, dpy, context);
+ /* dump decode dest surface */
+ VA_TRACE_SURFACE(va_TraceEndPicture, dpy, context, 1);
return va_status;
}
@@ -877,17 +849,12 @@ VAStatus vaSyncSurface (
{
VAStatus va_status;
VADriverContextP ctx;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL(va_FoolSyncSurface, dpy, render_target);
- if (ret)
- return VA_STATUS_SUCCESS;
-
va_status = ctx->vtable->vaSyncSurface( ctx, render_target );
- VA_TRACE(va_TraceSyncSurface, dpy, render_target);
+ VA_TRACE_LOG(va_TraceSyncSurface, dpy, render_target);
return va_status;
}
@@ -905,7 +872,7 @@ VAStatus vaQuerySurfaceStatus (
va_status = ctx->vtable->vaQuerySurfaceStatus( ctx, render_target, status );
- VA_TRACE(va_TraceQuerySurfaceStatus, dpy, render_target, status);
+ VA_TRACE_LOG(va_TraceQuerySurfaceStatus, dpy, render_target, status);
return va_status;
}
@@ -924,7 +891,7 @@ VAStatus vaQuerySurfaceError (
va_status = ctx->vtable->vaQuerySurfaceError( ctx, surface, error_status, error_info );
- VA_TRACE(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info);
+ VA_TRACE_LOG(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info);
return va_status;
}
@@ -934,7 +901,7 @@ int vaMaxNumImageFormats (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
return CTX(dpy)->max_image_formats;
@@ -1100,7 +1067,7 @@ int vaMaxNumSubpictureFormats (
VADisplay dpy
)
{
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
return CTX(dpy)->max_subpic_formats;
@@ -1121,15 +1088,10 @@ VAStatus vaQuerySubpictureFormats (
)
{
VADriverContextP ctx;
- int ret = 0;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_FOOL(va_FoolQuerySubpictureFormats, dpy, format_list, flags, num_formats);
- if (ret)
- return VA_STATUS_SUCCESS;
-
return ctx->vtable->vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
}
@@ -1275,12 +1237,12 @@ int vaMaxNumDisplayAttributes (
{
int tmp;
- if( !vaDisplayIsValid(dpy) )
+ if (!vaDisplayIsValid(dpy))
return 0;
tmp = CTX(dpy)->max_display_attributes;
- VA_TRACE(va_TraceMaxNumDisplayAttributes, dpy, tmp);
+ VA_TRACE_LOG(va_TraceMaxNumDisplayAttributes, dpy, tmp);
return tmp;
}
@@ -1298,14 +1260,13 @@ VAStatus vaQueryDisplayAttributes (
)
{
VADriverContextP ctx;
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
-
VAStatus va_status;
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
va_status = ctx->vtable->vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
- VA_TRACE(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
+ VA_TRACE_LOG(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
return va_status;
@@ -1324,14 +1285,13 @@ VAStatus vaGetDisplayAttributes (
)
{
VADriverContextP ctx;
+ VAStatus va_status;
+
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
-
- VAStatus va_status;
-
va_status = ctx->vtable->vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
- VA_TRACE(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
+ VA_TRACE_LOG(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
return va_status;
}
@@ -1349,13 +1309,14 @@ VAStatus vaSetDisplayAttributes (
)
{
VADriverContextP ctx;
+ VAStatus va_status;
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_TRACE(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
-
+ va_status = ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
+ VA_TRACE_LOG(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
- return ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
+ return va_status;
}
VAStatus vaLockSurface(VADisplay dpy,
diff --git a/va/va.h b/va/va.h
index ee80958..149072e 100644
--- a/va/va.h
+++ b/va/va.h
@@ -1232,8 +1232,8 @@ typedef struct _VAPictureH264
VASurfaceID picture_id;
unsigned int frame_idx;
unsigned int flags;
- unsigned int TopFieldOrderCnt;
- unsigned int BottomFieldOrderCnt;
+ signed int TopFieldOrderCnt;
+ signed int BottomFieldOrderCnt;
} VAPictureH264;
/* flags in VAPictureH264 could be OR of the following */
#define VA_PICTURE_H264_INVALID 0x00000001
diff --git a/va/va_backend_tpi.h b/va/va_backend_tpi.h
index f67b30f..56998de 100644
--- a/va/va_backend_tpi.h
+++ b/va/va_backend_tpi.h
@@ -66,26 +66,42 @@ struct VADriverVTableTPI
unsigned int luma_offset, /* could be 0 */
unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
unsigned int chroma_v_offset
- );
+ );
+ VAStatus (*vaCreateSurfaceFromKBuf)(
+ VADriverContextP ctx,
+ int width,
+ int height,
+ int format,
+ VASurfaceID *surface, /* out */
+ unsigned int kbuf_handle, /* kernel buffer handle*/
+ unsigned size, /* kernel buffer size */
+ unsigned int kBuf_fourcc, /* expected fourcc */
+ unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
+ unsigned int chroma_u_stride, /* chroma stride */
+ unsigned int chroma_v_stride,
+ unsigned int luma_offset, /* could be 0 */
+ unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
+ unsigned int chroma_v_offset
+ );
- VAStatus (*vaPutSurfaceBuf) (
- VADriverContextP ctx,
- VASurfaceID surface,
- unsigned char* data,
- int* data_len,
- short srcx,
- short srcy,
- unsigned short srcw,
- unsigned short srch,
- short destx,
- short desty,
- unsigned short destw,
- unsigned short desth,
- VARectangle *cliprects, /* client supplied clip list */
- unsigned int number_cliprects, /* number of clip rects in the clip list */
- unsigned int flags /* de-interlacing flags */
- );
+ VAStatus (*vaPutSurfaceBuf) (
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ unsigned char* data,
+ int* data_len,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ VARectangle *cliprects, /* client supplied clip list */
+ unsigned int number_cliprects, /* number of clip rects in the clip list */
+ unsigned int flags /* de-interlacing flags */
+ );
};
diff --git a/va/va_fool.c b/va/va_fool.c
index 53b8f7a..807307e 100644
--- a/va/va_fool.c
+++ b/va/va_fool.c
@@ -39,6 +39,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
+#include <fcntl.h>
/*
* Do dummy decode/encode, ignore the input data
@@ -46,42 +47,37 @@
* We export env "VA_FOOL", with which, we can do fake decode/encode:
*
* LIBVA_FOOL_DECODE:
- * . if set, decode does nothing, but fill in some YUV data
- * LIBVA_FOOL_ENCODE=<clip name>:
- * . if set, encode does nothing, but fill in the coded buffer from a H264 clip.
- * . VA CONTEXT/CONFIG/SURFACE will call into drivers, but VA Buffer creation is done in here
- * . Bypass all "vaBeginPic/vaRenderPic/vaEndPic"
+ * . if set, decode does nothing
+ * LIBVA_FOOL_ENCODE=<framename>:
+ * . if set, encode does nothing, but fill in the coded buffer from the content of files with
+ * name framename.0,framename.1,framename.2, ..., framename.N, framename.N,framename.N,...
+ * LIBVA_FOOL_JPEG=<framename>:fill the content of filename to codedbuf for jpeg encoding
* LIBVA_FOOL_POSTP:
* . if set, do nothing for vaPutSurface
*/
/* global settings */
-
-/* LIBVA_FOOL_DECODE/LIBVA_FOOL_ENCODE/LIBVA_FOOL_POSTP */
-int fool_decode = 0;
-int fool_encode = 0;
+int fool_codec = 0;
int fool_postp = 0;
-
-
-#define NAL_BUF_SIZE 65536 // maximum NAL unit size
-#define RING_BUF_SIZE 8192 // input ring buffer size, MUST be a power of two!
-#define MAX_FRAME 16
-#define SLICE_NUM 4
-
#define FOOL_CONTEXT_MAX 4
+
+#define FOOL_BUFID_MAGIC 0x12345600
+#define FOOL_BUFID_MASK 0xffffff00
/* per context settings */
static struct _fool_context {
VADisplay dpy; /* should use context as the key */
- VAProfile fool_profile; /* current profile for buffers */
- VAEntrypoint fool_entrypoint; /* current entrypoint */
+ char *fn_enc;/* file pattern with codedbuf content for encode */
+ char *segbuf_enc; /* the segment buffer of coded buffer, load frome fn_enc */
+ int file_count;
- FILE *fool_fp_codedclip; /* load a clip from disk for fooling encode*/
- char *frame_buf;
- VACodedBufferSegment *codebuf;
+ char *fn_jpg;/* file name of JPEG fool with codedbuf content */
+ char *segbuf_jpg; /* the segment buffer of coded buffer, load frome fn_jpg */
+ VAEntrypoint entrypoint; /* current entrypoint */
+
/* all buffers with same type share one malloc-ed memory
* bufferID = (buffer numbers with the same type << 8) || type
* the malloc-ed memory can be find by fool_buf[bufferID & 0xff]
@@ -89,18 +85,10 @@ static struct _fool_context {
*/
char *fool_buf[VABufferTypeMax]; /* memory of fool buffers */
unsigned int fool_buf_size[VABufferTypeMax]; /* size of memory of fool buffers */
+ unsigned int fool_buf_element[VABufferTypeMax]; /* element count of created buffers */
unsigned int fool_buf_count[VABufferTypeMax]; /* count of created buffers */
VAContextID context;
-} fool_context[FOOL_CONTEXT_MAX] = { {0} }; /* trace five context at the same time */
-
-#define FOOL_DECODE(idx) (fool_decode && (fool_context[idx].fool_entrypoint == VAEntrypointVLD))
-#define FOOL_ENCODE(idx) \
- (fool_encode \
- && (fool_context[idx].fool_entrypoint == VAEntrypointEncSlice) \
- && (fool_context[idx].fool_profile >= VAProfileH264Baseline) \
- && (fool_context[idx].fool_profile <= VAProfileH264High))
-
-
+} fool_context[FOOL_CONTEXT_MAX]; /* trace five context at the same time */
#define DPY2INDEX(dpy) \
int idx; \
@@ -112,40 +100,12 @@ static struct _fool_context {
if (idx == FOOL_CONTEXT_MAX) \
return 0; /* let driver go */
-
/* Prototype declarations (functions defined in va.c) */
void va_errorMessage(const char *msg, ...);
void va_infoMessage(const char *msg, ...);
-int va_parseConfig(char *env, char *env_value);
-
-VAStatus vaBufferInfo(
- VADisplay dpy,
- VAContextID context, /* in */
- VABufferID buf_id, /* in */
- VABufferType *type, /* out */
- unsigned int *size, /* out */
- unsigned int *num_elements /* out */
-);
-
-VAStatus vaLockSurface(VADisplay dpy,
- VASurfaceID surface,
- unsigned int *fourcc, /* following are output argument */
- unsigned int *luma_stride,
- unsigned int *chroma_u_stride,
- unsigned int *chroma_v_stride,
- unsigned int *luma_offset,
- unsigned int *chroma_u_offset,
- unsigned int *chroma_v_offset,
- unsigned int *buffer_name,
- void **buffer
-);
-
-VAStatus vaUnlockSurface(VADisplay dpy,
- VASurfaceID surface
-);
-
+int va_parseConfig(char *env, char *env_value);
void va_FoolInit(VADisplay dpy)
{
@@ -159,41 +119,30 @@ void va_FoolInit(VADisplay dpy)
if (fool_index == FOOL_CONTEXT_MAX)
return;
+ memset(&fool_context[fool_index], 0, sizeof(struct _fool_context));
if (va_parseConfig("LIBVA_FOOL_POSTP", NULL) == 0) {
fool_postp = 1;
va_infoMessage("LIBVA_FOOL_POSTP is on, dummy vaPutSurface\n");
}
-
-
+
if (va_parseConfig("LIBVA_FOOL_DECODE", NULL) == 0) {
- fool_decode = 1;
+ fool_codec |= VA_FOOL_FLAG_DECODE;
va_infoMessage("LIBVA_FOOL_DECODE is on, dummy decode\n");
}
-
-
if (va_parseConfig("LIBVA_FOOL_ENCODE", &env_value[0]) == 0) {
- fool_context[fool_index].fool_fp_codedclip = fopen(env_value, "r");
-
- if (fool_context[fool_index].fool_fp_codedclip) {
- fool_encode = 1;
- } else
- fool_encode = 0;
-
- if (fool_encode) /* malloc the buffer for fake clip */
- {
- fool_context[fool_index].frame_buf = malloc(MAX_FRAME*SLICE_NUM*NAL_BUF_SIZE*sizeof(char));
- fool_context[fool_index].codebuf = malloc(sizeof(VACodedBufferSegment));
- }
-
- if (fool_context[fool_index].frame_buf == NULL)
- fool_encode = 0;
-
- if (fool_encode)
- va_infoMessage("LIBVA_FOOL_ENCODE is on, dummy encode\n");
-
+ fool_codec |= VA_FOOL_FLAG_ENCODE;
+ fool_context[fool_index].fn_enc = strdup(env_value);
+ va_infoMessage("LIBVA_FOOL_ENCODE is on, load encode data from file with patten %s\n",
+ fool_context[fool_index].fn_enc);
}
-
- if (fool_encode || fool_decode)
+ if (va_parseConfig("LIBVA_FOOL_JPEG", &env_value[0]) == 0) {
+ fool_codec |= VA_FOOL_FLAG_JPEG;
+ fool_context[fool_index].fn_jpg = strdup(env_value);
+ va_infoMessage("LIBVA_FOOL_JPEG is on, load encode data from file with patten %s\n",
+ fool_context[fool_index].fn_jpg);
+ }
+
+ if (fool_codec)
fool_context[fool_index].dpy = dpy;
}
@@ -201,29 +150,23 @@ void va_FoolInit(VADisplay dpy)
int va_FoolEnd(VADisplay dpy)
{
int i;
-
DPY2INDEX(dpy);
for (i = 0; i < VABufferTypeMax; i++) {/* free memory */
if (fool_context[idx].fool_buf[i])
free(fool_context[idx].fool_buf[i]);
}
- if (fool_context[idx].fool_fp_codedclip)
- fclose(fool_context[idx].fool_fp_codedclip);
-
- if (fool_context[idx].frame_buf)
- free(fool_context[idx].frame_buf);
+ if (fool_context[idx].segbuf_enc)
+ free(fool_context[idx].segbuf_enc);
+ if (fool_context[idx].segbuf_jpg)
+ free(fool_context[idx].segbuf_jpg);
+ if (fool_context[idx].fn_enc)
+ free(fool_context[idx].fn_enc);
+ if (fool_context[idx].fn_jpg)
+ free(fool_context[idx].fn_jpg);
- if (fool_context[idx].codebuf)
- free(fool_context[idx].codebuf);
-
memset(&fool_context[idx], 0, sizeof(struct _fool_context));
- return 0;
-}
-
-int va_FoolCodedBuf(VADisplay dpy)
-{
- /* do nothing */
+
return 0;
}
@@ -239,310 +182,175 @@ int va_FoolCreateConfig(
{
DPY2INDEX(dpy);
- /* call into driver level to allocate real context/surface/buffers, etc */
- fool_context[idx].fool_profile = profile;
- fool_context[idx].fool_entrypoint = entrypoint;
- return 0;
-}
-
-static int yuvgen_planar(
- int width, int height,
- unsigned char *Y_start, int Y_pitch,
- unsigned char *U_start, int U_pitch,
- unsigned char *V_start, int V_pitch,
- int UV_interleave, int box_width, int row_shift,
- int field
-)
-{
- int row;
-
- /* copy Y plane */
- for (row=0;row<height;row++) {
- unsigned char *Y_row = Y_start + row * Y_pitch;
- int jj, xpos, ypos;
-
- ypos = (row / box_width) & 0x1;
-
- /* fill garbage data into the other field */
- if (((field == VA_TOP_FIELD) && (row &1))
- || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
- memset(Y_row, 0xff, width);
- continue;
- }
-
- for (jj=0; jj<width; jj++) {
- xpos = ((row_shift + jj) / box_width) & 0x1;
-
- if ((xpos == 0) && (ypos == 0))
- Y_row[jj] = 0xeb;
- if ((xpos == 1) && (ypos == 1))
- Y_row[jj] = 0xeb;
-
- if ((xpos == 1) && (ypos == 0))
- Y_row[jj] = 0x10;
- if ((xpos == 0) && (ypos == 1))
- Y_row[jj] = 0x10;
- }
- }
-
- /* copy UV data */
- for( row =0; row < height/2; row++) {
- unsigned short value = 0x80;
-
- /* fill garbage data into the other field */
- if (((field == VA_TOP_FIELD) && (row &1))
- || ((field == VA_BOTTOM_FIELD) && ((row &1)==0))) {
- value = 0xff;
- }
-
- if (UV_interleave) {
- unsigned short *UV_row = (unsigned short *)(U_start + row * U_pitch);
-
- memset(UV_row, value, width);
- } else {
- unsigned char *U_row = U_start + row * U_pitch;
- unsigned char *V_row = V_start + row * V_pitch;
-
- memset (U_row,value,width/2);
- memset (V_row,value,width/2);
- }
- }
-
- return 0;
+ fool_context[idx].entrypoint = entrypoint;
+
+ /*
+ * check fool_codec to align with current context
+ * e.g. fool_codec = decode then for encode, the
+ * vaBegin/vaRender/vaEnd also run into fool path
+ * which is not desired
+ */
+ if (((fool_codec & VA_FOOL_FLAG_DECODE) && (entrypoint == VAEntrypointVLD)) ||
+ ((fool_codec & VA_FOOL_FLAG_ENCODE) && (entrypoint == VAEntrypointEncSlice)) ||
+ ((fool_codec & VA_FOOL_FLAG_JPEG) && (entrypoint == VAEntrypointEncPicture)))
+ ; /* the fool_codec is meaningful */
+ else
+ fool_codec = 0;
+
+ return 0; /* driver continue */
}
-int va_FoolCreateSurfaces(
- VADisplay dpy,
- int width,
- int height,
- int format,
- int num_surfaces,
- VASurfaceID *surfaces /* out */
+VAStatus va_FoolCreateBuffer(
+ VADisplay dpy,
+ VAContextID context, /* in */
+ VABufferType type, /* in */
+ unsigned int size, /* in */
+ unsigned int num_elements, /* in */
+ void *data, /* in */
+ VABufferID *buf_id /* out */
)
{
- int i;
- unsigned int fourcc; /* following are output argument */
- unsigned int luma_stride;
- unsigned int chroma_u_stride;
- unsigned int chroma_v_stride;
- unsigned int luma_offset;
- unsigned int chroma_u_offset;
- unsigned int chroma_v_offset;
- unsigned int buffer_name;
- void *buffer = NULL;
- unsigned char *Y_data, *U_data, *V_data;
-
- int box_width = num_surfaces/2;
- int row_shift = 0;
- VAStatus va_status;
-
+ unsigned int new_size = size * num_elements;
+ unsigned int old_size;
DPY2INDEX(dpy);
- if (FOOL_DECODE(idx)) {
- /* call into driver level to allocate real context/surface/buffers, etc
- * fill in the YUV data, will be overwrite if it is encode context
- */
- for (i = 0; i < num_surfaces; i++) {
- /* fool decoder: fill with auto-generated YUV data */
- va_status = vaLockSurface(dpy, surfaces[i], &fourcc,
- &luma_stride, &chroma_u_stride, &chroma_v_stride,
- &luma_offset, &chroma_u_offset, &chroma_v_offset,
- &buffer_name, &buffer);
-
- if (va_status != VA_STATUS_SUCCESS)
- return 0;
-
- if (!buffer) {
- vaUnlockSurface(dpy, surfaces[i]);
- return 0;
- }
-
- Y_data = buffer;
-
- /* UV should be same for NV12 */
- U_data = buffer + chroma_u_offset;
- V_data = buffer + chroma_v_offset;
-
- yuvgen_planar(width, height,
- Y_data, luma_stride,
- U_data, chroma_v_stride,
- V_data, chroma_v_stride,
- (fourcc==VA_FOURCC_NV12),
- box_width, row_shift, 0);
-
- vaUnlockSurface(dpy, surfaces[i]);
-
- row_shift++;
- if (row_shift==(2*box_width))
- row_shift= 0;
- }
- return 0; /* the return value is ignored */
- }
- return 0; /* the return value is ignored */
+ old_size = fool_context[idx].fool_buf_size[type] * fool_context[idx].fool_buf_element[type];
+
+ if (old_size < new_size)
+ fool_context[idx].fool_buf[type] = realloc(fool_context[idx].fool_buf[type], new_size);
+
+ fool_context[idx].fool_buf_size[type] = size;
+ fool_context[idx].fool_buf_element[type] = num_elements;
+ fool_context[idx].fool_buf_count[type]++;
+ /* because we ignore the vaRenderPicture,
+ * all buffers with same type share same real memory
+ * bufferID = (magic number) | type
+ */
+ *buf_id = FOOL_BUFID_MAGIC | type;
+
+ return 1; /* don't call into driver */
}
-VAStatus va_FoolCreateBuffer (
- VADisplay dpy,
- VAContextID context, /* in */
- VABufferType type, /* in */
- unsigned int size, /* in */
- unsigned int num_elements, /* in */
- void *data, /* in */
- VABufferID *buf_id /* out */
+VAStatus va_FoolBufferInfo(
+ VADisplay dpy,
+ VABufferID buf_id, /* in */
+ VABufferType *type, /* out */
+ unsigned int *size, /* out */
+ unsigned int *num_elements /* out */
)
{
+ unsigned int magic = buf_id & FOOL_BUFID_MASK;
DPY2INDEX(dpy);
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx)) { /* fool buffer creation */
- int new_size = size * num_elements;
-
- if (type == VAEncCodedBufferType) /* only a VACodedBufferSegment */
- new_size = sizeof(VACodedBufferSegment);
-
- if (fool_context[idx].fool_buf_size[type] == 0)
- fool_context[idx].fool_buf[type] = calloc(1, new_size);
- else if (fool_context[idx].fool_buf_size[type] <= new_size)
- fool_context[idx].fool_buf[type] = realloc(fool_context[idx].fool_buf, new_size);
-
- if (fool_context[idx].fool_buf[type] == NULL) {
- va_FoolEnd(dpy);
- return 0; /* let driver go */
- }
-
- /* because we ignore the vaRenderPicture,
- * all buffers with same type share same real memory
- * bufferID = (buffer count << 8) | type
- */
- fool_context[idx].fool_buf_count[type]++;
- *buf_id = (fool_context[idx].fool_buf_count[type] << 8) | type;
-
- return 1; /* don't call into driver */
- }
+ if (magic != FOOL_BUFID_MAGIC)
+ return 0;
- return 0; /* let driver go ... */
+ *type = buf_id & 0xff;
+ *size = fool_context[idx].fool_buf_size[*type];
+ *num_elements = fool_context[idx].fool_buf_element[*type];;
+
+ return 1; /* don't call into driver */
}
-VAStatus va_FoolMapBuffer (
- VADisplay dpy,
- VABufferID buf_id, /* in */
- void **pbuf /* out */
-)
+static int va_FoolFillCodedBufEnc(int idx)
{
- VABufferType type;
- unsigned int size,frame_size = 0;
- unsigned int num_elements;
- DPY2INDEX(dpy);
-
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx)) { /* fool buffer creation */
- unsigned int buf_idx = buf_id & 0xff;
-
- /* Image buffer? */
- vaBufferInfo(dpy, fool_context[idx].context, buf_id, &type, &size, &num_elements);
- if (type == VAImageBufferType && FOOL_ENCODE(idx))
- return 0;
-
- /* buf_id is the buffer type */
- if (fool_context[idx].fool_buf[buf_idx] != NULL)
- *pbuf = fool_context[idx].fool_buf[buf_idx];
- else
- *pbuf = NULL;
-
- /* expect APP to MapBuffer when get the the coded data */
- if (*pbuf && (buf_idx == VAEncCodedBufferType)) { /* it is coded buffer */
- /* read from a clip */
- frame_size = va_FoolGetFrame(fool_context[idx].fool_fp_codedclip,
- fool_context[idx].frame_buf);
-
- memset(fool_context[idx].codebuf,0,sizeof(VACodedBufferSegment));
- fool_context[idx].codebuf->size = frame_size;
- fool_context[idx].codebuf->bit_offset = 0;
- fool_context[idx].codebuf->status = 0;
- fool_context[idx].codebuf->reserved = 0;
- fool_context[idx].codebuf->buf = fool_context[idx].frame_buf;
- fool_context[idx].codebuf->next = NULL;
- *pbuf = fool_context[idx].codebuf;
+ char file_name[1024];
+ struct stat file_stat;
+ VACodedBufferSegment *codedbuf;
+ int i, fd = -1;
+
+ /* try file_name.file_count, if fail, try file_name.file_count-- */
+ for (i=0; i<=1; i++) {
+ sprintf(file_name, "%s.%d",
+ fool_context[idx].fn_enc,
+ fool_context[idx].file_count);
+
+ if ((fd = open(file_name, O_RDONLY)) != -1) {
+ fstat(fd, &file_stat);
+ fool_context[idx].file_count++; /* open next file */
+ break;
}
- return 1; /* don't call into driver */
+
+ fool_context[idx].file_count--; /* fall back to previous file */
+ if (fool_context[idx].file_count < 0)
+ fool_context[idx].file_count = 0;
}
+ if (fd != -1) {
+ fool_context[idx].segbuf_enc = realloc(fool_context[idx].segbuf_enc, file_stat.st_size);
+ read(fd, fool_context[idx].segbuf_enc, file_stat.st_size);
+ close(fd);
+ }
+ codedbuf = (VACodedBufferSegment *)fool_context[idx].fool_buf[VAEncCodedBufferType];
+ codedbuf->size = file_stat.st_size;
+ codedbuf->bit_offset = 0;
+ codedbuf->status = 0;
+ codedbuf->reserved = 0;
+ codedbuf->buf = fool_context[idx].segbuf_enc;
+ codedbuf->next = NULL;
- return 0; /* let driver go ... */
+ return 0;
}
-int va_FoolBeginPicture(
- VADisplay dpy,
- VAContextID context,
- VASurfaceID render_target
-)
+static int va_FoolFillCodedBufJPG(int idx)
{
- DPY2INDEX(dpy);
-
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx)) {
- if (fool_context[idx].context == 0)
- fool_context[idx].context = context;
- return 1; /* don't call into driver level */
+ struct stat file_stat;
+ VACodedBufferSegment *codedbuf;
+ int i, fd = -1;
+
+ if ((fd = open(fool_context[idx].fn_jpg, O_RDONLY)) != -1)
+ fstat(fd, &file_stat);
+
+ if (fd != -1) {
+ fool_context[idx].segbuf_jpg = realloc(fool_context[idx].segbuf_jpg, file_stat.st_size);
+ read(fd, fool_context[idx].segbuf_jpg, file_stat.st_size);
+ close(fd);
}
+ codedbuf = (VACodedBufferSegment *)fool_context[idx].fool_buf[VAEncCodedBufferType];
+ codedbuf->size = file_stat.st_size;
+ codedbuf->bit_offset = 0;
+ codedbuf->status = 0;
+ codedbuf->reserved = 0;
+ codedbuf->buf = fool_context[idx].segbuf_jpg;
+ codedbuf->next = NULL;
- return 0; /* let driver go ... */
-}
-
-int va_FoolRenderPicture(
- VADisplay dpy,
- VAContextID context,
- VABufferID *buffers,
- int num_buffers
-)
-{
- DPY2INDEX(dpy);
-
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx))
- return 1; /* don't call into driver level */
-
- return 0; /* let driver go ... */
+ return 0;
}
-int va_FoolEndPicture(
- VADisplay dpy,
- VAContextID context
-)
+static int va_FoolFillCodedBuf(int idx)
{
- DPY2INDEX(dpy);
-
- /* don't call into driver level */
-
- /* do real fooling operation here */
-
- /* only support H264 encoding currently */
- if (FOOL_ENCODE(idx)) {
- /* expect vaMapBuffer will handle it
- * or else, need to save the codedbuf ID,
- * and fool encode it here
- */
- /* va_FoolCodedBuf(dpy); */
- return 1; /* don't call into driver level */
- }
-
- if (FOOL_DECODE(idx))
- return 1; /* don't call into driver level */
-
- return 0; /* let driver go ... */
+ if (fool_context[idx].entrypoint == VAEntrypointEncSlice)
+ va_FoolFillCodedBufEnc(idx);
+ else if (fool_context[idx].entrypoint == VAEntrypointEncPicture)
+ va_FoolFillCodedBufJPG(idx);
+
+ return 0;
}
-int va_FoolSyncSurface(
- VADisplay dpy,
- VASurfaceID render_target
+
+VAStatus va_FoolMapBuffer(
+ VADisplay dpy,
+ VABufferID buf_id, /* in */
+ void **pbuf /* out */
)
{
+ unsigned int buftype = buf_id & 0xff;
+ unsigned int magic = buf_id & FOOL_BUFID_MASK;
DPY2INDEX(dpy);
- /*Fill in black and white squares. */
- if (FOOL_DECODE(idx) || FOOL_DECODE(idx))
- return 1;
+ if (magic != FOOL_BUFID_MAGIC)
+ return 0;
- return 0;
+ /* buf_id is the buffer type */
+ *pbuf = fool_context[idx].fool_buf[buftype];
+ /* it is coded buffer, fill the fake segment buf from file */
+ if (*pbuf && (buftype == VAEncCodedBufferType))
+ va_FoolFillCodedBuf(idx);
+
+ return 1; /* don't call into driver */
}
VAStatus va_FoolUnmapBuffer(
@@ -550,28 +358,10 @@ VAStatus va_FoolUnmapBuffer(
VABufferID buf_id /* in */
)
{
- DPY2INDEX(dpy);
+ unsigned int magic = buf_id & FOOL_BUFID_MASK;
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx))
- return 1; /* fool buffer creation */
+ if (magic != FOOL_BUFID_MAGIC)
+ return 0;
- return 0;
+ return 1;
}
-
-VAStatus va_FoolQuerySubpictureFormats(
- VADisplay dpy,
- VAImageFormat *format_list,
- unsigned int *flags,
- unsigned int *num_formats
-)
-{
- DPY2INDEX(dpy);
-
- if (FOOL_ENCODE(idx) || FOOL_DECODE(idx)) {
- if (num_formats)
- *num_formats = 0;
- return 1;
- }
- return 0;
-}
-
diff --git a/va/va_fool.h b/va/va_fool.h
index ba11b50..5ea4830 100644
--- a/va/va_fool.h
+++ b/va/va_fool.h
@@ -28,35 +28,40 @@
#include <stdio.h>
-void va_FoolInit(VADisplay dpy);
-
-int va_FoolEnd(VADisplay dpy);
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int fool_codec;
+extern int fool_postp;
-int va_FoolGetFrame(FILE *input_fp, char *frame_buf);
+#define VA_FOOL_FLAG_DECODE 0x1
+#define VA_FOOL_FLAG_ENCODE 0x2
+#define VA_FOOL_FLAG_JPEG 0x4
-int va_FoolCodedBuf(VADisplay dpy);
+#define VA_FOOL_FUNC(fool_func,...) \
+ if (fool_codec) { \
+ ret = fool_func(__VA_ARGS__); \
+ }
+#define VA_FOOL_RETURN() \
+ if (fool_codec) { \
+ return VA_STATUS_SUCCESS; \
+ }
+void va_FoolInit(VADisplay dpy);
+int va_FoolEnd(VADisplay dpy);
int va_FoolCreateConfig(
- VADisplay dpy,
- VAProfile profile,
- VAEntrypoint entrypoint,
- VAConfigAttrib *attrib_list,
- int num_attribs,
- VAConfigID *config_id /* out */
+ VADisplay dpy,
+ VAProfile profile,
+ VAEntrypoint entrypoint,
+ VAConfigAttrib *attrib_list,
+ int num_attribs,
+ VAConfigID *config_id /* out */
);
-int va_FoolCreateSurfaces(
- VADisplay dpy,
- int width,
- int height,
- int format,
- int num_surfaces,
- VASurfaceID *surfaces /* out */
-);
-VAStatus va_FoolCreateBuffer (
+VAStatus va_FoolCreateBuffer(
VADisplay dpy,
VAContextID context, /* in */
VABufferType type, /* in */
@@ -72,41 +77,22 @@ VAStatus va_FoolMapBuffer (
void **pbuf /* out */
);
-int va_FoolBeginPicture(
- VADisplay dpy,
- VAContextID context,
- VASurfaceID render_target
-);
-
-int va_FoolRenderPicture(
- VADisplay dpy,
- VAContextID context,
- VABufferID *buffers,
- int num_buffers
-);
-
-int va_FoolEndPicture(
- VADisplay dpy,
- VAContextID context
-);
-
-VAStatus va_FoolUnmapBuffer (
- VADisplay dpy,
- VABufferID buf_id /* in */
+VAStatus va_FoolUnmapBuffer(
+ VADisplay dpy,
+ VABufferID buf_id /* in */
);
-
-VAStatus va_FoolQuerySubpictureFormats (
+VAStatus va_FoolBufferInfo (
VADisplay dpy,
- VAImageFormat *format_list,
- unsigned int *flags,
- unsigned int *num_formats
-);
-int va_FoolSyncSurface(
- VADisplay dpy,
- VASurfaceID render_target
+ VABufferID buf_id, /* in */
+ VABufferType *type, /* out */
+ unsigned int *size, /* out */
+ unsigned int *num_elements /* out */
);
-
-
+
+
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/va/va_fool_getframe.c b/va/va_fool_getframe.c
deleted file mode 100644
index 045bfb2..0000000
--- a/va/va_fool_getframe.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/* The code refers to
- * http://keyj.s2000.at/files/projects/h264-src.tar.gz
- */
-#include <string.h>
-#include <stdio.h>
-
-#define SLICE_NUM 4
-#define NAL_BUF_SIZE 65536 // maximum NAL unit size
-#define RING_BUF_SIZE 8192 // input ring buffer size, MUST be a power of two!
-
-typedef struct _nal_unit {
- int NumBytesInNALunit;
- int forbidden_zero_bit;
- int nal_ref_idc;
- int nal_unit_type;
- unsigned char *last_rbsp_byte;
-} nal_unit;
-
- typedef struct _slice_header {
- int first_mb_in_slice;
-} slice_header;
-
-static int get_next_nal_unit(FILE *input_fp, nal_unit *nalu);
-static int get_unsigned_exp_golomb();
-static void decode_slice_header(slice_header *sh);
-static void input_read(FILE *input_fp, unsigned char *dest, int size);
-static int input_get_bits(int bit_count);
-
-
-static unsigned char nal_buf[NAL_BUF_SIZE];
-static unsigned char ring_buf[RING_BUF_SIZE];
-static int input_remain = 0;
-static int ring_pos = 0;
-static int nal_pos;
-static int nal_bit;
-static int frame_no = 0;
-
-#define RING_MOD ((RING_BUF_SIZE)-1)
-#define HALF_RING ((RING_BUF_SIZE)/2)
-
-#define gnn_advance() do { \
- ring_pos = (ring_pos+1)&RING_MOD; \
- --input_remain; \
- if (ring_pos==0) input_read(input_fp, &ring_buf[HALF_RING],HALF_RING); \
- if (ring_pos==HALF_RING) input_read(input_fp, &ring_buf[0],HALF_RING); \
-} while(0)
-
-#define gnn_add_segment(end) do { \
- int size = end-segment_start; \
- if (size>0) { \
- memcpy(&nal_buf[nalu_size],&ring_buf[segment_start],size); \
- nalu_size += size; \
- } \
- segment_start = end&RING_MOD; \
-} while(0)
-
-static int input_get_bits(int bit_count)
-{
- int res = 0;
- register unsigned int x =
- (nal_buf[nal_pos]<<24)|
- (nal_buf[nal_pos+1]<<16)|
- (nal_buf[nal_pos+2]<<8)|
- nal_buf[nal_pos+3];
-
- res = (x>>(32-bit_count-nal_bit))&((1<<bit_count)-1);
- nal_bit += bit_count;
- nal_pos += nal_bit>>3;
- nal_bit &= 7;
-
- return res;
-}
-
-static int input_get_one_bit()
-{
- int res = (nal_buf[nal_pos]>>(7-nal_bit))&1;
-
- if (++nal_bit>7) {
- ++nal_pos;
- nal_bit = 0;
- }
- return res;
-}
-
-static int get_unsigned_exp_golomb()
-{
- int exp;
-
- for(exp = 0; !input_get_one_bit(); ++exp);
-
- if (exp)
- return (1<<exp) - 1 + input_get_bits(exp);
- else
- return 0;
-}
-
-static void decode_slice_header(slice_header *sh )
-{
- memset((void*)sh,0,sizeof(slice_header));
- sh->first_mb_in_slice = get_unsigned_exp_golomb();
-}
-
-static void input_read(FILE *input_fp, unsigned char *dest, int size)
-{
- int count = fread(dest, 1, size, input_fp);
-
- input_remain += count;
-}
-
-static int get_next_nal_unit(FILE *input_fp, nal_unit *nalu)
-{
- int i,segment_start;
- int nalu_size = 0;
- int NumBytesInRbsp = 0;
-
- /* search for the next NALU start
- * here is the sync that the start of the NALU is 0x00000001
- */
- for (;;) {
- if (input_remain<= 4) {
- /* clip restart */
- memset(ring_buf,0,sizeof(char)*RING_BUF_SIZE);
- memset(nal_buf,0,sizeof(char)*NAL_BUF_SIZE);
-
- fseek(input_fp,0,SEEK_SET);
- input_remain = 0;
- input_read(input_fp, ring_buf, RING_BUF_SIZE);
- ring_pos = 0;
- return 1;
- }
- if ((!ring_buf[ring_pos]) &&
- (!ring_buf[(ring_pos+1)&RING_MOD]) &&
- (!ring_buf[(ring_pos+2)&RING_MOD]) &&
- ( ring_buf[(ring_pos+3)&RING_MOD]==1))
- break;
- gnn_advance();
- }
-
- for(i=0;i<4;++i)
- gnn_advance();
-
- /* add bytes to the NALU until the end is found */
- segment_start = ring_pos;
- while (input_remain) {
- if ((!ring_buf[ring_pos]) &&
- (!ring_buf[(ring_pos+1)&RING_MOD]) &&
- (!ring_buf[(ring_pos+2)&RING_MOD]))
- break;
- ring_pos = (ring_pos+1)&RING_MOD;
- --input_remain;
-
- if (ring_pos==0) {
- gnn_add_segment(RING_BUF_SIZE);
- input_read(input_fp, &ring_buf[HALF_RING],HALF_RING);
- }
-
- if (ring_pos==HALF_RING) {
- gnn_add_segment(HALF_RING);
- input_read(input_fp, &ring_buf[0], HALF_RING);
- }
- }
-
- gnn_add_segment(ring_pos);
-
- /* read the NAL unit */
- nal_pos = 0; nal_bit = 0;
- nalu->forbidden_zero_bit = input_get_bits(1);
- nalu->nal_ref_idc = input_get_bits(2);
- nalu->nal_unit_type = input_get_bits(5);
- nalu->last_rbsp_byte = &nal_buf[nalu_size-1];
- nalu->NumBytesInNALunit = nalu_size;
-
- return 1;
-}
-
-int va_FoolGetFrame(FILE *input_fp, char *frame_buf)
-{
- int i = 0, frame_pos = 0;
- static slice_header sh;
- static nal_unit nalu;
- char nal_head[4] = {0x00,0x00,0x00,0x01};
-
- /* read the clip , here is the first frame,
- * &let the clip go on frame by frame
- */
- if (!frame_no)
- input_read(input_fp, ring_buf,RING_BUF_SIZE);
-
- while (get_next_nal_unit(input_fp, &nalu)) {
- if (nalu.nal_unit_type == 7 || nalu.nal_unit_type == 8) {
- memcpy(frame_buf+frame_pos, nal_head, sizeof(char)*4);
- frame_pos = frame_pos + 4;
- memcpy(frame_buf+frame_pos, nal_buf, sizeof(char)*(nalu.NumBytesInNALunit));
- frame_pos += nalu.NumBytesInNALunit;
- }
- else if (nalu.nal_unit_type == 1 || nalu.nal_unit_type == 5) {
- decode_slice_header(&sh);
- if (0 == sh.first_mb_in_slice) {
- ++frame_no;
- }
- memcpy(frame_buf+frame_pos, nal_head, sizeof(char)*4);
- frame_pos = frame_pos + 4;
- memcpy(frame_buf+frame_pos, nal_buf, sizeof(char)*(nalu.NumBytesInNALunit));
- frame_pos += nalu.NumBytesInNALunit;
- break;
- }
- }
-
- return frame_pos;
-}
diff --git a/va/va_tpi.c b/va/va_tpi.c
index 86385b0..e9169fc 100644
--- a/va/va_tpi.c
+++ b/va/va_tpi.c
@@ -137,7 +137,39 @@ VAStatus vaCreateSurfacesForUserPtr(
return VA_STATUS_ERROR_UNIMPLEMENTED;
}
+/*
+ * Create surface from the Kernel buffer
+ */
+VAStatus vaCreateSurfaceFromKBuf(
+ VADisplay dpy,
+ int width,
+ int height,
+ int format,
+ VASurfaceID *surface, /* out */
+ unsigned int kbuf_handle, /* kernel buffer handle*/
+ unsigned size, /* kernel buffer size */
+ unsigned int kBuf_fourcc, /* expected fourcc */
+ unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
+ unsigned int chroma_u_stride, /* chroma stride */
+ unsigned int chroma_v_stride,
+ unsigned int luma_offset, /* could be 0 */
+ unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
+ unsigned int chroma_v_offset
+)
+{
+ VADriverContextP ctx;
+ struct VADriverVTableTPI *tpi;
+ CHECK_DISPLAY(dpy);
+ ctx = CTX(dpy);
+ tpi = (struct VADriverVTableTPI *)ctx->vtable_tpi;
+ if (tpi && tpi->vaCreateSurfaceFromKBuf) {
+ return tpi->vaCreateSurfaceFromKBuf( ctx, width, height, format, surface, kbuf_handle,
+ size, kBuf_fourcc, luma_stride, chroma_u_stride,
+ chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset );
+ } else
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
VAStatus vaPutSurfaceBuf (
diff --git a/va/va_tpi.h b/va/va_tpi.h
index eb0b1d4..320a358 100644
--- a/va/va_tpi.h
+++ b/va/va_tpi.h
@@ -93,6 +93,27 @@ VAStatus vaCreateSurfacesForUserPtr(
unsigned int chroma_v_offset
);
+/*
+ * Create surface from the Kernel buffer
+ */
+VAStatus vaCreateSurfaceFromKbuf(
+ VADisplay dpy,
+ int width,
+ int height,
+ int format,
+ VASurfaceID *surface, /* out */
+ unsigned int kbuf_handle, /* kernel buffer handle*/
+ unsigned size, /* kernel buffer size */
+ unsigned int kBuf_fourcc, /* expected fourcc */
+ unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
+ unsigned int chroma_u_stride, /* chroma stride */
+ unsigned int chroma_v_stride,
+ unsigned int luma_offset, /* could be 0 */
+ unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
+ unsigned int chroma_v_offset
+);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/va/va_trace.c b/va/va_trace.c
index f356a19..eaee2f2 100644
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -40,29 +40,25 @@
#include <time.h>
#include <errno.h>
-
/*
* Env. to debug some issue, e.g. the decode/encode issue in a video conference scenerio:
* .LIBVA_TRACE=log_file: general VA parameters saved into log_file
* .LIBVA_TRACE_BUFDATA: dump VA buffer data into log_file (if not set, just calculate a checksum)
* .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_file
- * .LIBVA_TRACE_SURFACE=decoded_yuv_file: save the decoded YUV file decoded_yuv_file
+ * .LIBVA_TRACE_SURFACE=yuv_file: save surface YUV into file yuv_file. Use file name to determine
+ * decode/encode or jpeg surfaces
* .LIBVA_TRACE_LOGSIZE=numeric number: truncate the log_file or coded_clip_file, or decoded_yuv_file
* when the size is bigger than the number
*/
-
/* global settings */
/* LIBVA_TRACE */
-unsigned int trace_flag = 0;
+int trace_flag = 0;
/* LIBVA_TRACE_LOGSIZE */
static unsigned int trace_logsize = 0xffffffff; /* truncate the log when the size is bigger than it */
-/* LIBVA_TRACE_BUFDATA */
-static unsigned int trace_buffer_data; /* dump buffer data or not */
-
#define TRACE_CONTEXT_MAX 4
/* per context settings */
static struct _trace_context {
@@ -70,15 +66,15 @@ static struct _trace_context {
/* LIBVA_TRACE */
FILE *trace_fp_log; /* save the log into a file */
- char trace_log_fn[1024]; /* file name */
+ char *trace_log_fn; /* file name */
/* LIBVA_TRACE_CODEDBUF */
FILE *trace_fp_codedbuf; /* save the encode result into a file */
- char trace_codedbuf_fn[1024]; /* file name */
+ char *trace_codedbuf_fn; /* file name */
/* LIBVA_TRACE_SURFACE */
FILE *trace_fp_surface; /* save the surface YUV into a file */
- char trace_surface_fn[1024]; /* file name */
+ char *trace_surface_fn; /* file name */
VAContextID trace_context; /* current context */
@@ -94,7 +90,7 @@ static struct _trace_context {
unsigned int trace_frame_width; /* current frame width */
unsigned int trace_frame_height; /* current frame height */
unsigned int trace_sequence_start; /* get a new sequence for encoding or not */
-} trace_context[TRACE_CONTEXT_MAX] = { {0} }; /* trace five context at the same time */
+} trace_context[TRACE_CONTEXT_MAX]; /* trace five context at the same time */
#define DPY2INDEX(dpy) \
int idx; \
@@ -141,11 +137,22 @@ VAStatus vaUnlockSurface(VADisplay dpy,
VASurfaceID surface
);
+#define FILE_NAME_SUFFIX(env_value) \
+do { \
+ int tmp = strnlen(env_value, sizeof(env_value)); \
+ int left = sizeof(env_value) - tmp; \
+ \
+ snprintf(env_value+tmp, \
+ left, \
+ ".%04d.%05d", \
+ trace_index, \
+ suffix); \
+} while (0)
void va_TraceInit(VADisplay dpy)
{
char env_value[1024];
- unsigned int suffix = 0xffff & ((unsigned int)time(NULL));
+ unsigned short suffix = 0xffff & ((unsigned int)time(NULL));
int trace_index = 0;
FILE *tmp;
@@ -156,79 +163,59 @@ void va_TraceInit(VADisplay dpy)
if (trace_index == TRACE_CONTEXT_MAX)
return;
+ memset(&trace_context[trace_index], 0, sizeof(struct _trace_context));
if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
- trace_flag = 1;
-
- /*Check if there is still room for suffix .%d.%d*/
- if (strnlen(env_value, 1024) < (1024 - 8))
- snprintf(env_value+strnlen(env_value, 1024),
- (1025 - 8 - strnlen(env_value, 1024)),
- ".%d.%d", trace_index, suffix);
-
+ FILE_NAME_SUFFIX(env_value);
+ trace_context[trace_index].trace_log_fn = strdup(env_value);
+
tmp = fopen(env_value, "w");
if (tmp) {
trace_context[trace_index].trace_fp_log = tmp;
- strcpy(trace_context[trace_index].trace_log_fn, env_value);
- } else {
+ va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_context[trace_index].trace_log_fn);
+ trace_flag = VA_TRACE_FLAG_LOG;
+ } else
va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
- trace_context[trace_index].trace_fp_log = stderr;
- strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
- }
- va_infoMessage("LIBVA_TRACE is on, save log into %s\n", trace_context[trace_index].trace_log_fn);
}
- if (trace_flag == 0)
- return;
-
/* may re-get the global settings for multiple context */
if (va_parseConfig("LIBVA_TRACE_LOGSIZE", &env_value[0]) == 0) {
trace_logsize = atoi(env_value);
va_infoMessage("LIBVA_TRACE_LOGSIZE is on, size is %d\n", trace_logsize);
}
-
- if (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0) {
- trace_buffer_data = 1; /* dump buffer data */
+ if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) {
+ trace_flag |= VA_TRACE_FLAG_BUFDATA;
va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n");
}
-
/* per-context setting */
if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) {
- if (strnlen(env_value, 1024) < (1024 - 8))
- snprintf(env_value+strnlen(env_value, 1024),
- (1025 - 8 - strnlen(env_value, 1024)),
- ".%d.%d", trace_index, suffix);
-
- tmp = fopen(env_value, "w");
-
- if (tmp) {
- trace_context[trace_index].trace_fp_codedbuf = tmp;
- strcpy(trace_context[trace_index].trace_codedbuf_fn, env_value);
- } else {
- va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
- trace_context[trace_index].trace_fp_codedbuf = stderr;
- strcpy(trace_context[trace_index].trace_codedbuf_fn, "/dev/stderr");
- }
-
- va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save coded clip into %s\n", trace_context[trace_index].trace_codedbuf_fn);
+ FILE_NAME_SUFFIX(env_value);
+ trace_context[trace_index].trace_codedbuf_fn = strdup(env_value);
+ va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into log file %s\n",
+ trace_context[trace_index].trace_codedbuf_fn);
+ trace_flag |= VA_TRACE_FLAG_CODEDBUF;
}
if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) {
- sprintf(env_value+strnlen(env_value, 1024), ".%d.%d", trace_index, suffix);
-
- tmp = fopen(env_value, "w");
+ FILE_NAME_SUFFIX(env_value);
+ trace_context[trace_index].trace_surface_fn = strdup(env_value);
- if (tmp) {
- trace_context[trace_index].trace_fp_surface = tmp;
- strcpy(trace_context[trace_index].trace_surface_fn, env_value);
- } else {
- va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno));
- trace_context[trace_index].trace_fp_surface = stderr;
- strcpy(trace_context[trace_index].trace_surface_fn, "/dev/stderr");
- }
-
- va_infoMessage("LIBVA_TRACE_SURFACE is on, save coded clip into %s\n", trace_context[trace_index].trace_surface_fn);
+ va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n",
+ trace_context[trace_index].trace_surface_fn);
+
+ /* for surface data dump, it is time-consume, and may
+ * cause some side-effect, so only trace the needed surfaces
+ * to trace encode surface, set the trace file name to sth like *enc*
+ * to trace decode surface, set the trace file name to sth like *dec*
+ * if no dec/enc in file name, set both
+ */
+ if (strstr(env_value, "dec"))
+ trace_flag |= VA_TRACE_FLAG_SURFACE_DECODE;
+ if (strstr(env_value, "enc"))
+ trace_flag |= VA_TRACE_FLAG_SURFACE_ENCODE;
+ if (strstr(env_value, "jpeg") || strstr(env_value, "jpg"))
+ trace_flag |= VA_TRACE_FLAG_SURFACE_JPEG;
}
trace_context[trace_index].dpy = dpy;
@@ -239,15 +226,24 @@ void va_TraceEnd(VADisplay dpy)
{
DPY2INDEX(dpy);
- if (trace_context[idx].trace_fp_log && (trace_context[idx].trace_fp_log != stderr))
+ if (trace_context[idx].trace_fp_log)
fclose(trace_context[idx].trace_fp_log);
- if (trace_context[idx].trace_fp_codedbuf && (trace_context[idx].trace_fp_codedbuf != stderr))
+ if (trace_context[idx].trace_fp_codedbuf)
fclose(trace_context[idx].trace_fp_codedbuf);
- if (trace_context[idx].trace_fp_surface && (trace_context[idx].trace_fp_surface != stderr))
+ if (trace_context[idx].trace_fp_surface)
fclose(trace_context[idx].trace_fp_surface);
+ if (trace_context[idx].trace_log_fn)
+ free(trace_context[idx].trace_log_fn);
+
+ if (trace_context[idx].trace_codedbuf_fn)
+ free(trace_context[idx].trace_codedbuf_fn);
+
+ if (trace_context[idx].trace_surface_fn)
+ free(trace_context[idx].trace_surface_fn);
+
memset(&trace_context[idx], 0, sizeof(struct _trace_context));
}
@@ -272,9 +268,11 @@ void va_TraceMsg(int idx, const char *msg, ...)
{
va_list args;
+ if (!(trace_flag & VA_TRACE_FLAG_LOG))
+ return;
+
if (file_size(trace_context[idx].trace_fp_log) >= trace_logsize)
truncate_file(trace_context[idx].trace_fp_log);
-
if (msg) {
va_start(args, msg);
vfprintf(trace_context[idx].trace_fp_log, msg, args);
@@ -341,7 +339,7 @@ void va_TraceSurface(VADisplay dpy)
VAStatus va_status;
unsigned char check_sum = 0;
DPY2INDEX(dpy);
-
+
va_TraceMsg(idx, "==========dump surface data in file %s\n", trace_context[idx].trace_surface_fn);
if ((file_size(trace_context[idx].trace_fp_surface) >= trace_logsize)) {
@@ -388,21 +386,14 @@ void va_TraceSurface(VADisplay dpy)
tmp = Y_data;
for (i=0; i<trace_context[idx].trace_frame_height; i++) {
- for (j=0; j<trace_context[idx].trace_frame_width; j++)
- check_sum ^= tmp[j];
-
if (trace_context[idx].trace_fp_surface)
fwrite(tmp, trace_context[idx].trace_frame_width, 1, trace_context[idx].trace_fp_surface);
tmp = Y_data + i * luma_stride;
}
-
tmp = UV_data;
if (fourcc == VA_FOURCC_NV12) {
for (i=0; i<trace_context[idx].trace_frame_height/2; i++) {
- for (j=0; j<trace_context[idx].trace_frame_width; j++)
- check_sum ^= tmp[j];
-
if (trace_context[idx].trace_fp_surface)
fwrite(tmp, trace_context[idx].trace_frame_width, 1, trace_context[idx].trace_fp_surface);
@@ -412,7 +403,6 @@ void va_TraceSurface(VADisplay dpy)
vaUnlockSurface(dpy, trace_context[idx].trace_rendertarget);
- va_TraceMsg(idx, "\tchecksum = 0x%02x\n", check_sum & 0xff);
va_TraceMsg(idx, NULL);
}
@@ -446,6 +436,7 @@ void va_TraceCreateConfig(
)
{
int i;
+ int encode, decode, jpeg;
DPY2INDEX(dpy);
TRACE_FUNCNAME(idx);
@@ -461,6 +452,40 @@ void va_TraceCreateConfig(
trace_context[idx].trace_profile = profile;
trace_context[idx].trace_entrypoint = entrypoint;
+
+ /* avoid to create so many empty files */
+ encode = (trace_context[idx].trace_entrypoint == VAEntrypointEncSlice);
+ decode = (trace_context[idx].trace_entrypoint == VAEntrypointVLD);
+ jpeg = (trace_context[idx].trace_entrypoint == VAEntrypointEncPicture);
+ if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE)) ||
+ (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) ||
+ (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) {
+ FILE *tmp = fopen(trace_context[idx].trace_surface_fn, "w");
+
+ if (tmp)
+ trace_context[idx].trace_fp_surface = tmp;
+ else {
+ va_errorMessage("Open file %s failed (%s)\n",
+ trace_context[idx].trace_surface_fn,
+ strerror(errno));
+ trace_context[idx].trace_fp_surface = NULL;
+ trace_flag &= ~(VA_TRACE_FLAG_SURFACE);
+ }
+ }
+
+ if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) {
+ FILE *tmp = fopen(trace_context[idx].trace_codedbuf_fn, "w");
+
+ if (tmp)
+ trace_context[idx].trace_fp_codedbuf = tmp;
+ else {
+ va_errorMessage("Open file %s failed (%s)\n",
+ trace_context[idx].trace_codedbuf_fn,
+ strerror(errno));
+ trace_context[idx].trace_fp_codedbuf = NULL;
+ trace_flag &= ~VA_TRACE_FLAG_CODEDBUF;
+ }
+ }
}
@@ -610,10 +635,10 @@ static void va_TraceVABuffers(
for (i=0; i<size; i++) {
unsigned char value = p[i];
- if ((trace_buffer_data) && ((i%16) == 0))
+ if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && ((i%16) == 0))
va_TraceMsg(idx, "\n0x%08x:", i);
- if (trace_buffer_data)
+ if (trace_flag & VA_TRACE_FLAG_BUFDATA)
va_TraceMsg(idx, " %02x", value);
check_sum ^= value;
@@ -1901,7 +1926,7 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
va_TraceMsg(idx, "\tnum_buffers = %d\n", num_buffers);
for (i = 0; i < num_buffers; i++) {
- void *pbuf;
+ unsigned char *pbuf;
unsigned int j;
/* get buffer type information */
@@ -1913,7 +1938,7 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, "\t size = %d\n", size);
va_TraceMsg(idx, "\t num_elements = %d\n", num_elements);
- vaMapBuffer(dpy, buffers[i], &pbuf);
+ vaMapBuffer(dpy, buffers[i], (void **)&pbuf);
switch (trace_context[idx].trace_profile) {
case VAProfileMPEG2Simple:
@@ -1980,36 +2005,46 @@ void va_TraceRenderPicture(
va_TraceMsg(idx, NULL);
}
-
void va_TraceEndPicture(
VADisplay dpy,
- VAContextID context
+ VAContextID context,
+ int endpic_done
)
{
+ int encode, decode, jpeg;
DPY2INDEX(dpy);
TRACE_FUNCNAME(idx);
-
- va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
- va_TraceMsg(idx, "\trender_targets = 0x%08x\n", trace_context[idx].trace_rendertarget);
- /* want to trace codedbuf, and it is encode */
- if (trace_context[idx].trace_fp_codedbuf &&
- ((trace_context[idx].trace_entrypoint == VAEntrypointEncSlice) ||
- (trace_context[idx].trace_entrypoint == VAEntrypointEncPicture))) {
+ if (endpic_done == 0) {
+ va_TraceMsg(idx, "\tcontext = 0x%08x\n", context);
+ va_TraceMsg(idx, "\trender_targets = 0x%08x\n", trace_context[idx].trace_rendertarget);
+ }
+
+ encode = (trace_context[idx].trace_entrypoint == VAEntrypointEncSlice) &&
+ (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE);
+ decode = (trace_context[idx].trace_entrypoint == VAEntrypointVLD) &&
+ (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE);
+ jpeg = (trace_context[idx].trace_entrypoint == VAEntrypointEncPicture) &&
+ (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG);
+
+ /* want to trace encode source surface, do it before vaEndPicture */
+ if ((encode || jpeg) && (endpic_done == 0))
+ va_TraceSurface(dpy);
+
+ /* want to trace encoode codedbuf, do it after vaEndPicture */
+ if ((encode || jpeg) && (endpic_done == 1)) {
/* force the pipleline finish rendering */
vaSyncSurface(dpy, trace_context[idx].trace_rendertarget);
va_TraceCodedBuf(dpy);
}
- /* trace decoded surface for decoding, or the source sourface for encoding */
- if (trace_context[idx].trace_fp_surface) {
+ /* want to trace decode dest surface, do it after vaEndPicture */
+ if (decode && (endpic_done == 1)) {
/* force the pipleline finish rendering */
vaSyncSurface(dpy, trace_context[idx].trace_rendertarget);
-
va_TraceSurface(dpy);
}
-
va_TraceMsg(idx, NULL);
}
diff --git a/va/va_trace.h b/va/va_trace.h
index e8ae4f7..43b9fb8 100644
--- a/va/va_trace.h
+++ b/va/va_trace.h
@@ -25,6 +25,35 @@
#ifndef VA_TRACE_H
#define VA_TRACE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int trace_flag;
+
+#define VA_TRACE_FLAG_LOG 0x1
+#define VA_TRACE_FLAG_BUFDATA 0x2
+#define VA_TRACE_FLAG_CODEDBUF 0x4
+#define VA_TRACE_FLAG_SURFACE_DECODE 0x8
+#define VA_TRACE_FLAG_SURFACE_ENCODE 0x10
+#define VA_TRACE_FLAG_SURFACE_JPEG 0x20
+#define VA_TRACE_FLAG_SURFACE (VA_TRACE_FLAG_SURFACE_DECODE | \
+ VA_TRACE_FLAG_SURFACE_ENCODE | \
+ VA_TRACE_FLAG_SURFACE_JPEG)
+
+#define VA_TRACE_FUNC(trace_func,...) \
+ if (trace_flag) { \
+ trace_func(__VA_ARGS__); \
+ }
+#define VA_TRACE_LOG(trace_func,...) \
+ if (trace_flag & VA_TRACE_FLAG_LOG) { \
+ trace_func(__VA_ARGS__); \
+ }
+#define VA_TRACE_SURFACE(trace_func,...) \
+ if (trace_flag & (VA_TRACE_FLAG_SURFACE | VA_TRACE_FLAG_CODEDBUF)) { \
+ trace_func(__VA_ARGS__); \
+ }
+
void va_TraceInit(VADisplay dpy);
void va_TraceEnd(VADisplay dpy);
@@ -92,7 +121,8 @@ void va_TraceRenderPicture(
void va_TraceEndPicture(
VADisplay dpy,
- VAContextID context
+ VAContextID context,
+ int endpic_done
);
void va_TraceSyncSurface(
@@ -155,6 +185,9 @@ void va_TracePutSurface (
unsigned int flags /* de-interlacing flags */
);
-
+#ifdef __cplusplus
+}
+#endif
+
#endif /* VA_TRACE_H */
diff --git a/va/va_version.h b/va/va_version.h
deleted file mode 100644
index 41d542c..0000000
--- a/va/va_version.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef VA_VERSION_H
-#define VA_VERSION_H
-
-/**
- * VA_MAJOR_VERSION:
- *
- * The major version of the VA library (1, if %VA_VERSION is 1.2.3)
- */
-#define VA_MAJOR_VERSION (0)
-
-/**
- * VA_MINOR_VERSION:
- *
- * The minor version of the VA library (2, if %VA_VERSION is 1.2.3)
- */
-#define VA_MINOR_VERSION (32)
-
-/**
- * VA_MICRO_VERSION:
- *
- * The micro version of the VA library (3, if %VA_VERSION is 1.2.3)
- */
-#define VA_MICRO_VERSION (0)
-
-/**
- * VA_VERSION:
- *
- * The full version of the VA library, like 1.2.3
- */
-#define VA_VERSION 0.32.0
-
-/**
- * VA_VERSION_S:
- *
- * The full version of the VA library, in string form (suited for
- * string concatenation)
- */
-#define VA_VERSION_S "0.32.0"
-
-/**
- * VA_VERSION_HEX:
- *
- * Numerically encoded version of the VA library, like 0x010203
- */
-#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \
- (VA_MINOR_VERSION << 16) | \
- (VA_MICRO_VERSION << 8))
-
-/**
- * VA_CHECK_VERSION:
- * @major: major version, like 1 in 1.2.3
- * @minor: minor version, like 2 in 1.2.3
- * @micro: micro version, like 3 in 1.2.3
- *
- * Evaluates to %TRUE if the version of the VA library is greater
- * than @major, @minor and @micro
- */
-#define VA_CHECK_VERSION(major,minor,micro) \
- (VA_MAJOR_VERSION > (major) || \
- (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \
- (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro)))
-
-#endif /* VA_VERSION_H */
diff --git a/va/va_version.h.in b/va/va_version.h.in
index c9ea97a..0cc5ea7 100644
--- a/va/va_version.h.in
+++ b/va/va_version.h.in
@@ -28,43 +28,43 @@
/**
* VA_MAJOR_VERSION:
*
- * The major version of the VA library (1, if %VA_VERSION is 1.2.3)
+ * The major version of VA-API (1, if %VA_VERSION is 1.2.3)
*/
-#define VA_MAJOR_VERSION (@LIBVA_MAJOR_VERSION@)
+#define VA_MAJOR_VERSION @VA_API_MAJOR_VERSION@
/**
* VA_MINOR_VERSION:
*
- * The minor version of the VA library (2, if %VA_VERSION is 1.2.3)
+ * The minor version of VA-API (2, if %VA_VERSION is 1.2.3)
*/
-#define VA_MINOR_VERSION (@LIBVA_MINOR_VERSION@)
+#define VA_MINOR_VERSION @VA_API_MINOR_VERSION@
/**
* VA_MICRO_VERSION:
*
- * The micro version of the VA library (3, if %VA_VERSION is 1.2.3)
+ * The micro version of VA-API (3, if %VA_VERSION is 1.2.3)
*/
-#define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@)
+#define VA_MICRO_VERSION @VA_API_MICRO_VERSION@
/**
* VA_VERSION:
*
- * The full version of the VA library, like 1.2.3
+ * The full version of VA-API, like 1.2.3
*/
-#define VA_VERSION @LIBVA_VERSION@
+#define VA_VERSION @VA_API_VERSION@
/**
* VA_VERSION_S:
*
- * The full version of the VA library, in string form (suited for
- * string concatenation)
+ * The full version of VA-API, in string form (suited for string
+ * concatenation)
*/
-#define VA_VERSION_S "@LIBVA_VERSION@"
+#define VA_VERSION_S "@VA_API_VERSION@"
/**
* VA_VERSION_HEX:
*
- * Numerically encoded version of the VA library, like 0x010203
+ * Numerically encoded version of VA-API, like 0x010203
*/
#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \
(VA_MINOR_VERSION << 16) | \
@@ -76,8 +76,8 @@
* @minor: minor version, like 2 in 1.2.3
* @micro: micro version, like 3 in 1.2.3
*
- * Evaluates to %TRUE if the version of the VA library is greater
- * than @major, @minor and @micro
+ * Evaluates to %TRUE if the version of VA-API is greater than
+ * @major, @minor and @micro
*/
#define VA_CHECK_VERSION(major,minor,micro) \
(VA_MAJOR_VERSION > (major) || \
diff --git a/va/x11/va_fglrx.c b/va/x11/va_fglrx.c
index 5be0256..77149cb 100644
--- a/va/x11/va_fglrx.c
+++ b/va/x11/va_fglrx.c
@@ -78,23 +78,43 @@ static void ADL_Main_Memory_Free(void *arg)
}
}
-static int match_display(Display *x11_dpy, const char *display_name)
+static int get_display_name_length(const char *name)
+{
+ const char *m;
+
+ if (!name)
+ return 0;
+
+ /* Strip out screen number */
+ m = strchr(name, ':');
+ if (m) {
+ m = strchr(m, '.');
+ if (m)
+ return m - name;
+ }
+ return strlen(name);
+}
+
+static int match_display_name(Display *x11_dpy, const char *display_name)
{
Display *test_dpy;
char *test_dpy_name, *x11_dpy_name;
+ int test_dpy_namelen, x11_dpy_namelen;
int m;
test_dpy = XOpenDisplay(display_name);
if (!test_dpy)
return 0;
- test_dpy_name = XDisplayString(test_dpy);
- x11_dpy_name = XDisplayString(x11_dpy);
+ test_dpy_name = XDisplayString(test_dpy);
+ test_dpy_namelen = get_display_name_length(test_dpy_name);
+ x11_dpy_name = XDisplayString(x11_dpy);
+ x11_dpy_namelen = get_display_name_length(x11_dpy_name);
- if (x11_dpy_name && test_dpy_name)
- m = strcmp(x11_dpy_name, test_dpy_name) == 0;
- else
- m = !x11_dpy_name && !test_dpy_name;
+ m = (test_dpy_namelen == x11_dpy_namelen &&
+ (test_dpy_namelen == 0 ||
+ (test_dpy_namelen > 0 &&
+ strncmp(test_dpy_name, x11_dpy_name, test_dpy_namelen) == 0)));
XCloseDisplay(test_dpy);
return m;
@@ -204,14 +224,15 @@ Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen,
printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent);
printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum);
#endif
- if (match_display(dpy, lpCurrAdapterInfo->strDisplayName) &&
- screen == lpCurrXScreenInfo->iXScreenNum) {
- *clientDriverName = strdup("fglrx");
+ if (screen == lpCurrXScreenInfo->iXScreenNum &&
+ match_display_name(dpy, lpCurrAdapterInfo->strDisplayName)) {
+ if (clientDriverName)
+ *clientDriverName = strdup("fglrx");
+ success = True;
break;
}
}
- success = True;
end:
if (lpXScreenInfo)
ADL_Main_Memory_Free(&lpXScreenInfo);
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index e44dfa7..86b040a 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -26,6 +26,8 @@
#include "sysdeps.h"
#include "va.h"
#include "va_backend.h"
+#include "va_trace.h"
+#include "va_fool.h"
#include "va_x11.h"
#include "va_dri.h"
#include "va_dri2.h"
@@ -208,13 +210,6 @@ VADisplay vaGetDisplay (
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
-extern int fool_postp; /* do nothing for vaPutSurface if set */
-extern int trace_flag; /* trace vaPutSurface parameters */
-#define VA_TRACE(trace_func,...) \
- if (trace_flag) { \
- trace_func(__VA_ARGS__); \
- }
-
void va_TracePutSurface (
VADisplay dpy,
VASurfaceID surface,
@@ -258,8 +253,8 @@ VAStatus vaPutSurface (
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
- VA_TRACE(va_TracePutSurface, dpy, surface, (void *)draw, srcx, srcy, srcw, srch,
- destx, desty, destw, desth,
+ VA_TRACE_FUNC(va_TracePutSurface, dpy, surface, (void *)draw, srcx, srcy, srcw, srch,
+ destx, desty, destw, desth,
cliprects, number_cliprects, flags );
return ctx->vtable->vaPutSurface( ctx, surface, (void *)draw, srcx, srcy, srcw, srch,