From 7b8cc07dc7a9b954b9a8c9bde5091fb2e8d443dc Mon Sep 17 00:00:00 2001 From: Sean V Kelley Date: Sat, 18 Feb 2017 15:19:05 -0800 Subject: PROJECT HAS MOVED See https://github.com/01org/libva Signed-off-by: Sean V Kelley --- Android.mk | 4 - Makefile.am | 47 - PROJECT_HAS_MOVED | 11 + autogen.sh | 51 - build/gen_version.sh | 54 - configure.ac | 360 - debian.upstream/Makefile.am | 36 - debian.upstream/README.Debian | 7 - debian.upstream/changelog.in | 5 - debian.upstream/compat | 1 - debian.upstream/control.in | 111 - debian.upstream/copyright | 44 - debian.upstream/libva-dev.install | 3 - debian.upstream/libva-drm.install.in | 1 - debian.upstream/libva-egl.install.in | 1 - debian.upstream/libva-glx.install.in | 1 - debian.upstream/libva-wayland.install.in | 1 - debian.upstream/libva-x11.install.in | 1 - debian.upstream/libva.install.in | 1 - debian.upstream/rules | 14 - debian.upstream/vainfo.install | 1 - doc/Doxyfile | 1679 -- doc/Makefile.am | 63 - doc/va_footer.html | 4 - dummy_drv_video/Makefile.am | 33 - dummy_drv_video/dummy_drv_video.c | 1232 -- dummy_drv_video/dummy_drv_video.h | 83 - dummy_drv_video/object_heap.c | 267 - dummy_drv_video/object_heap.h | 100 - libva.spec | 151 - pkgconfig/Makefile.am | 57 - pkgconfig/libva-drm.pc.in | 12 - pkgconfig/libva-egl.pc.in | 13 - pkgconfig/libva-glx.pc.in | 12 - pkgconfig/libva-tpi.pc.in | 11 - pkgconfig/libva-wayland.pc.in | 12 - pkgconfig/libva-x11.pc.in | 12 - pkgconfig/libva.pc.in | 11 - style_unify | 10 - test/Android.mk | 4 - test/Makefile.am | 29 - test/basic/Android.mk | 234 - test/basic/Makefile.am | 87 - test/basic/test.c | 151 - test/basic/test_01.c | 42 - test/basic/test_02.c | 42 - test/basic/test_03.c | 67 - test/basic/test_04.c | 84 - test/basic/test_05.c | 78 - test/basic/test_06.c | 124 - test/basic/test_07.c | 119 - test/basic/test_08.c | 92 - test/basic/test_09.c | 112 - test/basic/test_10.c | 141 - test/basic/test_11.c | 180 - test/basic/test_android.c | 62 - test/basic/test_common.c | 168 - test/basic/test_x11.c | 61 - test/basic/testplan.txt | 106 - test/common/Makefile.am | 63 - test/common/va_display.c | 166 - test/common/va_display.h | 64 - test/common/va_display_android.cpp | 105 - test/common/va_display_drm.c | 91 - test/common/va_display_wayland.c | 193 - test/common/va_display_x11.c | 139 - test/decode/Android.mk | 27 - test/decode/Makefile.am | 49 - test/decode/loadjpeg.c | 137 - test/decode/mpeg2-I.gif | Bin 103275 -> 0 bytes test/decode/mpeg2-I.m2v | Bin 197 -> 0 bytes test/decode/mpeg2vldemo.cpp | 282 - test/decode/tinyjpeg-internal.h | 121 - test/decode/tinyjpeg.c | 873 - test/decode/tinyjpeg.h | 71 - test/encode/Android.mk | 50 - test/encode/Makefile.am | 74 - test/encode/avcenc.c | 2143 --- test/encode/h264encode.c | 2420 --- test/encode/jpegenc.c | 1001 - test/encode/jpegenc_utils.h | 355 - test/encode/mpeg2vaenc.c | 1546 -- test/encode/svctenc.c | 3104 ---- test/loadsurface.h | 489 - test/loadsurface_yuv.h | 28836 ----------------------------- test/putsurface/Android.mk | 24 - test/putsurface/Makefile.am | 59 - test/putsurface/putsurface_android.cpp | 124 - test/putsurface/putsurface_common.c | 685 - test/putsurface/putsurface_wayland.c | 338 - test/putsurface/putsurface_x11.c | 172 - test/v4l_h264/Makefile.am | 27 - test/v4l_h264/README.txt | 23 - test/v4l_h264/decode/Makefile.am | 39 - test/v4l_h264/decode/TCPSocketServer.cpp | 192 - test/v4l_h264/decode/TCPSocketServer.h | 128 - test/v4l_h264/decode/decode_x11.cpp | 704 - test/v4l_h264/encode/Makefile.am | 39 - test/v4l_h264/encode/TCPSocketClient.cpp | 123 - test/v4l_h264/encode/TCPSocketClient.h | 102 - test/v4l_h264/encode/avcenc.cpp | 508 - test/v4l_h264/encode/capture.cpp | 851 - test/vainfo/Android.mk | 27 - test/vainfo/Makefile.am | 44 - test/vainfo/vainfo.c | 164 - va/Android.mk | 178 - va/Makefile.am | 147 - va/android/Makefile.am | 24 - va/android/va_android.cpp | 229 - va/drm/Makefile.am | 58 - va/drm/va_drm.c | 128 - va/drm/va_drm.h | 61 - va/drm/va_drm_auth.c | 43 - va/drm/va_drm_auth.h | 35 - va/drm/va_drm_auth_x11.c | 172 - va/drm/va_drm_auth_x11.h | 35 - va/drm/va_drm_utils.c | 103 - va/drm/va_drm_utils.h | 83 - va/egl/Makefile.am | 43 - va/egl/va_backend_egl.h | 41 - va/egl/va_egl.c | 82 - va/egl/va_egl.h | 27 - va/glx/Makefile.am | 51 - va/glx/va_backend_glx.h | 54 - va/glx/va_glx.c | 167 - va/glx/va_glx.h | 109 - va/glx/va_glx_impl.c | 1127 -- va/glx/va_glx_impl.h | 37 - va/glx/va_glx_private.h | 86 - va/libva.syms | 11 - va/sysdeps.h | 59 - va/va.c | 1877 -- va/va.h | 3132 ---- va/va_android.h | 82 - va/va_backend.h | 562 - va/va_backend_tpi.h | 69 - va/va_backend_vpp.h | 71 - va/va_compat.c | 43 - va/va_compat.h | 116 - va/va_dec_hevc.h | 427 - va/va_dec_jpeg.h | 142 - va/va_dec_vp8.h | 243 - va/va_dec_vp9.h | 321 - va/va_drmcommon.h | 76 - va/va_enc_h264.h | 591 - va/va_enc_hevc.h | 701 - va/va_enc_jpeg.h | 156 - va/va_enc_mpeg2.h | 287 - va/va_enc_vp8.h | 330 - va/va_enc_vp9.h | 598 - va/va_fool.c | 375 - va/va_fool.h | 91 - va/va_tpi.c | 98 - va/va_tpi.h | 103 - va/va_trace.c | 5119 ----- va/va_trace.h | 250 - va/va_version.h.in | 87 - va/va_vpp.h | 744 - va/va_x11.h | 70 - va/wayland/Makefile.am | 69 - va/wayland/va_backend_wayland.h | 68 - va/wayland/va_wayland.c | 194 - va/wayland/va_wayland.h | 131 - va/wayland/va_wayland_drm.c | 238 - va/wayland/va_wayland_drm.h | 52 - va/wayland/va_wayland_emgd.c | 156 - va/wayland/va_wayland_emgd.h | 52 - va/wayland/va_wayland_private.h | 44 - va/wayland/wayland-drm-client-protocol.h | 290 - va/wayland/wayland-drm.xml | 185 - va/x11/Makefile.am | 58 - va/x11/dri2_util.c | 239 - va/x11/va_dri2.c | 424 - va/x11/va_dri2.h | 73 - va/x11/va_dri2str.h | 227 - va/x11/va_dri2tokens.h | 48 - va/x11/va_dricommon.c | 138 - va/x11/va_dricommon.h | 94 - va/x11/va_fglrx.c | 247 - va/x11/va_fglrx.h | 35 - va/x11/va_nvctrl.c | 400 - va/x11/va_nvctrl.h | 38 - va/x11/va_x11.c | 251 - 183 files changed, 11 insertions(+), 76963 deletions(-) delete mode 100644 Android.mk delete mode 100644 Makefile.am create mode 100644 PROJECT_HAS_MOVED delete mode 100755 autogen.sh delete mode 100644 build/gen_version.sh delete mode 100644 configure.ac delete mode 100644 debian.upstream/Makefile.am delete mode 100644 debian.upstream/README.Debian delete mode 100644 debian.upstream/changelog.in delete mode 100644 debian.upstream/compat delete mode 100644 debian.upstream/control.in delete mode 100644 debian.upstream/copyright delete mode 100644 debian.upstream/libva-dev.install delete mode 100644 debian.upstream/libva-drm.install.in delete mode 100644 debian.upstream/libva-egl.install.in delete mode 100644 debian.upstream/libva-glx.install.in delete mode 100644 debian.upstream/libva-wayland.install.in delete mode 100644 debian.upstream/libva-x11.install.in delete mode 100644 debian.upstream/libva.install.in delete mode 100755 debian.upstream/rules delete mode 100644 debian.upstream/vainfo.install delete mode 100644 doc/Doxyfile delete mode 100644 doc/Makefile.am delete mode 100644 doc/va_footer.html delete mode 100644 dummy_drv_video/Makefile.am delete mode 100644 dummy_drv_video/dummy_drv_video.c delete mode 100644 dummy_drv_video/dummy_drv_video.h delete mode 100644 dummy_drv_video/object_heap.c delete mode 100644 dummy_drv_video/object_heap.h delete mode 100644 libva.spec delete mode 100644 pkgconfig/Makefile.am delete mode 100644 pkgconfig/libva-drm.pc.in delete mode 100644 pkgconfig/libva-egl.pc.in delete mode 100644 pkgconfig/libva-glx.pc.in delete mode 100644 pkgconfig/libva-tpi.pc.in delete mode 100644 pkgconfig/libva-wayland.pc.in delete mode 100644 pkgconfig/libva-x11.pc.in delete mode 100644 pkgconfig/libva.pc.in delete mode 100755 style_unify delete mode 100644 test/Android.mk delete mode 100644 test/Makefile.am delete mode 100755 test/basic/Android.mk delete mode 100644 test/basic/Makefile.am delete mode 100644 test/basic/test.c delete mode 100644 test/basic/test_01.c delete mode 100644 test/basic/test_02.c delete mode 100644 test/basic/test_03.c delete mode 100644 test/basic/test_04.c delete mode 100644 test/basic/test_05.c delete mode 100644 test/basic/test_06.c delete mode 100644 test/basic/test_07.c delete mode 100644 test/basic/test_08.c delete mode 100644 test/basic/test_09.c delete mode 100644 test/basic/test_10.c delete mode 100644 test/basic/test_11.c delete mode 100644 test/basic/test_android.c delete mode 100644 test/basic/test_common.c delete mode 100644 test/basic/test_x11.c delete mode 100644 test/basic/testplan.txt delete mode 100644 test/common/Makefile.am delete mode 100644 test/common/va_display.c delete mode 100644 test/common/va_display.h delete mode 100644 test/common/va_display_android.cpp delete mode 100644 test/common/va_display_drm.c delete mode 100644 test/common/va_display_wayland.c delete mode 100644 test/common/va_display_x11.c delete mode 100755 test/decode/Android.mk delete mode 100644 test/decode/Makefile.am delete mode 100644 test/decode/loadjpeg.c delete mode 100644 test/decode/mpeg2-I.gif delete mode 100644 test/decode/mpeg2-I.m2v delete mode 100644 test/decode/mpeg2vldemo.cpp delete mode 100644 test/decode/tinyjpeg-internal.h delete mode 100644 test/decode/tinyjpeg.c delete mode 100644 test/decode/tinyjpeg.h delete mode 100755 test/encode/Android.mk delete mode 100644 test/encode/Makefile.am delete mode 100644 test/encode/avcenc.c delete mode 100644 test/encode/h264encode.c delete mode 100644 test/encode/jpegenc.c delete mode 100644 test/encode/jpegenc_utils.h delete mode 100644 test/encode/mpeg2vaenc.c delete mode 100644 test/encode/svctenc.c delete mode 100755 test/loadsurface.h delete mode 100644 test/loadsurface_yuv.h delete mode 100644 test/putsurface/Android.mk delete mode 100644 test/putsurface/Makefile.am delete mode 100644 test/putsurface/putsurface_android.cpp delete mode 100755 test/putsurface/putsurface_common.c delete mode 100644 test/putsurface/putsurface_wayland.c delete mode 100644 test/putsurface/putsurface_x11.c delete mode 100644 test/v4l_h264/Makefile.am delete mode 100644 test/v4l_h264/README.txt delete mode 100644 test/v4l_h264/decode/Makefile.am delete mode 100644 test/v4l_h264/decode/TCPSocketServer.cpp delete mode 100644 test/v4l_h264/decode/TCPSocketServer.h delete mode 100644 test/v4l_h264/decode/decode_x11.cpp delete mode 100644 test/v4l_h264/encode/Makefile.am delete mode 100644 test/v4l_h264/encode/TCPSocketClient.cpp delete mode 100644 test/v4l_h264/encode/TCPSocketClient.h delete mode 100644 test/v4l_h264/encode/avcenc.cpp delete mode 100644 test/v4l_h264/encode/capture.cpp delete mode 100644 test/vainfo/Android.mk delete mode 100644 test/vainfo/Makefile.am delete mode 100644 test/vainfo/vainfo.c delete mode 100755 va/Android.mk delete mode 100644 va/Makefile.am delete mode 100644 va/android/Makefile.am delete mode 100644 va/android/va_android.cpp delete mode 100644 va/drm/Makefile.am delete mode 100644 va/drm/va_drm.c delete mode 100644 va/drm/va_drm.h delete mode 100644 va/drm/va_drm_auth.c delete mode 100644 va/drm/va_drm_auth.h delete mode 100644 va/drm/va_drm_auth_x11.c delete mode 100644 va/drm/va_drm_auth_x11.h delete mode 100644 va/drm/va_drm_utils.c delete mode 100644 va/drm/va_drm_utils.h delete mode 100644 va/egl/Makefile.am delete mode 100644 va/egl/va_backend_egl.h delete mode 100644 va/egl/va_egl.c delete mode 100644 va/egl/va_egl.h delete mode 100644 va/glx/Makefile.am delete mode 100644 va/glx/va_backend_glx.h delete mode 100644 va/glx/va_glx.c delete mode 100644 va/glx/va_glx.h delete mode 100644 va/glx/va_glx_impl.c delete mode 100644 va/glx/va_glx_impl.h delete mode 100644 va/glx/va_glx_private.h delete mode 100644 va/libva.syms delete mode 100644 va/sysdeps.h delete mode 100644 va/va.c delete mode 100644 va/va.h delete mode 100644 va/va_android.h delete mode 100644 va/va_backend.h delete mode 100644 va/va_backend_tpi.h delete mode 100644 va/va_backend_vpp.h delete mode 100644 va/va_compat.c delete mode 100644 va/va_compat.h delete mode 100644 va/va_dec_hevc.h delete mode 100644 va/va_dec_jpeg.h delete mode 100644 va/va_dec_vp8.h delete mode 100644 va/va_dec_vp9.h delete mode 100644 va/va_drmcommon.h delete mode 100644 va/va_enc_h264.h delete mode 100644 va/va_enc_hevc.h delete mode 100644 va/va_enc_jpeg.h delete mode 100644 va/va_enc_mpeg2.h delete mode 100644 va/va_enc_vp8.h delete mode 100755 va/va_enc_vp9.h delete mode 100644 va/va_fool.c delete mode 100644 va/va_fool.h delete mode 100644 va/va_tpi.c delete mode 100644 va/va_tpi.h delete mode 100644 va/va_trace.c delete mode 100644 va/va_trace.h delete mode 100644 va/va_version.h.in delete mode 100644 va/va_vpp.h delete mode 100644 va/va_x11.h delete mode 100644 va/wayland/Makefile.am delete mode 100644 va/wayland/va_backend_wayland.h delete mode 100644 va/wayland/va_wayland.c delete mode 100644 va/wayland/va_wayland.h delete mode 100644 va/wayland/va_wayland_drm.c delete mode 100644 va/wayland/va_wayland_drm.h delete mode 100644 va/wayland/va_wayland_emgd.c delete mode 100644 va/wayland/va_wayland_emgd.h delete mode 100644 va/wayland/va_wayland_private.h delete mode 100644 va/wayland/wayland-drm-client-protocol.h delete mode 100644 va/wayland/wayland-drm.xml delete mode 100644 va/x11/Makefile.am delete mode 100644 va/x11/dri2_util.c delete mode 100644 va/x11/va_dri2.c delete mode 100644 va/x11/va_dri2.h delete mode 100644 va/x11/va_dri2str.h delete mode 100644 va/x11/va_dri2tokens.h delete mode 100644 va/x11/va_dricommon.c delete mode 100644 va/x11/va_dricommon.h delete mode 100644 va/x11/va_fglrx.c delete mode 100644 va/x11/va_fglrx.h delete mode 100644 va/x11/va_nvctrl.c delete mode 100644 va/x11/va_nvctrl.h delete mode 100644 va/x11/va_x11.c diff --git a/Android.mk b/Android.mk deleted file mode 100644 index 5cbb9d8..0000000 --- a/Android.mk +++ /dev/null @@ -1,4 +0,0 @@ -# Recursive call sub-folder Android.mk -# - - include $(call all-subdir-makefiles) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index beac7e9..0000000 --- a/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -# 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. - -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} - -AUTOMAKE_OPTIONS = foreign - -SUBDIRS = va dummy_drv_video pkgconfig test debian.upstream doc - -# 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 - -DEB_BUILDDIR = debian.build - -deb: - @[ -d debian ] || ln -s debian.upstream debian - dpkg-buildpackage -rfakeroot -uc -us - -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/PROJECT_HAS_MOVED b/PROJECT_HAS_MOVED new file mode 100644 index 0000000..d0ea6dd --- /dev/null +++ b/PROJECT_HAS_MOVED @@ -0,0 +1,11 @@ +We've consolidated our VAAPI Media software projects upstream onto +github and have been updating distributions with the new source +locations. Changes are in flight. Next release will be on Github. + +Libva project has moved to https://github.com/01org/libva + +Use https://github.com/01org/libva/issues/new to file bugs on the +libva github site + +Doxygen files are regularly updated through Github Pages and can +be accessed directly through [github pages libva](http://01org.github.io/libva/) diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index af7d03c..0000000 --- a/autogen.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# 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. - -PROJECT="libva" - -test -n "$srcdir" || srcdir="`dirname \"$0\"`" -test -n "$srcdir" || srcdir=. - -if ! test -f "$srcdir/configure.ac"; then - echo "Failed to find the top-level $PROJECT directory" - exit 1 -fi - -olddir="`pwd`" -cd "$srcdir" - -mkdir -p m4 - -AUTORECONF=`which autoreconf` -if test -z $AUTORECONF; then - echo "*** No autoreconf found ***" - exit 1 -else - autoreconf -v --install || exit $? -fi - -cd "$olddir" - -if test -z "$NOCONFIGURE"; then - $srcdir/configure "$@" && echo "Now type 'make' to compile $PROJECT." -fi diff --git a/build/gen_version.sh b/build/gen_version.sh deleted file mode 100644 index 8864f7d..0000000 --- a/build/gen_version.sh +++ /dev/null @@ -1,54 +0,0 @@ -# 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. - -#!/bin/sh - -libva_topdir="$1" -version_h_in="$2" - -parse_configure_ac() { - sed -n "/^m4_define.*${1}.*\[\([0-9]*\)\].*/s//\1/p" ${libva_topdir}/configure.ac -} - -parse_configure() { - sed -n "/^${1}=\([0-9]*\)/s//\1/p" ${libva_topdir}/configure -} - -if test -f "${libva_topdir}/configure.ac"; then - 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 - 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 -va_api_version="$va_api_major_version.$va_api_minor_version.$va_api_micro_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/configure.ac b/configure.ac deleted file mode 100644 index dd0c611..0000000 --- a/configure.ac +++ /dev/null @@ -1,360 +0,0 @@ -# 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. - -# 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], [40]) -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) -# 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], [0]) -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]) -]) - -# 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...0 where -# = VA-API major version + 1 -# = 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]) - -# Wayland minimum version number -m4_define([wayland_api_version], [1.0.0]) - -AC_PREREQ(2.57) -AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) -AC_CONFIG_SRCDIR([Makefile.am]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([dist-bzip2]) - -AC_CONFIG_HEADERS([config.h]) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -TODAY="`LC_ALL=C date +'%a, %d %b %Y %X %z'`" -AC_SUBST(TODAY) - -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 -LIBVA_VERSION=libva_version -AC_SUBST(LIBVA_MAJOR_VERSION) -AC_SUBST(LIBVA_MINOR_VERSION) -AC_SUBST(LIBVA_MICRO_VERSION) -AC_SUBST(LIBVA_VERSION) - -LIBVA_LT_CURRENT=libva_lt_current -LIBVA_LT_REV=libva_lt_revision -LIBVA_LT_AGE=libva_lt_age -LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" -AC_SUBST(LIBVA_LT_VERSION) -AC_SUBST(LIBVA_LT_LDFLAGS) - -AC_ARG_ENABLE(docs, - [AC_HELP_STRING([--enable-docs], - [build Doxygen documentation @<:@default=no@:>@])], - [], [enable_docs="no"]) - -AC_ARG_ENABLE(drm, - [AC_HELP_STRING([--enable-drm], - [build with VA/DRM API support @<:@default=yes@:>@])], - [], [enable_drm="yes"]) - -AC_ARG_ENABLE(x11, - [AC_HELP_STRING([--enable-x11], - [build with VA/X11 API support @<:@default=yes@:>@])], - [], [enable_x11="yes"]) - -AC_ARG_ENABLE(glx, - [AC_HELP_STRING([--enable-glx], - [build with VA/GLX API support @<:@default=yes@:>@])], - [], [enable_glx="yes"]) - -AC_ARG_ENABLE(egl, - [AC_HELP_STRING([--enable-egl], - [build with VA/EGL API support @<:@default=yes@:>@])], - [], [enable_egl="yes"]) - -AC_ARG_ENABLE([wayland], - [AC_HELP_STRING([--enable-wayland], - [build with VA/Wayland API support @<:@default=yes@:>@])], - [], [enable_wayland="yes"]) - -AC_ARG_ENABLE(dummy-driver, - [AC_HELP_STRING([--enable-dummy-driver], - [build dummy video driver @<:@default=yes@:>@])], - [], [enable_dummy_driver="yes"]) -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) - -AC_ARG_WITH(drivers-path, - [AC_HELP_STRING([--with-drivers-path=[[path]]], - [drivers path])], - [], [with_drivers_path="$libdir/dri"]) - -LIBVA_DRIVERS_PATH="$with_drivers_path" -AC_SUBST(LIBVA_DRIVERS_PATH) - -AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_PROG_CC -AC_PROG_CXX -AM_PROG_CC_C_O -PKG_PROG_PKG_CONFIG - -AC_HEADER_STDC -AC_SYS_LARGEFILE - -# Check for Doxygen -if test "$enable_docs" = "yes"; then - AC_CHECK_TOOL([DOXYGEN], [doxygen], [no]) - if test "$DOXYGEN" = "no"; then - enable_docs="no" - fi -fi -AM_CONDITIONAL(ENABLE_DOCS, test "$enable_docs" = "yes") - -# Check for __attribute__((visibility())) -AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], - ac_cv_have_gnuc_visibility_attribute, - [cat > conftest.c </dev/null 2>&1; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - if grep '\.protected.*bar' conftest.s >/dev/null; then - ac_cv_have_gnuc_visibility_attribute="yes" - fi - fi - fi - rm -f conftest.[cs] -]) -if test "$ac_cv_have_gnuc_visibility_attribute" = "yes"; then - AC_DEFINE([HAVE_GNUC_VISIBILITY_ATTRIBUTE], [1], - [Defined to 1 if GCC visibility attribute is supported]) -fi - -# Check for DRM (mandatory) -LIBDRM_VERSION=libdrm_version -PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION]) -AC_SUBST(LIBDRM_VERSION) - -USE_DRM="no" -if test "$enable_drm" = "yes"; then - USE_DRM="yes" - AC_DEFINE([HAVE_VA_DRM], [1], [Defined to 1 if VA/DRM API is built]) -fi -AM_CONDITIONAL(USE_DRM, test "$USE_DRM" = "yes") - -# Check for X11 -USE_X11="no" -if test "$enable_x11" = "yes"; then - USE_X11="yes" - PKG_CHECK_MODULES([X11], [x11], [:], [USE_X11="no"]) - PKG_CHECK_MODULES([XEXT], [xext], [:], [USE_X11="no"]) - PKG_CHECK_MODULES([XFIXES], [xfixes], [:], [USE_X11="no"]) - if test "$USE_X11" = "yes"; then - AC_DEFINE([HAVE_VA_X11], [1], [Defined to 1 if VA/X11 API is built]) - fi -fi -AM_CONDITIONAL(USE_X11, test "$USE_X11" = "yes") - -# Check for GLX -USE_GLX="no" -if test "$USE_X11:$enable_glx" = "yes:yes"; then - PKG_CHECK_MODULES([GLX], [gl x11], [USE_GLX="yes"], [:]) - saved_CPPFLAGS="$CPPFLAGS" - saved_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $GLX_CFLAGS" - LIBS="$LIBS $GLX_LIBS" - AC_CHECK_HEADERS([GL/gl.h GL/glx.h], [:], [USE_GLX="no"]) - AC_CHECK_LIB([GL], [glXCreateContext], [:] [USE_GLX="no"]) - CPPFLAGS="$saved_CPPFLAGS" - LIBS="$saved_LIBS" - if test "$USE_GLX" = "yes"; then - AC_DEFINE([HAVE_VA_GLX], [1], [Defined to 1 if VA/GLX API is built]) - fi -fi -AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") - -# Check for EGL -USE_EGL="no" -if test "$enable_egl" = "yes"; then - PKG_CHECK_MODULES([EGL], [egl], [USE_EGL="yes"], [:]) - saved_CPPFLAGS="$CPPFLAGS" - saved_LIBS="$LIBS" - CPPFLAGS="$CPPFLAGS $EGL_CFLAGS" - LIBS="$LIBS $EGL_LIBS" - AC_CHECK_HEADERS([EGL/egl.h], [:], [USE_EGL="no"]) - AC_CHECK_LIB([EGL], [eglGetDisplay], [:], [USE_EGL="no"]) - CPPFLAGS="$saved_CPPFLAGS" - LIBS="$saved_LIBS" - if test "$USE_EGL" = "yes"; then - AC_DEFINE([HAVE_VA_EGL], [1], [Defined to 1 if VA/EGL API is built]) - fi -fi -AM_CONDITIONAL(USE_EGL, test "$USE_EGL" = "yes") - -# Check for Wayland -WAYLAND_API_VERSION=wayland_api_version -AC_SUBST(WAYLAND_API_VERSION) - -USE_WAYLAND="no" -if test "$enable_wayland" = "yes"; then - PKG_CHECK_MODULES([WAYLAND], [wayland-client >= wayland_api_version], - [USE_WAYLAND="yes"], [:]) - if test "$USE_WAYLAND" = "yes"; then - - WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client` - AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],, - [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH]) - - AC_DEFINE([HAVE_VA_WAYLAND], [1], - [Defined to 1 if VA/Wayland API is built]) - fi -fi - -AM_CONDITIONAL(USE_WAYLAND, test "$USE_WAYLAND" = "yes") - -pkgconfigdir=${libdir}/pkgconfig -AC_SUBST(pkgconfigdir) - -# Check for builds without backend -if test "$USE_DRM:$USE_X11:$USE_WAYLAND" = "no:no:no"; then - AC_MSG_ERROR([Please select at least one backend (DRM, X11, Wayland)]) -fi - -# Define __vaDriverInit*() function name for dummy backend -VA_DRIVER_INIT_FUNC="__vaDriverInit_${VA_API_MAJOR_VERSION}_${VA_API_MINOR_VERSION}" -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC], [$VA_DRIVER_INIT_FUNC], - [Defined to the versioned __vaDriverInit function name]) - -AC_OUTPUT([ - Makefile - debian.upstream/Makefile - debian.upstream/changelog - debian.upstream/control - debian.upstream/libva$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva.install.in - debian.upstream/libva-drm$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva-drm.install.in - debian.upstream/libva-egl$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva-egl.install.in - debian.upstream/libva-glx$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva-glx.install.in - debian.upstream/libva-wayland$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva-wayland.install.in - debian.upstream/libva-x11-$LIBVA_MAJOR_VERSION.install:\ -debian.upstream/libva-x11.install.in - doc/Makefile - dummy_drv_video/Makefile - pkgconfig/Makefile - pkgconfig/libva-drm.pc - pkgconfig/libva-egl.pc - pkgconfig/libva-glx.pc - pkgconfig/libva-tpi.pc - pkgconfig/libva-wayland.pc - pkgconfig/libva-x11.pc - pkgconfig/libva.pc - test/Makefile - test/basic/Makefile - test/common/Makefile - test/decode/Makefile - test/encode/Makefile - test/putsurface/Makefile - test/vainfo/Makefile - va/Makefile - va/drm/Makefile - va/egl/Makefile - va/glx/Makefile - va/va_version.h - va/wayland/Makefile - va/x11/Makefile -]) - -# Print a small summary -BACKENDS="" -AS_IF([test x$USE_DRM = xyes], [BACKENDS="$BACKENDS drm"]) -AS_IF([test x$USE_X11 = xyes], [BACKENDS="$BACKENDS x11"]) -AS_IF([test x$USE_GLX = xyes], [BACKENDS="$BACKENDS glx"]) -AS_IF([test x$USE_EGL = xyes], [BACKENDS="$BACKENDS egl"]) -AS_IF([test x$USE_WAYLAND = xyes], [BACKENDS="$BACKENDS wayland"]) - -echo -echo "libva - ${LIBVA_VERSION} (VA-API ${VA_API_VERSION})" -echo -echo Installation prefix .............. : $prefix -echo Default driver path .............. : $LIBVA_DRIVERS_PATH -echo Extra window systems ............. : $BACKENDS -echo Build dummy driver ............... : $enable_dummy_driver -echo Build documentation .............. : $enable_docs -echo diff --git a/debian.upstream/Makefile.am b/debian.upstream/Makefile.am deleted file mode 100644 index 8367ef7..0000000 --- a/debian.upstream/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -DEBIANFILES = \ - README.Debian \ - changelog.in \ - compat \ - control.in \ - copyright \ - libva-dev.install \ - libva-drm.install.in \ - libva-egl.install.in \ - libva-glx.install.in \ - libva-wayland.install.in \ - libva-x11.install.in \ - libva.install.in \ - rules \ - vainfo.install \ - $(NULL) - -DEBIANGENFILES = \ - changelog \ - control \ - libva$(LIBVA_MAJOR_VERSION).install \ - libva-drm$(LIBVA_MAJOR_VERSION).install \ - libva-egl$(LIBVA_MAJOR_VERSION).install \ - libva-glx$(LIBVA_MAJOR_VERSION).install \ - libva-wayland$(LIBVA_MAJOR_VERSION).install \ - libva-x11-$(LIBVA_MAJOR_VERSION).install \ - $(NULL) - -EXTRA_DIST = $(DEBIANFILES) - -DISTCLEANFILES = $(DEBIANGENFILES) - -dist_noinst_DATA = $(DEBIANGENFILES) - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/debian.upstream/README.Debian b/debian.upstream/README.Debian deleted file mode 100644 index d10d702..0000000 --- a/debian.upstream/README.Debian +++ /dev/null @@ -1,7 +0,0 @@ -libva for Debian ----------------- - -This library implements the Video Acceleration (VA) API for Linux. -It will load a hardware dependendent video acceleration driver. - - -- Waldo Bastian Mon, 18 Jun 2007 21:35:31 -0700 diff --git a/debian.upstream/changelog.in b/debian.upstream/changelog.in deleted file mode 100644 index f5482c4..0000000 --- a/debian.upstream/changelog.in +++ /dev/null @@ -1,5 +0,0 @@ -libva (@PACKAGE_VERSION@-1) unstable; urgency=low - - * Autogenerated package, see NEWS file for ChangeLog. - - -- Gwenole Beauchesne @TODAY@ diff --git a/debian.upstream/compat b/debian.upstream/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/debian.upstream/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/debian.upstream/control.in b/debian.upstream/control.in deleted file mode 100644 index 6d7d82c..0000000 --- a/debian.upstream/control.in +++ /dev/null @@ -1,111 +0,0 @@ -Source: libva -Priority: extra -Maintainer: Gwenole Beauchesne -Build-Depends: automake, - autotools-dev, - cdbs, - debhelper (>= 5), - libdrm-dev (>= @LIBDRM_VERSION@), -@USE_X11_TRUE@ libx11-dev, libxext-dev, libxfixes-dev, -@USE_GLX_TRUE@ libgl-dev, -@USE_WAYLAND_TRUE@ libwayland-dev (>= @WAYLAND_API_VERSION@), - libtool, - pkg-config -Standards-Version: 3.7.2 -Section: libs - -Package: libva-dev -Section: libdevel -Architecture: any -Depends: libdrm-dev (>= @LIBDRM_VERSION@), -@USE_DRM_TRUE@ libva-drm@LIBVA_MAJOR_VERSION@, -@USE_X11_TRUE@ libva-x11-@LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libx11-dev, -@USE_GLX_TRUE@ libva-glx@LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libgl-dev, -@USE_EGL_TRUE@ libva-egl@LIBVA_MAJOR_VERSION@ (= ${binary:Version}), -@USE_WAYLAND_TRUE@ libva-wayland@LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libwayland-dev (>= @WAYLAND_API_VERSION@), - libva@LIBVA_MAJOR_VERSION@ (= ${binary:Version}), - 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: libva@LIBVA_MAJOR_VERSION@ -Section: libs -Architecture: any -Depends: ${shlibs:Depends} -Description: Video Acceleration (VA) API for Linux -- Core runtime - The libva library implements the Video Acceleration (VA) API for Linux. - The library loads a hardware dependendent driver. - . - This package contains the Core runtime library. - -@USE_DRM_TRUE@Package: libva-drm@LIBVA_MAJOR_VERSION@ -@USE_DRM_TRUE@Section: libs -@USE_DRM_TRUE@Architecture: any -@USE_DRM_TRUE@Depends: ${shlibs:Depends} -@USE_DRM_TRUE@Description: Video Acceleration (VA) API for Linux -- DRM runtime -@USE_DRM_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux. -@USE_DRM_TRUE@ The library loads a hardware dependendent driver. -@USE_DRM_TRUE@ . -@USE_DRM_TRUE@ This package contains the VA/DRM runtime library. - -@USE_X11_TRUE@Package: libva-x11-@LIBVA_MAJOR_VERSION@ -@USE_X11_TRUE@Section: libs -@USE_X11_TRUE@Architecture: any -@USE_X11_TRUE@Depends: ${shlibs:Depends} -@USE_X11_TRUE@Description: Video Acceleration (VA) API for Linux -- X11 runtime -@USE_X11_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux. -@USE_X11_TRUE@ The library loads a hardware dependendent driver. -@USE_X11_TRUE@ . -@USE_X11_TRUE@ This package contains the VA/X11 runtime library. - -@USE_GLX_TRUE@Package: libva-glx@LIBVA_MAJOR_VERSION@ -@USE_GLX_TRUE@Section: libs -@USE_GLX_TRUE@Architecture: any -@USE_GLX_TRUE@Depends: ${shlibs:Depends} -@USE_GLX_TRUE@Description: Video Acceleration (VA) API for Linux -- GLX runtime -@USE_GLX_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux. -@USE_GLX_TRUE@ The library loads a hardware dependendent driver. -@USE_GLX_TRUE@ . -@USE_GLX_TRUE@ This package contains the VA/GLX runtime library. - -@USE_EGL_TRUE@Package: libva-egl@LIBVA_MAJOR_VERSION@ -@USE_EGL_TRUE@Section: libs -@USE_EGL_TRUE@Architecture: any -@USE_EGL_TRUE@Depends: ${shlibs:Depends} -@USE_EGL_TRUE@Description: Video Acceleration (VA) API for Linux -- EGL runtime -@USE_EGL_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux. -@USE_EGL_TRUE@ The library loads a hardware dependendent driver. -@USE_EGL_TRUE@ . -@USE_EGL_TRUE@ This package contains the VA/EGL runtime library. - -@USE_WAYLAND_TRUE@Package: libva-wayland@LIBVA_MAJOR_VERSION@ -@USE_WAYLAND_TRUE@Section: libs -@USE_WAYLAND_TRUE@Architecture: any -@USE_WAYLAND_TRUE@Depends: ${shlibs:Depends} -@USE_WAYLAND_TRUE@Description: Video Acceleration (VA) API for Linux -- Wayland runtime -@USE_WAYLAND_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux. -@USE_WAYLAND_TRUE@ The library loads a hardware dependendent driver. -@USE_WAYLAND_TRUE@ . -@USE_WAYLAND_TRUE@ This package contains the VA/Wayland runtime library. - -Package: libva@LIBVA_MAJOR_VERSION@-dbg -Section: libdevel -Architecture: any -Depends: libva@LIBVA_MAJOR_VERSION@ (= ${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 info files. - -Package: vainfo -Architecture: any -Depends: libva@LIBVA_MAJOR_VERSION@ (= ${Source-Version}) -Description: Video Acceleration (VA) API for Linux -- info program - The libva library implements the Video Acceleration (VA) API for Linux. - The library loads a hardware dependendent driver. - . - This package contains the `vainfo' program. diff --git a/debian.upstream/copyright b/debian.upstream/copyright deleted file mode 100644 index 38b60ef..0000000 --- a/debian.upstream/copyright +++ /dev/null @@ -1,44 +0,0 @@ -This package was debianized by Waldo Bastian on -Mon, 18 Jun 2007 21:35:31 -0700. - -It was downloaded from - -Upstream Author(s): - - Waldo Bastian - Jonathan Bian - -Copyright: - - (C) Copyright IBM Corporation 2004 - Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - Copyright 2000 VA Linux Systems, Inc. - Copyright 2007 Intel Corportation - -License: - - 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. - -The Debian packaging is (C) 2007, Intel Corporation and -is licensed under the GPL, see `/usr/share/common-licenses/GPL'. - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. diff --git a/debian.upstream/libva-dev.install b/debian.upstream/libva-dev.install deleted file mode 100644 index 2611cdb..0000000 --- a/debian.upstream/libva-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -debian/tmp/usr/include/va/va*.h -debian/tmp/usr/lib/libva*.so -debian/tmp/usr/lib/pkgconfig/libva*.pc diff --git a/debian.upstream/libva-drm.install.in b/debian.upstream/libva-drm.install.in deleted file mode 100644 index 7a9b5f2..0000000 --- a/debian.upstream/libva-drm.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva-drm.so.* diff --git a/debian.upstream/libva-egl.install.in b/debian.upstream/libva-egl.install.in deleted file mode 100644 index 5554b69..0000000 --- a/debian.upstream/libva-egl.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva-egl.so.* diff --git a/debian.upstream/libva-glx.install.in b/debian.upstream/libva-glx.install.in deleted file mode 100644 index 2d33032..0000000 --- a/debian.upstream/libva-glx.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva-glx.so.* diff --git a/debian.upstream/libva-wayland.install.in b/debian.upstream/libva-wayland.install.in deleted file mode 100644 index 2563fea..0000000 --- a/debian.upstream/libva-wayland.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva-wayland.so.* diff --git a/debian.upstream/libva-x11.install.in b/debian.upstream/libva-x11.install.in deleted file mode 100644 index 461d7bd..0000000 --- a/debian.upstream/libva-x11.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva-x11.so.* diff --git a/debian.upstream/libva.install.in b/debian.upstream/libva.install.in deleted file mode 100644 index bad195c..0000000 --- a/debian.upstream/libva.install.in +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/lib/libva.so.* diff --git a/debian.upstream/rules b/debian.upstream/rules deleted file mode 100755 index 40b76be..0000000 --- a/debian.upstream/rules +++ /dev/null @@ -1,14 +0,0 @@ -#!/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/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.upstream/vainfo.install b/debian.upstream/vainfo.install deleted file mode 100644 index 8ef46a0..0000000 --- a/debian.upstream/vainfo.install +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/bin/vainfo \ No newline at end of file diff --git a/doc/Doxyfile b/doc/Doxyfile deleted file mode 100644 index 920dd3f..0000000 --- a/doc/Doxyfile +++ /dev/null @@ -1,1679 +0,0 @@ -# Doxyfile 1.7.3 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = VA-API - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description for a project that appears at the top of each page and should give viewer a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = $(VA_HEADER_DIR) - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = YES - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = YES - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = YES - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even if there is only one candidate or it is obvious which candidate to choose by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = $(VA_HEADER_FILES) - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = */test/* - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html-out - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = $(VA_HTML_FOOTER) - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [0,1..20]) -# that doxygen will group on one line in the generated HTML documentation. -# Note that a value of 0 will completely suppress the enum values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 1 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called Helvetica to the output -# directory and reference it in all dot files that doxygen generates. -# When you want a differently looking font you can specify the font name -# using DOT_FONTNAME. You need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, svg, gif or svg. -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 3926979..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2007-2011 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. - -all: html -install-data-local: install-html - -EXTRA_DIST = \ - Doxyfile \ - $(NULL) - -VA_HEADER_DIR = $(top_srcdir)/va -VA_HEADER_FILES = \ - $(VA_HEADER_DIR)/va.h \ - $(VA_HEADER_DIR)/va_enc_h264.h \ - $(VA_HEADER_DIR)/va_vpp.h \ - $(NULL) - -VA_HTML_FOOTER = va_footer.html -VA_HTML_FRAGMENTS = $(VA_HTML_FOOTER) - -export VA_HEADER_DIR -export VA_HEADER_FILES -export VA_HTML_FOOTER -html-out/index.html: Doxyfile $(VA_HEADER_FILES) $(VA_HTML_FRAGMENTS) - $(DOXYGEN) $< - -if ENABLE_DOCS -html: html-out/index.html -install-html-local: - install -d $(DESTDIR)$(docdir)/html - for file in `ls html-out/` ; do \ - if test -f html-out/$$file ; then \ - install -m 0644 html-out/$$file $(DESTDIR)$(docdir)/html ; \ - else \ - install -d $(DESTDIR)$(docdir)/html/$$file ; \ - install -m 0644 html-out/$$file/* $(DESTDIR)$(docdir)/html/$$file; \ - fi ; \ - done -uninstall-local: - rm -rf $(DESTDIR)$(docdir)/html -endif - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/doc/va_footer.html b/doc/va_footer.html deleted file mode 100644 index 9f1875c..0000000 --- a/doc/va_footer.html +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am deleted file mode 100644 index 3468f01..0000000 --- a/dummy_drv_video/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# 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. - -AM_CPPFLAGS = -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 -dummy_drv_video_la_LIBADD = -dummy_drv_video_la_DEPENDENCIES = -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/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c deleted file mode 100644 index 282f208..0000000 --- a/dummy_drv_video/dummy_drv_video.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include - -#include "dummy_drv_video.h" - -#include "assert.h" -#include -#include -#include -#include - -#define ASSERT assert - -#define INIT_DRIVER_DATA struct dummy_driver_data * const driver_data = (struct dummy_driver_data *) ctx->pDriverData; - -#define CONFIG(id) ((object_config_p) object_heap_lookup( &driver_data->config_heap, id )) -#define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id )) -#define SURFACE(id) ((object_surface_p) object_heap_lookup( &driver_data->surface_heap, id )) -#define BUFFER(id) ((object_buffer_p) object_heap_lookup( &driver_data->buffer_heap, id )) - -#define CONFIG_ID_OFFSET 0x01000000 -#define CONTEXT_ID_OFFSET 0x02000000 -#define SURFACE_ID_OFFSET 0x04000000 -#define BUFFER_ID_OFFSET 0x08000000 - -static void dummy__error_message(const char *msg, ...) -{ - va_list args; - - fprintf(stderr, "dummy_drv_video error: "); - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); -} - -static void dummy__information_message(const char *msg, ...) -{ - va_list args; - - fprintf(stderr, "dummy_drv_video: "); - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); -} - -VAStatus dummy_QueryConfigProfiles( - VADriverContextP ctx, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ - ) -{ - int i = 0; - - profile_list[i++] = VAProfileMPEG2Simple; - profile_list[i++] = VAProfileMPEG2Main; - profile_list[i++] = VAProfileMPEG4Simple; - profile_list[i++] = VAProfileMPEG4AdvancedSimple; - profile_list[i++] = VAProfileMPEG4Main; - profile_list[i++] = VAProfileH264Baseline; - profile_list[i++] = VAProfileH264Main; - profile_list[i++] = VAProfileH264High; - profile_list[i++] = VAProfileVC1Simple; - profile_list[i++] = VAProfileVC1Main; - profile_list[i++] = VAProfileVC1Advanced; - - /* If the assert fails then DUMMY_MAX_PROFILES needs to be bigger */ - ASSERT(i <= DUMMY_MAX_PROFILES); - *num_profiles = i; - - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_QueryConfigEntrypoints( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint *entrypoint_list, /* out */ - int *num_entrypoints /* out */ - ) -{ - switch (profile) { - case VAProfileMPEG2Simple: - case VAProfileMPEG2Main: - *num_entrypoints = 2; - entrypoint_list[0] = VAEntrypointVLD; - entrypoint_list[1] = VAEntrypointMoComp; - break; - - case VAProfileMPEG4Simple: - case VAProfileMPEG4AdvancedSimple: - case VAProfileMPEG4Main: - *num_entrypoints = 1; - entrypoint_list[0] = VAEntrypointVLD; - break; - - case VAProfileH264Baseline: - case VAProfileH264Main: - case VAProfileH264High: - *num_entrypoints = 1; - entrypoint_list[0] = VAEntrypointVLD; - break; - - case VAProfileVC1Simple: - case VAProfileVC1Main: - case VAProfileVC1Advanced: - *num_entrypoints = 1; - entrypoint_list[0] = VAEntrypointVLD; - break; - - default: - *num_entrypoints = 0; - break; - } - - /* If the assert fails then DUMMY_MAX_ENTRYPOINTS needs to be bigger */ - ASSERT(*num_entrypoints <= DUMMY_MAX_ENTRYPOINTS); - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_GetConfigAttributes( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs - ) -{ - int i; - - /* Other attributes don't seem to be defined */ - /* What to do if we don't know the attribute? */ - for (i = 0; i < num_attribs; i++) - { - switch (attrib_list[i].type) - { - case VAConfigAttribRTFormat: - attrib_list[i].value = VA_RT_FORMAT_YUV420; - break; - - default: - /* Do nothing */ - attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; - break; - } - } - - return VA_STATUS_SUCCESS; -} - -static VAStatus dummy__update_attribute(object_config_p obj_config, VAConfigAttrib *attrib) -{ - int i; - /* Check existing attrbiutes */ - for(i = 0; obj_config->attrib_count < i; i++) - { - if (obj_config->attrib_list[i].type == attrib->type) - { - /* Update existing attribute */ - obj_config->attrib_list[i].value = attrib->value; - return VA_STATUS_SUCCESS; - } - } - if (obj_config->attrib_count < DUMMY_MAX_CONFIG_ATTRIBUTES) - { - i = obj_config->attrib_count; - obj_config->attrib_list[i].type = attrib->type; - obj_config->attrib_list[i].value = attrib->value; - obj_config->attrib_count++; - return VA_STATUS_SUCCESS; - } - return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; -} - -VAStatus dummy_CreateConfig( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus; - int configID; - object_config_p obj_config; - int i; - - /* Validate profile & entrypoint */ - switch (profile) { - case VAProfileMPEG2Simple: - case VAProfileMPEG2Main: - if ((VAEntrypointVLD == entrypoint) || - (VAEntrypointMoComp == entrypoint)) - { - vaStatus = VA_STATUS_SUCCESS; - } - else - { - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - } - break; - - case VAProfileMPEG4Simple: - case VAProfileMPEG4AdvancedSimple: - case VAProfileMPEG4Main: - if (VAEntrypointVLD == entrypoint) - { - vaStatus = VA_STATUS_SUCCESS; - } - else - { - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - } - break; - - case VAProfileH264Baseline: - case VAProfileH264Main: - case VAProfileH264High: - if (VAEntrypointVLD == entrypoint) - { - vaStatus = VA_STATUS_SUCCESS; - } - else - { - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - } - break; - - case VAProfileVC1Simple: - case VAProfileVC1Main: - case VAProfileVC1Advanced: - if (VAEntrypointVLD == entrypoint) - { - vaStatus = VA_STATUS_SUCCESS; - } - else - { - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; - } - break; - - default: - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; - break; - } - - if (VA_STATUS_SUCCESS != vaStatus) - { - return vaStatus; - } - - configID = object_heap_allocate( &driver_data->config_heap ); - obj_config = CONFIG(configID); - if (NULL == obj_config) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaStatus; - } - - obj_config->profile = profile; - obj_config->entrypoint = entrypoint; - obj_config->attrib_list[0].type = VAConfigAttribRTFormat; - obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420; - obj_config->attrib_count = 1; - - for(i = 0; i < num_attribs; i++) - { - vaStatus = dummy__update_attribute(obj_config, &(attrib_list[i])); - if (VA_STATUS_SUCCESS != vaStatus) - { - break; - } - } - - /* Error recovery */ - if (VA_STATUS_SUCCESS != vaStatus) - { - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); - } - else - { - *config_id = configID; - } - - return vaStatus; -} - -VAStatus dummy_DestroyConfig( - VADriverContextP ctx, - VAConfigID config_id - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus; - object_config_p obj_config; - - obj_config = CONFIG(config_id); - if (NULL == obj_config) - { - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; - return vaStatus; - } - - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_QueryConfigAttributes( - VADriverContextP ctx, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list, /* out */ - int *num_attribs /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_config_p obj_config; - int i; - - obj_config = CONFIG(config_id); - ASSERT(obj_config); - - *profile = obj_config->profile; - *entrypoint = obj_config->entrypoint; - *num_attribs = obj_config->attrib_count; - for(i = 0; i < obj_config->attrib_count; i++) - { - attrib_list[i] = obj_config->attrib_list[i]; - } - - return vaStatus; -} - -VAStatus dummy_CreateSurfaces( - VADriverContextP ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - int i; - - /* We only support one format */ - if (VA_RT_FORMAT_YUV420 != format) - { - return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; - } - - for (i = 0; i < num_surfaces; i++) - { - int surfaceID = object_heap_allocate( &driver_data->surface_heap ); - object_surface_p obj_surface = SURFACE(surfaceID); - if (NULL == obj_surface) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - break; - } - obj_surface->surface_id = surfaceID; - surfaces[i] = surfaceID; - } - - /* Error recovery */ - if (VA_STATUS_SUCCESS != vaStatus) - { - /* surfaces[i-1] was the last successful allocation */ - for(; i--; ) - { - object_surface_p obj_surface = SURFACE(surfaces[i]); - surfaces[i] = VA_INVALID_SURFACE; - ASSERT(obj_surface); - object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); - } - } - - return vaStatus; -} - -VAStatus dummy_DestroySurfaces( - VADriverContextP ctx, - VASurfaceID *surface_list, - int num_surfaces - ) -{ - INIT_DRIVER_DATA - int i; - for(i = num_surfaces; i--; ) - { - object_surface_p obj_surface = SURFACE(surface_list[i]); - ASSERT(obj_surface); - object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface); - } - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_QueryImageFormats( - VADriverContextP ctx, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_CreateImage( - VADriverContextP ctx, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_DeriveImage( - VADriverContextP ctx, - VASurfaceID surface, - VAImage *image /* out */ -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_DestroyImage( - VADriverContextP ctx, - VAImageID image -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_SetImagePalette( - VADriverContextP ctx, - VAImageID image, - unsigned char *palette -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_GetImage( - VADriverContextP ctx, - VASurfaceID surface, - int x, /* coordinates of the upper left source pixel */ - int y, - unsigned int width, /* width and height of the region */ - unsigned int height, - VAImageID image -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - - -VAStatus dummy_PutImage( - VADriverContextP ctx, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int src_width, - unsigned int src_height, - int dest_x, - int dest_y, - unsigned int dest_width, - unsigned int dest_height -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_QuerySubpictureFormats( - VADriverContextP ctx, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_CreateSubpicture( - VADriverContextP ctx, - VAImageID image, - VASubpictureID *subpicture /* out */ -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_DestroySubpicture( - VADriverContextP ctx, - VASubpictureID subpicture -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_SetSubpictureImage( - VADriverContextP ctx, - VASubpictureID subpicture, - VAImageID image -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_SetSubpicturePalette( - VADriverContextP ctx, - VASubpictureID subpicture, - /* - * pointer to an array holding the palette data. The size of the array is - * num_palette_entries * entry_bytes in size. The order of the components - * in the palette is described by the component_order in VASubpicture struct - */ - unsigned char *palette -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_SetSubpictureChromakey( - VADriverContextP ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_SetSubpictureGlobalAlpha( - VADriverContextP ctx, - VASubpictureID subpicture, - float global_alpha -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - - -VAStatus dummy_AssociateSubpicture( - VADriverContextP ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - unsigned short src_width, - unsigned short src_height, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short dest_width, - unsigned short dest_height, - /* - * whether to enable chroma-keying or global-alpha - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_DeassociateSubpicture( - VADriverContextP ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces -) -{ - /* TODO */ - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_CreateContext( - VADriverContextP ctx, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - VAContextID *context /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_config_p obj_config; - int i; - - obj_config = CONFIG(config_id); - if (NULL == obj_config) - { - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; - return vaStatus; - } - - /* Validate flag */ - /* Validate picture dimensions */ - - int contextID = object_heap_allocate( &driver_data->context_heap ); - object_context_p obj_context = CONTEXT(contextID); - if (NULL == obj_context) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaStatus; - } - - obj_context->context_id = contextID; - *context = contextID; - obj_context->current_render_target = -1; - obj_context->config_id = config_id; - obj_context->picture_width = picture_width; - obj_context->picture_height = picture_height; - obj_context->num_render_targets = num_render_targets; - obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID)); - if (obj_context->render_targets == NULL) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaStatus; - } - - for(i = 0; i < num_render_targets; i++) - { - if (NULL == SURFACE(render_targets[i])) - { - vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; - break; - } - obj_context->render_targets[i] = render_targets[i]; - } - obj_context->flags = flag; - - /* Error recovery */ - if (VA_STATUS_SUCCESS != vaStatus) - { - obj_context->context_id = -1; - obj_context->config_id = -1; - free(obj_context->render_targets); - obj_context->render_targets = NULL; - obj_context->num_render_targets = 0; - obj_context->flags = 0; - object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); - } - - return vaStatus; -} - - -VAStatus dummy_DestroyContext( - VADriverContextP ctx, - VAContextID context - ) -{ - INIT_DRIVER_DATA - object_context_p obj_context = CONTEXT(context); - ASSERT(obj_context); - - obj_context->context_id = -1; - obj_context->config_id = -1; - obj_context->picture_width = 0; - obj_context->picture_height = 0; - if (obj_context->render_targets) - { - free(obj_context->render_targets); - } - obj_context->render_targets = NULL; - obj_context->num_render_targets = 0; - obj_context->flags = 0; - - obj_context->current_render_target = -1; - - object_heap_free( &driver_data->context_heap, (object_base_p) obj_context); - - return VA_STATUS_SUCCESS; -} - - - -static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size) -{ - VAStatus vaStatus = VA_STATUS_SUCCESS; - - obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size); - if (NULL == obj_buffer->buffer_data) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - return vaStatus; -} - -VAStatus dummy_CreateBuffer( - VADriverContextP ctx, - VAContextID context, /* in */ - VABufferType type, /* in */ - unsigned int size, /* in */ - unsigned int num_elements, /* in */ - void *data, /* in */ - VABufferID *buf_id /* out */ -) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - int bufferID; - object_buffer_p obj_buffer; - - /* Validate type */ - switch (type) - { - case VAPictureParameterBufferType: - case VAIQMatrixBufferType: - case VABitPlaneBufferType: - case VASliceGroupMapBufferType: - case VASliceParameterBufferType: - case VASliceDataBufferType: - case VAMacroblockParameterBufferType: - case VAResidualDataBufferType: - case VADeblockingParameterBufferType: - case VAImageBufferType: - /* Ok */ - break; - default: - vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; - return vaStatus; - } - - bufferID = object_heap_allocate( &driver_data->buffer_heap ); - obj_buffer = BUFFER(bufferID); - if (NULL == obj_buffer) - { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaStatus; - } - - obj_buffer->buffer_data = NULL; - - vaStatus = dummy__allocate_buffer(obj_buffer, size * num_elements); - if (VA_STATUS_SUCCESS == vaStatus) - { - obj_buffer->max_num_elements = num_elements; - obj_buffer->num_elements = num_elements; - if (data) - { - memcpy(obj_buffer->buffer_data, data, size * num_elements); - } - } - - if (VA_STATUS_SUCCESS == vaStatus) - { - *buf_id = bufferID; - } - - return vaStatus; -} - - -VAStatus dummy_BufferSetNumElements( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_buffer_p obj_buffer = BUFFER(buf_id); - ASSERT(obj_buffer); - - if ((num_elements < 0) || (num_elements > obj_buffer->max_num_elements)) - { - vaStatus = VA_STATUS_ERROR_UNKNOWN; - } - if (VA_STATUS_SUCCESS == vaStatus) - { - obj_buffer->num_elements = num_elements; - } - - return vaStatus; -} - -VAStatus dummy_MapBuffer( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - void **pbuf /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; - object_buffer_p obj_buffer = BUFFER(buf_id); - ASSERT(obj_buffer); - if (NULL == obj_buffer) - { - vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; - return vaStatus; - } - - if (NULL != obj_buffer->buffer_data) - { - *pbuf = obj_buffer->buffer_data; - vaStatus = VA_STATUS_SUCCESS; - } - return vaStatus; -} - -VAStatus dummy_UnmapBuffer( - VADriverContextP ctx, - VABufferID buf_id /* in */ - ) -{ - /* Do nothing */ - return VA_STATUS_SUCCESS; -} - -static void dummy__destroy_buffer(struct dummy_driver_data *driver_data, object_buffer_p obj_buffer) -{ - if (NULL != obj_buffer->buffer_data) - { - free(obj_buffer->buffer_data); - obj_buffer->buffer_data = NULL; - } - - object_heap_free( &driver_data->buffer_heap, (object_base_p) obj_buffer); -} - -VAStatus dummy_DestroyBuffer( - VADriverContextP ctx, - VABufferID buffer_id - ) -{ - INIT_DRIVER_DATA - object_buffer_p obj_buffer = BUFFER(buffer_id); - ASSERT(obj_buffer); - - dummy__destroy_buffer(driver_data, obj_buffer); - return VA_STATUS_SUCCESS; -} - -VAStatus dummy_BeginPicture( - VADriverContextP ctx, - VAContextID context, - VASurfaceID render_target - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_context_p obj_context; - object_surface_p obj_surface; - - obj_context = CONTEXT(context); - ASSERT(obj_context); - - obj_surface = SURFACE(render_target); - ASSERT(obj_surface); - - obj_context->current_render_target = obj_surface->base.id; - - return vaStatus; -} - -VAStatus dummy_RenderPicture( - VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_context_p obj_context; - object_surface_p obj_surface; - int i; - - obj_context = CONTEXT(context); - ASSERT(obj_context); - - obj_surface = SURFACE(obj_context->current_render_target); - ASSERT(obj_surface); - - /* verify that we got valid buffer references */ - for(i = 0; i < num_buffers; i++) - { - object_buffer_p obj_buffer = BUFFER(buffers[i]); - ASSERT(obj_buffer); - if (NULL == obj_buffer) - { - vaStatus = VA_STATUS_ERROR_INVALID_BUFFER; - break; - } - } - - /* Release buffers */ - for(i = 0; i < num_buffers; i++) - { - object_buffer_p obj_buffer = BUFFER(buffers[i]); - ASSERT(obj_buffer); - dummy__destroy_buffer(driver_data, obj_buffer); - } - - return vaStatus; -} - -VAStatus dummy_EndPicture( - VADriverContextP ctx, - VAContextID context - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_context_p obj_context; - object_surface_p obj_surface; - - obj_context = CONTEXT(context); - ASSERT(obj_context); - - obj_surface = SURFACE(obj_context->current_render_target); - ASSERT(obj_surface); - - // For now, assume that we are done with rendering right away - obj_context->current_render_target = -1; - - return vaStatus; -} - - -VAStatus dummy_SyncSurface( - VADriverContextP ctx, - VASurfaceID render_target - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_surface_p obj_surface; - - obj_surface = SURFACE(render_target); - ASSERT(obj_surface); - - return vaStatus; -} - -VAStatus dummy_QuerySurfaceStatus( - VADriverContextP ctx, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ - ) -{ - INIT_DRIVER_DATA - VAStatus vaStatus = VA_STATUS_SUCCESS; - object_surface_p obj_surface; - - obj_surface = SURFACE(render_target); - ASSERT(obj_surface); - - *status = VASurfaceReady; - - return vaStatus; -} - -VAStatus dummy_PutSurface( - VADriverContextP ctx, - VASurfaceID surface, - void *draw, /* X Drawable */ - 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 */ - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -/* - * Query display attributes - * The caller must provide a "attr_list" array that can hold at - * least vaMaxNumDisplayAttributes() entries. The actual number of attributes - * returned in "attr_list" is returned in "num_attributes". - */ -VAStatus dummy_QueryDisplayAttributes ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -/* - * Get display attributes - * This function returns the current attribute values in "attr_list". - * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can have their values retrieved. - */ -VAStatus dummy_GetDisplayAttributes ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -/* - * Set display attributes - * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or - * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED - */ -VAStatus dummy_SetDisplayAttributes ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, - int num_attributes - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - - -VAStatus dummy_BufferInfo( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - VABufferType *type, /* out */ - unsigned int *size, /* out */ - unsigned int *num_elements /* out */ - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; -} - - - -VAStatus dummy_LockSurface( - VADriverContextP ctx, - 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 - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; -} - -VAStatus dummy_UnlockSurface( - VADriverContextP ctx, - VASurfaceID surface - ) -{ - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; -} - -VAStatus dummy_Terminate( VADriverContextP ctx ) -{ - INIT_DRIVER_DATA - object_buffer_p obj_buffer; - object_config_p obj_config; - object_heap_iterator iter; - - /* Clean up left over buffers */ - obj_buffer = (object_buffer_p) object_heap_first( &driver_data->buffer_heap, &iter); - while (obj_buffer) - { - dummy__information_message("vaTerminate: bufferID %08x still allocated, destroying\n", obj_buffer->base.id); - dummy__destroy_buffer(driver_data, obj_buffer); - obj_buffer = (object_buffer_p) object_heap_next( &driver_data->buffer_heap, &iter); - } - object_heap_destroy( &driver_data->buffer_heap ); - - /* TODO cleanup */ - object_heap_destroy( &driver_data->surface_heap ); - - /* TODO cleanup */ - object_heap_destroy( &driver_data->context_heap ); - - /* Clean up configIDs */ - obj_config = (object_config_p) object_heap_first( &driver_data->config_heap, &iter); - while (obj_config) - { - object_heap_free( &driver_data->config_heap, (object_base_p) obj_config); - obj_config = (object_config_p) object_heap_next( &driver_data->config_heap, &iter); - } - object_heap_destroy( &driver_data->config_heap ); - - free(ctx->pDriverData); - ctx->pDriverData = NULL; - - return VA_STATUS_SUCCESS; -} - -VAStatus VA_DRIVER_INIT_FUNC( VADriverContextP ctx ) -{ - struct VADriverVTable * const vtable = ctx->vtable; - int result; - struct dummy_driver_data *driver_data; - - ctx->version_major = VA_MAJOR_VERSION; - ctx->version_minor = VA_MINOR_VERSION; - ctx->max_profiles = DUMMY_MAX_PROFILES; - ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS; - ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES; - ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS; - ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS; - ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES; - ctx->str_vendor = DUMMY_STR_VENDOR; - - vtable->vaTerminate = dummy_Terminate; - vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; - vtable->vaQueryConfigProfiles = dummy_QueryConfigProfiles; - vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints; - vtable->vaQueryConfigAttributes = dummy_QueryConfigAttributes; - vtable->vaCreateConfig = dummy_CreateConfig; - vtable->vaDestroyConfig = dummy_DestroyConfig; - vtable->vaGetConfigAttributes = dummy_GetConfigAttributes; - vtable->vaCreateSurfaces = dummy_CreateSurfaces; - vtable->vaDestroySurfaces = dummy_DestroySurfaces; - vtable->vaCreateContext = dummy_CreateContext; - vtable->vaDestroyContext = dummy_DestroyContext; - vtable->vaCreateBuffer = dummy_CreateBuffer; - vtable->vaBufferSetNumElements = dummy_BufferSetNumElements; - vtable->vaMapBuffer = dummy_MapBuffer; - vtable->vaUnmapBuffer = dummy_UnmapBuffer; - vtable->vaDestroyBuffer = dummy_DestroyBuffer; - vtable->vaBeginPicture = dummy_BeginPicture; - vtable->vaRenderPicture = dummy_RenderPicture; - vtable->vaEndPicture = dummy_EndPicture; - vtable->vaSyncSurface = dummy_SyncSurface; - vtable->vaQuerySurfaceStatus = dummy_QuerySurfaceStatus; - vtable->vaPutSurface = dummy_PutSurface; - vtable->vaQueryImageFormats = dummy_QueryImageFormats; - vtable->vaCreateImage = dummy_CreateImage; - vtable->vaDeriveImage = dummy_DeriveImage; - vtable->vaDestroyImage = dummy_DestroyImage; - vtable->vaSetImagePalette = dummy_SetImagePalette; - vtable->vaGetImage = dummy_GetImage; - vtable->vaPutImage = dummy_PutImage; - vtable->vaQuerySubpictureFormats = dummy_QuerySubpictureFormats; - vtable->vaCreateSubpicture = dummy_CreateSubpicture; - vtable->vaDestroySubpicture = dummy_DestroySubpicture; - vtable->vaSetSubpictureImage = dummy_SetSubpictureImage; - vtable->vaSetSubpictureChromakey = dummy_SetSubpictureChromakey; - vtable->vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha; - vtable->vaAssociateSubpicture = dummy_AssociateSubpicture; - vtable->vaDeassociateSubpicture = dummy_DeassociateSubpicture; - vtable->vaQueryDisplayAttributes = dummy_QueryDisplayAttributes; - vtable->vaGetDisplayAttributes = dummy_GetDisplayAttributes; - vtable->vaSetDisplayAttributes = dummy_SetDisplayAttributes; - vtable->vaLockSurface = dummy_LockSurface; - vtable->vaUnlockSurface = dummy_UnlockSurface; - vtable->vaBufferInfo = dummy_BufferInfo; - - driver_data = (struct dummy_driver_data *) malloc( sizeof(*driver_data) ); - ctx->pDriverData = (void *) driver_data; - - result = object_heap_init( &driver_data->config_heap, sizeof(struct object_config), CONFIG_ID_OFFSET ); - ASSERT( result == 0 ); - - result = object_heap_init( &driver_data->context_heap, sizeof(struct object_context), CONTEXT_ID_OFFSET ); - ASSERT( result == 0 ); - - result = object_heap_init( &driver_data->surface_heap, sizeof(struct object_surface), SURFACE_ID_OFFSET ); - ASSERT( result == 0 ); - - result = object_heap_init( &driver_data->buffer_heap, sizeof(struct object_buffer), BUFFER_ID_OFFSET ); - ASSERT( result == 0 ); - - - return VA_STATUS_SUCCESS; -} - diff --git a/dummy_drv_video/dummy_drv_video.h b/dummy_drv_video/dummy_drv_video.h deleted file mode 100644 index cd849c5..0000000 --- a/dummy_drv_video/dummy_drv_video.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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. - */ - -#ifndef _DUMMY_DRV_VIDEO_H_ -#define _DUMMY_DRV_VIDEO_H_ - -#include -#include "object_heap.h" - -#define DUMMY_MAX_PROFILES 11 -#define DUMMY_MAX_ENTRYPOINTS 5 -#define DUMMY_MAX_CONFIG_ATTRIBUTES 10 -#define DUMMY_MAX_IMAGE_FORMATS 10 -#define DUMMY_MAX_SUBPIC_FORMATS 4 -#define DUMMY_MAX_DISPLAY_ATTRIBUTES 4 -#define DUMMY_STR_VENDOR "Dummy Driver 1.0" - -struct dummy_driver_data { - struct object_heap config_heap; - struct object_heap context_heap; - struct object_heap surface_heap; - struct object_heap buffer_heap; -}; - -struct object_config { - struct object_base base; - VAProfile profile; - VAEntrypoint entrypoint; - VAConfigAttrib attrib_list[DUMMY_MAX_CONFIG_ATTRIBUTES]; - int attrib_count; -}; - -struct object_context { - struct object_base base; - VAContextID context_id; - VAConfigID config_id; - VASurfaceID current_render_target; - int picture_width; - int picture_height; - int num_render_targets; - int flags; - VASurfaceID *render_targets; -}; - -struct object_surface { - struct object_base base; - VASurfaceID surface_id; -}; - -struct object_buffer { - struct object_base base; - void *buffer_data; - int max_num_elements; - int num_elements; -}; - -typedef struct object_config *object_config_p; -typedef struct object_context *object_context_p; -typedef struct object_surface *object_surface_p; -typedef struct object_buffer *object_buffer_p; - -#endif /* _DUMMY_DRV_VIDEO_H_ */ diff --git a/dummy_drv_video/object_heap.c b/dummy_drv_video/object_heap.c deleted file mode 100644 index 7f18a1f..0000000 --- a/dummy_drv_video/object_heap.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include "object_heap.h" - -#define ASSERT assert - -#define LAST_FREE -1 -#define ALLOCATED -2 - -/* - * Expands the heap - * Return 0 on success, -1 on error - */ -static int -object_heap_expand(object_heap_p heap) -{ - int i; - void *new_heap_index; - int next_free; - int new_heap_size = heap->heap_size + heap->heap_increment; - int bucket_index = new_heap_size / heap->heap_increment - 1; - - if (bucket_index >= heap->num_buckets) { - int new_num_buckets = heap->num_buckets + 8; - void **new_bucket; - - new_bucket = realloc(heap->bucket, new_num_buckets * sizeof(void *)); - if (NULL == new_bucket) { - return -1; - } - - heap->num_buckets = new_num_buckets; - heap->bucket = new_bucket; - } - - new_heap_index = (void *) malloc(heap->heap_increment * heap->object_size); - if (NULL == new_heap_index) { - return -1; /* Out of memory */ - } - - heap->bucket[bucket_index] = new_heap_index; - next_free = heap->next_free; - for (i = new_heap_size; i-- > heap->heap_size;) { - object_base_p obj = (object_base_p)(new_heap_index + (i - heap->heap_size) * heap->object_size); - obj->id = i + heap->id_offset; - obj->next_free = next_free; - next_free = i; - } - heap->next_free = next_free; - heap->heap_size = new_heap_size; - return 0; /* Success */ -} - -/* - * Return 0 on success, -1 on error - */ -int -object_heap_init(object_heap_p heap, int object_size, int id_offset) -{ - pthread_mutex_init(&heap->mutex, NULL); - heap->object_size = object_size; - heap->id_offset = id_offset & OBJECT_HEAP_OFFSET_MASK; - heap->heap_size = 0; - heap->heap_increment = 16; - heap->next_free = LAST_FREE; - heap->num_buckets = 0; - heap->bucket = NULL; - return object_heap_expand(heap); -} - -/* - * Allocates an object - * Returns the object ID on success, returns -1 on error - */ -static int -object_heap_allocate_unlocked(object_heap_p heap) -{ - object_base_p obj; - int bucket_index, obj_index; - - if (LAST_FREE == heap->next_free) { - if (-1 == object_heap_expand(heap)) { - return -1; /* Out of memory */ - } - } - ASSERT(heap->next_free >= 0); - - bucket_index = heap->next_free / heap->heap_increment; - obj_index = heap->next_free % heap->heap_increment; - - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); - heap->next_free = obj->next_free; - obj->next_free = ALLOCATED; - return obj->id; -} - -int -object_heap_allocate(object_heap_p heap) -{ - int ret; - - pthread_mutex_lock(&heap->mutex); - ret = object_heap_allocate_unlocked(heap); - pthread_mutex_unlock(&heap->mutex); - return ret; -} - -/* - * Lookup an object by object ID - * Returns a pointer to the object on success, returns NULL on error - */ -static object_base_p -object_heap_lookup_unlocked(object_heap_p heap, int id) -{ - object_base_p obj; - int bucket_index, obj_index; - - if ((id < heap->id_offset) || (id > (heap->heap_size + heap->id_offset))) { - return NULL; - } - id &= OBJECT_HEAP_ID_MASK; - bucket_index = id / heap->heap_increment; - obj_index = id % heap->heap_increment; - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); - - /* Check if the object has in fact been allocated */ - if (obj->next_free != ALLOCATED) { - return NULL; - } - return obj; -} - -object_base_p -object_heap_lookup(object_heap_p heap, int id) -{ - object_base_p obj; - - pthread_mutex_lock(&heap->mutex); - obj = object_heap_lookup_unlocked(heap, id); - pthread_mutex_unlock(&heap->mutex); - return obj; -} - -/* - * Iterate over all objects in the heap. - * Returns a pointer to the first object on the heap, returns NULL if heap is empty. - */ -object_base_p -object_heap_first(object_heap_p heap, object_heap_iterator *iter) -{ - *iter = -1; - return object_heap_next(heap, iter); -} - -/* - * Iterate over all objects in the heap. - * Returns a pointer to the next object on the heap, returns NULL if heap is empty. - */ -static object_base_p -object_heap_next_unlocked(object_heap_p heap, object_heap_iterator *iter) -{ - object_base_p obj; - int bucket_index, obj_index; - int i = *iter + 1; - - while (i < heap->heap_size) { - bucket_index = i / heap->heap_increment; - obj_index = i % heap->heap_increment; - - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); - if (obj->next_free == ALLOCATED) { - *iter = i; - return obj; - } - i++; - } - *iter = i; - return NULL; -} - -object_base_p -object_heap_next(object_heap_p heap, object_heap_iterator *iter) -{ - object_base_p obj; - - pthread_mutex_lock(&heap->mutex); - obj = object_heap_next_unlocked(heap, iter); - pthread_mutex_unlock(&heap->mutex); - return obj; -} - -/* - * Frees an object - */ -static void -object_heap_free_unlocked(object_heap_p heap, object_base_p obj) -{ - /* Check if the object has in fact been allocated */ - ASSERT(obj->next_free == ALLOCATED); - - obj->next_free = heap->next_free; - heap->next_free = obj->id & OBJECT_HEAP_ID_MASK; -} - -void -object_heap_free(object_heap_p heap, object_base_p obj) -{ - if (!obj) - return; - pthread_mutex_lock(&heap->mutex); - object_heap_free_unlocked(heap, obj); - pthread_mutex_unlock(&heap->mutex); -} - -/* - * Destroys a heap, the heap must be empty. - */ -void -object_heap_destroy(object_heap_p heap) -{ - object_base_p obj; - int bucket_index, obj_index, i; - - /* Check if heap is empty */ - for (i = 0; i < heap->heap_size; i++) { - /* Check if object is not still allocated */ - bucket_index = i / heap->heap_increment; - obj_index = i % heap->heap_increment; - obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size); - ASSERT(obj->next_free != ALLOCATED); - } - - for (i = 0; i < heap->heap_size / heap->heap_increment; i++) { - free(heap->bucket[i]); - } - - pthread_mutex_destroy(&heap->mutex); - - free(heap->bucket); - heap->bucket = NULL; - heap->heap_size = 0; - heap->next_free = LAST_FREE; -} diff --git a/dummy_drv_video/object_heap.h b/dummy_drv_video/object_heap.h deleted file mode 100644 index 58e1183..0000000 --- a/dummy_drv_video/object_heap.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - */ - -#ifndef OBJECT_HEAP_H -#define OBJECT_HEAP_H - -#include - -#define OBJECT_HEAP_OFFSET_MASK 0x7F000000 -#define OBJECT_HEAP_ID_MASK 0x00FFFFFF - -typedef struct object_base *object_base_p; -typedef struct object_heap *object_heap_p; - -struct object_base { - int id; - int next_free; -}; - -struct object_heap { - pthread_mutex_t mutex; - int object_size; - int id_offset; - int next_free; - int heap_size; - int heap_increment; - void **bucket; - int num_buckets; -}; - -typedef int object_heap_iterator; - -/* - * Return 0 on success, -1 on error - */ -int -object_heap_init(object_heap_p heap, int object_size, int id_offset); - -/* - * Allocates an object - * Returns the object ID on success, returns -1 on error - */ -int -object_heap_allocate(object_heap_p heap); - -/* - * Lookup an allocated object by object ID - * Returns a pointer to the object on success, returns NULL on error - */ -object_base_p -object_heap_lookup(object_heap_p heap, int id); - -/* - * Iterate over all objects in the heap. - * Returns a pointer to the first object on the heap, returns NULL if heap is empty. - */ -object_base_p -object_heap_first(object_heap_p heap, object_heap_iterator *iter); - -/* - * Iterate over all objects in the heap. - * Returns a pointer to the next object on the heap, returns NULL if heap is empty. - */ -object_base_p -object_heap_next(object_heap_p heap, object_heap_iterator *iter); - -/* - * Frees an object - */ -void -object_heap_free(object_heap_p heap, object_base_p obj); - -/* - * Destroys a heap, the heap must be empty. - */ -void -object_heap_destroy(object_heap_p heap); - -#endif /* OBJECT_HEAP_H */ diff --git a/libva.spec b/libva.spec deleted file mode 100644 index 28842a3..0000000 --- a/libva.spec +++ /dev/null @@ -1,151 +0,0 @@ -#%define moduledir %(pkg-config xorg-server --variable=moduledir) -%define libversion 1.0.11 - -Name: libva -Version: %{libversion} -Release: 0.0 -License: MIT -Source: %{name}-%{version}.tar.bz2 -NoSource: 0 -Group: Development/Libraries -Summary: Video Acceleration (VA) API for Linux -URL: http://freedesktop.org/wiki/Software/vaapi -BuildRoot: %{_tmppath}/%{name}-%{version}-build - -Requires: xorg-x11-server-Xorg - -Requires: /sbin/ldconfig -BuildRequires: pkgconfig(xv) -BuildRequires: pkgconfig(xrandr) -BuildRequires: pkgconfig(xorg-server) -BuildRequires: pkgconfig(libdrm) -BuildRequires: pkgconfig(x11) -BuildRequires: pkgconfig(xext) -BuildRequires: pkgconfig(xdamage) -BuildRequires: pkgconfig(xfixes) -BuildRequires: pkgconfig(dri2proto) -BuildRequires: pkgconfig(damageproto) -BuildRequires: pkgconfig(kbproto) -BuildRequires: pkgconfig(xextproto) -BuildRequires: pkgconfig(fixesproto) -BuildRequires: pkgconfig(xproto) -BuildRequires: pkgconfig(gl) -BuildRequires: libtool - - - - - -%description -The libva library implements the Video Acceleration (VA) API for Linux. -The library loads a hardware dependendent driver. - -%package devel -Summary: Video Acceleration (VA) API for Linux -- development files -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: pkgconfig - -%description devel -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. - -%prep -%setup -q - -%build -unset LD_AS_NEEDED -%autogen -make - -%install -%make_install - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -%{_libdir}/libva.so.1 -%{_libdir}/libva.so.%{libversion} -%{_libdir}/libva-tpi.so.1 -%{_libdir}/libva-tpi.so.%{libversion} -%{_libdir}/libva-x11.so.1 -%{_libdir}/libva-x11.so.%{libversion} -%{_libdir}/libva-glx.so.1 -%{_libdir}/libva-glx.so.%{libversion} -%{_libdir}/libva-egl.so.1 -%{_libdir}/libva-egl.so.%{libversion} -%{_bindir}/vainfo -%{_bindir}/test_* -%{_bindir}/h264encode -%{_bindir}/mpeg2vldemo -%{_bindir}/putsurface - -%{_libdir}/dri/dummy_drv_video.so - -%files devel -%defattr(-,root,root,-) -%dir %{_includedir}/va -%{_includedir}/va/* -%{_libdir}/libva.so -%{_libdir}/libva-tpi.so -%{_libdir}/libva-x11.so -%{_libdir}/libva-glx.so -%{_libdir}/libva-egl.so -%{_libdir}/pkgconfig/libva.pc -%{_libdir}/pkgconfig/libva-tpi.pc -%{_libdir}/pkgconfig/libva-x11.pc -%{_libdir}/pkgconfig/libva-glx.pc -%{_libdir}/pkgconfig/libva-egl.pc - -%changelog -* Tue Jan 25 2011 Austin Yuan 1.0.1 -- Updated libva source to 1.0.8 -* Wed Dec 23 2009 Prajwal Mohan 1.0.1 -- Updated libva source to IMG Alpha7 -* Fri Dec 18 2009 Prajwal Mohan 0.31.0 -- Updated libva source to IMG Alpha6 -* Tue Nov 24 2009 Prajwal Mohan 0.31.0 -- Updated libva source -* Mon Nov 9 2009 Prajwal Mohan 0.31.0 -- Update to version 0.31.0 -* Tue Jul 7 2009 Prajwal Mohan 0.30.4 -- Update to version 0.30.4 -* Wed Jun 24 2009 Prajwal Mohan 0.30.20090618 -- Update to version 0.30.20090618_Alpha2.3 -* Thu Jun 11 2009 Priya Vijayan 0.30.20090608 -- Update to version 0.30.20090608 -* Tue Jun 2 2009 Anas Nashif - 0.30~20090514 -- unset LD_AS_NEEDED -* Fri May 15 2009 Anas Nashif 0.30~20090514 -- Update to latest snapshot 20090514 -* Wed Apr 29 2009 Anas Nashif 0.30~20090428 -- Update to 20090428 snpashot -* Sun Apr 26 2009 Anas Nashif 0.30~20090423 -- Update libva.pc with new includedir -* Sun Apr 26 2009 Anas Nashif 0.30~20090423 -- Update to latest snapshot 20090423 -* Sun Apr 26 2009 Anas Nashif 0.30~20090423 -- Update to latest snapshot: 20090423 -* Mon Mar 23 2009 Anas Nashif 0.30~20090323 -- Update to 0.30~20090323 -* Fri Jan 16 2009 Priya Vijayan 0.31 -- Fixing vainfo.c -* Fri Jan 16 2009 Priya Vijayan 0.31 -- fixing va_backend.h -* Fri Jan 16 2009 Priya Vijayan 0.31 -- Updating source -* Tue Jan 6 2009 Priya Vijayan 0.30 -- Update to 0.28-working combination with X Server -* Fri Dec 19 2008 Priya Vijayan 0.30.0 -- Added definition of FOURCC IYUV - * Dec 16 2008 Priya Vijayan -- Initial Import to MRST -* Mon Oct 13 2008 shengquan.yuan@intel.com -- packaged mrst-video-decode-src version 0.0.1 using the buildservice spec file wizard diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am deleted file mode 100644 index a3435a4..0000000 --- a/pkgconfig/Makefile.am +++ /dev/null @@ -1,57 +0,0 @@ -# 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 -if USE_DRM -pcfiles += libva-drm.pc -endif -if USE_X11 -pcfiles += libva-x11.pc -endif -if USE_GLX -pcfiles += libva-glx.pc -endif -if USE_EGL -pcfiles += libva-egl.pc -endif -if USE_WAYLAND -pcfiles += libva-wayland.pc -endif - -all_pcfiles_in = libva.pc.in -all_pcfiles_in += libva-tpi.pc.in -all_pcfiles_in += libva-drm.pc.in -all_pcfiles_in += libva-x11.pc.in -all_pcfiles_in += libva-glx.pc.in -all_pcfiles_in += libva-egl.pc.in -all_pcfiles_in += libva-wayland.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/pkgconfig/libva-drm.pc.in b/pkgconfig/libva-drm.pc.in deleted file mode 100644 index b3fb471..0000000 --- a/pkgconfig/libva-drm.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=drm - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff --git a/pkgconfig/libva-egl.pc.in b/pkgconfig/libva-egl.pc.in deleted file mode 100644 index d80fcc8..0000000 --- a/pkgconfig/libva-egl.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=egl - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} - diff --git a/pkgconfig/libva-glx.pc.in b/pkgconfig/libva-glx.pc.in deleted file mode 100644 index 8599866..0000000 --- a/pkgconfig/libva-glx.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=glx - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff --git a/pkgconfig/libva-tpi.pc.in b/pkgconfig/libva-tpi.pc.in deleted file mode 100644 index bc7fdd7..0000000 --- a/pkgconfig/libva-tpi.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libva-tpi -Description: Userspace Video Acceleration (VA) 3rd party interface -Requires: libva -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-tpi -Cflags: -I${includedir} diff --git a/pkgconfig/libva-wayland.pc.in b/pkgconfig/libva-wayland.pc.in deleted file mode 100644 index ee92ac2..0000000 --- a/pkgconfig/libva-wayland.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=wayland - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva wayland-client -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff --git a/pkgconfig/libva-x11.pc.in b/pkgconfig/libva-x11.pc.in deleted file mode 100644 index 4e7330c..0000000 --- a/pkgconfig/libva-x11.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=x11 - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff --git a/pkgconfig/libva.pc.in b/pkgconfig/libva.pc.in deleted file mode 100644 index 8b03f98..0000000 --- a/pkgconfig/libva.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -driverdir=@LIBVA_DRIVERS_PATH@ - -Name: libva -Description: Userspace Video Acceleration (VA) core interface -Version: @VA_API_VERSION@ -Libs: -L${libdir} -lva -Cflags: -I${includedir} diff --git a/style_unify b/style_unify deleted file mode 100755 index 4915e63..0000000 --- a/style_unify +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -file=$(find . -name "*.[ch]" -o -name "*.cpp") -for i in $file -do - echo $i - astyle --style=linux -s4 -c -s -p -U -H -n $i -done - - - diff --git a/test/Android.mk b/test/Android.mk deleted file mode 100644 index f3f122c..0000000 --- a/test/Android.mk +++ /dev/null @@ -1,4 +0,0 @@ -# Recursive call sub-folder Android.mk -# - include $(call all-subdir-makefiles) - diff --git a/test/Makefile.am b/test/Makefile.am deleted file mode 100644 index 6083bb3..0000000 --- a/test/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# 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. - -SUBDIRS = common decode encode vainfo - -if USE_X11 -SUBDIRS += basic putsurface -endif - -EXTRA_DIST = loadsurface.h loadsurface_yuv.h diff --git a/test/basic/Android.mk b/test/basic/Android.mk deleted file mode 100755 index 2b4255c..0000000 --- a/test/basic/Android.mk +++ /dev/null @@ -1,234 +0,0 @@ -# For test_01 -# ===================================================== - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_01.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_001 - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_02 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_02.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_02_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_03 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_03.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_03_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_04g -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_04.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_04_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_05 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_05.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_05_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_06 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_06.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_06_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_07 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_07.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_07_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_08 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_08.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_08_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_09 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_09.c \ - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_09_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_10 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_10.c - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_10_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - -# For test_11 -# ===================================================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - test_11.c - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TOPDIR)/hardware/intel/libva/va/ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := test_11_android - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger - -include $(BUILD_EXECUTABLE) - diff --git a/test/basic/Makefile.am b/test/basic/Makefile.am deleted file mode 100644 index 21f48dd..0000000 --- a/test/basic/Makefile.am +++ /dev/null @@ -1,87 +0,0 @@ -# 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. - -noinst_PROGRAMS = \ - test_01 \ - test_02 \ - test_03 \ - test_04 \ - test_05 \ - test_06 \ - test_07 \ - test_08 \ - test_09 \ - test_10 \ - test_11 \ - $(NULL) - -AM_CFLAGS = \ - -DIN_LIBVA \ - -I$(top_srcdir) \ - $(X11_CFLAGS) \ - $(NULL) - -TEST_LIBS = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/va/libva-x11.la \ - $(X11_LIBS) \ - $(NULL) - -test_01_LDADD = $(TEST_LIBS) -test_01_SOURCES = test_01.c - -test_02_LDADD = $(TEST_LIBS) -test_02_SOURCES = test_02.c - -test_03_LDADD = $(TEST_LIBS) -test_03_SOURCES = test_03.c - -test_04_LDADD = $(TEST_LIBS) -test_04_SOURCES = test_04.c - -test_05_LDADD = $(TEST_LIBS) -test_05_SOURCES = test_05.c - -test_06_LDADD = $(TEST_LIBS) -test_06_SOURCES = test_06.c - -test_07_LDADD = $(TEST_LIBS) -test_07_SOURCES = test_07.c - -test_08_LDADD = $(TEST_LIBS) -test_08_SOURCES = test_08.c - -test_09_LDADD = $(TEST_LIBS) -test_09_SOURCES = test_09.c - -test_10_LDADD = $(TEST_LIBS) -test_10_SOURCES = test_10.c - -test_11_LDADD = $(TEST_LIBS) -test_11_SOURCES = test_11.c - -EXTRA_DIST = test_common.c test_x11.c - -valgrind: $(noinst_PROGRAMS) - for a in $(noinst_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done diff --git a/test/basic/test.c b/test/basic/test.c deleted file mode 100644 index a03a8b2..0000000 --- a/test/basic/test.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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. - */ - -#include - -#include "assert.h" -#include -#include -#include -#include - -#define ASSERT assert - -int main(int argc, const char* argv[]) -{ - Display *dpy; - VADisplay va_dpy; - VAStatus va_status; - int major_version, minor_version; - - dpy = XOpenDisplay(NULL); - ASSERT( dpy ); - printf("XOpenDisplay: dpy = %08x\n", dpy); - - va_dpy = vaGetDisplay(dpy); - ASSERT( va_dpy ); - printf("vaGetDisplay: va_dpy = %08x\n", va_dpy); - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - ASSERT( VA_STATUS_SUCCESS == va_status ); - printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version); - - { - VASurfaceID surfaces[21]; - int i; - - surfaces[20] = -1; - va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( -1 == surfaces[20] ); /* bounds check */ - for(i = 0; i < 20; i++) - { - printf("Surface %d surface_id = %08x\n", i, surfaces[i]); - } - Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0)); - printf("Window = %08x\n", win); - XMapWindow(dpy, win); - XSync(dpy, False); - - vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0); - - sleep(10); - va_status = vaDestroySurface(va_dpy, surfaces, 20); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - { - int num_profiles; - int i; - VAProfile *profiles = malloc(vaMaxNumProfiles(va_dpy) * sizeof(VAProfile)); - ASSERT(profiles); - printf("vaMaxNumProfiles = %d\n", vaMaxNumProfiles(va_dpy)); - - va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - printf("vaQueryConfigProfiles reports %d profiles\n", num_profiles); - for(i = 0; i < num_profiles; i++) - { - printf("Profile %d\n", profiles[i]); - } - } - - { - VASurfaceID surfaces[20]; - VAContextID context; - VAConfigAttrib attrib; - VAConfigID config_id; - int i; - - attrib.type = VAConfigAttribRTFormat; - va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - ASSERT(attrib.value & VA_RT_FORMAT_YUV420); - /* Found desired RT format, keep going */ - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1, - &config_id); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyContext(va_dpy, context); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurface(va_dpy, surfaces, 20); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - { - VABufferID picture_buf[3]; - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[0]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[1]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[2]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyBuffer(va_dpy, picture_buf[0]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaDestroyBuffer(va_dpy, picture_buf[2]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaDestroyBuffer(va_dpy, picture_buf[1]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - va_status = vaTerminate(va_dpy); - ASSERT( VA_STATUS_SUCCESS == va_status ); - printf("vaTerminate\n"); - - XCloseDisplay(dpy); - - return 0; -} diff --git a/test/basic/test_01.c b/test/basic/test_01.c deleted file mode 100644 index 4075655..0000000 --- a/test/basic/test_01.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Initialize & Terminate" - -#include "test_common.c" - -void pre() -{ -} - -void post() -{ -} - -void test() -{ - test_init(); - - test_terminate(); -} diff --git a/test/basic/test_02.c b/test/basic/test_02.c deleted file mode 100644 index 5622a18..0000000 --- a/test/basic/test_02.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Query profiles" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -void test() -{ - test_profiles(); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_03.c b/test/basic/test_03.c deleted file mode 100644 index d2af494..0000000 --- a/test/basic/test_03.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Query entrypoints for all profiles" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - status("vaMaxEntryPoints = %d\n", max_entrypoints); - ASSERT(max_entrypoints > 0); - - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - for(i = 0; i < num_profiles; i++) - { - memset(entrypoints, 0xff, max_entrypoints * sizeof(VAEntrypoint)); - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaQueryConfigEntryPoints(%s) reports %d entrypoints\n", profile2string(profiles[i]), num_entrypoints); - ASSERT(num_entrypoints <= max_entrypoints); - ASSERT(num_entrypoints > 0); - for(j = 0; j < num_entrypoints; j++) - { - status(" entrypoint %d [%s]\n", entrypoints[j], entrypoint2string(entrypoints[j])); - } - } - - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_04.c b/test/basic/test_04.c deleted file mode 100644 index 2e3329c..0000000 --- a/test/basic/test_04.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Get config attributes for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -#define DEADVALUE 0xdeaddead - -void test() -{ - VAConfigAttrib attributes[] = { - { type: VAConfigAttribRTFormat, value: DEADVALUE }, - { type: VAConfigAttribSpatialResidual, value: DEADVALUE }, - { type: VAConfigAttribSpatialClipping, value: DEADVALUE }, - { type: VAConfigAttribIntraResidual, value: DEADVALUE }, - { type: VAConfigAttribEncryption, value: DEADVALUE } - }; - int max_entrypoints; - int num_entrypoints; - int num_attribs = sizeof(attributes) / sizeof(VAConfigAttrib); - int i, j, k; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigAttrib *attrib_list = (VAConfigAttrib *) malloc(sizeof(attributes)); - ASSERT(attrib_list); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - memcpy(attrib_list, attributes, sizeof(attributes)); - status("vaGetConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaGetConfigAttributes(va_dpy, profiles[i], entrypoints[j], attrib_list, num_attribs); - ASSERT( VA_STATUS_SUCCESS == va_status ); - for(k = 0; k < num_attribs; k++) - { - status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); - ASSERT(attrib_list[k].value != DEADVALUE); - } - } - } - - free(attrib_list); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_05.c b/test/basic/test_05.c deleted file mode 100644 index a05100d..0000000 --- a/test/basic/test_05.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Create/destroy configs for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j; - int config_count = 0; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - ASSERT(configs); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", configs[config_count]); - config_count++; - } - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyConfig for config %08x\n", configs[i]); - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - free(configs); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_06.c b/test/basic/test_06.c deleted file mode 100644 index e782d81..0000000 --- a/test/basic/test_06.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Get config attributes from configs" - -#include "test_common.c" - -int max_entrypoints; -VAEntrypoint *entrypoints; - -VAConfigID *configs; -int config_count = 0; - - - -void pre() -{ - int i, j; - - test_init(); - test_profiles(); - - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - ASSERT(configs); - - // Create configs - for(i = 0; i < num_profiles; i++) - { - int num_entrypoints; - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - config_count++; - } - } -} - -void test() -{ - int i, j, k; - int max_attribs; - - max_attribs = vaMaxNumConfigAttributes(va_dpy); - ASSERT(max_attribs > 0); - - VAConfigAttrib *attrib_list = malloc(max_attribs * sizeof(VAConfigAttrib)); - ASSERT(attrib_list); - - config_count = 0; - for(i = 0; i < num_profiles; i++) - { - int num_entrypoints; - - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - for(j = 0; j < num_entrypoints; j++) - { - VAProfile profile= -1; - VAEntrypoint entrypoint = -1; - int num_attribs = -1; - - status("Checking vaQueryConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - memset(attrib_list, 0xff, max_attribs * sizeof(VAConfigAttrib)); - - va_status = vaQueryConfigAttributes(va_dpy, configs[config_count], &profile, &entrypoint, attrib_list, &num_attribs); - config_count++; - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( profile == profiles[i] ); - ASSERT( entrypoint == entrypoints[j] ); - ASSERT( num_attribs >= 0 ); - for(k = 0; k < num_attribs; k++) - { - status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); - ASSERT(attrib_list[k].value != VA_ATTRIB_NOT_SUPPORTED); - } - } - } - - free(attrib_list); -} - -void post() -{ - int i; - for(i = 0; i < config_count; i++) - { - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - free(configs); - free(entrypoints); - test_terminate(); -} diff --git a/test/basic/test_07.c b/test/basic/test_07.c deleted file mode 100644 index 752b0bf..0000000 --- a/test/basic/test_07.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Create and destory surfaces" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead - -void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2) -{ - int i,j; - - for(i = 0; i < surface_count1; i++) - { - for(j = 0; j < surface_count2; j++) - { - if ((surface_list1 == surface_list2) && (i == j)) continue; - ASSERT(surface_list1[i] != VA_INVALID_SURFACE); - ASSERT(surface_list2[j] != VA_INVALID_SURFACE); - ASSERT(surface_list1[i] != surface_list2[j]); - } - } -} - - -void test() -{ - VASurfaceID surfaces_1[1+1]; - VASurfaceID surfaces_4[4+1]; - VASurfaceID surfaces_16[16+1]; - VASurfaceID surfaces_6[6+1]; - - memset(surfaces_1, 0xff, sizeof(surfaces_1)); - memset(surfaces_4, 0xff, sizeof(surfaces_4)); - memset(surfaces_16, 0xff, sizeof(surfaces_16)); - memset(surfaces_6, 0xff, sizeof(surfaces_6)); - - status("vaCreateSurfaces 1 surface\n"); - surfaces_1[1] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_1, 1, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */ - - status("vaCreateSurfaces 4 surfaces\n"); - surfaces_4[4] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_4, 4, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */ - - status("vaCreateSurfaces 16 surfaces\n"); - surfaces_16[16] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_16, 16, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */ - - test_unique_surfaces(surfaces_1, 1, surfaces_4, 4); - test_unique_surfaces(surfaces_4, 4, surfaces_16, 4); - test_unique_surfaces(surfaces_4, 4, surfaces_16, 16); - test_unique_surfaces(surfaces_4, 1, surfaces_16, 16); - test_unique_surfaces(surfaces_1, 1, surfaces_16, 16); - - status("vaDestroySurface 4 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateSurfaces 6 surfaces\n"); - surfaces_6[6] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, 352, 288, surfaces_6, 6, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */ - - test_unique_surfaces(surfaces_1, 1, surfaces_6, 6); - test_unique_surfaces(surfaces_6, 6, surfaces_16, 16); - test_unique_surfaces(surfaces_1, 1, surfaces_16, 6); - - status("vaDestroySurface 16 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroySurface 1 surface\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroySurface 6 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_08.c b/test/basic/test_08.c deleted file mode 100644 index 299882f..0000000 --- a/test/basic/test_08.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Create and destory surfaces of different sizes" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead - -void test_unique_surfaces(VASurfaceID *surface_list, int surface_count) -{ - int i,j; - - for(i = 0; i < surface_count; i++) - { - ASSERT(surface_list[i] != VA_INVALID_SURFACE); - for(j = 0; j < i; j++) - { - if (i == j) continue; - ASSERT(surface_list[i] != surface_list[j]); - } - } -} - -typedef struct test_size { int w; int h; } test_size_t; - -test_size_t test_sizes[] = { - { 10, 10 }, - { 128, 128 }, - { 176, 144 }, - { 144, 176 }, - { 352, 288 }, - { 399, 299 }, - { 640, 480 }, - { 1280, 720 } -}; - -#define NUM_SIZES (sizeof(test_sizes) / sizeof(test_size_t)) - -void test() -{ - VASurfaceID surfaces[NUM_SIZES+1]; - unsigned int i; - - memset(surfaces, 0xff, sizeof(surfaces)); - - for(i = 0; i < NUM_SIZES; i++) - { - status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h); - surfaces[i+1] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, test_sizes[i].w, test_sizes[i].h, &surfaces[i], 1, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces[i+1] ); - } - - test_unique_surfaces(surfaces, NUM_SIZES); - - status("vaDestroySurface all surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces, NUM_SIZES); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_09.c b/test/basic/test_09.c deleted file mode 100644 index 897d6fc..0000000 --- a/test/basic/test_09.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Create/destroy contexts for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j; - int config_count = 0; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - ASSERT(configs); - VAContextID *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContextID)); - ASSERT(contexts); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", configs[config_count]); - config_count++; - } - } - - int width = 352; - int height = 288; - int surface_count = 4; - int total_surfaces = config_count * surface_count; - - VASurfaceID *surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - ASSERT(surfaces); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, width, height, surfaces, total_surfaces, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(i = 0; i < config_count; i++) - { - status("vaCreateContext with config %08x\n", configs[i]); - int flags = 0; - va_status = vaCreateContext( va_dpy, configs[i], width, height, flags, surfaces + i*surface_count, surface_count, &contexts[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyContext for context %08x\n", contexts[i]); - va_status = vaDestroyContext( va_dpy, contexts[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyConfig for config %08x\n", configs[i]); - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(contexts); - free(configs); - free(surfaces); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/basic/test_10.c b/test/basic/test_10.c deleted file mode 100644 index e79debc..0000000 --- a/test/basic/test_10.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Create and destroy buffers" - -#include "test_common.c" - -VAConfigID config; -VAContextID context; -VASurfaceID *surfaces; -int total_surfaces; - -void pre() -{ - test_init(); - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", config); - - int width = 352; - int height = 288; - int surface_count = 4; - total_surfaces = surface_count; - - surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - assert(surfaces); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, width, height, surfaces, total_surfaces, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateContext with config %08x\n", config); - int flags = 0; - va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void test_unique_buffers(VABufferID *buffer_list, int buffer_count) -{ - int i,j; - - for(i = 0; i < buffer_count; i++) - { - for(j = 0; j < i; j++) - { - ASSERT(buffer_list[i] != buffer_list[j]); - } - } -} - -VABufferType buffer_types[] = -{ - VAPictureParameterBufferType, - VAIQMatrixBufferType, - VABitPlaneBufferType, - VASliceGroupMapBufferType, - VASliceParameterBufferType, - VASliceDataBufferType, - VAMacroblockParameterBufferType, - VAResidualDataBufferType, - VADeblockingParameterBufferType, -}; - -unsigned int buffer_sizes[] = -{ - sizeof(VAPictureParameterBufferMPEG4), - sizeof(VAIQMatrixBufferH264), - 32*1024, - 48*1024, - sizeof(VASliceParameterBufferMPEG2), - 128*1024, - sizeof(VAMacroblockParameterBufferMPEG2), - 32*1024, - 15*1024, -}; - - -#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) - -#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) - -void test() -{ - VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; - unsigned int i; - memset(buffer_ids, 0xff, sizeof(buffer_ids)); - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - buffer_ids[i+1] = DEAD_BUFFER_ID; - va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, NULL, &buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_BUFFER_ID == buffer_ids[i+1] ); /* Bounds check */ - } - test_unique_buffers(buffer_ids, NUM_BUFFER_TYPES); - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } -} - -void post() -{ - status("vaDestroyContext for context %08x\n", context); - va_status = vaDestroyContext( va_dpy, context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroyConfig for config %08x\n", config); - va_status = vaDestroyConfig( va_dpy, config ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(surfaces); - - test_terminate(); -} diff --git a/test/basic/test_11.c b/test/basic/test_11.c deleted file mode 100644 index 143d084..0000000 --- a/test/basic/test_11.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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. - */ - -#define TEST_DESCRIPTION "Map and unmap buffers" - -#include "test_common.c" - -VAConfigID config; -VAContextID context; -VASurfaceID *surfaces; -int total_surfaces; - -void pre() -{ - test_init(); - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", config); - - int width = 352; - int height = 288; - int surface_count = 4; - total_surfaces = surface_count; - - surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - assert(surfaces); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, width, height, surfaces, total_surfaces, NULL, 0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateContext with config %08x\n", config); - int flags = 0; - va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void test_unique_buffers(VABufferID *buffer_list, int buffer_count) -{ - int i,j; - - for(i = 0; i < buffer_count; i++) - { - for(j = 0; j < i; j++) - { - ASSERT(buffer_list[i] != buffer_list[j]); - } - } -} - -VABufferType buffer_types[] = -{ - VAPictureParameterBufferType, - VAIQMatrixBufferType, - VABitPlaneBufferType, - VASliceGroupMapBufferType, - VASliceParameterBufferType, - VASliceDataBufferType, - VAMacroblockParameterBufferType, - VAResidualDataBufferType, - VADeblockingParameterBufferType, -}; - -unsigned int buffer_sizes[] = -{ - sizeof(VAPictureParameterBufferMPEG4), - sizeof(VAIQMatrixBufferH264), - 32*1024, - 48*1024, - sizeof(VASliceParameterBufferMPEG2), - 128*1024, - sizeof(VAMacroblockParameterBufferMPEG2), - 32*1024, - 15*1024, -}; - - -#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) - -#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) - -void test() -{ - VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; - uint32_t *input_data[NUM_BUFFER_TYPES]; - unsigned int i, j; - memset(buffer_ids, 0xff, sizeof(buffer_ids)); - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - uint32_t *data; - - input_data[i] = malloc(buffer_sizes[i]+4); - ASSERT(input_data[i]); - - /* Generate input data */ - for(j = buffer_sizes[i] / 4; j--;) - { - input_data[i][j] = random(); - } - - /* Copy to secondary buffer */ - data = malloc(buffer_sizes[i]); - ASSERT(data); - memcpy(data, input_data[i], buffer_sizes[i]); - - /* Create buffer and fill with data */ - va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]); - - /* Wipe secondary buffer */ - memset(data, 0, buffer_sizes[i]); - free(data); - } - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - void *data = NULL; - /* Fetch VA Buffer */ - va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]); - - /* Compare data */ - ASSERT( memcmp(input_data[i], data, buffer_sizes[i]) == 0 ); - } - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - va_status = vaUnmapBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(input_data[i]); - } -} - - - -void post() -{ - status("vaDestroyContext for context %08x\n", context); - va_status = vaDestroyContext( va_dpy, context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroyConfig for config %08x\n", config); - va_status = vaDestroyConfig( va_dpy, config ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(surfaces); - - test_terminate(); -} diff --git a/test/basic/test_android.c b/test/basic/test_android.c deleted file mode 100644 index 2bb247a..0000000 --- a/test/basic/test_android.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - */ -#define Display unsigned int -Display *dpy; -VADisplay va_dpy; -VAStatus va_status; -VAProfile *profiles ; -int major_version, minor_version; - -void test_init() -{ - dpy = (Display*)malloc(sizeof(Display)); - *(dpy) = 0x18c34078; - ASSERT( dpy ); - status("malloc Display: dpy = %08x\n", dpy); - - va_dpy = vaGetDisplay(dpy); - ASSERT( va_dpy ); - status("vaGetDisplay: va_dpy = %08x\n", va_dpy); - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaInitialize: major = %d minor = %d\n", major_version, minor_version); -} - -void test_terminate() -{ - va_status = vaTerminate(va_dpy); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaTerminate\n"); - - free(dpy); - status("free Display\n"); - - if (profiles) - { - free(profiles); - profiles = NULL; - } -} - diff --git a/test/basic/test_common.c b/test/basic/test_common.c deleted file mode 100644 index fd4c26f..0000000 --- a/test/basic/test_common.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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. - */ - -#include -#ifdef ANDROID -#include -#else -#include -#endif -#include "assert.h" -#include -#include -#include -#include -#include -#include - -#define ASSERT assert - -void status(const char *msg, ...); -#ifdef ANDROID -#include "test_android.c" -#else -#include "test_x11.c" -#endif - -Display *dpy; -VADisplay va_dpy; -VAStatus va_status; -int major_version, minor_version; -int print_status = 0; -int num_profiles; -VAProfile *profiles = NULL; - -void pre(); -void test(); -void post(); - -void status(const char *msg, ...) -{ - if (!print_status) return; - va_list args; - printf("--- "); - va_start(args, msg); - vfprintf(stdout, msg, args); - va_end(args); -} - - -int main(int argc, const char* argv[]) -{ - const char *name = strrchr(argv[0], '/'); - if (name) - name++; - else - name = argv[0]; - printf("*** %s: %s\n", name, TEST_DESCRIPTION); - pre(); - print_status = 1; - test(); - print_status = 0; - post(); - printf("*** %s: Finished\n", name); - return 0; -} - -#define PROFILE(profile) case VAProfile##profile: return("VAProfile" #profile); - -const char *profile2string(VAProfile profile) -{ - switch(profile) - { - PROFILE(None) - PROFILE(MPEG2Simple) - PROFILE(MPEG2Main) - PROFILE(MPEG4Simple) - PROFILE(MPEG4AdvancedSimple) - PROFILE(MPEG4Main) - PROFILE(H263Baseline) - PROFILE(H264Baseline) - PROFILE(H264Main) - PROFILE(H264High) - PROFILE(H264ConstrainedBaseline) - PROFILE(H264MultiviewHigh) - PROFILE(H264StereoHigh) - PROFILE(VC1Simple) - PROFILE(VC1Main) - PROFILE(VC1Advanced) - PROFILE(JPEGBaseline) - PROFILE(VP8Version0_3) - PROFILE(HEVCMain) - PROFILE(HEVCMain10) - PROFILE(VP9Profile0) - PROFILE(VP9Profile1) - PROFILE(VP9Profile2) - PROFILE(VP9Profile3) - } - ASSERT(0); - return "Unknown"; -} - -#define ENTRYPOINT(profile) case VAEntrypoint##profile: return("VAEntrypoint" #profile); - -const char *entrypoint2string(VAEntrypoint entrypoint) -{ - switch(entrypoint) - { - ENTRYPOINT(VLD) - ENTRYPOINT(IZZ) - ENTRYPOINT(IDCT) - ENTRYPOINT(MoComp) - ENTRYPOINT(Deblocking) - ENTRYPOINT(EncSlice) - ENTRYPOINT(EncPicture) - ENTRYPOINT(EncSliceLP) - ENTRYPOINT(VideoProc) - } - ASSERT(0); - return "Unknown"; -} - - -void test_profiles() -{ - int max_profiles; - int i; - max_profiles = vaMaxNumProfiles(va_dpy); - status("vaMaxNumProfiles = %d\n", max_profiles); - ASSERT(max_profiles > 0); - profiles = malloc(max_profiles * sizeof(VAProfile)); - ASSERT(profiles); - - va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaQueryConfigProfiles reports %d profiles\n", num_profiles); - ASSERT(num_profiles <= max_profiles); - ASSERT(num_profiles > 0); - - if (print_status) - { - for(i = 0; i < num_profiles; i++) - { - status(" profile %d [%s]\n", profiles[i], profile2string(profiles[i])); - } - } -} diff --git a/test/basic/test_x11.c b/test/basic/test_x11.c deleted file mode 100644 index df8f362..0000000 --- a/test/basic/test_x11.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -Display *dpy; -VADisplay va_dpy; -VAStatus va_status; -VAProfile *profiles ; -int major_version, minor_version; - -void test_init() -{ - dpy = XOpenDisplay(NULL); - ASSERT( dpy ); - status("XOpenDisplay: dpy = %08x\n", dpy); - - va_dpy = vaGetDisplay(dpy); - ASSERT( va_dpy ); - status("vaGetDisplay: va_dpy = %08x\n", va_dpy); - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaInitialize: major = %d minor = %d\n", major_version, minor_version); -} - -void test_terminate() -{ - va_status = vaTerminate(va_dpy); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaTerminate\n"); - - XCloseDisplay(dpy); - status("XCloseDisplay\n"); - - if (profiles) - { - free(profiles); - profiles = NULL; - } -} - diff --git a/test/basic/testplan.txt b/test/basic/testplan.txt deleted file mode 100644 index 1cc573b..0000000 --- a/test/basic/testplan.txt +++ /dev/null @@ -1,106 +0,0 @@ - -Test 1 -- Initialize & Terminate -- vaGetDisplay, vaInitialize, vaTerminate - -Test 2 -- Query profiles -- vaQueryConfigProfiles, vaMaxNumProfiles - -Test 3 -- Query Entrypoints for all profiles -- vaQueryConfigEntryPoints, vaMaxNumEntryPoints - -Test 4 -- Get Config attributes for all profiles / entrypoints -- vaGetConfigAttributes - -Test 5 -- Create & destroy config for each profile / entrypoint -- vaCreateConfig, vaDestroyConfig - -Test 6 -- Get config attributes of various possible configs -- vaQueryConfigAttributes, vaMaxNumConfigAttributes -- Check if results for vaGetConfigAttributes match with vaQueryConfigAttributes for -a given profile / entrypoint - -Test 7 -- Create and destroy surfaces -- vaCreateSurfaces, vaDestroySurface -- Create surfaces of 352 x 288 pixels -- Create 1, 4 and 16 surfaces, destroy 4, create 6 surfaces, destroy 16, 1 -and 6 surfaces. - -Test 8 -- Create and destroy surfaces of different sizes -- Create surfaces of 10 x 10 pixels, 128 x 128 pixels, 176 x 144 pixels, 144 x 176 -pixels, 352 x 288 pixels, 399 x 299 pixels, 640 x 480 pixels, 1280 x 720 -pixels - -Test 9 -- Create and destroy a context for each profile / entrypoint -- Pass 4 surfaces of 352 x 288 pixels -- vaCreateContext, vaDestroyContext -- See also Test 5 - -Test 10 -- Create and destroy buffers -- vaCreateBuffer, vaDestroyBuffer -- For each different buffertype, create a buffer, then destroy them one by -one. - -Test 11 -- Map & unmap buffers -- vaBufferData, vaMapBuffer, vaUnmapBuffer -- For each different buffertype, copy data to the buffer with vaBufferData. -Then map the buffer and verify the contents of the buffer. - -Test 12 -- Render single MPEG2 I-frame -- vaBeginPicture, vaRenderPicture (num_buffers == 1), vaEndPicture - -Test 13 -- Render single MPEG2 I-frame, multiple buffer submission -- vaRenderPicture (num_buffers > 1) - -Test 14 -- Render single MPEG2 I-frame, split buffers -- Slice split over 2 buffers - -Test 15 -- Render single MPEG2 I-frame, split buffers -- Slice split over 3 buffers - -Test 16 -- Sync Surface -- Render single MPEG2 I-frame, then check vaQuerySurfaceStatus, vaSyncSurface and vaQuerySurfaceStatus - -Test 17 -- Query image formats -- vaMaxNumImageFormats, vaQueryImageFormats - -Test 18 -- Create and destroy vaImage -- vaCreateImage, vaDestroyImage - -Test 19 -- Get image data -- Render single MPEG2 I-frame, copy surface data to image, check resulting -image -- vaGetImage - -Test 20 -- Put image data -- Render single MPEG2 I-frame, copy half of a VAImage to surface, copy -surface back to VAImage, check resulting image -- vaPutImage - -Test 21 -- Query subpicture formats -- vaMaxNumSubpictureFormats, vaQuerySubpictureFromats - -Test 22 -- Create and destory subpictures -- vaCreateSubpicture, vaDestroySubpicture - diff --git a/test/common/Makefile.am b/test/common/Makefile.am deleted file mode 100644 index 763847d..0000000 --- a/test/common/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2012 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. - -noinst_LTLIBRARIES = libva-display.la - -libva_display_cflags = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - -I$(top_builddir) \ - -DIN_LIBVA \ - $(NULL) - -libva_display_libs = \ - $(top_builddir)/va/libva.la \ - $(NULL) - -source_c = va_display.c -source_h = va_display.h - -if USE_X11 -source_c += va_display_x11.c -libva_display_cflags += $(X11_CFLAGS) -libva_display_libs += $(top_builddir)/va/libva-x11.la $(X11_LIBS) -endif - -if USE_DRM -source_c += va_display_drm.c -libva_display_cflags += $(DRM_CFLAGS) -libva_display_libs += $(top_builddir)/va/libva-drm.la $(DRM_LIBS) -endif - -if USE_WAYLAND -source_c += va_display_wayland.c -libva_display_cflags += $(WAYLAND_CFLAGS) -libva_display_libs += $(top_builddir)/va/libva-wayland.la $(WAYLAND_LIBS) -endif - -libva_display_la_SOURCES= $(source_c) -noinst_HEADERS = $(source_h) -libva_display_la_CFLAGS = $(libva_display_cflags) -libva_display_la_LIBADD = $(libva_display_libs) - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/test/common/va_display.c b/test/common/va_display.c deleted file mode 100644 index dd58dd2..0000000 --- a/test/common/va_display.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include -#include "va_display.h" - -extern const VADisplayHooks va_display_hooks_android; -extern const VADisplayHooks va_display_hooks_wayland; -extern const VADisplayHooks va_display_hooks_x11; -extern const VADisplayHooks va_display_hooks_drm; - -static const VADisplayHooks *g_display_hooks; -static const VADisplayHooks *g_display_hooks_available[] = { -#ifdef ANDROID - &va_display_hooks_android, -#else -#ifdef HAVE_VA_WAYLAND - &va_display_hooks_wayland, -#endif -#ifdef HAVE_VA_X11 - &va_display_hooks_x11, -#endif -#ifdef HAVE_VA_DRM - &va_display_hooks_drm, -#endif -#endif - NULL -}; - -static const char *g_display_name; - -static const char * -get_display_name(int argc, char *argv[]) -{ - const char *display_name = NULL; - int i; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "--display") != 0) - continue; - argv[i] = NULL; - - if (++i < argc) { - display_name = argv[i]; - argv[i] = NULL; - } - } - return display_name; -} - -static void -print_display_names(void) -{ - const VADisplayHooks **h; - - printf("Available displays:\n"); - for (h = g_display_hooks_available; *h != NULL; h++) - printf(" %s\n", (*h)->name); -} - -static void -sanitize_args(int *argc, char *argv[]) -{ - char **out_args = argv; - int i, n = *argc; - - for (i = 0; i < n; i++) { - if (argv[i]) - *out_args++ = argv[i]; - } - *out_args = NULL; - *argc = out_args - argv; -} - -void -va_init_display_args(int *argc, char *argv[]) -{ - const char *display_name; - - display_name = get_display_name(*argc, argv); - if (display_name && strcmp(display_name, "help") == 0) { - print_display_names(); - exit(0); - } - g_display_name = display_name; - - sanitize_args(argc, argv); -} - -VADisplay -va_open_display(void) -{ - VADisplay va_dpy = NULL; - unsigned int i; - - for (i = 0; !va_dpy && g_display_hooks_available[i]; i++) { - g_display_hooks = g_display_hooks_available[i]; - if (g_display_name && - strcmp(g_display_name, g_display_hooks->name) != 0) - continue; - if (!g_display_hooks->open_display) - continue; - va_dpy = g_display_hooks->open_display(); - } - - if (!va_dpy) { - fprintf(stderr, "error: failed to initialize display"); - if (g_display_name) - fprintf(stderr, " '%s'", g_display_name); - fprintf(stderr, "\n"); - abort(); - } - return va_dpy; -} - -void -va_close_display(VADisplay va_dpy) -{ - if (!va_dpy) - return; - - if (g_display_hooks && g_display_hooks->close_display) - g_display_hooks->close_display(va_dpy); -} - -VAStatus -va_put_surface( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -) -{ - if (!va_dpy) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - if (g_display_hooks && g_display_hooks->put_surface) - return g_display_hooks->put_surface(va_dpy, surface, src_rect, dst_rect); - return VA_STATUS_ERROR_UNIMPLEMENTED; -} diff --git a/test/common/va_display.h b/test/common/va_display.h deleted file mode 100644 index 4ed33e0..0000000 --- a/test/common/va_display.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#ifndef VA_DISPLAY_H -#define VA_DISPLAY_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - const char *name; - VADisplay (*open_display) (void); - void (*close_display) (VADisplay va_dpy); - VAStatus (*put_surface) (VADisplay va_dpy, VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect); -} VADisplayHooks; - -void -va_init_display_args(int *argc, char *argv[]); - -VADisplay -va_open_display(void); - -void -va_close_display(VADisplay va_dpy); - -VAStatus -va_put_surface( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -); - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DISPLAY_H */ diff --git a/test/common/va_display_android.cpp b/test/common/va_display_android.cpp deleted file mode 100644 index b05a47a..0000000 --- a/test/common/va_display_android.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include -#include "va_display.h" - -#include -#include -#include - -static unsigned int fake_display = 0xdeada01d; - -using namespace android; - -static sp client = NULL; -static sp surface_ctr = NULL; -static sp anw = NULL; - -static VADisplay -va_open_display_android(void) -{ - return vaGetDisplay(&fake_display); -} - -static void -va_close_display_android(VADisplay va_dpy) -{ -} - -static int create_window(int x, int y, int width, int height) -{ - client = new SurfaceComposerClient(); - - surface_ctr = client->createSurface( - String8("Test Surface"), - width, height, - PIXEL_FORMAT_RGB_888, 0); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctr->setLayer(0x7FFFFFFF); - surface_ctr->show(); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctr->setPosition(x, y); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctr->setSize(width, height); - SurfaceComposerClient::closeGlobalTransaction(); - - anw = surface_ctr->getSurface(); - - return 0; -} - - -static VAStatus -va_put_surface_android( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -) -{ - if (anw == NULL) - create_window(dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height); - - return vaPutSurface(va_dpy, surface, anw, - src_rect->x, src_rect->y, - src_rect->width, src_rect->height, - dst_rect->x, dst_rect->y, - dst_rect->width, dst_rect->height, - NULL, 0, - VA_FRAME_PICTURE); -} - -extern "C" -const VADisplayHooks va_display_hooks_android = { - "android", - va_open_display_android, - va_close_display_android, - va_put_surface_android -}; diff --git a/test/common/va_display_drm.c b/test/common/va_display_drm.c deleted file mode 100644 index b6394cd..0000000 --- a/test/common/va_display_drm.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include -#include -#include -#ifdef IN_LIBVA -# include "va/drm/va_drm.h" -#else -# include -#endif -#include "va_display.h" - -static int drm_fd = -1; - -static VADisplay -va_open_display_drm(void) -{ - VADisplay va_dpy; - int i; - - static const char *drm_device_paths[] = { - "/dev/dri/renderD128", - "/dev/dri/card0", - NULL - }; - - for (i = 0; drm_device_paths[i]; i++) { - drm_fd = open(drm_device_paths[i], O_RDWR); - if (drm_fd < 0) - continue; - - va_dpy = vaGetDisplayDRM(drm_fd); - if (va_dpy) - return va_dpy; - - close(drm_fd); - drm_fd = -1; - } - return NULL; -} - -static void -va_close_display_drm(VADisplay va_dpy) -{ - if (drm_fd < 0) - return; - - close(drm_fd); - drm_fd = -1; -} - - -static VAStatus -va_put_surface_drm( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -) -{ - return VA_STATUS_ERROR_OPERATION_FAILED; -} - -const VADisplayHooks va_display_hooks_drm = { - "drm", - va_open_display_drm, - va_close_display_drm, - va_put_surface_drm, -}; diff --git a/test/common/va_display_wayland.c b/test/common/va_display_wayland.c deleted file mode 100644 index abcb2b6..0000000 --- a/test/common/va_display_wayland.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include -#include -#ifdef IN_LIBVA -# include "va/wayland/va_wayland.h" -#else -# include -#endif -#include "va_display.h" - -struct display { - struct wl_display *display; - struct wl_registry *registry; - struct wl_compositor *compositor; - struct wl_shell *shell; - struct wl_shell_surface *shell_surface; - struct wl_surface *surface; - unsigned int ref_count; - int event_fd; -}; - -static struct display *g_display; - -static void -registry_handle_global( - void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version -) -{ - struct display * const d = data; - - if (strcmp(interface, "wl_compositor") == 0) - d->compositor = - wl_registry_bind(registry, id, &wl_compositor_interface, 1); - else if (strcmp(interface, "wl_shell") == 0) - d->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); -} - -static const struct wl_registry_listener registry_listener = { - registry_handle_global, - NULL, -}; - -static VADisplay -va_open_display_wayland(void) -{ - struct display *d; - - if (g_display) { - d = g_display; - d->ref_count++; - } - else { - d = calloc(1, sizeof(*d)); - if (!d) - return NULL; - d->event_fd = -1; - - d->display = wl_display_connect(NULL); - if (!d->display) { - free(d); - return NULL; - } - wl_display_set_user_data(d->display, d); - d->registry = wl_display_get_registry(d->display); - wl_registry_add_listener(d->registry, ®istry_listener, d); - d->event_fd = wl_display_get_fd(d->display); - wl_display_dispatch(d->display); - - d->ref_count = 1; - g_display = d; - } - return vaGetDisplayWl(d->display); -} - -static void -va_close_display_wayland(VADisplay va_dpy) -{ - struct display * const d = g_display; - - if (!d || --d->ref_count > 0) - return; - - if (d->surface) { - wl_surface_destroy(d->surface); - d->surface = NULL; - } - - if (d->shell_surface) { - wl_shell_surface_destroy(d->shell_surface); - d->shell_surface = NULL; - } - - if (d->shell) { - wl_shell_destroy(d->shell); - d->shell = NULL; - } - - if (d->compositor) { - wl_compositor_destroy(d->compositor); - d->compositor = NULL; - } - - if (d->display) { - wl_display_disconnect(d->display); - d->display = NULL; - } - free(g_display); - g_display = NULL; -} - -static int -ensure_window(VADisplay va_dpy, unsigned int width, unsigned int height) -{ - struct display * const d = g_display; - - if (!d->surface) { - d->surface = wl_compositor_create_surface(d->compositor); - if (!d->surface) - return 0; - } - - if (!d->shell_surface) { - d->shell_surface = wl_shell_get_shell_surface(d->shell, d->surface); - if (!d->shell_surface) - return 0; - wl_shell_surface_set_toplevel(d->shell_surface); - } - return 1; -} - -static VAStatus -va_put_surface_wayland( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -) -{ - struct display * const d = g_display; - VAStatus va_status; - struct wl_buffer *buffer; - - if (!ensure_window(va_dpy, dst_rect->width, dst_rect->height)) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - - va_status = vaGetSurfaceBufferWl(va_dpy, surface, VA_FRAME_PICTURE, &buffer); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - wl_surface_attach(d->surface, buffer, 0, 0); - wl_surface_damage( - d->surface, - dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height - ); - - wl_surface_commit(d->surface); - wl_display_flush(d->display); - return VA_STATUS_SUCCESS; -} - -const VADisplayHooks va_display_hooks_wayland = { - "wayland", - va_open_display_wayland, - va_close_display_wayland, - va_put_surface_wayland, -}; diff --git a/test/common/va_display_x11.c b/test/common/va_display_x11.c deleted file mode 100644 index 336bf86..0000000 --- a/test/common/va_display_x11.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include -#include -#include -#include "va_display.h" - -static Display *x11_display; -static Window x11_window; - -static VADisplay -va_open_display_x11(void) -{ - x11_display = XOpenDisplay(NULL); - if (!x11_display) { - fprintf(stderr, "error: can't connect to X server!\n"); - return NULL; - } - return vaGetDisplay(x11_display); -} - -static void -va_close_display_x11(VADisplay va_dpy) -{ - if (!x11_display) - return; - - if (x11_window) { - XUnmapWindow(x11_display, x11_window); - XDestroyWindow(x11_display, x11_window); - x11_window = None; - } - XCloseDisplay(x11_display); - x11_display = NULL; -} - -static int -ensure_window(unsigned int width, unsigned int height) -{ - Window win, rootwin; - unsigned int black_pixel, white_pixel; - int screen; - - if (!x11_display) - return 0; - - if (x11_window) { - XResizeWindow(x11_display, x11_window, width, height); - return 1; - } - - screen = DefaultScreen(x11_display); - rootwin = RootWindow(x11_display, screen); - black_pixel = BlackPixel(x11_display, screen); - white_pixel = WhitePixel(x11_display, screen); - - win = XCreateSimpleWindow( - x11_display, - rootwin, - 0, 0, width, height, - 1, black_pixel, white_pixel - ); - if (!win) - return 0; - x11_window = win; - - XMapWindow(x11_display, x11_window); - XSync(x11_display, False); - return 1; -} - -static inline bool -validate_rect(const VARectangle *rect) -{ - return (rect && - rect->x >= 0 && - rect->y >= 0 && - rect->width > 0 && - rect->height > 0); -} - -static VAStatus -va_put_surface_x11( - VADisplay va_dpy, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect -) -{ - unsigned int win_width, win_height; - - if (!va_dpy) - return VA_STATUS_ERROR_INVALID_DISPLAY; - if (surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - if (!validate_rect(src_rect) || !validate_rect(dst_rect)) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - win_width = dst_rect->x + dst_rect->width; - win_height = dst_rect->y + dst_rect->height; - if (!ensure_window(win_width, win_height)) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - return vaPutSurface(va_dpy, surface, x11_window, - src_rect->x, src_rect->y, - src_rect->width, src_rect->height, - dst_rect->x, dst_rect->y, - dst_rect->width, dst_rect->height, - NULL, 0, - VA_FRAME_PICTURE); -} - -const VADisplayHooks va_display_hooks_x11 = { - "x11", - va_open_display_x11, - va_close_display_x11, - va_put_surface_x11, -}; diff --git a/test/decode/Android.mk b/test/decode/Android.mk deleted file mode 100755 index 52f7bfd..0000000 --- a/test/decode/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -# For test_01 -# ===================================================== - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - mpeg2vldemo.cpp \ - ../common/va_display.c \ - ../common/va_display_android.cpp - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../../va \ - $(LOCAL_PATH)/../common \ - $(TARGET_OUT_HEADERS)/libva - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := mpeg2vldemo - -LOCAL_SHARED_LIBRARIES := libva libva-android libdl libdrm libcutils libutils libgui - -include $(BUILD_EXECUTABLE) - diff --git a/test/decode/Makefile.am b/test/decode/Makefile.am deleted file mode 100644 index e84bf43..0000000 --- a/test/decode/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -# 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. - -bin_PROGRAMS = mpeg2vldemo loadjpeg - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/test/common \ - $(NULL) - -TEST_LIBS = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - $(NULL) - -mpeg2vldemo_LDADD = $(TEST_LIBS) -mpeg2vldemo_SOURCES = mpeg2vldemo.cpp - -loadjpeg_LDADD = $(TEST_LIBS) -loadjpeg_SOURCES = loadjpeg.c tinyjpeg.c - -valgrind: $(bin_PROGRAMS) - for a in $(bin_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done - -EXTRA_DIST = \ - tinyjpeg.h \ - tinyjpeg-internal.h \ - $(NULL) diff --git a/test/decode/loadjpeg.c b/test/decode/loadjpeg.c deleted file mode 100644 index 7a9a235..0000000 --- a/test/decode/loadjpeg.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Small jpeg decoder library - testing application - * - * Copyright (c) 2006, Luc Saillard - * Copyright (c) 2012 Intel Corporation. - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "tinyjpeg.h" -#include -#include -#include -#include -#include "va_display.h" - -static void exitmessage(const char *message) __attribute__((noreturn)); -static void exitmessage(const char *message) -{ - printf("%s\n", message); - exit(0); -} - -static int filesize(FILE *fp) -{ - long pos; - fseek(fp, 0, SEEK_END); - pos = ftell(fp); - fseek(fp, 0, SEEK_SET); - return pos; -} - -/** - * Load one jpeg image, and decompress it, and save the result. - */ -int convert_one_image(const char *infilename) -{ - FILE *fp; - unsigned int length_of_file; - unsigned int width, height; - unsigned char *buf; - struct jdec_private *jdec; - - /* Load the Jpeg into memory */ - fp = fopen(infilename, "rb"); - if (fp == NULL) - exitmessage("Cannot open filename\n"); - length_of_file = filesize(fp); - buf = (unsigned char *)malloc(length_of_file + 4); - if (buf == NULL) - exitmessage("Not enough memory for loading file\n"); - fread(buf, length_of_file, 1, fp); - fclose(fp); - - /* Decompress it */ - jdec = tinyjpeg_init(); - if (jdec == NULL) - exitmessage("Not enough memory to alloc the structure need for decompressing\n"); - - if (tinyjpeg_parse_header(jdec, buf, length_of_file)<0) - exitmessage(tinyjpeg_get_errorstring(jdec)); - - /* Get the size of the image */ - tinyjpeg_get_size(jdec, &width, &height); - - printf("Decoding JPEG image %dx%d...\n", width, height); - if (tinyjpeg_decode(jdec) < 0) - exitmessage(tinyjpeg_get_errorstring(jdec)); - - tinyjpeg_free(jdec); - - free(buf); - return 0; -} - -static void usage(void) -{ - fprintf(stderr, "Usage: loadjpeg \n"); - exit(1); -} - -/** - * main - * - */ -int main(int argc, char *argv[]) -{ - char *input_filename; - clock_t start_time, finish_time; - unsigned int duration; - int current_argument; - - va_init_display_args(&argc, argv); - - if (argc < 2) - usage(); - - current_argument = 1; - input_filename = argv[current_argument]; - - start_time = clock(); - convert_one_image(input_filename); - finish_time = clock(); - duration = finish_time - start_time; - printf("Decoding finished in %u ticks\n", duration); - - return 0; -} - - - - diff --git a/test/decode/mpeg2-I.gif b/test/decode/mpeg2-I.gif deleted file mode 100644 index 81a25eb..0000000 Binary files a/test/decode/mpeg2-I.gif and /dev/null differ diff --git a/test/decode/mpeg2-I.m2v b/test/decode/mpeg2-I.m2v deleted file mode 100644 index f00fa01..0000000 Binary files a/test/decode/mpeg2-I.m2v and /dev/null differ diff --git a/test/decode/mpeg2vldemo.cpp b/test/decode/mpeg2vldemo.cpp deleted file mode 100644 index 715ea49..0000000 --- a/test/decode/mpeg2vldemo.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2007-2008 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. - */ - -/* - * it is a real program to show how VAAPI decode work, - * It does VLD decode for a simple MPEG2 clip "mpeg2-I.m2v" - * "mpeg2-I.m2v" and VA parameters are hardcoded into mpeg2vldemo.c, - * See mpeg2-I.jif to know how those VA parameters come from - * - * gcc -o mpeg2vldemo mpeg2vldemo.c -lva -lva-x11 -I/usr/include/va - * ./mpeg2vldemo : only do decode - * ./mpeg2vldemo : decode+display - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "va_display.h" - -#define CHECK_VASTATUS(va_status,func) \ -if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ -} - -/* Data dump of a 16x16 MPEG2 video clip,it has one I frame - */ -static unsigned char mpeg2_clip[]={ - 0x00,0x00,0x01,0xb3,0x01,0x00,0x10,0x13,0xff,0xff,0xe0,0x18,0x00,0x00,0x01,0xb5, - 0x14,0x8a,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0xb8,0x00,0x08,0x00,0x00,0x00,0x00, - 0x01,0x00,0x00,0x0f,0xff,0xf8,0x00,0x00,0x01,0xb5,0x8f,0xff,0xf3,0x41,0x80,0x00, - 0x00,0x01,0x01,0x13,0xe1,0x00,0x15,0x81,0x54,0xe0,0x2a,0x05,0x43,0x00,0x2d,0x60, - 0x18,0x01,0x4e,0x82,0xb9,0x58,0xb1,0x83,0x49,0xa4,0xa0,0x2e,0x05,0x80,0x4b,0x7a, - 0x00,0x01,0x38,0x20,0x80,0xe8,0x05,0xff,0x60,0x18,0xe0,0x1d,0x80,0x98,0x01,0xf8, - 0x06,0x00,0x54,0x02,0xc0,0x18,0x14,0x03,0xb2,0x92,0x80,0xc0,0x18,0x94,0x42,0x2c, - 0xb2,0x11,0x64,0xa0,0x12,0x5e,0x78,0x03,0x3c,0x01,0x80,0x0e,0x80,0x18,0x80,0x6b, - 0xca,0x4e,0x01,0x0f,0xe4,0x32,0xc9,0xbf,0x01,0x42,0x69,0x43,0x50,0x4b,0x01,0xc9, - 0x45,0x80,0x50,0x01,0x38,0x65,0xe8,0x01,0x03,0xf3,0xc0,0x76,0x00,0xe0,0x03,0x20, - 0x28,0x18,0x01,0xa9,0x34,0x04,0xc5,0xe0,0x0b,0x0b,0x04,0x20,0x06,0xc0,0x89,0xff, - 0x60,0x12,0x12,0x8a,0x2c,0x34,0x11,0xff,0xf6,0xe2,0x40,0xc0,0x30,0x1b,0x7a,0x01, - 0xa9,0x0d,0x00,0xac,0x64 -}; - -/* hardcoded here without a bitstream parser helper - * please see picture mpeg2-I.jpg for bitstream details - */ -static VAPictureParameterBufferMPEG2 pic_param={ - horizontal_size:16, - vertical_size:16, - forward_reference_picture:0xffffffff, - backward_reference_picture:0xffffffff, - picture_coding_type:1, - f_code:0xffff, - { - { - intra_dc_precision:0, - picture_structure:3, - top_field_first:0, - frame_pred_frame_dct:1, - concealment_motion_vectors:0, - q_scale_type:0, - intra_vlc_format:0, - alternate_scan:0, - repeat_first_field:0, - progressive_frame:1 , - is_first_field:1 - }, - } -}; - -/* see MPEG2 spec65 for the defines of matrix */ -static VAIQMatrixBufferMPEG2 iq_matrix = { - load_intra_quantiser_matrix:1, - load_non_intra_quantiser_matrix:1, - load_chroma_intra_quantiser_matrix:0, - load_chroma_non_intra_quantiser_matrix:0, - intra_quantiser_matrix:{ - 8, 16, 16, 19, 16, 19, 22, 22, - 22, 22, 22, 22, 26, 24, 26, 27, - 27, 27, 26, 26, 26, 26, 27, 27, - 27, 29, 29, 29, 34, 34, 34, 29, - 29, 29, 27, 27, 29, 29, 32, 32, - 34, 34, 37, 38, 37, 35, 35, 34, - 35, 38, 38, 40, 40, 40, 48, 48, - 46, 46, 56, 56, 58, 69, 69, 83 - }, - non_intra_quantiser_matrix:{16}, - chroma_intra_quantiser_matrix:{0}, - chroma_non_intra_quantiser_matrix:{0} -}; - -#if 1 -static VASliceParameterBufferMPEG2 slice_param={ - slice_data_size:150, - slice_data_offset:0, - slice_data_flag:0, - macroblock_offset:38, /* 4byte + 6bits=38bits */ - slice_horizontal_position:0, - slice_vertical_position:0, - quantiser_scale_code:2, - intra_slice_flag:0 -}; -#endif - -#define CLIP_WIDTH 16 -#define CLIP_HEIGHT 16 - -#define WIN_WIDTH (CLIP_WIDTH<<1) -#define WIN_HEIGHT (CLIP_HEIGHT<<1) - -int main(int argc,char **argv) -{ - VAEntrypoint entrypoints[5]; - int num_entrypoints,vld_entrypoint; - VAConfigAttrib attrib; - VAConfigID config_id; - VASurfaceID surface_id; - VAContextID context_id; - VABufferID pic_param_buf,iqmatrix_buf,slice_param_buf,slice_data_buf; - int major_ver, minor_ver; - VADisplay va_dpy; - VAStatus va_status; - int putsurface=0; - - va_init_display_args(&argc, argv); - - if (argc > 1) - putsurface=1; - - va_dpy = va_open_display(); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - assert(va_status == VA_STATUS_SUCCESS); - - va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints, - &num_entrypoints); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - - for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { - if (entrypoints[vld_entrypoint] == VAEntrypointVLD) - break; - } - if (vld_entrypoint == num_entrypoints) { - /* not find VLD entry point */ - assert(0); - } - - /* Assuming finding VLD, find out the format for the render target */ - attrib.type = VAConfigAttribRTFormat; - vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1); - if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1,&config_id); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, CLIP_WIDTH, CLIP_HEIGHT, - &surface_id, 1, - NULL, 0 - ); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(va_dpy, config_id, - CLIP_WIDTH, - ((CLIP_HEIGHT+15)/16)*16, - VA_PROGRESSIVE, - &surface_id, - 1, - &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VAPictureParameterBufferType, - sizeof(VAPictureParameterBufferMPEG2), - 1, &pic_param, - &pic_param_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VAIQMatrixBufferType, - sizeof(VAIQMatrixBufferMPEG2), - 1, &iq_matrix, - &iqmatrix_buf ); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VASliceParameterBufferType, - sizeof(VASliceParameterBufferMPEG2), - 1, - &slice_param, &slice_param_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VASliceDataBufferType, - 0xc4-0x2f+1, - 1, - mpeg2_clip+0x2f, - &slice_data_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaBeginPicture(va_dpy, context_id, surface_id); - CHECK_VASTATUS(va_status, "vaBeginPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &iqmatrix_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &slice_data_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaEndPicture(va_dpy,context_id); - CHECK_VASTATUS(va_status, "vaEndPicture"); - - va_status = vaSyncSurface(va_dpy, surface_id); - CHECK_VASTATUS(va_status, "vaSyncSurface"); - - if (putsurface) { - VARectangle src_rect, dst_rect; - - src_rect.x = 0; - src_rect.y = 0; - src_rect.width = CLIP_WIDTH; - src_rect.height = CLIP_HEIGHT; - - dst_rect.x = 0; - dst_rect.y = 0; - dst_rect.width = WIN_WIDTH; - dst_rect.height = WIN_HEIGHT; - - va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect); - CHECK_VASTATUS(va_status, "vaPutSurface"); - } - printf("press any key to exit\n"); - getchar(); - - vaDestroySurfaces(va_dpy,&surface_id,1); - vaDestroyConfig(va_dpy,config_id); - vaDestroyContext(va_dpy,context_id); - - vaTerminate(va_dpy); - va_close_display(va_dpy); - return 0; -} diff --git a/test/decode/tinyjpeg-internal.h b/test/decode/tinyjpeg-internal.h deleted file mode 100644 index 6801c31..0000000 --- a/test/decode/tinyjpeg-internal.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Small jpeg decoder library (Internal header) - * - * Copyright (c) 2006, Luc Saillard - * Copyright (c) 2012 Intel Corporation. - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#ifndef __TINYJPEG_INTERNAL_H_ -#define __TINYJPEG_INTERNAL_H_ - -#include - -#define SANITY_CHECK 1 - -struct jdec_private; - -#define HUFFMAN_BITS_SIZE 256 - -#define HUFFMAN_TABLES 4 -#define COMPONENTS 4 -#define JPEG_MAX_WIDTH 2048 -#define JPEG_MAX_HEIGHT 2048 -#define JPEG_SCAN_MAX 4 - -enum std_markers { - DQT = 0xDB, /* Define Quantization Table */ - SOF = 0xC0, /* Start of Frame (size information) */ - DHT = 0xC4, /* Huffman Table */ - SOI = 0xD8, /* Start of Image */ - SOS = 0xDA, /* Start of Scan */ - RST = 0xD0, /* Reset Marker d0 -> .. */ - RST7 = 0xD7, /* Reset Marker .. -> d7 */ - EOI = 0xD9, /* End of Image */ - DRI = 0xDD, /* Define Restart Interval */ - APP0 = 0xE0, -}; - - -struct huffman_table -{ - /*bits and values*/ - unsigned char bits[16]; - unsigned char values[256]; -}; - -struct component -{ - unsigned int Hfactor; - unsigned int Vfactor; - unsigned char quant_table_index; - unsigned int cid; -}; - - -typedef void (*decode_MCU_fct) (struct jdec_private *priv); -typedef void (*convert_colorspace_fct) (struct jdec_private *priv); - -struct jpeg_sos -{ - unsigned int nr_components; - struct { - unsigned int component_id; - unsigned int dc_selector; - unsigned int ac_selector; - }components[4]; -}; - -struct jdec_private -{ - /* Public variables */ - unsigned int width[JPEG_SCAN_MAX], height[JPEG_SCAN_MAX]; /* Size of the image */ - - /* Private variables */ - const unsigned char *stream_begin, *stream_end,*stream_scan; - unsigned int stream_length; - - const unsigned char *stream; /* Pointer to the current stream */ - - struct component component_infos[COMPONENTS]; - unsigned int nf_components; - unsigned char Q_tables[COMPONENTS][64]; /* quantization tables, zigzag*/ - unsigned char Q_tables_valid[COMPONENTS]; - struct huffman_table HTDC[HUFFMAN_TABLES]; /* DC huffman tables */ - unsigned char HTDC_valid[HUFFMAN_TABLES]; - struct huffman_table HTAC[HUFFMAN_TABLES]; /* AC huffman tables */ - unsigned char HTAC_valid[HUFFMAN_TABLES]; - struct jpeg_sos cur_sos; /* current sos values*/ - int default_huffman_table_initialized; - int restart_interval; -}; - -#endif - diff --git a/test/decode/tinyjpeg.c b/test/decode/tinyjpeg.c deleted file mode 100644 index fb58eb9..0000000 --- a/test/decode/tinyjpeg.c +++ /dev/null @@ -1,873 +0,0 @@ -/* - * Small jpeg decoder library - * - * Copyright (c) 2006, Luc Saillard - * Copyright (c) 2012 Intel Corporation. - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include -#include -#include - -#include "tinyjpeg.h" -#include "tinyjpeg-internal.h" - -// for libva -#include -#include -#include -#include -#include -#include -#include "va_display.h" - - -#define cY 0 -#define cCb 1 -#define cCr 2 - -#define BLACK_Y 0 -#define BLACK_U 127 -#define BLACK_V 127 - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -#define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) - -#if DEBUG -#define trace(fmt, args...) do { \ - fprintf(stderr, fmt, ## args); \ - fflush(stderr); \ -} while(0) -#else -#define trace(fmt, args...) do { } while (0) -#endif -#define error(fmt, args...) do { \ - snprintf(error_string, sizeof(error_string), fmt, ## args); \ - return -1; \ -} while(0) -/* The variables for different image scans */ -static int scan_num=0; -static int next_image_found=0; -/* Global variable to return the last error found while deconding */ -static char error_string[256]; -static VAHuffmanTableBufferJPEGBaseline default_huffman_table_param={ - huffman_table: - { - // lumiance component - { - num_dc_codes:{0,1,5,1,1,1,1,1,1,0,0,0}, // 12 bits is ok for baseline profile - dc_values:{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b}, - num_ac_codes:{0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125}, - ac_values:{ - 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa - },/*,0xonly,0xthe,0xfirst,0x162,0xbytes,0xare,0xavailable,0x*/ - }, - // chrom component - { - num_dc_codes:{0,3,1,1,1,1,1,1,1,1,1,0}, // 12 bits is ok for baseline profile - dc_values:{0,1,2,3,4,5,6,7,8,9,0xa,0xb}, - num_ac_codes:{0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119}, - ac_values:{ - 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa - },/*,0xonly,0xthe,0xfirst,0x162,0xbytes,0xare,0xavailable,0x*/ - }, - } -}; - -#define be16_to_cpu(x) (((x)[0]<<8)|(x)[1]) - - -static int build_default_huffman_tables(struct jdec_private *priv) -{ - int i = 0; - if (priv->default_huffman_table_initialized) - return 0; - - for (i = 0; i < 4; i++) { - priv->HTDC_valid[i] = 1; - memcpy(priv->HTDC[i].bits, default_huffman_table_param.huffman_table[i%2].num_dc_codes, - sizeof(default_huffman_table_param.huffman_table[i%2].num_dc_codes)); - memcpy(priv->HTDC[i].values, default_huffman_table_param.huffman_table[i%2].dc_values, - sizeof(default_huffman_table_param.huffman_table[i%2].dc_values)); - priv->HTAC_valid[i] = 1; - memcpy(priv->HTAC[i].bits, default_huffman_table_param.huffman_table[i%2].num_ac_codes, - sizeof(default_huffman_table_param.huffman_table[i%2].num_ac_codes)); - memcpy(priv->HTAC[i].values, default_huffman_table_param.huffman_table[i%2].ac_values, - sizeof(default_huffman_table_param.huffman_table[i%2].ac_values)); - } - priv->default_huffman_table_initialized = 1; - return 0; -} - - -static void print_SOF(const unsigned char *stream) -{ - int width, height, nr_components, precision; -#if DEBUG - const char *nr_components_to_string[] = { - "????", - "Grayscale", - "????", - "YCbCr", - "CYMK" - }; -#endif - - precision = stream[2]; - height = be16_to_cpu(stream+3); - width = be16_to_cpu(stream+5); - nr_components = stream[7]; - - trace("> SOF marker\n"); - trace("Size:%dx%d nr_components:%d (%s) precision:%d\n", - width, height, - nr_components, nr_components_to_string[nr_components], - precision); -} - -static int parse_DQT(struct jdec_private *priv, const unsigned char *stream) -{ - int qi; - const unsigned char *dqt_block_end; - - trace("> DQT marker\n"); - dqt_block_end = stream + be16_to_cpu(stream); - stream += 2; /* Skip length */ - - while (stream < dqt_block_end) - { - qi = *stream++; -#if SANITY_CHECK - if (qi>>4) - error("16 bits quantization table is not supported\n"); - if (qi>4) - error("No more 4 quantization table is supported (got %d)\n", qi); -#endif - memcpy(priv->Q_tables[qi&0x0F], stream, 64); - priv->Q_tables_valid[qi & 0x0f] = 1; - stream += 64; - } - trace("< DQT marker\n"); - return 0; -} - -static int parse_SOF(struct jdec_private *priv, const unsigned char *stream) -{ - int i, width, height, nr_components, cid, sampling_factor; - unsigned char Q_table; - struct component *c; - - trace("> SOF marker\n"); - print_SOF(stream); - - height = be16_to_cpu(stream+3); - width = be16_to_cpu(stream+5); - nr_components = stream[7]; - priv->nf_components = nr_components; -#if SANITY_CHECK - if (stream[2] != 8) - error("Precision other than 8 is not supported\n"); - if (width>JPEG_MAX_WIDTH || height>JPEG_MAX_HEIGHT) - printf("WARNING:Width and Height (%dx%d) seems suspicious\n", width, height); - if (nr_components != 3) - printf("ERROR:We only support YUV images\n"); - if (height%16) - printf("WARNING:Height need to be a multiple of 16 (current height is %d)\n", height); - if (width%16) - printf("WARNING:Width need to be a multiple of 16 (current Width is %d)\n", width); -#endif - stream += 8; - for (i=0; icomponent_infos[i]; - c->cid = cid; - if (Q_table >= COMPONENTS) - error("Bad Quantization table index (got %d, max allowed %d)\n", Q_table, COMPONENTS-1); - c->Vfactor = sampling_factor&0xf; - c->Hfactor = sampling_factor>>4; - c->quant_table_index = Q_table; - trace("Component:%d factor:%dx%d Quantization table:%d\n", - cid, c->Hfactor, c->Vfactor, Q_table ); - - } - priv->width[scan_num] = width; - priv->height[scan_num] = height; - - trace("< SOF marker\n"); - - return 0; -} - -static int parse_SOS(struct jdec_private *priv, const unsigned char *stream) -{ - unsigned int i, cid, table; - unsigned int nr_components = stream[2]; - - trace("> SOS marker\n"); - - priv->cur_sos.nr_components= nr_components; - - stream += 3; - for (i=0;icur_sos.components[i].component_id = cid; - priv->cur_sos.components[i].dc_selector = ((table>>4)&0x0F); - priv->cur_sos.components[i].ac_selector = (table&0x0F); -#if SANITY_CHECK - if ((table&0xf)>=4) - error("We do not support more than 2 AC Huffman table\n"); - if ((table>>4)>=4) - error("We do not support more than 2 DC Huffman table\n"); - if (cid != priv->component_infos[i].cid) - error("SOS cid order (%d:%d) isn't compatible with the SOF marker (%d:%d)\n", - i, cid, i, priv->component_infos[i].cid); - trace("ComponentId:%d tableAC:%d tableDC:%d\n", cid, table&0xf, table>>4); -#endif - } - priv->stream = stream+3; - trace("< SOS marker\n"); - return 0; -} - -int tinyjpeg_parse_SOS(struct jdec_private *priv, const unsigned char *stream) -{ - return parse_SOS(priv, stream); -} - - -static int parse_DHT(struct jdec_private *priv, const unsigned char *stream) -{ - unsigned int count, i; - int length, index; - unsigned char Tc, Th; - - length = be16_to_cpu(stream) - 2; - stream += 2; /* Skip length */ - - trace("> DHT marker (length=%d)\n", length); - - while (length>0) { - index = *stream++; - - Tc = index & 0xf0; // it is not important to <<4 - Th = index & 0x0f; - if (Tc) { - memcpy(priv->HTAC[index & 0xf].bits, stream, 16); - } - else { - memcpy(priv->HTDC[index & 0xf].bits, stream, 16); - } - - count = 0; - for (i=0; i<16; i++) { - count += *stream++; - } - -#if SANITY_CHECK - if (count >= HUFFMAN_BITS_SIZE) - error("No more than %d bytes is allowed to describe a huffman table", HUFFMAN_BITS_SIZE); - if ( (index &0xf) >= HUFFMAN_TABLES) - error("No more than %d Huffman tables is supported (got %d)\n", HUFFMAN_TABLES, index&0xf); - trace("Huffman table %s[%d] length=%d\n", (index&0xf0)?"AC":"DC", index&0xf, count); -#endif - - if (Tc) { - memcpy(priv->HTAC[index & 0xf].values, stream, count); - priv->HTAC_valid[index & 0xf] = 1; - } - else { - memcpy(priv->HTDC[index & 0xf].values, stream, count); - priv->HTDC_valid[index & 0xf] = 1; - } - - length -= 1; - length -= 16; - length -= count; - stream += count; - } - trace("< DHT marker\n"); - return 0; -} -static int parse_DRI(struct jdec_private *priv, const unsigned char *stream) -{ - unsigned int length; - - trace("> DRI marker\n"); - - length = be16_to_cpu(stream); - -#if SANITY_CHECK - if (length != 4) - error("Length of DRI marker need to be 4\n"); -#endif - - priv->restart_interval = be16_to_cpu(stream+2); - -#if DEBUG - trace("Restart interval = %d\n", priv->restart_interval); -#endif - - trace("< DRI marker\n"); - - return 0; -} - -static int findEOI(struct jdec_private *priv,const unsigned char *stream) -{ - while (stream<=priv->stream_end&& !(*stream == 0xff && *(stream+1) == 0xd9 )) //searching for the end of image marker - { - stream++; - continue; - } - priv->stream_scan=stream; - return 0; -} - -static int findSOI(struct jdec_private *priv,const unsigned char *stream) -{ - while (!(*stream == 0xff && *(stream+1) == 0xd8 ) ) //searching for the start of image marker - { - if(stream<=priv->stream_end) - { - stream++; - continue; - } - else - return 0; // No more images in the file. - } - priv->stream=stream+2; - return 1; -} - -static int parse_JFIF(struct jdec_private *priv, const unsigned char *stream) -{ - int chuck_len; - int marker; - int sos_marker_found = 0; - int dht_marker_found = 0; - int dqt_marker_found = 0; - const unsigned char *next_chunck; - - next_image_found = findSOI(priv,stream); - stream=priv->stream; - - while (!sos_marker_found && stream<=priv->stream_end) - { - while((*stream == 0xff)) - stream++; - - marker = *stream++; - chuck_len = be16_to_cpu(stream); - next_chunck = stream + chuck_len; - switch (marker) - { - case SOF: - if (parse_SOF(priv, stream) < 0) - return -1; - break; - case DQT: - if (parse_DQT(priv, stream) < 0) - return -1; - dqt_marker_found = 1; - break; - case SOS: - if (parse_SOS(priv, stream) < 0) - return -1; - sos_marker_found = 1; - break; - case DHT: - if (parse_DHT(priv, stream) < 0) - return -1; - dht_marker_found = 1; - break; - case DRI: - if (parse_DRI(priv, stream) < 0) - return -1; - break; - default: - trace("> Unknown marker %2.2x\n", marker); - break; - } - - stream = next_chunck; - } - - if(next_image_found){ - if (!dht_marker_found) { - trace("No Huffman table loaded, using the default one\n"); - build_default_huffman_tables(priv); - } - if (!dqt_marker_found) { - error("ERROR:No Quantization table loaded, using the default one\n"); - } - } -#ifdef SANITY_CHECK - if ( (priv->component_infos[cY].Hfactor < priv->component_infos[cCb].Hfactor) - || (priv->component_infos[cY].Hfactor < priv->component_infos[cCr].Hfactor)) - error("Horizontal sampling factor for Y should be greater than horitontal sampling factor for Cb or Cr\n"); - if ( (priv->component_infos[cY].Vfactor < priv->component_infos[cCb].Vfactor) - || (priv->component_infos[cY].Vfactor < priv->component_infos[cCr].Vfactor)) - error("Vertical sampling factor for Y should be greater than vertical sampling factor for Cb or Cr\n"); - if ( (priv->component_infos[cCb].Hfactor!=1) - || (priv->component_infos[cCr].Hfactor!=1) - || (priv->component_infos[cCb].Vfactor!=1) - || (priv->component_infos[cCr].Vfactor!=1)) - printf("ERROR:Sampling other than 1x1 for Cr and Cb is not supported"); -#endif - findEOI(priv,stream); - return next_image_found; -} - -/******************************************************************************* - * - * Functions exported of the library. - * - * Note: Some applications can access directly to internal pointer of the - * structure. It's is not recommended, but if you have many images to - * uncompress with the same parameters, some functions can be called to speedup - * the decoding. - * - ******************************************************************************/ - -/** - * Allocate a new tinyjpeg decoder object. - * - * Before calling any other functions, an object need to be called. - */ -struct jdec_private *tinyjpeg_init(void) -{ - struct jdec_private *priv; - - priv = (struct jdec_private *)calloc(1, sizeof(struct jdec_private)); - if (priv == NULL) - return NULL; - return priv; -} - -/** - * Free a tinyjpeg object. - * - * No others function can be called after this one. - */ -void tinyjpeg_free(struct jdec_private *priv) -{ - free(priv); -} - -/** - * Initialize the tinyjpeg object and prepare the decoding of the stream. - * - * Check if the jpeg can be decoded with this jpeg decoder. - * Fill some table used for preprocessing. - */ -int tinyjpeg_parse_header(struct jdec_private *priv, const unsigned char *buf, unsigned int size) -{ - int ret; - - /* Identify the file */ - if ((buf[0] != 0xFF) || (buf[1] != SOI)) - error("Not a JPG file ?\n"); - - priv->stream_begin = buf; - priv->stream_length = size; - priv->stream_end = priv->stream_begin + priv->stream_length; - - priv->stream = priv->stream_begin; - ret = parse_JFIF(priv, priv->stream); - return ret; -} - - -int tinyjpeg_decode(struct jdec_private *priv) -{ -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - - VAEntrypoint entrypoints[5]; - int num_entrypoints,vld_entrypoint; - VAConfigAttrib attrib; - VAConfigID config_id; - VASurfaceID surface_id; - VAContextID context_id; - VABufferID pic_param_buf,iqmatrix_buf,huffmantable_buf,slice_param_buf,slice_data_buf; - int major_ver, minor_ver; - VADisplay va_dpy; - VAStatus va_status; - int max_h_factor, max_v_factor; - int putsurface=1; - unsigned int i, j; - - int surface_type; - char *type; - int ChromaTypeIndex; - - VASurfaceAttrib forcc; - forcc.type =VASurfaceAttribPixelFormat; - forcc.flags=VA_SURFACE_ATTRIB_SETTABLE; - forcc.value.type=VAGenericValueTypeInteger; - - - va_dpy = va_open_display(); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - assert(va_status == VA_STATUS_SUCCESS); - - va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileJPEGBaseline, entrypoints, - &num_entrypoints); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - - for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { - if (entrypoints[vld_entrypoint] == VAEntrypointVLD) - break; - } - if (vld_entrypoint == num_entrypoints) { - /* not find VLD entry point */ - assert(0); - } - - /* Assuming finding VLD, find out the format for the render target */ - attrib.type = VAConfigAttribRTFormat; - vaGetConfigAttributes(va_dpy, VAProfileJPEGBaseline, VAEntrypointVLD, - &attrib, 1); - if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - va_status = vaCreateConfig(va_dpy, VAProfileJPEGBaseline, VAEntrypointVLD, - &attrib, 1,&config_id); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - - while (next_image_found){ - VAPictureParameterBufferJPEGBaseline pic_param; - memset(&pic_param, 0, sizeof(pic_param)); - pic_param.picture_width = priv->width[scan_num]; - pic_param.picture_height = priv->height[scan_num]; - pic_param.num_components = priv->nf_components; - - - for (i=0; icomponent_infos[i].cid; - pic_param.components[i].h_sampling_factor = priv->component_infos[i].Hfactor; - pic_param.components[i].v_sampling_factor = priv->component_infos[i].Vfactor; - pic_param.components[i].quantiser_table_selector = priv->component_infos[i].quant_table_index; - } - int h1, h2, h3, v1, v2, v3; - h1 = pic_param.components[0].h_sampling_factor; - h2 = pic_param.components[1].h_sampling_factor; - h3 = pic_param.components[2].h_sampling_factor; - v1 = pic_param.components[0].v_sampling_factor; - v2 = pic_param.components[1].v_sampling_factor; - v3 = pic_param.components[2].v_sampling_factor; - - if (h1 == 2 && h2 == 1 && h3 == 1 && - v1 == 2 && v2 == 1 && v3 == 1) { - //surface_type = VA_RT_FORMAT_IMC3; - surface_type = VA_RT_FORMAT_YUV420; - forcc.value.value.i = VA_FOURCC_IMC3; - ChromaTypeIndex = 1; - type = "VA_FOURCC_IMC3"; - } - else if (h1 == 2 && h2 == 1 && h3 == 1 && - v1 == 1 && v2 == 1 && v3 == 1) { - //surface_type = VA_RT_FORMAT_YUV422H; - surface_type = VA_RT_FORMAT_YUV422; - forcc.value.value.i = VA_FOURCC_422H; - ChromaTypeIndex = 2; - type = "VA_FOURCC_422H"; - } - else if (h1 == 1 && h2 == 1 && h3 == 1 && - v1 == 1 && v2 == 1 && v3 == 1) { - surface_type = VA_RT_FORMAT_YUV444; - forcc.value.value.i = VA_FOURCC_444P; - //forcc.value.value.i = VA_FOURCC_RGBP; - ChromaTypeIndex = 3; - type = "VA_FOURCC_444P"; - } - else if (h1 == 4 && h2 == 1 && h3 == 1 && - v1 == 1 && v2 == 1 && v3 == 1) { - surface_type = VA_RT_FORMAT_YUV411; - forcc.value.value.i = VA_FOURCC_411P; - ChromaTypeIndex = 4; - type = "VA_FOURCC_411P"; - } - else if (h1 == 1 && h2 == 1 && h3 == 1 && - v1 == 2 && v2 == 1 && v3 == 1) { - //surface_type = VA_RT_FORMAT_YUV422V; - surface_type = VA_RT_FORMAT_YUV422; - forcc.value.value.i = VA_FOURCC_422V; - ChromaTypeIndex = 5; - type = "VA_FOURCC_422V"; - } - else if (h1 == 2 && h2 == 1 && h3 == 1 && - v1 == 2 && v2 == 2 && v3 == 2) { - //surface_type = VA_RT_FORMAT_YUV422H; - surface_type = VA_RT_FORMAT_YUV422; - forcc.value.value.i = VA_FOURCC_422H; - ChromaTypeIndex = 6; - type = "VA_FOURCC_422H"; - } - else if (h2 == 2 && h2 == 2 && h3 == 2 && - v1 == 2 && v2 == 1 && v3 == 1) { - //surface_type = VA_RT_FORMAT_YUV422V; - surface_type = VA_RT_FORMAT_YUV422; - forcc.value.value.i = VA_FOURCC_422V; - ChromaTypeIndex = 7; - type = "VA_FOURCC_422V"; - } - else - { - surface_type = VA_RT_FORMAT_YUV400; - forcc.value.value.i = VA_FOURCC('Y','8','0','0'); - ChromaTypeIndex = 0; - type = "Format_400P"; - } - - va_status = vaCreateSurfaces(va_dpy,surface_type, - priv->width[scan_num],priv->height[scan_num], //alignment? - &surface_id, 1, &forcc, 1); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(va_dpy, config_id, - priv->width[scan_num], priv->height[scan_num], // alignment? - VA_PROGRESSIVE, - &surface_id, - 1, - &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VAPictureParameterBufferType, // VAPictureParameterBufferJPEGBaseline? - sizeof(VAPictureParameterBufferJPEGBaseline), - 1, &pic_param, - &pic_param_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - VAIQMatrixBufferJPEGBaseline iq_matrix; - const unsigned int num_quant_tables = - MIN(COMPONENTS, ARRAY_ELEMS(iq_matrix.load_quantiser_table)); - // todo, only mask it if non-default quant matrix is used. do we need build default quant matrix? - memset(&iq_matrix, 0, sizeof(VAIQMatrixBufferJPEGBaseline)); - for (i = 0; i < num_quant_tables; i++) { - if (!priv->Q_tables_valid[i]) - continue; - iq_matrix.load_quantiser_table[i] = 1; - for (j = 0; j < 64; j++) - iq_matrix.quantiser_table[i][j] = priv->Q_tables[i][j]; - } - va_status = vaCreateBuffer(va_dpy, context_id, - VAIQMatrixBufferType, // VAIQMatrixBufferJPEGBaseline? - sizeof(VAIQMatrixBufferJPEGBaseline), - 1, &iq_matrix, - &iqmatrix_buf ); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - VAHuffmanTableBufferJPEGBaseline huffman_table; - const unsigned int num_huffman_tables = - MIN(COMPONENTS, ARRAY_ELEMS(huffman_table.load_huffman_table)); - memset(&huffman_table, 0, sizeof(VAHuffmanTableBufferJPEGBaseline)); - assert(sizeof(huffman_table.huffman_table[0].num_dc_codes) == - sizeof(priv->HTDC[0].bits)); - assert(sizeof(huffman_table.huffman_table[0].dc_values[0]) == - sizeof(priv->HTDC[0].values[0])); - for (i = 0; i < num_huffman_tables; i++) { - if (!priv->HTDC_valid[i] || !priv->HTAC_valid[i]) - continue; - huffman_table.load_huffman_table[i] = 1; - memcpy(huffman_table.huffman_table[i].num_dc_codes, priv->HTDC[i].bits, - sizeof(huffman_table.huffman_table[i].num_dc_codes)); - memcpy(huffman_table.huffman_table[i].dc_values, priv->HTDC[i].values, - sizeof(huffman_table.huffman_table[i].dc_values)); - memcpy(huffman_table.huffman_table[i].num_ac_codes, priv->HTAC[i].bits, - sizeof(huffman_table.huffman_table[i].num_ac_codes)); - memcpy(huffman_table.huffman_table[i].ac_values, priv->HTAC[i].values, - sizeof(huffman_table.huffman_table[i].ac_values)); - memset(huffman_table.huffman_table[i].pad, 0, - sizeof(huffman_table.huffman_table[i].pad)); - } - va_status = vaCreateBuffer(va_dpy, context_id, - VAHuffmanTableBufferType, // VAHuffmanTableBufferJPEGBaseline? - sizeof(VAHuffmanTableBufferJPEGBaseline), - 1, &huffman_table, - &huffmantable_buf ); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - // one slice for whole image? - max_h_factor = priv->component_infos[0].Hfactor; - max_v_factor = priv->component_infos[0].Vfactor; - static VASliceParameterBufferJPEGBaseline slice_param; - slice_param.slice_data_size = (priv->stream_scan - priv->stream); - slice_param.slice_data_offset = 0; - slice_param.slice_data_flag = VA_SLICE_DATA_FLAG_ALL; - slice_param.slice_horizontal_position = 0; - slice_param.slice_vertical_position = 0; - slice_param.num_components = priv->cur_sos.nr_components; - for (i = 0; i < slice_param.num_components; i++) { - slice_param.components[i].component_selector = priv->cur_sos.components[i].component_id; /* FIXME: set to values specified in SOS */ - slice_param.components[i].dc_table_selector = priv->cur_sos.components[i].dc_selector; /* FIXME: set to values specified in SOS */ - slice_param.components[i].ac_table_selector = priv->cur_sos.components[i].ac_selector; /* FIXME: set to values specified in SOS */ - } - slice_param.restart_interval = priv->restart_interval; - slice_param.num_mcus = ((priv->width[scan_num]+max_h_factor*8-1)/(max_h_factor*8))* - ((priv->height[scan_num]+max_v_factor*8-1)/(max_v_factor*8)); // ?? 720/16? - - va_status = vaCreateBuffer(va_dpy, context_id, - VASliceParameterBufferType, // VASliceParameterBufferJPEGBaseline? - sizeof(VASliceParameterBufferJPEGBaseline), - 1, - &slice_param, &slice_param_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VASliceDataBufferType, - priv->stream_scan - priv->stream, - 1, - (void*)priv->stream, // jpeg_clip, - &slice_data_buf); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - va_status = vaBeginPicture(va_dpy, context_id, surface_id); - CHECK_VASTATUS(va_status, "vaBeginPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &iqmatrix_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &huffmantable_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &slice_data_buf, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaEndPicture(va_dpy,context_id); - CHECK_VASTATUS(va_status, "vaEndPicture"); - - va_status = vaSyncSurface(va_dpy, surface_id); - CHECK_VASTATUS(va_status, "vaSyncSurface"); - - if (putsurface) { - VARectangle src_rect, dst_rect; - - src_rect.x = 0; - src_rect.y = 0; - src_rect.width = priv->width[scan_num]; - src_rect.height = priv->height[scan_num]; - dst_rect = src_rect; - - va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect); - CHECK_VASTATUS(va_status, "vaPutSurface"); - } - scan_num++; - - vaDestroySurfaces(va_dpy,&surface_id,1); - vaDestroyConfig(va_dpy,config_id); - vaDestroyContext(va_dpy,context_id); - - parse_JFIF(priv,priv->stream); - if(priv->width[scan_num] == 0 && priv->height[scan_num] == 0) - break; - } - // va_close_display(va_dpy); - vaTerminate(va_dpy); - printf("press any key to exit23\n"); - getchar(); - return 0; -} -const char *tinyjpeg_get_errorstring(struct jdec_private *priv) -{ - /* FIXME: the error string must be store in the context */ - priv = priv; - return error_string; -} -void tinyjpeg_get_size(struct jdec_private *priv, unsigned int *width, unsigned int *height) -{ - *width = priv->width[scan_num]; - *height = priv->height[scan_num]; -} - - diff --git a/test/decode/tinyjpeg.h b/test/decode/tinyjpeg.h deleted file mode 100644 index 5a76e41..0000000 --- a/test/decode/tinyjpeg.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Small jpeg decoder library (header file) - * - * Copyright (c) 2006, Luc Saillard - * Copyright (c) 2012 Intel Corporation. - * All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#ifndef __JPEGDEC_H__ -#define __JPEGDEC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct jdec_private; - -/* Flags that can be set by any applications */ -#define TINYJPEG_FLAGS_MJPEG_TABLE (1<<1) - -/* Format accepted in outout */ -enum tinyjpeg_fmt { - TINYJPEG_FMT_GREY = 1, - TINYJPEG_FMT_BGR24, - TINYJPEG_FMT_RGB24, - TINYJPEG_FMT_YUV420P, -}; - -struct jdec_private *tinyjpeg_init(void); -void tinyjpeg_free(struct jdec_private *priv); - -int tinyjpeg_parse_header(struct jdec_private *priv, const unsigned char *buf, unsigned int size); -int tinyjpeg_decode(struct jdec_private *priv); -const char *tinyjpeg_get_errorstring(struct jdec_private *priv); -void tinyjpeg_get_size(struct jdec_private *priv, unsigned int *width, unsigned int *height); - -#ifdef __cplusplus -} -#endif - -#endif - - - diff --git a/test/encode/Android.mk b/test/encode/Android.mk deleted file mode 100755 index 430ffd9..0000000 --- a/test/encode/Android.mk +++ /dev/null @@ -1,50 +0,0 @@ -# For test_01 -# ===================================================== - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - ../common/va_display.c \ - ../common/va_display_android.cpp \ - h264encode.c - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../../va \ - $(LOCAL_PATH)/../common \ - $(TARGET_OUT_HEADERS)/libva - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := h264encode - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui libm - -include $(BUILD_EXECUTABLE) - - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - ../common/va_display.c \ - ../common/va_display_android.cpp \ - avcenc.c - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../../va \ - $(LOCAL_PATH)/../common \ - $(TARGET_OUT_HEADERS)/libva - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := avcenc - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui - -include $(BUILD_EXECUTABLE) - diff --git a/test/encode/Makefile.am b/test/encode/Makefile.am deleted file mode 100644 index 9a47c2c..0000000 --- a/test/encode/Makefile.am +++ /dev/null @@ -1,74 +0,0 @@ -# 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. - -bin_PROGRAMS = avcenc mpeg2vaenc h264encode jpegenc -noinst_PROGRAMS = svctenc - -AM_CPPFLAGS = \ - -Wall \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - $(NULL) - -h264encode_SOURCES = h264encode.c -h264encode_CFLAGS = -I$(top_srcdir)/test/common -g -h264encode_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - -lpthread -lm - -avcenc_SOURCES = avcenc.c -avcenc_CFLAGS = -I$(top_srcdir)/test/common -g -avcenc_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - -lpthread - -mpeg2vaenc_SOURCES = mpeg2vaenc.c -mpeg2vaenc_CFLAGS = -I$(top_srcdir)/test/common -mpeg2vaenc_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - -lpthread - -jpegenc_SOURCES = jpegenc.c -jpegenc_CFLAGS = -I$(top_srcdir)/test/common -g -jpegenc_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - -lpthread - -svctenc_SOURCES = svctenc.c -svctenc_CFLAGS = -I$(top_srcdir)/test/common -g -svctenc_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - -lpthread -lm - -valgrind: $(bin_PROGRAMS) $(noinst_PROGRAMS) - for a in $(bin_PROGRAMS) $(noinst_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done - -EXTRA_DIST = \ - jpegenc_utils.h \ - $(NULL) diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c deleted file mode 100644 index dbc932c..0000000 --- a/test/encode/avcenc.c +++ /dev/null @@ -1,2143 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -/* - * Simple AVC encoder based on libVA. - * - * Usage: - * ./avcenc [qp] - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include "va_display.h" - -#define NAL_REF_IDC_NONE 0 -#define NAL_REF_IDC_LOW 1 -#define NAL_REF_IDC_MEDIUM 2 -#define NAL_REF_IDC_HIGH 3 - -#define NAL_NON_IDR 1 -#define NAL_IDR 5 -#define NAL_SPS 7 -#define NAL_PPS 8 -#define NAL_SEI 6 - -#define SLICE_TYPE_P 0 -#define SLICE_TYPE_B 1 -#define SLICE_TYPE_I 2 - -#define FRAME_IDR 7 - -#define ENTROPY_MODE_CAVLC 0 -#define ENTROPY_MODE_CABAC 1 - -#define PROFILE_IDC_BASELINE 66 -#define PROFILE_IDC_MAIN 77 -#define PROFILE_IDC_HIGH 100 - -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - -static VADisplay va_dpy; - -static int picture_width, picture_width_in_mbs; -static int picture_height, picture_height_in_mbs; -static int frame_size; -static unsigned char *newImageBuffer = 0; - -static int qp_value = 26; - -static int intra_period = 30; -static int frame_bit_rate = -1; -static int frame_rate = 30; -static int ip_period = 1; -static int roi_test_enable = 0; - -static VAEntrypoint select_entrypoint = VAEntrypointEncSlice; - -#define MAX_SLICES 32 - - -static unsigned int MaxFrameNum = (1<<12); -static unsigned int Log2MaxFrameNum = 12; -static unsigned int Log2MaxPicOrderCntLsb = 8; - -static const struct option longopts[] = { - {"qp", required_argument, 0, 1}, - {"fb", required_argument, 0, 2}, - {"mode", required_argument, 0, 3}, - {"low-power", no_argument, 0, 4}, - {"roi-test", no_argument, 0, 5}, - { NULL, 0, NULL, 0} -}; - -static int -build_packed_pic_buffer(unsigned char **header_buffer); - -static int -build_packed_seq_buffer(unsigned char **header_buffer); - -static int -build_packed_sei_pic_timing(unsigned int cpb_removal_length, - unsigned int dpb_output_length, - unsigned char **sei_buffer); - -static int -build_packed_idr_sei_buffer_timing(unsigned int init_cpb_removal_delay_length, - unsigned int cpb_removal_length, - unsigned int dpb_output_length, - unsigned char **sei_buffer); - -struct upload_thread_param -{ - FILE *yuv_fp; - VASurfaceID surface_id; -}; - -static void -upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id); - -static struct { - VAProfile profile; - int constraint_set_flag; - VAEncSequenceParameterBufferH264 seq_param; - VAEncPictureParameterBufferH264 pic_param; - VAEncSliceParameterBufferH264 slice_param[MAX_SLICES]; - VAContextID context_id; - VAConfigID config_id; - VABufferID seq_param_buf_id; /* Sequence level parameter */ - VABufferID pic_param_buf_id; /* Picture level parameter */ - VABufferID slice_param_buf_id[MAX_SLICES]; /* Slice level parameter, multil slices */ - VABufferID codedbuf_buf_id; /* Output buffer, compressed data */ - VABufferID packed_seq_header_param_buf_id; - VABufferID packed_seq_buf_id; - VABufferID packed_pic_header_param_buf_id; - VABufferID packed_pic_buf_id; - VABufferID packed_sei_header_param_buf_id; /* the SEI buffer */ - VABufferID packed_sei_buf_id; - VABufferID misc_parameter_hrd_buf_id; - VABufferID misc_parameter_roi_buf_id; - - int num_slices; - int codedbuf_i_size; - int codedbuf_pb_size; - int current_input_surface; - int rate_control_method; - struct upload_thread_param upload_thread_param; - pthread_t upload_thread_id; - int upload_thread_value; - int i_initial_cpb_removal_delay; - int i_initial_cpb_removal_delay_offset; - int i_initial_cpb_removal_delay_length; - int i_cpb_removal_delay; - int i_cpb_removal_delay_length; - int i_dpb_output_delay_length; - int time_offset_length; - - unsigned long long idr_frame_num; - unsigned long long prev_idr_cpb_removal; - unsigned long long current_idr_cpb_removal; - unsigned long long current_cpb_removal; - /* This is relative to the current_cpb_removal */ - unsigned int current_dpb_removal_delta; -} avcenc_context; - -static VAPictureH264 ReferenceFrames[16], RefPicList0[32], RefPicList1[32]; - -static void create_encode_pipe() -{ - VAEntrypoint entrypoints[5]; - int num_entrypoints,slice_entrypoint; - VAConfigAttrib attrib[3]; - int major_ver, minor_ver; - VAStatus va_status; - - va_dpy = va_open_display(); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - vaQueryConfigEntrypoints(va_dpy, avcenc_context.profile, entrypoints, - &num_entrypoints); - - for (slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) { - if (entrypoints[slice_entrypoint] == select_entrypoint) - break; - } - - if (slice_entrypoint == num_entrypoints) { - /* not find Slice entry point */ - assert(0); - } - - /* find out the format for the render target, and rate control mode */ - attrib[0].type = VAConfigAttribRTFormat; - attrib[1].type = VAConfigAttribRateControl; - - /* This is to query whether the ROI is supported */ - attrib[2].type = VAConfigAttribEncROI; - vaGetConfigAttributes(va_dpy, avcenc_context.profile, select_entrypoint, - &attrib[0], 3); - - if ((attrib[0].value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - if ((attrib[1].value & avcenc_context.rate_control_method) == 0) { - /* Can't find matched RC mode */ - printf("Can't find the desired RC mode, exit\n"); - assert(0); - } - - if (roi_test_enable){ - if (attrib[2].value != VA_ATTRIB_NOT_SUPPORTED) { - VAConfigAttribValEncROI *roi_config = (VAConfigAttribValEncROI *)&(attrib[2].value); - if(roi_config->bits.num_roi_regions == 0 || - roi_config->bits.roi_rc_qp_delat_support == 0) { - roi_test_enable = 0; - printf("WARNING: do not support ROI or ROI delta QP ! \n"); - } - } else { - roi_test_enable = 0; - printf("WARNING: do not support VAConfigAttribValEncROI! \n"); - } - } - - attrib[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */ - attrib[1].value = avcenc_context.rate_control_method; /* set to desired RC mode */ - - if (roi_test_enable){ - va_status = vaCreateConfig(va_dpy, avcenc_context.profile, select_entrypoint, - &attrib[0], 3,&avcenc_context.config_id); - }else { - va_status = vaCreateConfig(va_dpy, avcenc_context.profile, select_entrypoint, - &attrib[0], 2,&avcenc_context.config_id); - } - CHECK_VASTATUS(va_status, "vaCreateConfig"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(va_dpy, avcenc_context.config_id, - picture_width, picture_height, - VA_PROGRESSIVE, - 0, 0, - &avcenc_context.context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); -} - -static void destory_encode_pipe() -{ - vaDestroyContext(va_dpy,avcenc_context.context_id); - vaDestroyConfig(va_dpy,avcenc_context.config_id); - vaTerminate(va_dpy); - va_close_display(va_dpy); -} - -/*************************************************** - * - * The encode pipe resource define - * - ***************************************************/ -#define SID_INPUT_PICTURE_0 0 -#define SID_INPUT_PICTURE_1 1 -#define SID_REFERENCE_PICTURE_L0 2 -#define SID_REFERENCE_PICTURE_L1 3 -#define SID_RECON_PICTURE 4 -#define SID_NUMBER SID_RECON_PICTURE + 1 - -#define SURFACE_NUM 16 /* 16 surfaces for reference */ - -static VASurfaceID surface_ids[SID_NUMBER]; -static VASurfaceID ref_surface[SURFACE_NUM]; -static int use_slot[SURFACE_NUM]; - -static unsigned long long current_frame_display = 0; -static unsigned long long current_IDR_display = 0; - -static VAPictureH264 CurrentCurrPic; - -#define current_slot (current_frame_display % SURFACE_NUM) - -static int frame_number; -static unsigned long long enc_frame_number; -static int current_frame_type; -static int current_frame_num; -static unsigned int current_poc; - -static unsigned int num_ref_frames = 2; -static unsigned int numShortTerm = 0; -/***************************************************/ - -static int get_free_slot() -{ - int i, index = -1; - - for (i = 0; i < SURFACE_NUM; i++) { - if (use_slot[i] == 0) { - index = i; - break; - } - } - if (index < 0) { - printf("WARNING: No free slot to store the reconstructed frame \n"); - index = SURFACE_NUM - 1; - } - return index; -} - -static void * -upload_thread_function(void *data) -{ - struct upload_thread_param *param = data; - - upload_yuv_to_surface(param->yuv_fp, param->surface_id); - - return NULL; -} - -static void alloc_encode_resource(FILE *yuv_fp) -{ - VAStatus va_status; - - // Create surface - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, picture_width, picture_height, - surface_ids, SID_NUMBER, - NULL, 0 - ); - - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - // Create surface - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, picture_width, picture_height, - ref_surface, SURFACE_NUM, - NULL, 0 - ); - - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - - newImageBuffer = (unsigned char *)malloc(frame_size); - - /* firstly upload YUV data to SID_INPUT_PICTURE_1 */ - avcenc_context.upload_thread_param.yuv_fp = yuv_fp; - avcenc_context.upload_thread_param.surface_id = surface_ids[SID_INPUT_PICTURE_1]; - - avcenc_context.upload_thread_value = pthread_create(&avcenc_context.upload_thread_id, - NULL, - upload_thread_function, - (void*)&avcenc_context.upload_thread_param); -} - -static void release_encode_resource() -{ - pthread_join(avcenc_context.upload_thread_id, NULL); - free(newImageBuffer); - - // Release all the surfaces resource - vaDestroySurfaces(va_dpy, surface_ids, SID_NUMBER); - // Release all the reference surfaces - vaDestroySurfaces(va_dpy, ref_surface, SURFACE_NUM); -} - -static void avcenc_update_sei_param(int is_idr) -{ - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_sei_buffer = NULL; - VAStatus va_status; - - if (is_idr) - length_in_bits = build_packed_idr_sei_buffer_timing( - avcenc_context.i_initial_cpb_removal_delay_length, - avcenc_context.i_cpb_removal_delay_length, - avcenc_context.i_dpb_output_delay_length, - &packed_sei_buffer); - else - length_in_bits = build_packed_sei_pic_timing( - avcenc_context.i_cpb_removal_delay_length, - avcenc_context.i_dpb_output_delay_length, - &packed_sei_buffer); - - packed_header_param_buffer.type = VAEncPackedHeaderH264_SEI; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &avcenc_context.packed_sei_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_sei_buffer, - &avcenc_context.packed_sei_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - free(packed_sei_buffer); - return; -} - -#define partition(ref, field, key, ascending) \ - while (i <= j) { \ - if (ascending) { \ - while (ref[i].field < key) \ - i++; \ - while (ref[j].field > key) \ - j--; \ - } else { \ - while (ref[i].field > key) \ - i++; \ - while (ref[j].field < key) \ - j--; \ - } \ - if (i <= j) { \ - tmp = ref[i]; \ - ref[i] = ref[j]; \ - ref[j] = tmp; \ - i++; \ - j--; \ - } \ - } \ - -static void sort_one(VAPictureH264 ref[], int left, int right, - int ascending, int frame_idx) -{ - int i = left, j = right; - unsigned int key; - VAPictureH264 tmp; - - if (frame_idx) { - key = ref[(left + right) / 2].frame_idx; - partition(ref, frame_idx, key, ascending); - } else { - key = ref[(left + right) / 2].TopFieldOrderCnt; - partition(ref, TopFieldOrderCnt, (signed int)key, ascending); - } - - /* recursion */ - if (left < j) - sort_one(ref, left, j, ascending, frame_idx); - - if (i < right) - sort_one(ref, i, right, ascending, frame_idx); -} - -static void sort_two(VAPictureH264 ref[], int left, int right, unsigned int key, unsigned int frame_idx, - int partition_ascending, int list0_ascending, int list1_ascending) -{ - int i = left, j = right; - VAPictureH264 tmp; - - if (frame_idx) { - partition(ref, frame_idx, key, partition_ascending); - } else { - partition(ref, TopFieldOrderCnt, (signed int)key, partition_ascending); - } - - sort_one(ref, left, i-1, list0_ascending, frame_idx); - sort_one(ref, j+1, right, list1_ascending, frame_idx); -} - -static int update_RefPicList() -{ - - if (current_frame_type == SLICE_TYPE_P) { - memcpy(RefPicList0, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_one(RefPicList0, 0, numShortTerm-1, 0, 1); - } - - if (current_frame_type == SLICE_TYPE_B) { - memcpy(RefPicList0, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_two(RefPicList0, 0, numShortTerm-1, current_poc, 0, - 1, 0, 1); - - memcpy(RefPicList1, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_two(RefPicList1, 0, numShortTerm-1, current_poc, 0, - 0, 1, 0); - } - - return 0; -} - -static void avcenc_update_picture_parameter(int slice_type, int is_idr) -{ - VAEncPictureParameterBufferH264 *pic_param; - VAStatus va_status; - int recon_index; - - recon_index = get_free_slot(); - // Picture level - pic_param = &avcenc_context.pic_param; - - pic_param->CurrPic.picture_id = ref_surface[recon_index]; - pic_param->CurrPic.frame_idx = current_frame_num; - pic_param->CurrPic.flags = 0; - - pic_param->CurrPic.TopFieldOrderCnt = current_poc; - pic_param->CurrPic.BottomFieldOrderCnt = pic_param->CurrPic.TopFieldOrderCnt; - - assert(avcenc_context.codedbuf_buf_id != VA_INVALID_ID); - pic_param->coded_buf = avcenc_context.codedbuf_buf_id; - pic_param->frame_num = current_frame_num; - pic_param->pic_fields.bits.idr_pic_flag = !!is_idr; - pic_param->pic_fields.bits.reference_pic_flag = (slice_type != SLICE_TYPE_B); - CurrentCurrPic = pic_param->CurrPic; - - if (slice_type == SLICE_TYPE_P || slice_type == SLICE_TYPE_B) - memset(pic_param->ReferenceFrames, 0xff, 16 * sizeof(VAPictureH264)); /* invalid all */ - - if ((slice_type == SLICE_TYPE_P) || (slice_type == SLICE_TYPE_B)) { - pic_param->ReferenceFrames[0] = RefPicList0[0]; - } - if (slice_type == SLICE_TYPE_B) { - pic_param->ReferenceFrames[1] = RefPicList1[0]; - } - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPictureParameterBufferType, - sizeof(*pic_param), 1, pic_param, - &avcenc_context.pic_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - -} - -#ifndef VA_FOURCC_I420 -#define VA_FOURCC_I420 0x30323449 -#endif - -static void upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id) -{ - VAImage surface_image; - VAStatus va_status; - void *surface_p = NULL; - unsigned char *y_src, *u_src, *v_src; - unsigned char *y_dst, *u_dst, *v_dst; - int y_size = picture_width * picture_height; - int u_size = (picture_width >> 1) * (picture_height >> 1); - int row, col; - size_t n_items; - - do { - n_items = fread(newImageBuffer, frame_size, 1, yuv_fp); - } while (n_items != 1); - - va_status = vaDeriveImage(va_dpy, surface_id, &surface_image); - CHECK_VASTATUS(va_status,"vaDeriveImage"); - - vaMapBuffer(va_dpy, surface_image.buf, &surface_p); - assert(VA_STATUS_SUCCESS == va_status); - - y_src = newImageBuffer; - u_src = newImageBuffer + y_size; /* UV offset for NV12 */ - v_src = newImageBuffer + y_size + u_size; - - y_dst = surface_p + surface_image.offsets[0]; - u_dst = surface_p + surface_image.offsets[1]; /* UV offset for NV12 */ - v_dst = surface_p + surface_image.offsets[2]; - - /* Y plane */ - for (row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width); - y_dst += surface_image.pitches[0]; - y_src += picture_width; - } - - if (surface_image.format.fourcc == VA_FOURCC_NV12) { /* UV plane */ - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col * 2] = u_src[col]; - u_dst[col * 2 + 1] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - u_src += (picture_width / 2); - v_src += (picture_width / 2); - } - } else if (surface_image.format.fourcc == VA_FOURCC_YV12 || - surface_image.format.fourcc == VA_FOURCC_I420) { - const int U = surface_image.format.fourcc == VA_FOURCC_I420 ? 1 : 2; - const int V = surface_image.format.fourcc == VA_FOURCC_I420 ? 2 : 1; - - u_dst = surface_p + surface_image.offsets[U]; - v_dst = surface_p + surface_image.offsets[V]; - - for (row = 0; row < surface_image.height / 2; row++) { - memcpy(u_dst, u_src, surface_image.width / 2); - memcpy(v_dst, v_src, surface_image.width / 2); - u_dst += surface_image.pitches[U]; - v_dst += surface_image.pitches[V]; - u_src += (picture_width / 2); - v_src += (picture_width / 2); - } - } - - vaUnmapBuffer(va_dpy, surface_image.buf); - vaDestroyImage(va_dpy, surface_image.image_id); -} - -static void avcenc_update_slice_parameter(int slice_type) -{ - VAEncSliceParameterBufferH264 *slice_param; - VAStatus va_status; - int i; - - // Slice level - i = 0; - slice_param = &avcenc_context.slice_param[i]; - slice_param->macroblock_address = 0; - slice_param->num_macroblocks = picture_height_in_mbs * picture_width_in_mbs; - slice_param->pic_parameter_set_id = 0; - slice_param->slice_type = slice_type; - slice_param->direct_spatial_mv_pred_flag = 0; - slice_param->num_ref_idx_l0_active_minus1 = 0; /* FIXME: ??? */ - slice_param->num_ref_idx_l1_active_minus1 = 0; - slice_param->cabac_init_idc = 0; - slice_param->slice_qp_delta = 0; - slice_param->disable_deblocking_filter_idc = 0; - slice_param->slice_alpha_c0_offset_div2 = 2; - slice_param->slice_beta_offset_div2 = 2; - slice_param->idr_pic_id = 0; - - /* FIXME: fill other fields */ - if ((slice_type == SLICE_TYPE_P) || (slice_type == SLICE_TYPE_B)) { - memset(slice_param->RefPicList0, 0xFF, 32 * sizeof(VAPictureH264)); - slice_param->RefPicList0[0] = RefPicList0[0]; - } - - if ((slice_type == SLICE_TYPE_B)) { - memset(slice_param->RefPicList1, 0xFF, 32 * sizeof(VAPictureH264)); - slice_param->RefPicList1[0] = RefPicList1[0]; - } - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncSliceParameterBufferType, - sizeof(*slice_param), 1, slice_param, - &avcenc_context.slice_param_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - i++; - -#if 0 - slice_param = &avcenc_context.slice_param[i]; - slice_param->macroblock_address = picture_height_in_mbs * picture_width_in_mbs / 2; - slice_param->num_macroblocks = picture_height_in_mbs * picture_width_in_mbs / 2; - slice_param->pic_parameter_set_id = 0; - slice_param->slice_type = slice_type; - slice_param->direct_spatial_mv_pred_flag = 0; - slice_param->num_ref_idx_l0_active_minus1 = 0; /* FIXME: ??? */ - slice_param->num_ref_idx_l1_active_minus1 = 0; - slice_param->cabac_init_idc = 0; - slice_param->slice_qp_delta = 0; - slice_param->disable_deblocking_filter_idc = 0; - slice_param->slice_alpha_c0_offset_div2 = 2; - slice_param->slice_beta_offset_div2 = 2; - slice_param->idr_pic_id = 0; - - /* FIXME: fill other fields */ - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncSliceParameterBufferType, - sizeof(*slice_param), 1, slice_param, - &avcenc_context.slice_param_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - i++; -#endif - - avcenc_context.num_slices = i; -} - -static int update_ReferenceFrames(void) -{ - int i; - /* B-frame is not used for reference */ - if (current_frame_type == SLICE_TYPE_B) - return 0; - - CurrentCurrPic.flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; - numShortTerm++; - if (numShortTerm > num_ref_frames) - numShortTerm = num_ref_frames; - for (i=numShortTerm-1; i>0; i--) - ReferenceFrames[i] = ReferenceFrames[i-1]; - ReferenceFrames[0] = CurrentCurrPic; - - if (current_frame_type != SLICE_TYPE_B) - current_frame_num++; - if (current_frame_num > MaxFrameNum) - current_frame_num = 0; - - /* Update the use_slot. Only when the surface is used in reference - * frame list, the use_slot[index] is set - */ - for (i = 0; i < SURFACE_NUM; i++) { - int j; - bool found; - - found = false; - for (j = 0; j < numShortTerm; j++) { - if (ref_surface[i] == ReferenceFrames[j].picture_id) { - found = true; - break; - } - } - if (found) - use_slot[i] = 1; - else - use_slot[i] = 0; - } - - return 0; -} - -static int begin_picture(FILE *yuv_fp, int frame_num, int display_num, int slice_type, int is_idr) -{ - VAStatus va_status; - - if (avcenc_context.upload_thread_value != 0) { - fprintf(stderr, "FATAL error!!!\n"); - exit(1); - } - - pthread_join(avcenc_context.upload_thread_id, NULL); - - avcenc_context.upload_thread_value = -1; - - if (avcenc_context.current_input_surface == SID_INPUT_PICTURE_0) - avcenc_context.current_input_surface = SID_INPUT_PICTURE_1; - else - avcenc_context.current_input_surface = SID_INPUT_PICTURE_0; - - if (is_idr) { - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_seq_buffer = NULL, *packed_pic_buffer = NULL; - - assert(slice_type == SLICE_TYPE_I); - length_in_bits = build_packed_seq_buffer(&packed_seq_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderSequence; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &avcenc_context.packed_seq_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_seq_buffer, - &avcenc_context.packed_seq_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - length_in_bits = build_packed_pic_buffer(&packed_pic_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderPicture; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &avcenc_context.packed_pic_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_pic_buffer, - &avcenc_context.packed_pic_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_seq_buffer); - free(packed_pic_buffer); - } - - /* sequence parameter set */ - VAEncSequenceParameterBufferH264 *seq_param = &avcenc_context.seq_param; - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncSequenceParameterBufferType, - sizeof(*seq_param), 1, seq_param, - &avcenc_context.seq_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - - /* hrd parameter */ - VAEncMiscParameterBuffer *misc_param; - VAEncMiscParameterHRD *misc_hrd_param; - vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl), - 1, - NULL, - &avcenc_context.misc_parameter_hrd_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(va_dpy, - avcenc_context.misc_parameter_hrd_buf_id, - (void **)&misc_param); - misc_param->type = VAEncMiscParameterTypeHRD; - misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data; - - if (frame_bit_rate > 0) { - misc_hrd_param->initial_buffer_fullness = frame_bit_rate * 1000 * 4; - misc_hrd_param->buffer_size = frame_bit_rate * 1000 * 8; - } else { - misc_hrd_param->initial_buffer_fullness = 0; - misc_hrd_param->buffer_size = 0; - } - - vaUnmapBuffer(va_dpy, avcenc_context.misc_parameter_hrd_buf_id); - - /* ROI parameter: hard code for test on only one region (0,0,120,120) with qp_delta=4 */ - if(roi_test_enable) - { - VAEncMiscParameterBufferROI *misc_roi_param; - - int roi_num = 1; - vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterBufferROI) + roi_num * sizeof(VAEncROI), - 1, - NULL, - &avcenc_context.misc_parameter_roi_buf_id); - vaMapBuffer(va_dpy, - avcenc_context.misc_parameter_roi_buf_id, - (void **)&misc_param); - misc_param->type = VAEncMiscParameterTypeROI; - misc_roi_param = (VAEncMiscParameterBufferROI *)misc_param->data; - { - misc_roi_param->roi_flags.bits.roi_value_is_qp_delta = 1; - /* - * Max/Min delta_qp is only used in CBR mode. It is ingored under CQP mode. - * max_delta_qp means the allowed upper bound of qp delta. (qp + X) - * min_delta_qp means the allowed lower bound of qp delta. (qp -X) - * So it will be better that it is positive. Otherwise the driver will - * use the default bound setting. - */ - misc_roi_param->max_delta_qp = 3; - misc_roi_param->min_delta_qp = 3; - /* one example of ROI region conf. - * please change it on the fly. - */ - VAEncROI *region_roi =(VAEncROI *)((char *)misc_param + sizeof(VAEncMiscParameterBuffer) + - sizeof(VAEncMiscParameterBufferROI)); - - /* - * Under CQP mode roi_value specifies the qp_delta that is added to frame qp - * Under CBR mode roi_value specifies the important level (positive means that - * it is important. negative means that it is less important). - */ - region_roi->roi_value = 4; - region_roi->roi_rectangle.x = 0; - region_roi->roi_rectangle.y = 0; - region_roi->roi_rectangle.width = (120 < picture_width/4)? 120:picture_width/4; - region_roi->roi_rectangle.height = (120 < picture_height/4)? 120:picture_height/4; - - misc_roi_param->roi = region_roi; - misc_roi_param->num_roi = 1; - } - - vaUnmapBuffer(va_dpy, avcenc_context.misc_parameter_roi_buf_id); - } - return 0; -} - -int avcenc_render_picture() -{ - VAStatus va_status; - VABufferID va_buffers[20]; - unsigned int num_va_buffers = 0; - int i; - - va_buffers[num_va_buffers++] = avcenc_context.seq_param_buf_id; - va_buffers[num_va_buffers++] = avcenc_context.pic_param_buf_id; - - if (avcenc_context.packed_seq_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_seq_header_param_buf_id; - - if (avcenc_context.packed_seq_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_seq_buf_id; - - if (avcenc_context.packed_pic_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_pic_header_param_buf_id; - - if (avcenc_context.packed_pic_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_pic_buf_id; - - if (avcenc_context.packed_sei_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_sei_header_param_buf_id; - - if (avcenc_context.packed_sei_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.packed_sei_buf_id; - - if (avcenc_context.misc_parameter_hrd_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.misc_parameter_hrd_buf_id; - - if (avcenc_context.misc_parameter_roi_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = avcenc_context.misc_parameter_roi_buf_id; - - va_status = vaBeginPicture(va_dpy, - avcenc_context.context_id, - surface_ids[avcenc_context.current_input_surface]); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - - va_status = vaRenderPicture(va_dpy, - avcenc_context.context_id, - va_buffers, - num_va_buffers); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - for(i = 0; i < avcenc_context.num_slices; i++) { - va_status = vaRenderPicture(va_dpy, - avcenc_context.context_id, - &avcenc_context.slice_param_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - } - - va_status = vaEndPicture(va_dpy, avcenc_context.context_id); - CHECK_VASTATUS(va_status,"vaEndPicture"); - - return 0; -} - -static int avcenc_destroy_buffers(VABufferID *va_buffers, unsigned int num_va_buffers) -{ - VAStatus va_status; - unsigned int i; - - for (i = 0; i < num_va_buffers; i++) { - if (va_buffers[i] != VA_INVALID_ID) { - va_status = vaDestroyBuffer(va_dpy, va_buffers[i]); - CHECK_VASTATUS(va_status,"vaDestroyBuffer"); - va_buffers[i] = VA_INVALID_ID; - } - } - - return 0; -} - -static void end_picture() -{ - - update_ReferenceFrames(); - avcenc_destroy_buffers(&avcenc_context.seq_param_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.pic_param_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_seq_header_param_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_seq_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_pic_header_param_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_pic_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_sei_header_param_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.packed_sei_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.slice_param_buf_id[0], avcenc_context.num_slices); - avcenc_destroy_buffers(&avcenc_context.codedbuf_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.misc_parameter_hrd_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.misc_parameter_roi_buf_id, 1); - - memset(avcenc_context.slice_param, 0, sizeof(avcenc_context.slice_param)); - avcenc_context.num_slices = 0; -} - -#define BITSTREAM_ALLOCATE_STEPPING 4096 - -struct __bitstream { - unsigned int *buffer; - int bit_offset; - int max_size_in_dword; -}; - -typedef struct __bitstream bitstream; - -#if 0 -static int -get_coded_bitsteam_length(unsigned char *buffer, int buffer_length) -{ - int i; - - for (i = 0; i < buffer_length - 3; i++) { - if (!buffer[i] && - !buffer[i + 1] && - !buffer[i + 2] && - !buffer[i + 3]) - break; - } - - return i; -} -#endif - -static unsigned int -va_swap32(unsigned int val) -{ - unsigned char *pval = (unsigned char *)&val; - - return ((pval[0] << 24) | - (pval[1] << 16) | - (pval[2] << 8) | - (pval[3] << 0)); -} - -static void -bitstream_start(bitstream *bs) -{ - bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); - assert(bs->buffer); - bs->bit_offset = 0; -} - -static void -bitstream_end(bitstream *bs) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (bit_offset) { - bs->buffer[pos] = va_swap32((bs->buffer[pos] << bit_left)); - } -} - -static void -bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (!size_in_bits) - return; - - bs->bit_offset += size_in_bits; - - if (bit_left > size_in_bits) { - bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); - } else { - size_in_bits -= bit_left; - bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); - bs->buffer[pos] = va_swap32(bs->buffer[pos]); - - if (pos + 1 == bs->max_size_in_dword) { - bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); - assert(bs->buffer); - } - - bs->buffer[pos + 1] = val; - } -} - -static void -bitstream_put_ue(bitstream *bs, unsigned int val) -{ - int size_in_bits = 0; - int tmp_val = ++val; - - while (tmp_val) { - tmp_val >>= 1; - size_in_bits++; - } - - bitstream_put_ui(bs, 0, size_in_bits - 1); // leading zero - bitstream_put_ui(bs, val, size_in_bits); -} - -static void -bitstream_put_se(bitstream *bs, int val) -{ - unsigned int new_val; - - if (val <= 0) - new_val = -2 * val; - else - new_val = 2 * val - 1; - - bitstream_put_ue(bs, new_val); -} - -static void -bitstream_byte_aligning(bitstream *bs, int bit) -{ - int bit_offset = (bs->bit_offset & 0x7); - int bit_left = 8 - bit_offset; - int new_val; - - if (!bit_offset) - return; - - assert(bit == 0 || bit == 1); - - if (bit) - new_val = (1 << bit_left) - 1; - else - new_val = 0; - - bitstream_put_ui(bs, new_val, bit_left); -} - -static void -rbsp_trailing_bits(bitstream *bs) -{ - bitstream_put_ui(bs, 1, 1); - bitstream_byte_aligning(bs, 0); -} - -static void nal_start_code_prefix(bitstream *bs) -{ - bitstream_put_ui(bs, 0x00000001, 32); -} - -static void nal_header(bitstream *bs, int nal_ref_idc, int nal_unit_type) -{ - bitstream_put_ui(bs, 0, 1); /* forbidden_zero_bit: 0 */ - bitstream_put_ui(bs, nal_ref_idc, 2); - bitstream_put_ui(bs, nal_unit_type, 5); -} - -static void sps_rbsp(bitstream *bs) -{ - VAEncSequenceParameterBufferH264 *seq_param = &avcenc_context.seq_param; - int profile_idc = PROFILE_IDC_BASELINE; - - if (avcenc_context.profile == VAProfileH264High) - profile_idc = PROFILE_IDC_HIGH; - else if (avcenc_context.profile == VAProfileH264Main) - profile_idc = PROFILE_IDC_MAIN; - - bitstream_put_ui(bs, profile_idc, 8); /* profile_idc */ - bitstream_put_ui(bs, !!(avcenc_context.constraint_set_flag & 1), 1); /* constraint_set0_flag */ - bitstream_put_ui(bs, !!(avcenc_context.constraint_set_flag & 2), 1); /* constraint_set1_flag */ - bitstream_put_ui(bs, !!(avcenc_context.constraint_set_flag & 4), 1); /* constraint_set2_flag */ - bitstream_put_ui(bs, !!(avcenc_context.constraint_set_flag & 8), 1); /* constraint_set3_flag */ - bitstream_put_ui(bs, 0, 4); /* reserved_zero_4bits */ - bitstream_put_ui(bs, seq_param->level_idc, 8); /* level_idc */ - bitstream_put_ue(bs, seq_param->seq_parameter_set_id); /* seq_parameter_set_id */ - - if ( profile_idc == PROFILE_IDC_HIGH) { - bitstream_put_ue(bs, 1); /* chroma_format_idc = 1, 4:2:0 */ - bitstream_put_ue(bs, 0); /* bit_depth_luma_minus8 */ - bitstream_put_ue(bs, 0); /* bit_depth_chroma_minus8 */ - bitstream_put_ui(bs, 0, 1); /* qpprime_y_zero_transform_bypass_flag */ - bitstream_put_ui(bs, 0, 1); /* seq_scaling_matrix_present_flag */ - } - - bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_frame_num_minus4); /* log2_max_frame_num_minus4 */ - bitstream_put_ue(bs, seq_param->seq_fields.bits.pic_order_cnt_type); /* pic_order_cnt_type */ - - if (seq_param->seq_fields.bits.pic_order_cnt_type == 0) - bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4); /* log2_max_pic_order_cnt_lsb_minus4 */ - else { - assert(0); - } - - bitstream_put_ue(bs, seq_param->max_num_ref_frames); /* num_ref_frames */ - bitstream_put_ui(bs, 0, 1); /* gaps_in_frame_num_value_allowed_flag */ - - bitstream_put_ue(bs, seq_param->picture_width_in_mbs - 1); /* pic_width_in_mbs_minus1 */ - bitstream_put_ue(bs, seq_param->picture_height_in_mbs - 1); /* pic_height_in_map_units_minus1 */ - bitstream_put_ui(bs, seq_param->seq_fields.bits.frame_mbs_only_flag, 1); /* frame_mbs_only_flag */ - - if (!seq_param->seq_fields.bits.frame_mbs_only_flag) { - assert(0); - } - - bitstream_put_ui(bs, seq_param->seq_fields.bits.direct_8x8_inference_flag, 1); /* direct_8x8_inference_flag */ - bitstream_put_ui(bs, seq_param->frame_cropping_flag, 1); /* frame_cropping_flag */ - - if (seq_param->frame_cropping_flag) { - bitstream_put_ue(bs, seq_param->frame_crop_left_offset); /* frame_crop_left_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_right_offset); /* frame_crop_right_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_top_offset); /* frame_crop_top_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_bottom_offset); /* frame_crop_bottom_offset */ - } - - if ( frame_bit_rate < 0 ) { - bitstream_put_ui(bs, 0, 1); /* vui_parameters_present_flag */ - } else { - bitstream_put_ui(bs, 1, 1); /* vui_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* aspect_ratio_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* overscan_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* video_signal_type_present_flag */ - bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */ - bitstream_put_ui(bs, 1, 1); /* timing_info_present_flag */ - { - bitstream_put_ui(bs, 1, 32); - bitstream_put_ui(bs, frame_rate * 2, 32); - bitstream_put_ui(bs, 1, 1); - } - bitstream_put_ui(bs, 1, 1); /* nal_hrd_parameters_present_flag */ - { - // hrd_parameters - bitstream_put_ue(bs, 0); /* cpb_cnt_minus1 */ - bitstream_put_ui(bs, 0, 4); /* bit_rate_scale */ - bitstream_put_ui(bs, 2, 4); /* cpb_size_scale */ - - /* the frame_bit_rate is in kbps */ - bitstream_put_ue(bs, (((frame_bit_rate * 1000)>> 6) - 1)); /* bit_rate_value_minus1[0] */ - bitstream_put_ue(bs, ((frame_bit_rate * 8000) >> 6) - 1); /* cpb_size_value_minus1[0] */ - bitstream_put_ui(bs, 1, 1); /* cbr_flag[0] */ - - /* initial_cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, - (avcenc_context.i_initial_cpb_removal_delay_length - 1), 5); - /* cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, - (avcenc_context.i_cpb_removal_delay_length - 1), 5); - /* dpb_output_delay_length_minus1 */ - bitstream_put_ui(bs, - (avcenc_context.i_dpb_output_delay_length - 1), 5); - /* time_offset_length */ - bitstream_put_ui(bs, - (avcenc_context.time_offset_length - 1), 5); - } - bitstream_put_ui(bs, 0, 1); /* vcl_hrd_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* low_delay_hrd_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_struct_present_flag */ - bitstream_put_ui(bs, 0, 1); /* bitstream_restriction_flag */ - } - - rbsp_trailing_bits(bs); /* rbsp_trailing_bits */ -} - -#if 0 -static void build_nal_sps(FILE *avc_fp) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_SPS); - sps_rbsp(&bs); - bitstream_end(&bs, avc_fp); -} -#endif - -static void pps_rbsp(bitstream *bs) -{ - VAEncPictureParameterBufferH264 *pic_param = &avcenc_context.pic_param; - - bitstream_put_ue(bs, pic_param->pic_parameter_set_id); /* pic_parameter_set_id */ - bitstream_put_ue(bs, pic_param->seq_parameter_set_id); /* seq_parameter_set_id */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.entropy_coding_mode_flag, 1); /* entropy_coding_mode_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_order_present_flag: 0 */ - - bitstream_put_ue(bs, 0); /* num_slice_groups_minus1 */ - - bitstream_put_ue(bs, pic_param->num_ref_idx_l0_active_minus1); /* num_ref_idx_l0_active_minus1 */ - bitstream_put_ue(bs, pic_param->num_ref_idx_l1_active_minus1); /* num_ref_idx_l1_active_minus1 1 */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.weighted_pred_flag, 1); /* weighted_pred_flag: 0 */ - bitstream_put_ui(bs, pic_param->pic_fields.bits.weighted_bipred_idc, 2); /* weighted_bipred_idc: 0 */ - - bitstream_put_se(bs, pic_param->pic_init_qp - 26); /* pic_init_qp_minus26 */ - bitstream_put_se(bs, 0); /* pic_init_qs_minus26 */ - bitstream_put_se(bs, 0); /* chroma_qp_index_offset */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.deblocking_filter_control_present_flag, 1); /* deblocking_filter_control_present_flag */ - bitstream_put_ui(bs, 0, 1); /* constrained_intra_pred_flag */ - bitstream_put_ui(bs, 0, 1); /* redundant_pic_cnt_present_flag */ - - /* more_rbsp_data */ - bitstream_put_ui(bs, pic_param->pic_fields.bits.transform_8x8_mode_flag, 1); /*transform_8x8_mode_flag */ - bitstream_put_ui(bs, 0, 1); /* pic_scaling_matrix_present_flag */ - bitstream_put_se(bs, pic_param->second_chroma_qp_index_offset ); /*second_chroma_qp_index_offset */ - - rbsp_trailing_bits(bs); -} - -#if 0 -static void build_nal_pps(FILE *avc_fp) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_PPS); - pps_rbsp(&bs); - bitstream_end(&bs, avc_fp); -} - -static void -build_header(FILE *avc_fp) -{ - build_nal_sps(avc_fp); - build_nal_pps(avc_fp); -} -#endif - -static int -build_packed_pic_buffer(unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_PPS); - pps_rbsp(&bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_seq_buffer(unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_SPS); - sps_rbsp(&bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_idr_sei_buffer_timing(unsigned int init_cpb_removal_delay_length, - unsigned int cpb_removal_length, - unsigned int dpb_output_length, - unsigned char **sei_buffer) -{ - unsigned char *byte_buf; - int bp_byte_size, i, pic_byte_size; - unsigned int cpb_removal_delay; - - bitstream nal_bs; - bitstream sei_bp_bs, sei_pic_bs; - - bitstream_start(&sei_bp_bs); - bitstream_put_ue(&sei_bp_bs, 0); /*seq_parameter_set_id*/ - /* SEI buffer period info */ - /* NALHrdBpPresentFlag == 1 */ - bitstream_put_ui(&sei_bp_bs, avcenc_context.i_initial_cpb_removal_delay, - init_cpb_removal_delay_length); - bitstream_put_ui(&sei_bp_bs, avcenc_context.i_initial_cpb_removal_delay_offset, - init_cpb_removal_delay_length); - if ( sei_bp_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_bp_bs, 1, 1); - } - bitstream_end(&sei_bp_bs); - bp_byte_size = (sei_bp_bs.bit_offset + 7) / 8; - - /* SEI pic timing info */ - bitstream_start(&sei_pic_bs); - /* The info of CPB and DPB delay is controlled by CpbDpbDelaysPresentFlag, - * which is derived as 1 if one of the following conditions is true: - * nal_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - * vcl_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - */ - cpb_removal_delay = (avcenc_context.current_cpb_removal - avcenc_context.prev_idr_cpb_removal); - bitstream_put_ui(&sei_pic_bs, cpb_removal_delay, cpb_removal_length); - bitstream_put_ui(&sei_pic_bs, avcenc_context.current_dpb_removal_delta, - dpb_output_length); - if ( sei_pic_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_pic_bs, 1, 1); - } - /* The pic_structure_present_flag determines whether the pic_structure - * info is written into the SEI pic timing info. - * Currently it is set to zero. - */ - bitstream_end(&sei_pic_bs); - pic_byte_size = (sei_pic_bs.bit_offset + 7) / 8; - - bitstream_start(&nal_bs); - nal_start_code_prefix(&nal_bs); - nal_header(&nal_bs, NAL_REF_IDC_NONE, NAL_SEI); - - /* Write the SEI buffer period data */ - bitstream_put_ui(&nal_bs, 0, 8); - bitstream_put_ui(&nal_bs, bp_byte_size, 8); - - byte_buf = (unsigned char *)sei_bp_bs.buffer; - for(i = 0; i < bp_byte_size; i++) { - bitstream_put_ui(&nal_bs, byte_buf[i], 8); - } - free(byte_buf); - /* write the SEI pic timing data */ - bitstream_put_ui(&nal_bs, 0x01, 8); - bitstream_put_ui(&nal_bs, pic_byte_size, 8); - - byte_buf = (unsigned char *)sei_pic_bs.buffer; - for(i = 0; i < pic_byte_size; i++) { - bitstream_put_ui(&nal_bs, byte_buf[i], 8); - } - free(byte_buf); - - rbsp_trailing_bits(&nal_bs); - bitstream_end(&nal_bs); - - *sei_buffer = (unsigned char *)nal_bs.buffer; - - return nal_bs.bit_offset; -} - -static int -build_packed_sei_pic_timing(unsigned int cpb_removal_length, - unsigned int dpb_output_length, - unsigned char **sei_buffer) -{ - unsigned char *byte_buf; - int i, pic_byte_size; - unsigned int cpb_removal_delay; - - bitstream nal_bs; - bitstream sei_pic_bs; - - bitstream_start(&sei_pic_bs); - /* The info of CPB and DPB delay is controlled by CpbDpbDelaysPresentFlag, - * which is derived as 1 if one of the following conditions is true: - * nal_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - * vcl_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - */ - cpb_removal_delay = (avcenc_context.current_cpb_removal - avcenc_context.current_idr_cpb_removal); - bitstream_put_ui(&sei_pic_bs, cpb_removal_delay, cpb_removal_length); - bitstream_put_ui(&sei_pic_bs, avcenc_context.current_dpb_removal_delta, - dpb_output_length); - if ( sei_pic_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_pic_bs, 1, 1); - } - - /* The pic_structure_present_flag determines whether the pic_structure - * info is written into the SEI pic timing info. - * Currently it is set to zero. - */ - bitstream_end(&sei_pic_bs); - pic_byte_size = (sei_pic_bs.bit_offset + 7) / 8; - - bitstream_start(&nal_bs); - nal_start_code_prefix(&nal_bs); - nal_header(&nal_bs, NAL_REF_IDC_NONE, NAL_SEI); - - /* write the SEI Pic timing data */ - bitstream_put_ui(&nal_bs, 0x01, 8); - bitstream_put_ui(&nal_bs, pic_byte_size, 8); - - byte_buf = (unsigned char *)sei_pic_bs.buffer; - for(i = 0; i < pic_byte_size; i++) { - bitstream_put_ui(&nal_bs, byte_buf[i], 8); - } - free(byte_buf); - - rbsp_trailing_bits(&nal_bs); - bitstream_end(&nal_bs); - - *sei_buffer = (unsigned char *)nal_bs.buffer; - - return nal_bs.bit_offset; -} - -#if 0 -static void -slice_header(bitstream *bs, int frame_num, int display_frame, int slice_type, int nal_ref_idc, int is_idr) -{ - VAEncSequenceParameterBufferH264 *seq_param = &avcenc_context.seq_param; - VAEncPictureParameterBufferH264 *pic_param = &avcenc_context.pic_param; - int is_cabac = (pic_param->pic_fields.bits.entropy_coding_mode_flag == ENTROPY_MODE_CABAC); - - bitstream_put_ue(bs, 0); /* first_mb_in_slice: 0 */ - bitstream_put_ue(bs, slice_type); /* slice_type */ - bitstream_put_ue(bs, 0); /* pic_parameter_set_id: 0 */ - bitstream_put_ui(bs, frame_num & 0x0F, seq_param->seq_fields.bits.log2_max_frame_num_minus4 + 4); /* frame_num */ - - /* frame_mbs_only_flag == 1 */ - if (!seq_param->seq_fields.bits.frame_mbs_only_flag) { - /* FIXME: */ - assert(0); - } - - if (is_idr) - bitstream_put_ue(bs, 0); /* idr_pic_id: 0 */ - - if (seq_param->seq_fields.bits.pic_order_cnt_type == 0) { - bitstream_put_ui(bs, (display_frame*2) & 0x3F, seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 + 4); - /* only support frame */ - } else { - /* FIXME: */ - assert(0); - } - - /* redundant_pic_cnt_present_flag == 0 */ - - /* slice type */ - if (slice_type == SLICE_TYPE_P) { - bitstream_put_ui(bs, 0, 1); /* num_ref_idx_active_override_flag: 0 */ - /* ref_pic_list_reordering */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0: 0 */ - } else if (slice_type == SLICE_TYPE_B) { - bitstream_put_ui(bs, 1, 1); /* direct_spatial_mv_pred: 1 */ - bitstream_put_ui(bs, 0, 1); /* num_ref_idx_active_override_flag: 0 */ - /* ref_pic_list_reordering */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0: 0 */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l1: 0 */ - } - - /* weighted_pred_flag == 0 */ - - /* dec_ref_pic_marking */ - if (nal_ref_idc != 0) { - if ( is_idr) { - bitstream_put_ui(bs, 0, 1); /* no_output_of_prior_pics_flag: 0 */ - bitstream_put_ui(bs, 0, 1); /* long_term_reference_flag: 0 */ - } else { - bitstream_put_ui(bs, 0, 1); /* adaptive_ref_pic_marking_mode_flag: 0 */ - } - } - - if (is_cabac && (slice_type != SLICE_TYPE_I)) - bitstream_put_ue(bs, 0); /* cabac_init_idc: 0 */ - - bitstream_put_se(bs, 0); /* slice_qp_delta: 0 */ - - if (pic_param->pic_fields.bits.deblocking_filter_control_present_flag == 1) { - bitstream_put_ue(bs, 0); /* disable_deblocking_filter_idc: 0 */ - bitstream_put_se(bs, 2); /* slice_alpha_c0_offset_div2: 2 */ - bitstream_put_se(bs, 2); /* slice_beta_offset_div2: 2 */ - } -} - -static void -slice_data(bitstream *bs) -{ - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int i, slice_data_length; - VAStatus va_status; - VASurfaceStatus surface_status; - - va_status = vaSyncSurface(va_dpy, surface_ids[avcenc_context.current_input_surface]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - - surface_status = 0; - va_status = vaQuerySurfaceStatus(va_dpy, surface_ids[avcenc_context.current_input_surface], &surface_status); - CHECK_VASTATUS(va_status,"vaQuerySurfaceStatus"); - - va_status = vaMapBuffer(va_dpy, avcenc_context.codedbuf_buf_id, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - coded_mem = coded_buffer_segment->buf; - - slice_data_length = get_coded_bitsteam_length(coded_mem, codedbuf_size); - - for (i = 0; i < slice_data_length; i++) { - bitstream_put_ui(bs, *coded_mem, 8); - coded_mem++; - } - - vaUnmapBuffer(va_dpy, avcenc_context.codedbuf_buf_id); -} - -static void -build_nal_slice(FILE *avc_fp, int frame_num, int display_frame, int slice_type, int is_idr) -{ - bitstream bs; - - bitstream_start(&bs); - slice_data(&bs); - bitstream_end(&bs, avc_fp); -} - -#endif - -static int -store_coded_buffer(FILE *avc_fp, int slice_type) -{ - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int slice_data_length; - VAStatus va_status; - VASurfaceStatus surface_status; - size_t w_items; - - va_status = vaSyncSurface(va_dpy, surface_ids[avcenc_context.current_input_surface]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - - surface_status = 0; - va_status = vaQuerySurfaceStatus(va_dpy, surface_ids[avcenc_context.current_input_surface], &surface_status); - CHECK_VASTATUS(va_status,"vaQuerySurfaceStatus"); - - va_status = vaMapBuffer(va_dpy, avcenc_context.codedbuf_buf_id, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - coded_mem = coded_buffer_segment->buf; - - if (coded_buffer_segment->status & VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK) { - if (slice_type == SLICE_TYPE_I) - avcenc_context.codedbuf_i_size *= 2; - else - avcenc_context.codedbuf_pb_size *= 2; - - vaUnmapBuffer(va_dpy, avcenc_context.codedbuf_buf_id); - return -1; - } - - slice_data_length = coded_buffer_segment->size; - - do { - w_items = fwrite(coded_mem, slice_data_length, 1, avc_fp); - } while (w_items != 1); - - vaUnmapBuffer(va_dpy, avcenc_context.codedbuf_buf_id); - - return 0; -} - -/* - * It is from the h264encode.c but it simplifies something. - * For example: When one frame is encoded as I-frame under the scenario with - * P-B frames, it will be regarded as IDR frame(key-frame) and then new GOP is - * started. If the video clip is encoded as all I-frames, the first frame - * is regarded as IDR and the remaining is regarded as I-frame. - * - */ - -static void encoding2display_order( - unsigned long long encoding_order,int gop_size, - int ip_period, - unsigned long long *displaying_order, - int *frame_type) -{ - int encoding_order_gop = 0; - - /* When ip_period is 0, all are I/IDR frames */ - if (ip_period == 0) { /* all are I/IDR frames */ - if (encoding_order == 0) - *frame_type = FRAME_IDR; - else - *frame_type = SLICE_TYPE_I; - - *displaying_order = encoding_order; - return; - } - - /* new sequence like - * IDR PPPPP IDRPPPPP - * IDR (PBB)(PBB)(PBB)(PBB) IDR (PBB)(PBB)(PBB)(PBB) - */ - encoding_order_gop = encoding_order % gop_size; - - if (encoding_order_gop == 0) { /* the first frame */ - *frame_type = FRAME_IDR; - *displaying_order = encoding_order; - } else { - int gop_delta; - - gop_delta = 1; - - if ((ip_period != 1) && ((gop_size - 1) % ip_period)) { - int ipb_size; - ipb_size = (gop_size - 1) / ip_period * ip_period + 1; - if (encoding_order_gop >= ipb_size) { - gop_delta = ipb_size; - ip_period = gop_size - ipb_size; - } - } - - if (((encoding_order_gop - gop_delta) % ip_period) == 0) { /* P frames */ - *frame_type = SLICE_TYPE_P; - *displaying_order = encoding_order + ip_period - 1; - } else { - *frame_type = SLICE_TYPE_B; - *displaying_order = encoding_order - 1; - } - } -} - - -static void -encode_picture(FILE *yuv_fp, FILE *avc_fp, - int frame_num, int display_num, - int is_idr, - int slice_type, int next_is_bpic, - int next_display_num) -{ - VAStatus va_status; - int ret = 0, codedbuf_size; - - begin_picture(yuv_fp, frame_num, display_num, slice_type, is_idr); - - //if (next_display_num < frame_number) { - if (1) { - int index; - - /* prepare for next frame */ - if (avcenc_context.current_input_surface == SID_INPUT_PICTURE_0) - index = SID_INPUT_PICTURE_1; - else - index = SID_INPUT_PICTURE_0; - if ( next_display_num >= frame_number ) - next_display_num = frame_number - 1; - fseeko(yuv_fp, (off_t)frame_size * next_display_num, SEEK_SET); - - avcenc_context.upload_thread_param.yuv_fp = yuv_fp; - avcenc_context.upload_thread_param.surface_id = surface_ids[index]; - - avcenc_context.upload_thread_value = pthread_create(&avcenc_context.upload_thread_id, - NULL, - upload_thread_function, - (void*)&avcenc_context.upload_thread_param); - } - - do { - avcenc_destroy_buffers(&avcenc_context.codedbuf_buf_id, 1); - avcenc_destroy_buffers(&avcenc_context.pic_param_buf_id, 1); - - - if (SLICE_TYPE_I == slice_type) { - codedbuf_size = avcenc_context.codedbuf_i_size; - } else { - codedbuf_size = avcenc_context.codedbuf_pb_size; - } - - /* coded buffer */ - va_status = vaCreateBuffer(va_dpy, - avcenc_context.context_id, - VAEncCodedBufferType, - codedbuf_size, 1, NULL, - &avcenc_context.codedbuf_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - /* Update the RefPicList */ - update_RefPicList(); - - /* picture parameter set */ - avcenc_update_picture_parameter(slice_type, is_idr); - - /* slice parameter */ - avcenc_update_slice_parameter(slice_type); - - if (avcenc_context.rate_control_method == VA_RC_CBR) - avcenc_update_sei_param(is_idr); - - avcenc_render_picture(); - - ret = store_coded_buffer(avc_fp, slice_type); - } while (ret); - - end_picture(slice_type, next_is_bpic); -} - -static void show_help() -{ - printf("Usage: avnenc [--qp=qpvalue|--fb=framebitrate] [--mode=0(I frames only)/1(I and P frames)/2(I, P and B frames)] [--low-power] [--roi-test]\n"); -} - -static void avcenc_context_seq_param_init(VAEncSequenceParameterBufferH264 *seq_param, - int width, int height) - -{ - int width_in_mbs = (width + 15) / 16; - int height_in_mbs = (height + 15) / 16; - int frame_cropping_flag = 0; - int frame_crop_bottom_offset = 0; - - seq_param->seq_parameter_set_id = 0; - seq_param->level_idc = 41; - seq_param->intra_period = intra_period; - seq_param->intra_idr_period = seq_param->intra_period; - seq_param->ip_period = ip_period; - seq_param->max_num_ref_frames = 4; - seq_param->picture_width_in_mbs = width_in_mbs; - seq_param->picture_height_in_mbs = height_in_mbs; - seq_param->seq_fields.bits.frame_mbs_only_flag = 1; - seq_param->seq_fields.bits.chroma_format_idc = 1; - - - if (frame_bit_rate > 0) - seq_param->bits_per_second = 1000 * frame_bit_rate; /* use kbps as input */ - else - seq_param->bits_per_second = 0; - - seq_param->time_scale = frame_rate * 2; - seq_param->num_units_in_tick = 1; /* Tc = num_units_in_tick / time_sacle */ - - if (height_in_mbs * 16 - height) { - frame_cropping_flag = 1; - frame_crop_bottom_offset = - (height_in_mbs * 16 - height) / (2 * (!seq_param->seq_fields.bits.frame_mbs_only_flag + 1)); - } - - seq_param->frame_cropping_flag = frame_cropping_flag; - seq_param->frame_crop_left_offset = 0; - seq_param->frame_crop_right_offset = 0; - seq_param->frame_crop_top_offset = 0; - seq_param->frame_crop_bottom_offset = frame_crop_bottom_offset; - - seq_param->seq_fields.bits.pic_order_cnt_type = 0; - seq_param->seq_fields.bits.direct_8x8_inference_flag = 0; - - seq_param->seq_fields.bits.log2_max_frame_num_minus4 = Log2MaxFrameNum - 4; - seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = Log2MaxPicOrderCntLsb - 4; - - if (frame_bit_rate > 0) - seq_param->vui_parameters_present_flag = 1; //HRD info located in vui - else - seq_param->vui_parameters_present_flag = 0; -} - -static void avcenc_context_pic_param_init(VAEncPictureParameterBufferH264 *pic_param) -{ - pic_param->seq_parameter_set_id = 0; - pic_param->pic_parameter_set_id = 0; - - pic_param->last_picture = 0; - pic_param->frame_num = 0; - - pic_param->pic_init_qp = (qp_value >= 0 ? qp_value : 26); - pic_param->num_ref_idx_l0_active_minus1 = 0; - pic_param->num_ref_idx_l1_active_minus1 = 0; - - pic_param->pic_fields.bits.idr_pic_flag = 0; - pic_param->pic_fields.bits.reference_pic_flag = 0; - pic_param->pic_fields.bits.entropy_coding_mode_flag = ENTROPY_MODE_CABAC; - pic_param->pic_fields.bits.weighted_pred_flag = 0; - pic_param->pic_fields.bits.weighted_bipred_idc = 0; - - if (avcenc_context.constraint_set_flag & 0x7) - pic_param->pic_fields.bits.transform_8x8_mode_flag = 0; - else - pic_param->pic_fields.bits.transform_8x8_mode_flag = 1; - - pic_param->pic_fields.bits.deblocking_filter_control_present_flag = 1; - - memset(pic_param->ReferenceFrames, 0xff, 16 * sizeof(VAPictureH264)); /* invalid all */ -} - -static void avcenc_context_sei_init() -{ - /* it comes for the bps defined in SPS */ - avcenc_context.i_initial_cpb_removal_delay = 2 * 90000; - avcenc_context.i_initial_cpb_removal_delay_offset = 2 * 90000; - - avcenc_context.i_cpb_removal_delay = 2; - avcenc_context.i_initial_cpb_removal_delay_length = 24; - avcenc_context.i_cpb_removal_delay_length = 24; - avcenc_context.i_dpb_output_delay_length = 24; - avcenc_context.time_offset_length = 24; - - avcenc_context.prev_idr_cpb_removal = avcenc_context.i_initial_cpb_removal_delay / 90000; - avcenc_context.current_idr_cpb_removal = avcenc_context.prev_idr_cpb_removal; - avcenc_context.current_cpb_removal = 0; - avcenc_context.idr_frame_num = 0; -} - -static void avcenc_context_init(int width, int height) -{ - int i; - memset(&avcenc_context, 0, sizeof(avcenc_context)); - avcenc_context.profile = VAProfileH264Main; - - memset(&use_slot, 0, sizeof(use_slot)); - switch (avcenc_context.profile) { - case VAProfileH264Baseline: - avcenc_context.constraint_set_flag |= (1 << 0); /* Annex A.2.1 */ - break; - - case VAProfileH264Main: - avcenc_context.constraint_set_flag |= (1 << 1); /* Annex A.2.2 */ - break; - - case VAProfileH264High: - avcenc_context.constraint_set_flag |= (1 << 3); /* Annex A.2.4 */ - break; - - default: - break; - } - - avcenc_context.seq_param_buf_id = VA_INVALID_ID; - avcenc_context.pic_param_buf_id = VA_INVALID_ID; - avcenc_context.packed_seq_header_param_buf_id = VA_INVALID_ID; - avcenc_context.packed_seq_buf_id = VA_INVALID_ID; - avcenc_context.packed_pic_header_param_buf_id = VA_INVALID_ID; - avcenc_context.packed_pic_buf_id = VA_INVALID_ID; - avcenc_context.codedbuf_buf_id = VA_INVALID_ID; - avcenc_context.misc_parameter_hrd_buf_id = VA_INVALID_ID; - avcenc_context.codedbuf_i_size = width * height; - avcenc_context.codedbuf_pb_size = width * height; - avcenc_context.current_input_surface = SID_INPUT_PICTURE_0; - avcenc_context.upload_thread_value = -1; - avcenc_context.packed_sei_header_param_buf_id = VA_INVALID_ID; - avcenc_context.packed_sei_buf_id = VA_INVALID_ID; - avcenc_context.misc_parameter_roi_buf_id = VA_INVALID_ID; - - if (qp_value == -1) - avcenc_context.rate_control_method = VA_RC_CBR; - else if (qp_value == -2) - avcenc_context.rate_control_method = VA_RC_VBR; - else { - assert(qp_value >= 0 && qp_value <= 51); - avcenc_context.rate_control_method = VA_RC_CQP; - } - - for (i = 0; i < MAX_SLICES; i++) { - avcenc_context.slice_param_buf_id[i] = VA_INVALID_ID; - } - - avcenc_context_seq_param_init(&avcenc_context.seq_param, width, height); - avcenc_context_pic_param_init(&avcenc_context.pic_param); - if (avcenc_context.rate_control_method == VA_RC_CBR) - avcenc_context_sei_init(); -} - -int main(int argc, char *argv[]) -{ - int f; - FILE *yuv_fp; - FILE *avc_fp; - off_t file_size; - int mode_value; - struct timeval tpstart,tpend; - float timeuse; - - va_init_display_args(&argc, argv); - - if(argc < 5) { - show_help(); - return -1; - } - - picture_width = atoi(argv[1]); - picture_height = atoi(argv[2]); - picture_width_in_mbs = (picture_width + 15) / 16; - picture_height_in_mbs = (picture_height + 15) / 16; - - if (argc > 5) { - int o; - - optind = 5; - - while ((o = getopt_long_only(argc, argv, "", longopts, NULL)) != -1) { - switch (o) { - case 1: // qp - frame_bit_rate = -1; - qp_value = atoi(optarg); - - if (qp_value > 51) - qp_value = 51; - - if (qp_value < 0) - qp_value = 0; - - break; - - case 2: // fb - qp_value = -1; - frame_bit_rate = atoi(optarg); - - if (frame_bit_rate <= 0) { - show_help(); - - return -1; - } - - break; - - case 3: // mode - mode_value = atoi(optarg); - - if (mode_value == 0) - ip_period = 0; - else if (mode_value == 1) - ip_period = 1; - else if (mode_value == 2) - /* Hack mechanism before adding the parameter of B-frame number */ - ip_period = 2; - else { - printf("mode_value = %d\n", mode_value); - show_help(); - return -1; - } - - break; - - case 4: // low-power mode - select_entrypoint = VAEntrypointEncSliceLP; - break; - - case 5: // roi-test enable/disable - roi_test_enable = 1; - break; - - default: - show_help(); - return -1; - } - } - } else - qp_value = 28; //default const QP mode - - yuv_fp = fopen(argv[3],"rb"); - if ( yuv_fp == NULL){ - printf("Can't open input YUV file\n"); - return -1; - } - fseeko(yuv_fp, (off_t)0, SEEK_END); - file_size = ftello(yuv_fp); - frame_size = picture_width * picture_height + ((picture_width * picture_height) >> 1) ; - - if ( (file_size < frame_size) || (file_size % frame_size) ) { - fclose(yuv_fp); - printf("The YUV file's size is not correct\n"); - return -1; - } - frame_number = file_size / frame_size; - fseeko(yuv_fp, (off_t)0, SEEK_SET); - - avc_fp = fopen(argv[4], "wb"); - if ( avc_fp == NULL) { - fclose(yuv_fp); - printf("Can't open output avc file\n"); - return -1; - } - gettimeofday(&tpstart,NULL); - avcenc_context_init(picture_width, picture_height); - create_encode_pipe(); - alloc_encode_resource(yuv_fp); - - enc_frame_number = 0; - for ( f = 0; f < frame_number; f++) { //picture level loop - unsigned long long next_frame_display; - int next_frame_type; - - enc_frame_number = f; - - encoding2display_order(enc_frame_number, intra_period, ip_period, - ¤t_frame_display, ¤t_frame_type); - - encoding2display_order(enc_frame_number + 1, intra_period, ip_period, - &next_frame_display, &next_frame_type); - - if (current_frame_type == FRAME_IDR) { - numShortTerm = 0; - current_frame_num = 0; - memset(&use_slot, 0, sizeof(use_slot)); - current_IDR_display = current_frame_display; - if (avcenc_context.rate_control_method == VA_RC_CBR) { - unsigned long long frame_interval; - - frame_interval = enc_frame_number - avcenc_context.idr_frame_num; - - /* Based on the H264 spec the removal time of the IDR access - * unit is derived as the following: - * the removal time of previous IDR unit + Tc * cpb_removal_delay(n) - */ - avcenc_context.current_cpb_removal = avcenc_context.prev_idr_cpb_removal + - frame_interval * 2; - avcenc_context.idr_frame_num = enc_frame_number; - avcenc_context.current_idr_cpb_removal = avcenc_context.current_cpb_removal; - if (ip_period) - avcenc_context.current_dpb_removal_delta = (ip_period + 1) * 2; - else - avcenc_context.current_dpb_removal_delta = 2; - } - } else { - if (avcenc_context.rate_control_method == VA_RC_CBR) { - unsigned long long frame_interval; - - frame_interval = enc_frame_number - avcenc_context.idr_frame_num; - - /* Based on the H264 spec the removal time of the non-IDR access - * unit is derived as the following: - * the removal time of current IDR unit + Tc * cpb_removal_delay(n) - */ - avcenc_context.current_cpb_removal = avcenc_context.current_idr_cpb_removal + - frame_interval * 2; - if (current_frame_type == SLICE_TYPE_I || - current_frame_type == SLICE_TYPE_P) { - if (ip_period) - avcenc_context.current_dpb_removal_delta = (ip_period + 1) * 2; - else - avcenc_context.current_dpb_removal_delta = 2; - } else - avcenc_context.current_dpb_removal_delta = 2; - } - } - - /* use the simple mechanism to calc the POC */ - current_poc = (current_frame_display - current_IDR_display) * 2; - - encode_picture(yuv_fp, avc_fp, frame_number, current_frame_display, - (current_frame_type == FRAME_IDR) ? 1 : 0, - (current_frame_type == FRAME_IDR) ? SLICE_TYPE_I : current_frame_type, - (next_frame_type == SLICE_TYPE_B) ? 1 : 0, - next_frame_display); - if ((current_frame_type == FRAME_IDR) && - (avcenc_context.rate_control_method == VA_RC_CBR)) { - /* after one IDR frame is written, it needs to update the - * prev_idr_cpb_removal for next IDR - */ - avcenc_context.prev_idr_cpb_removal = avcenc_context.current_idr_cpb_removal; - } - printf("\r %d/%d ...", f, frame_number); - fflush(stdout); - } - - gettimeofday(&tpend,NULL); - timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+ tpend.tv_usec-tpstart.tv_usec; - timeuse/=1000000; - printf("\ndone!\n"); - printf("encode %d frames in %f secondes, FPS is %.1f\n",frame_number, timeuse, frame_number/timeuse); - release_encode_resource(); - destory_encode_pipe(); - - fclose(yuv_fp); - fclose(avc_fp); - - return 0; -} diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c deleted file mode 100644 index 8d8ea30..0000000 --- a/test/encode/h264encode.c +++ /dev/null @@ -1,2420 +0,0 @@ -/* - * Copyright (c) 2007-2013 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. - */ -#include "sysdeps.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "va_display.h" - -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - -#include "../loadsurface.h" - -#define NAL_REF_IDC_NONE 0 -#define NAL_REF_IDC_LOW 1 -#define NAL_REF_IDC_MEDIUM 2 -#define NAL_REF_IDC_HIGH 3 - -#define NAL_NON_IDR 1 -#define NAL_IDR 5 -#define NAL_SPS 7 -#define NAL_PPS 8 -#define NAL_SEI 6 - -#define SLICE_TYPE_P 0 -#define SLICE_TYPE_B 1 -#define SLICE_TYPE_I 2 -#define IS_P_SLICE(type) (SLICE_TYPE_P == (type)) -#define IS_B_SLICE(type) (SLICE_TYPE_B == (type)) -#define IS_I_SLICE(type) (SLICE_TYPE_I == (type)) - - -#define ENTROPY_MODE_CAVLC 0 -#define ENTROPY_MODE_CABAC 1 - -#define PROFILE_IDC_BASELINE 66 -#define PROFILE_IDC_MAIN 77 -#define PROFILE_IDC_HIGH 100 - -#define BITSTREAM_ALLOCATE_STEPPING 4096 - -#define SURFACE_NUM 16 /* 16 surfaces for source YUV */ -#define SURFACE_NUM 16 /* 16 surfaces for reference */ -static VADisplay va_dpy; -static VAProfile h264_profile = ~0; -static VAConfigAttrib attrib[VAConfigAttribTypeMax]; -static VAConfigAttrib config_attrib[VAConfigAttribTypeMax]; -static int config_attrib_num = 0, enc_packed_header_idx; -static VASurfaceID src_surface[SURFACE_NUM]; -static VABufferID coded_buf[SURFACE_NUM]; -static VASurfaceID ref_surface[SURFACE_NUM]; -static VAConfigID config_id; -static VAContextID context_id; -static VAEncSequenceParameterBufferH264 seq_param; -static VAEncPictureParameterBufferH264 pic_param; -static VAEncSliceParameterBufferH264 slice_param; -static VAPictureH264 CurrentCurrPic; -static VAPictureH264 ReferenceFrames[16], RefPicList0_P[32], RefPicList0_B[32], RefPicList1_B[32]; - -static unsigned int MaxFrameNum = (2<<16); -static unsigned int MaxPicOrderCntLsb = (2<<8); -static unsigned int Log2MaxFrameNum = 16; -static unsigned int Log2MaxPicOrderCntLsb = 8; - -static unsigned int num_ref_frames = 2; -static unsigned int numShortTerm = 0; -static int constraint_set_flag = 0; -static int h264_packedheader = 0; /* support pack header? */ -static int h264_maxref = (1<<16|1); -static int h264_entropy_mode = 1; /* cabac */ - -static char *coded_fn = NULL, *srcyuv_fn = NULL, *recyuv_fn = NULL; -static FILE *coded_fp = NULL, *srcyuv_fp = NULL, *recyuv_fp = NULL; -static unsigned long long srcyuv_frames = 0; -static int srcyuv_fourcc = VA_FOURCC_NV12; -static int calc_psnr = 0; - -static int frame_width = 176; -static int frame_height = 144; -static int frame_width_mbaligned; -static int frame_height_mbaligned; -static int frame_rate = 30; -static unsigned int frame_count = 60; -static unsigned int frame_coded = 0; -static unsigned int frame_bitrate = 0; -static unsigned int frame_slices = 1; -static double frame_size = 0; -static int initial_qp = 26; -static int minimal_qp = 0; -static int intra_period = 30; -static int intra_idr_period = 60; -static int ip_period = 1; -static int rc_mode = -1; -static int rc_default_modes[] = { - VA_RC_VBR, - VA_RC_CQP, - VA_RC_VBR_CONSTRAINED, - VA_RC_CBR, - VA_RC_VCM, - VA_RC_NONE, -}; -static unsigned long long current_frame_encoding = 0; -static unsigned long long current_frame_display = 0; -static unsigned long long current_IDR_display = 0; -static unsigned int current_frame_num = 0; -static int current_frame_type; -#define current_slot (current_frame_display % SURFACE_NUM) - -static int misc_priv_type = 0; -static int misc_priv_value = 0; - -#define MIN(a, b) ((a)>(b)?(b):(a)) -#define MAX(a, b) ((a)>(b)?(a):(b)) - -/* thread to save coded data/upload source YUV */ -struct storage_task_t { - void *next; - unsigned long long display_order; - unsigned long long encode_order; -}; -static struct storage_task_t *storage_task_header = NULL, *storage_task_tail = NULL; -#define SRC_SURFACE_IN_ENCODING 0 -#define SRC_SURFACE_IN_STORAGE 1 -static int srcsurface_status[SURFACE_NUM]; -static int encode_syncmode = 0; -static pthread_mutex_t encode_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t encode_cond = PTHREAD_COND_INITIALIZER; -static pthread_t encode_thread; - -/* for performance profiling */ -static unsigned int UploadPictureTicks=0; -static unsigned int BeginPictureTicks=0; -static unsigned int RenderPictureTicks=0; -static unsigned int EndPictureTicks=0; -static unsigned int SyncPictureTicks=0; -static unsigned int SavePictureTicks=0; -static unsigned int TotalTicks=0; - -struct __bitstream { - unsigned int *buffer; - int bit_offset; - int max_size_in_dword; -}; -typedef struct __bitstream bitstream; - - -static unsigned int -va_swap32(unsigned int val) -{ - unsigned char *pval = (unsigned char *)&val; - - return ((pval[0] << 24) | - (pval[1] << 16) | - (pval[2] << 8) | - (pval[3] << 0)); -} - -static void -bitstream_start(bitstream *bs) -{ - bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); - assert(bs->buffer); - bs->bit_offset = 0; -} - -static void -bitstream_end(bitstream *bs) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (bit_offset) { - bs->buffer[pos] = va_swap32((bs->buffer[pos] << bit_left)); - } -} - -static void -bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (!size_in_bits) - return; - - bs->bit_offset += size_in_bits; - - if (bit_left > size_in_bits) { - bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); - } else { - size_in_bits -= bit_left; - bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); - bs->buffer[pos] = va_swap32(bs->buffer[pos]); - - if (pos + 1 == bs->max_size_in_dword) { - bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); - assert(bs->buffer); - } - - bs->buffer[pos + 1] = val; - } -} - -static void -bitstream_put_ue(bitstream *bs, unsigned int val) -{ - int size_in_bits = 0; - int tmp_val = ++val; - - while (tmp_val) { - tmp_val >>= 1; - size_in_bits++; - } - - bitstream_put_ui(bs, 0, size_in_bits - 1); // leading zero - bitstream_put_ui(bs, val, size_in_bits); -} - -static void -bitstream_put_se(bitstream *bs, int val) -{ - unsigned int new_val; - - if (val <= 0) - new_val = -2 * val; - else - new_val = 2 * val - 1; - - bitstream_put_ue(bs, new_val); -} - -static void -bitstream_byte_aligning(bitstream *bs, int bit) -{ - int bit_offset = (bs->bit_offset & 0x7); - int bit_left = 8 - bit_offset; - int new_val; - - if (!bit_offset) - return; - - assert(bit == 0 || bit == 1); - - if (bit) - new_val = (1 << bit_left) - 1; - else - new_val = 0; - - bitstream_put_ui(bs, new_val, bit_left); -} - -static void -rbsp_trailing_bits(bitstream *bs) -{ - bitstream_put_ui(bs, 1, 1); - bitstream_byte_aligning(bs, 0); -} - -static void nal_start_code_prefix(bitstream *bs) -{ - bitstream_put_ui(bs, 0x00000001, 32); -} - -static void nal_header(bitstream *bs, int nal_ref_idc, int nal_unit_type) -{ - bitstream_put_ui(bs, 0, 1); /* forbidden_zero_bit: 0 */ - bitstream_put_ui(bs, nal_ref_idc, 2); - bitstream_put_ui(bs, nal_unit_type, 5); -} - -static void sps_rbsp(bitstream *bs) -{ - int profile_idc = PROFILE_IDC_BASELINE; - - if (h264_profile == VAProfileH264High) - profile_idc = PROFILE_IDC_HIGH; - else if (h264_profile == VAProfileH264Main) - profile_idc = PROFILE_IDC_MAIN; - - bitstream_put_ui(bs, profile_idc, 8); /* profile_idc */ - bitstream_put_ui(bs, !!(constraint_set_flag & 1), 1); /* constraint_set0_flag */ - bitstream_put_ui(bs, !!(constraint_set_flag & 2), 1); /* constraint_set1_flag */ - bitstream_put_ui(bs, !!(constraint_set_flag & 4), 1); /* constraint_set2_flag */ - bitstream_put_ui(bs, !!(constraint_set_flag & 8), 1); /* constraint_set3_flag */ - bitstream_put_ui(bs, 0, 4); /* reserved_zero_4bits */ - bitstream_put_ui(bs, seq_param.level_idc, 8); /* level_idc */ - bitstream_put_ue(bs, seq_param.seq_parameter_set_id); /* seq_parameter_set_id */ - - if ( profile_idc == PROFILE_IDC_HIGH) { - bitstream_put_ue(bs, 1); /* chroma_format_idc = 1, 4:2:0 */ - bitstream_put_ue(bs, 0); /* bit_depth_luma_minus8 */ - bitstream_put_ue(bs, 0); /* bit_depth_chroma_minus8 */ - bitstream_put_ui(bs, 0, 1); /* qpprime_y_zero_transform_bypass_flag */ - bitstream_put_ui(bs, 0, 1); /* seq_scaling_matrix_present_flag */ - } - - bitstream_put_ue(bs, seq_param.seq_fields.bits.log2_max_frame_num_minus4); /* log2_max_frame_num_minus4 */ - bitstream_put_ue(bs, seq_param.seq_fields.bits.pic_order_cnt_type); /* pic_order_cnt_type */ - - if (seq_param.seq_fields.bits.pic_order_cnt_type == 0) - bitstream_put_ue(bs, seq_param.seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4); /* log2_max_pic_order_cnt_lsb_minus4 */ - else { - assert(0); - } - - bitstream_put_ue(bs, seq_param.max_num_ref_frames); /* num_ref_frames */ - bitstream_put_ui(bs, 0, 1); /* gaps_in_frame_num_value_allowed_flag */ - - bitstream_put_ue(bs, seq_param.picture_width_in_mbs - 1); /* pic_width_in_mbs_minus1 */ - bitstream_put_ue(bs, seq_param.picture_height_in_mbs - 1); /* pic_height_in_map_units_minus1 */ - bitstream_put_ui(bs, seq_param.seq_fields.bits.frame_mbs_only_flag, 1); /* frame_mbs_only_flag */ - - if (!seq_param.seq_fields.bits.frame_mbs_only_flag) { - assert(0); - } - - bitstream_put_ui(bs, seq_param.seq_fields.bits.direct_8x8_inference_flag, 1); /* direct_8x8_inference_flag */ - bitstream_put_ui(bs, seq_param.frame_cropping_flag, 1); /* frame_cropping_flag */ - - if (seq_param.frame_cropping_flag) { - bitstream_put_ue(bs, seq_param.frame_crop_left_offset); /* frame_crop_left_offset */ - bitstream_put_ue(bs, seq_param.frame_crop_right_offset); /* frame_crop_right_offset */ - bitstream_put_ue(bs, seq_param.frame_crop_top_offset); /* frame_crop_top_offset */ - bitstream_put_ue(bs, seq_param.frame_crop_bottom_offset); /* frame_crop_bottom_offset */ - } - - //if ( frame_bit_rate < 0 ) { //TODO EW: the vui header isn't correct - if ( 1 ) { - bitstream_put_ui(bs, 0, 1); /* vui_parameters_present_flag */ - } else { - bitstream_put_ui(bs, 1, 1); /* vui_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* aspect_ratio_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* overscan_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* video_signal_type_present_flag */ - bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */ - bitstream_put_ui(bs, 1, 1); /* timing_info_present_flag */ - { - bitstream_put_ui(bs, 15, 32); - bitstream_put_ui(bs, 900, 32); - bitstream_put_ui(bs, 1, 1); - } - bitstream_put_ui(bs, 1, 1); /* nal_hrd_parameters_present_flag */ - { - // hrd_parameters - bitstream_put_ue(bs, 0); /* cpb_cnt_minus1 */ - bitstream_put_ui(bs, 4, 4); /* bit_rate_scale */ - bitstream_put_ui(bs, 6, 4); /* cpb_size_scale */ - - bitstream_put_ue(bs, frame_bitrate - 1); /* bit_rate_value_minus1[0] */ - bitstream_put_ue(bs, frame_bitrate*8 - 1); /* cpb_size_value_minus1[0] */ - bitstream_put_ui(bs, 1, 1); /* cbr_flag[0] */ - - bitstream_put_ui(bs, 23, 5); /* initial_cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, 23, 5); /* cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, 23, 5); /* dpb_output_delay_length_minus1 */ - bitstream_put_ui(bs, 23, 5); /* time_offset_length */ - } - bitstream_put_ui(bs, 0, 1); /* vcl_hrd_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* low_delay_hrd_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_struct_present_flag */ - bitstream_put_ui(bs, 0, 1); /* bitstream_restriction_flag */ - } - - rbsp_trailing_bits(bs); /* rbsp_trailing_bits */ -} - - -static void pps_rbsp(bitstream *bs) -{ - bitstream_put_ue(bs, pic_param.pic_parameter_set_id); /* pic_parameter_set_id */ - bitstream_put_ue(bs, pic_param.seq_parameter_set_id); /* seq_parameter_set_id */ - - bitstream_put_ui(bs, pic_param.pic_fields.bits.entropy_coding_mode_flag, 1); /* entropy_coding_mode_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_order_present_flag: 0 */ - - bitstream_put_ue(bs, 0); /* num_slice_groups_minus1 */ - - bitstream_put_ue(bs, pic_param.num_ref_idx_l0_active_minus1); /* num_ref_idx_l0_active_minus1 */ - bitstream_put_ue(bs, pic_param.num_ref_idx_l1_active_minus1); /* num_ref_idx_l1_active_minus1 1 */ - - bitstream_put_ui(bs, pic_param.pic_fields.bits.weighted_pred_flag, 1); /* weighted_pred_flag: 0 */ - bitstream_put_ui(bs, pic_param.pic_fields.bits.weighted_bipred_idc, 2); /* weighted_bipred_idc: 0 */ - - bitstream_put_se(bs, pic_param.pic_init_qp - 26); /* pic_init_qp_minus26 */ - bitstream_put_se(bs, 0); /* pic_init_qs_minus26 */ - bitstream_put_se(bs, 0); /* chroma_qp_index_offset */ - - bitstream_put_ui(bs, pic_param.pic_fields.bits.deblocking_filter_control_present_flag, 1); /* deblocking_filter_control_present_flag */ - bitstream_put_ui(bs, 0, 1); /* constrained_intra_pred_flag */ - bitstream_put_ui(bs, 0, 1); /* redundant_pic_cnt_present_flag */ - - /* more_rbsp_data */ - bitstream_put_ui(bs, pic_param.pic_fields.bits.transform_8x8_mode_flag, 1); /*transform_8x8_mode_flag */ - bitstream_put_ui(bs, 0, 1); /* pic_scaling_matrix_present_flag */ - bitstream_put_se(bs, pic_param.second_chroma_qp_index_offset ); /*second_chroma_qp_index_offset */ - - rbsp_trailing_bits(bs); -} - -static void slice_header(bitstream *bs) -{ - int first_mb_in_slice = slice_param.macroblock_address; - - bitstream_put_ue(bs, first_mb_in_slice); /* first_mb_in_slice: 0 */ - bitstream_put_ue(bs, slice_param.slice_type); /* slice_type */ - bitstream_put_ue(bs, slice_param.pic_parameter_set_id); /* pic_parameter_set_id: 0 */ - bitstream_put_ui(bs, pic_param.frame_num, seq_param.seq_fields.bits.log2_max_frame_num_minus4 + 4); /* frame_num */ - - /* frame_mbs_only_flag == 1 */ - if (!seq_param.seq_fields.bits.frame_mbs_only_flag) { - /* FIXME: */ - assert(0); - } - - if (pic_param.pic_fields.bits.idr_pic_flag) - bitstream_put_ue(bs, slice_param.idr_pic_id); /* idr_pic_id: 0 */ - - if (seq_param.seq_fields.bits.pic_order_cnt_type == 0) { - bitstream_put_ui(bs, pic_param.CurrPic.TopFieldOrderCnt, seq_param.seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 + 4); - /* pic_order_present_flag == 0 */ - } else { - /* FIXME: */ - assert(0); - } - - /* redundant_pic_cnt_present_flag == 0 */ - /* slice type */ - if (IS_P_SLICE(slice_param.slice_type)) { - bitstream_put_ui(bs, slice_param.num_ref_idx_active_override_flag, 1); /* num_ref_idx_active_override_flag: */ - - if (slice_param.num_ref_idx_active_override_flag) - bitstream_put_ue(bs, slice_param.num_ref_idx_l0_active_minus1); - - /* ref_pic_list_reordering */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0: 0 */ - } else if (IS_B_SLICE(slice_param.slice_type)) { - bitstream_put_ui(bs, slice_param.direct_spatial_mv_pred_flag, 1); /* direct_spatial_mv_pred: 1 */ - - bitstream_put_ui(bs, slice_param.num_ref_idx_active_override_flag, 1); /* num_ref_idx_active_override_flag: */ - - if (slice_param.num_ref_idx_active_override_flag) { - bitstream_put_ue(bs, slice_param.num_ref_idx_l0_active_minus1); - bitstream_put_ue(bs, slice_param.num_ref_idx_l1_active_minus1); - } - - /* ref_pic_list_reordering */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0: 0 */ - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l1: 0 */ - } - - if ((pic_param.pic_fields.bits.weighted_pred_flag && - IS_P_SLICE(slice_param.slice_type)) || - ((pic_param.pic_fields.bits.weighted_bipred_idc == 1) && - IS_B_SLICE(slice_param.slice_type))) { - /* FIXME: fill weight/offset table */ - assert(0); - } - - /* dec_ref_pic_marking */ - if (pic_param.pic_fields.bits.reference_pic_flag) { /* nal_ref_idc != 0 */ - unsigned char no_output_of_prior_pics_flag = 0; - unsigned char long_term_reference_flag = 0; - unsigned char adaptive_ref_pic_marking_mode_flag = 0; - - if (pic_param.pic_fields.bits.idr_pic_flag) { - bitstream_put_ui(bs, no_output_of_prior_pics_flag, 1); /* no_output_of_prior_pics_flag: 0 */ - bitstream_put_ui(bs, long_term_reference_flag, 1); /* long_term_reference_flag: 0 */ - } else { - bitstream_put_ui(bs, adaptive_ref_pic_marking_mode_flag, 1); /* adaptive_ref_pic_marking_mode_flag: 0 */ - } - } - - if (pic_param.pic_fields.bits.entropy_coding_mode_flag && - !IS_I_SLICE(slice_param.slice_type)) - bitstream_put_ue(bs, slice_param.cabac_init_idc); /* cabac_init_idc: 0 */ - - bitstream_put_se(bs, slice_param.slice_qp_delta); /* slice_qp_delta: 0 */ - - /* ignore for SP/SI */ - - if (pic_param.pic_fields.bits.deblocking_filter_control_present_flag) { - bitstream_put_ue(bs, slice_param.disable_deblocking_filter_idc); /* disable_deblocking_filter_idc: 0 */ - - if (slice_param.disable_deblocking_filter_idc != 1) { - bitstream_put_se(bs, slice_param.slice_alpha_c0_offset_div2); /* slice_alpha_c0_offset_div2: 2 */ - bitstream_put_se(bs, slice_param.slice_beta_offset_div2); /* slice_beta_offset_div2: 2 */ - } - } - - if (pic_param.pic_fields.bits.entropy_coding_mode_flag) { - bitstream_byte_aligning(bs, 1); - } -} - -static int -build_packed_pic_buffer(unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_PPS); - pps_rbsp(&bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_seq_buffer(unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_SPS); - sps_rbsp(&bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_sei_buffer_timing(unsigned int init_cpb_removal_length, - unsigned int init_cpb_removal_delay, - unsigned int init_cpb_removal_delay_offset, - unsigned int cpb_removal_length, - unsigned int cpb_removal_delay, - unsigned int dpb_output_length, - unsigned int dpb_output_delay, - unsigned char **sei_buffer) -{ - unsigned char *byte_buf; - int bp_byte_size, i, pic_byte_size; - - bitstream nal_bs; - bitstream sei_bp_bs, sei_pic_bs; - - bitstream_start(&sei_bp_bs); - bitstream_put_ue(&sei_bp_bs, 0); /*seq_parameter_set_id*/ - bitstream_put_ui(&sei_bp_bs, init_cpb_removal_delay, cpb_removal_length); - bitstream_put_ui(&sei_bp_bs, init_cpb_removal_delay_offset, cpb_removal_length); - if ( sei_bp_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_bp_bs, 1, 1); - } - bitstream_end(&sei_bp_bs); - bp_byte_size = (sei_bp_bs.bit_offset + 7) / 8; - - bitstream_start(&sei_pic_bs); - bitstream_put_ui(&sei_pic_bs, cpb_removal_delay, cpb_removal_length); - bitstream_put_ui(&sei_pic_bs, dpb_output_delay, dpb_output_length); - if ( sei_pic_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_pic_bs, 1, 1); - } - bitstream_end(&sei_pic_bs); - pic_byte_size = (sei_pic_bs.bit_offset + 7) / 8; - - bitstream_start(&nal_bs); - nal_start_code_prefix(&nal_bs); - nal_header(&nal_bs, NAL_REF_IDC_NONE, NAL_SEI); - - /* Write the SEI buffer period data */ - bitstream_put_ui(&nal_bs, 0, 8); - bitstream_put_ui(&nal_bs, bp_byte_size, 8); - - byte_buf = (unsigned char *)sei_bp_bs.buffer; - for(i = 0; i < bp_byte_size; i++) { - bitstream_put_ui(&nal_bs, byte_buf[i], 8); - } - free(byte_buf); - /* write the SEI timing data */ - bitstream_put_ui(&nal_bs, 0x01, 8); - bitstream_put_ui(&nal_bs, pic_byte_size, 8); - - byte_buf = (unsigned char *)sei_pic_bs.buffer; - for(i = 0; i < pic_byte_size; i++) { - bitstream_put_ui(&nal_bs, byte_buf[i], 8); - } - free(byte_buf); - - rbsp_trailing_bits(&nal_bs); - bitstream_end(&nal_bs); - - *sei_buffer = (unsigned char *)nal_bs.buffer; - - return nal_bs.bit_offset; -} - -static int build_packed_slice_buffer(unsigned char **header_buffer) -{ - bitstream bs; - int is_idr = !!pic_param.pic_fields.bits.idr_pic_flag; - int is_ref = !!pic_param.pic_fields.bits.reference_pic_flag; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - - if (IS_I_SLICE(slice_param.slice_type)) { - nal_header(&bs, NAL_REF_IDC_HIGH, is_idr ? NAL_IDR : NAL_NON_IDR); - } else if (IS_P_SLICE(slice_param.slice_type)) { - nal_header(&bs, NAL_REF_IDC_MEDIUM, NAL_NON_IDR); - } else { - assert(IS_B_SLICE(slice_param.slice_type)); - nal_header(&bs, is_ref ? NAL_REF_IDC_LOW : NAL_REF_IDC_NONE, NAL_NON_IDR); - } - - slice_header(&bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - - -/* - * Helper function for profiling purposes - */ -static unsigned int GetTickCount() -{ - struct timeval tv; - if (gettimeofday(&tv, NULL)) - return 0; - return tv.tv_usec/1000+tv.tv_sec*1000; -} - -/* - Assume frame sequence is: Frame#0,#1,#2,...,#M,...,#X,... (encoding order) - 1) period between Frame #X and Frame #N = #X - #N - 2) 0 means infinite for intra_period/intra_idr_period, and 0 is invalid for ip_period - 3) intra_idr_period % intra_period (intra_period > 0) and intra_period % ip_period must be 0 - 4) intra_period and intra_idr_period take precedence over ip_period - 5) if ip_period > 1, intra_period and intra_idr_period are not the strict periods - of I/IDR frames, see bellow examples - ------------------------------------------------------------------- - intra_period intra_idr_period ip_period frame sequence (intra_period/intra_idr_period/ip_period) - 0 ignored 1 IDRPPPPPPP ... (No IDR/I any more) - 0 ignored >=2 IDR(PBB)(PBB)... (No IDR/I any more) - 1 0 ignored IDRIIIIIII... (No IDR any more) - 1 1 ignored IDR IDR IDR IDR... - 1 >=2 ignored IDRII IDRII IDR... (1/3/ignore) - >=2 0 1 IDRPPP IPPP I... (3/0/1) - >=2 0 >=2 IDR(PBB)(PBB)(IBB) (6/0/3) - (PBB)(IBB)(PBB)(IBB)... - >=2 >=2 1 IDRPPPPP IPPPPP IPPPPP (6/18/1) - IDRPPPPP IPPPPP IPPPPP... - >=2 >=2 >=2 {IDR(PBB)(PBB)(IBB)(PBB)(IBB)(PBB)} (6/18/3) - {IDR(PBB)(PBB)(IBB)(PBB)(IBB)(PBB)}... - {IDR(PBB)(PBB)(IBB)(PBB)} (6/12/3) - {IDR(PBB)(PBB)(IBB)(PBB)}... - {IDR(PBB)(PBB)} (6/6/3) - {IDR(PBB)(PBB)}. -*/ - -/* - * Return displaying order with specified periods and encoding order - * displaying_order: displaying order - * frame_type: frame type - */ -#define FRAME_P 0 -#define FRAME_B 1 -#define FRAME_I 2 -#define FRAME_IDR 7 -void encoding2display_order( - unsigned long long encoding_order,int intra_period, - int intra_idr_period,int ip_period, - unsigned long long *displaying_order, - int *frame_type) -{ - int encoding_order_gop = 0; - - if (intra_period == 1) { /* all are I/IDR frames */ - *displaying_order = encoding_order; - if (intra_idr_period == 0) - *frame_type = (encoding_order == 0)?FRAME_IDR:FRAME_I; - else - *frame_type = (encoding_order % intra_idr_period == 0)?FRAME_IDR:FRAME_I; - return; - } - - if (intra_period == 0) - intra_idr_period = 0; - - /* new sequence like - * IDR PPPPP IPPPPP - * IDR (PBB)(PBB)(IBB)(PBB) - */ - encoding_order_gop = (intra_idr_period == 0)? encoding_order: - (encoding_order % (intra_idr_period + ((ip_period == 1)?0:1))); - - if (encoding_order_gop == 0) { /* the first frame */ - *frame_type = FRAME_IDR; - *displaying_order = encoding_order; - } else if (((encoding_order_gop - 1) % ip_period) != 0) { /* B frames */ - *frame_type = FRAME_B; - *displaying_order = encoding_order - 1; - } else if ((intra_period != 0) && /* have I frames */ - (encoding_order_gop >= 2) && - ((ip_period == 1 && encoding_order_gop % intra_period == 0) || /* for IDR PPPPP IPPPP */ - /* for IDR (PBB)(PBB)(IBB) */ - (ip_period >= 2 && ((encoding_order_gop - 1) / ip_period % (intra_period / ip_period)) == 0))) { - *frame_type = FRAME_I; - *displaying_order = encoding_order + ip_period - 1; - } else { - *frame_type = FRAME_P; - *displaying_order = encoding_order + ip_period - 1; - } -} - - -static char *fourcc_to_string(int fourcc) -{ - switch (fourcc) { - case VA_FOURCC_NV12: - return "NV12"; - case VA_FOURCC_IYUV: - return "IYUV"; - case VA_FOURCC_YV12: - return "YV12"; - case VA_FOURCC_UYVY: - return "UYVY"; - default: - return "Unknown"; - } -} - -static int string_to_fourcc(char *str) -{ - int fourcc; - - if (!strncmp(str, "NV12", 4)) - fourcc = VA_FOURCC_NV12; - else if (!strncmp(str, "IYUV", 4)) - fourcc = VA_FOURCC_IYUV; - else if (!strncmp(str, "YV12", 4)) - fourcc = VA_FOURCC_YV12; - else if (!strncmp(str, "UYVY", 4)) - fourcc = VA_FOURCC_UYVY; - else { - printf("Unknow FOURCC\n"); - fourcc = -1; - } - return fourcc; -} - - -static char *rc_to_string(int rcmode) -{ - switch (rc_mode) { - case VA_RC_NONE: - return "NONE"; - case VA_RC_CBR: - return "CBR"; - case VA_RC_VBR: - return "VBR"; - case VA_RC_VCM: - return "VCM"; - case VA_RC_CQP: - return "CQP"; - case VA_RC_VBR_CONSTRAINED: - return "VBR_CONSTRAINED"; - default: - return "Unknown"; - } -} - -static int string_to_rc(char *str) -{ - int rc_mode; - - if (!strncmp(str, "NONE", 4)) - rc_mode = VA_RC_NONE; - else if (!strncmp(str, "CBR", 3)) - rc_mode = VA_RC_CBR; - else if (!strncmp(str, "VBR", 3)) - rc_mode = VA_RC_VBR; - else if (!strncmp(str, "VCM", 3)) - rc_mode = VA_RC_VCM; - else if (!strncmp(str, "CQP", 3)) - rc_mode = VA_RC_CQP; - else if (!strncmp(str, "VBR_CONSTRAINED", 15)) - rc_mode = VA_RC_VBR_CONSTRAINED; - else { - printf("Unknown RC mode\n"); - rc_mode = -1; - } - return rc_mode; -} - - -static int print_help(void) -{ - printf("./h264encode \n"); - printf(" -w -h \n"); - printf(" -framecount \n"); - printf(" -n \n"); - printf(" if set to 0 and srcyuv is set, the frame count is from srcuv file\n"); - printf(" -o \n"); - printf(" -f \n"); - printf(" --intra_period \n"); - printf(" --idr_period \n"); - printf(" --ip_period \n"); - printf(" --bitrate \n"); - printf(" --initialqp \n"); - printf(" --minqp \n"); - printf(" --rcmode \n"); - printf(" --syncmode: sequentially upload source, encoding, save result, no multi-thread\n"); - printf(" --srcyuv load YUV from a file\n"); - printf(" --fourcc source YUV fourcc\n"); - printf(" --recyuv save reconstructed YUV into a file\n"); - printf(" --enablePSNR calculate PSNR of recyuv vs. srcyuv\n"); - printf(" --entropy <0|1>, 1 means cabac, 0 cavlc\n"); - printf(" --profile \n"); - return 0; -} - -static int process_cmdline(int argc, char *argv[]) -{ - int c; - const struct option long_opts[] = { - {"help", no_argument, NULL, 0 }, - {"bitrate", required_argument, NULL, 1 }, - {"minqp", required_argument, NULL, 2 }, - {"initialqp", required_argument, NULL, 3 }, - {"intra_period", required_argument, NULL, 4 }, - {"idr_period", required_argument, NULL, 5 }, - {"ip_period", required_argument, NULL, 6 }, - {"rcmode", required_argument, NULL, 7 }, - {"srcyuv", required_argument, NULL, 9 }, - {"recyuv", required_argument, NULL, 10 }, - {"fourcc", required_argument, NULL, 11 }, - {"syncmode", no_argument, NULL, 12 }, - {"enablePSNR", no_argument, NULL, 13 }, - {"prit", required_argument, NULL, 14 }, - {"priv", required_argument, NULL, 15 }, - {"framecount", required_argument, NULL, 16 }, - {"entropy", required_argument, NULL, 17 }, - {"profile", required_argument, NULL, 18 }, - {NULL, no_argument, NULL, 0 }}; - int long_index; - - while ((c =getopt_long_only(argc,argv,"w:h:n:f:o:?",long_opts,&long_index)) != EOF) { - switch (c) { - case 'w': - frame_width = atoi(optarg); - break; - case 'h': - frame_height = atoi(optarg); - break; - case 'n': - case 16: - frame_count = atoi(optarg); - break; - case 'f': - frame_rate = atoi(optarg); - break; - case 'o': - coded_fn = strdup(optarg); - break; - case 0: - print_help(); - exit(0); - case 1: - frame_bitrate = atoi(optarg); - break; - case 2: - minimal_qp = atoi(optarg); - break; - case 3: - initial_qp = atoi(optarg); - break; - case 4: - intra_period = atoi(optarg); - break; - case 5: - intra_idr_period = atoi(optarg); - break; - case 6: - ip_period = atoi(optarg); - break; - case 7: - rc_mode = string_to_rc(optarg); - if (rc_mode < 0) { - print_help(); - exit(1); - } - break; - case 9: - srcyuv_fn = strdup(optarg); - break; - case 10: - recyuv_fn = strdup(optarg); - break; - case 11: - srcyuv_fourcc = string_to_fourcc(optarg); - if (srcyuv_fourcc <= 0) { - print_help(); - exit(1); - } - break; - case 12: - encode_syncmode = 1; - break; - case 13: - calc_psnr = 1; - break; - case 14: - misc_priv_type = strtol(optarg, NULL, 0); - break; - case 15: - misc_priv_value = strtol(optarg, NULL, 0); - break; - case 17: - h264_entropy_mode = atoi(optarg) ? 1: 0; - break; - case 18: - if (strncmp(optarg, "BP", 2) == 0) - h264_profile = VAProfileH264Baseline; - else if (strncmp(optarg, "MP", 2) == 0) - h264_profile = VAProfileH264Main; - else if (strncmp(optarg, "HP", 2) == 0) - h264_profile = VAProfileH264High; - else - h264_profile = 0; - break; - case ':': - case '?': - print_help(); - exit(0); - } - } - - if (ip_period < 1) { - printf(" ip_period must be greater than 0\n"); - exit(0); - } - if (intra_period != 1 && intra_period % ip_period != 0) { - printf(" intra_period must be a multiplier of ip_period\n"); - exit(0); - } - if (intra_period != 0 && intra_idr_period % intra_period != 0) { - printf(" intra_idr_period must be a multiplier of intra_period\n"); - exit(0); - } - - if (frame_bitrate == 0) - frame_bitrate = frame_width * frame_height * 12 * frame_rate / 50; - - /* open source file */ - if (srcyuv_fn) { - srcyuv_fp = fopen(srcyuv_fn,"r"); - - if (srcyuv_fp == NULL) - printf("Open source YUV file %s failed, use auto-generated YUV data\n", srcyuv_fn); - else { - struct stat tmp; - - fstat(fileno(srcyuv_fp), &tmp); - srcyuv_frames = tmp.st_size / (frame_width * frame_height * 1.5); - printf("Source YUV file %s with %llu frames\n", srcyuv_fn, srcyuv_frames); - - if (frame_count == 0) - frame_count = srcyuv_frames; - } - } - - /* open source file */ - if (recyuv_fn) { - recyuv_fp = fopen(recyuv_fn,"w+"); - - if (recyuv_fp == NULL) - printf("Open reconstructed YUV file %s failed\n", recyuv_fn); - } - - if (coded_fn == NULL) { - struct stat buf; - if (stat("/tmp", &buf) == 0) - coded_fn = strdup("/tmp/test.264"); - else if (stat("/sdcard", &buf) == 0) - coded_fn = strdup("/sdcard/test.264"); - else - coded_fn = strdup("./test.264"); - } - - /* store coded data into a file */ - coded_fp = fopen(coded_fn,"w+"); - if (coded_fp == NULL) { - printf("Open file %s failed, exit\n", coded_fn); - exit(1); - } - - frame_width_mbaligned = (frame_width + 15) & (~15); - frame_height_mbaligned = (frame_height + 15) & (~15); - if (frame_width != frame_width_mbaligned || - frame_height != frame_height_mbaligned) { - printf("Source frame is %dx%d and will code clip to %dx%d with crop\n", - frame_width, frame_height, - frame_width_mbaligned, frame_height_mbaligned - ); - } - - return 0; -} - -static int init_va(void) -{ - VAProfile profile_list[]={VAProfileH264High,VAProfileH264Main,VAProfileH264Baseline,VAProfileH264ConstrainedBaseline}; - VAEntrypoint *entrypoints; - int num_entrypoints, slice_entrypoint; - int support_encode = 0; - int major_ver, minor_ver; - VAStatus va_status; - unsigned int i; - - va_dpy = va_open_display(); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - num_entrypoints = vaMaxNumEntrypoints(va_dpy); - entrypoints = malloc(num_entrypoints * sizeof(*entrypoints)); - if (!entrypoints) { - fprintf(stderr, "error: failed to initialize VA entrypoints array\n"); - exit(1); - } - - /* use the highest profile */ - for (i = 0; i < sizeof(profile_list)/sizeof(profile_list[0]); i++) { - if ((h264_profile != ~0) && h264_profile != profile_list[i]) - continue; - - h264_profile = profile_list[i]; - vaQueryConfigEntrypoints(va_dpy, h264_profile, entrypoints, &num_entrypoints); - for (slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) { - if (entrypoints[slice_entrypoint] == VAEntrypointEncSlice) { - support_encode = 1; - break; - } - } - if (support_encode == 1) - break; - } - - if (support_encode == 0) { - printf("Can't find VAEntrypointEncSlice for H264 profiles\n"); - exit(1); - } else { - switch (h264_profile) { - case VAProfileH264Baseline: - printf("Use profile VAProfileH264Baseline\n"); - ip_period = 1; - constraint_set_flag |= (1 << 0); /* Annex A.2.1 */ - h264_entropy_mode = 0; - break; - case VAProfileH264ConstrainedBaseline: - printf("Use profile VAProfileH264ConstrainedBaseline\n"); - constraint_set_flag |= (1 << 0 | 1 << 1); /* Annex A.2.2 */ - ip_period = 1; - break; - - case VAProfileH264Main: - printf("Use profile VAProfileH264Main\n"); - constraint_set_flag |= (1 << 1); /* Annex A.2.2 */ - break; - - case VAProfileH264High: - constraint_set_flag |= (1 << 3); /* Annex A.2.4 */ - printf("Use profile VAProfileH264High\n"); - break; - default: - printf("unknow profile. Set to Baseline"); - h264_profile = VAProfileH264Baseline; - ip_period = 1; - constraint_set_flag |= (1 << 0); /* Annex A.2.1 */ - break; - } - } - - /* find out the format for the render target, and rate control mode */ - for (i = 0; i < VAConfigAttribTypeMax; i++) - attrib[i].type = i; - - va_status = vaGetConfigAttributes(va_dpy, h264_profile, VAEntrypointEncSlice, - &attrib[0], VAConfigAttribTypeMax); - CHECK_VASTATUS(va_status, "vaGetConfigAttributes"); - /* check the interested configattrib */ - if ((attrib[VAConfigAttribRTFormat].value & VA_RT_FORMAT_YUV420) == 0) { - printf("Not find desired YUV420 RT format\n"); - exit(1); - } else { - config_attrib[config_attrib_num].type = VAConfigAttribRTFormat; - config_attrib[config_attrib_num].value = VA_RT_FORMAT_YUV420; - config_attrib_num++; - } - - if (attrib[VAConfigAttribRateControl].value != VA_ATTRIB_NOT_SUPPORTED) { - int tmp = attrib[VAConfigAttribRateControl].value; - - printf("Support rate control mode (0x%x):", tmp); - - if (tmp & VA_RC_NONE) - printf("NONE "); - if (tmp & VA_RC_CBR) - printf("CBR "); - if (tmp & VA_RC_VBR) - printf("VBR "); - if (tmp & VA_RC_VCM) - printf("VCM "); - if (tmp & VA_RC_CQP) - printf("CQP "); - if (tmp & VA_RC_VBR_CONSTRAINED) - printf("VBR_CONSTRAINED "); - - printf("\n"); - - if (rc_mode == -1 || !(rc_mode & tmp)) { - if (rc_mode != -1) { - printf("Warning: Don't support the specified RateControl mode: %s!!!, switch to ", rc_to_string(rc_mode)); - } - - for (i = 0; i < sizeof(rc_default_modes) / sizeof(rc_default_modes[0]); i++) { - if (rc_default_modes[i] & tmp) { - rc_mode = rc_default_modes[i]; - break; - } - } - - printf("RateControl mode: %s\n", rc_to_string(rc_mode)); - } - - config_attrib[config_attrib_num].type = VAConfigAttribRateControl; - config_attrib[config_attrib_num].value = rc_mode; - config_attrib_num++; - } - - - if (attrib[VAConfigAttribEncPackedHeaders].value != VA_ATTRIB_NOT_SUPPORTED) { - int tmp = attrib[VAConfigAttribEncPackedHeaders].value; - - printf("Support VAConfigAttribEncPackedHeaders\n"); - - h264_packedheader = 1; - config_attrib[config_attrib_num].type = VAConfigAttribEncPackedHeaders; - config_attrib[config_attrib_num].value = VA_ENC_PACKED_HEADER_NONE; - - if (tmp & VA_ENC_PACKED_HEADER_SEQUENCE) { - printf("Support packed sequence headers\n"); - config_attrib[config_attrib_num].value |= VA_ENC_PACKED_HEADER_SEQUENCE; - } - - if (tmp & VA_ENC_PACKED_HEADER_PICTURE) { - printf("Support packed picture headers\n"); - config_attrib[config_attrib_num].value |= VA_ENC_PACKED_HEADER_PICTURE; - } - - if (tmp & VA_ENC_PACKED_HEADER_SLICE) { - printf("Support packed slice headers\n"); - config_attrib[config_attrib_num].value |= VA_ENC_PACKED_HEADER_SLICE; - } - - if (tmp & VA_ENC_PACKED_HEADER_MISC) { - printf("Support packed misc headers\n"); - config_attrib[config_attrib_num].value |= VA_ENC_PACKED_HEADER_MISC; - } - - enc_packed_header_idx = config_attrib_num; - config_attrib_num++; - } - - if (attrib[VAConfigAttribEncInterlaced].value != VA_ATTRIB_NOT_SUPPORTED) { - int tmp = attrib[VAConfigAttribEncInterlaced].value; - - printf("Support VAConfigAttribEncInterlaced\n"); - - if (tmp & VA_ENC_INTERLACED_FRAME) - printf("support VA_ENC_INTERLACED_FRAME\n"); - if (tmp & VA_ENC_INTERLACED_FIELD) - printf("Support VA_ENC_INTERLACED_FIELD\n"); - if (tmp & VA_ENC_INTERLACED_MBAFF) - printf("Support VA_ENC_INTERLACED_MBAFF\n"); - if (tmp & VA_ENC_INTERLACED_PAFF) - printf("Support VA_ENC_INTERLACED_PAFF\n"); - - config_attrib[config_attrib_num].type = VAConfigAttribEncInterlaced; - config_attrib[config_attrib_num].value = VA_ENC_PACKED_HEADER_NONE; - config_attrib_num++; - } - - if (attrib[VAConfigAttribEncMaxRefFrames].value != VA_ATTRIB_NOT_SUPPORTED) { - h264_maxref = attrib[VAConfigAttribEncMaxRefFrames].value; - - printf("Support %d RefPicList0 and %d RefPicList1\n", - h264_maxref & 0xffff, (h264_maxref >> 16) & 0xffff ); - } - - if (attrib[VAConfigAttribEncMaxSlices].value != VA_ATTRIB_NOT_SUPPORTED) - printf("Support %d slices\n", attrib[VAConfigAttribEncMaxSlices].value); - - if (attrib[VAConfigAttribEncSliceStructure].value != VA_ATTRIB_NOT_SUPPORTED) { - int tmp = attrib[VAConfigAttribEncSliceStructure].value; - - printf("Support VAConfigAttribEncSliceStructure\n"); - - if (tmp & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS) - printf("Support VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS\n"); - if (tmp & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) - printf("Support VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS\n"); - if (tmp & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) - printf("Support VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS\n"); - } - if (attrib[VAConfigAttribEncMacroblockInfo].value != VA_ATTRIB_NOT_SUPPORTED) { - printf("Support VAConfigAttribEncMacroblockInfo\n"); - } - - free(entrypoints); - return 0; -} - -static int setup_encode() -{ - VAStatus va_status; - VASurfaceID *tmp_surfaceid; - int codedbuf_size, i; - - va_status = vaCreateConfig(va_dpy, h264_profile, VAEntrypointEncSlice, - &config_attrib[0], config_attrib_num, &config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig"); - - /* create source surfaces */ - va_status = vaCreateSurfaces(va_dpy, - VA_RT_FORMAT_YUV420, frame_width_mbaligned, frame_height_mbaligned, - &src_surface[0], SURFACE_NUM, - NULL, 0); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - /* create reference surfaces */ - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, frame_width_mbaligned, frame_height_mbaligned, - &ref_surface[0], SURFACE_NUM, - NULL, 0 - ); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - tmp_surfaceid = calloc(2 * SURFACE_NUM, sizeof(VASurfaceID)); - memcpy(tmp_surfaceid, src_surface, SURFACE_NUM * sizeof(VASurfaceID)); - memcpy(tmp_surfaceid + SURFACE_NUM, ref_surface, SURFACE_NUM * sizeof(VASurfaceID)); - - /* Create a context for this encode pipe */ - va_status = vaCreateContext(va_dpy, config_id, - frame_width_mbaligned, frame_height_mbaligned, - VA_PROGRESSIVE, - tmp_surfaceid, 2 * SURFACE_NUM, - &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - free(tmp_surfaceid); - - codedbuf_size = (frame_width_mbaligned * frame_height_mbaligned * 400) / (16*16); - - for (i = 0; i < SURFACE_NUM; i++) { - /* create coded buffer once for all - * other VA buffers which won't be used again after vaRenderPicture. - * so APP can always vaCreateBuffer for every frame - * but coded buffer need to be mapped and accessed after vaRenderPicture/vaEndPicture - * so VA won't maintain the coded buffer - */ - va_status = vaCreateBuffer(va_dpy,context_id,VAEncCodedBufferType, - codedbuf_size, 1, NULL, &coded_buf[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - } - - return 0; -} - - - -#define partition(ref, field, key, ascending) \ - while (i <= j) { \ - if (ascending) { \ - while (ref[i].field < key) \ - i++; \ - while (ref[j].field > key) \ - j--; \ - } else { \ - while (ref[i].field > key) \ - i++; \ - while (ref[j].field < key) \ - j--; \ - } \ - if (i <= j) { \ - tmp = ref[i]; \ - ref[i] = ref[j]; \ - ref[j] = tmp; \ - i++; \ - j--; \ - } \ - } \ - -static void sort_one(VAPictureH264 ref[], int left, int right, - int ascending, int frame_idx) -{ - int i = left, j = right; - unsigned int key; - VAPictureH264 tmp; - - if (frame_idx) { - key = ref[(left + right) / 2].frame_idx; - partition(ref, frame_idx, key, ascending); - } else { - key = ref[(left + right) / 2].TopFieldOrderCnt; - partition(ref, TopFieldOrderCnt, (signed int)key, ascending); - } - - /* recursion */ - if (left < j) - sort_one(ref, left, j, ascending, frame_idx); - - if (i < right) - sort_one(ref, i, right, ascending, frame_idx); -} - -static void sort_two(VAPictureH264 ref[], int left, int right, unsigned int key, unsigned int frame_idx, - int partition_ascending, int list0_ascending, int list1_ascending) -{ - int i = left, j = right; - VAPictureH264 tmp; - - if (frame_idx) { - partition(ref, frame_idx, key, partition_ascending); - } else { - partition(ref, TopFieldOrderCnt, (signed int)key, partition_ascending); - } - - - sort_one(ref, left, i-1, list0_ascending, frame_idx); - sort_one(ref, j+1, right, list1_ascending, frame_idx); -} - -static int update_ReferenceFrames(void) -{ - int i; - - if (current_frame_type == FRAME_B) - return 0; - - CurrentCurrPic.flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; - numShortTerm++; - if (numShortTerm > num_ref_frames) - numShortTerm = num_ref_frames; - for (i=numShortTerm-1; i>0; i--) - ReferenceFrames[i] = ReferenceFrames[i-1]; - ReferenceFrames[0] = CurrentCurrPic; - - if (current_frame_type != FRAME_B) - current_frame_num++; - if (current_frame_num > MaxFrameNum) - current_frame_num = 0; - - return 0; -} - - -static int update_RefPicList(void) -{ - unsigned int current_poc = CurrentCurrPic.TopFieldOrderCnt; - - if (current_frame_type == FRAME_P) { - memcpy(RefPicList0_P, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_one(RefPicList0_P, 0, numShortTerm-1, 0, 1); - } - - if (current_frame_type == FRAME_B) { - memcpy(RefPicList0_B, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_two(RefPicList0_B, 0, numShortTerm-1, current_poc, 0, - 1, 0, 1); - - memcpy(RefPicList1_B, ReferenceFrames, numShortTerm * sizeof(VAPictureH264)); - sort_two(RefPicList1_B, 0, numShortTerm-1, current_poc, 0, - 0, 1, 0); - } - - return 0; -} - - -static int render_sequence(void) -{ - VABufferID seq_param_buf, rc_param_buf, misc_param_tmpbuf, render_id[2]; - VAStatus va_status; - VAEncMiscParameterBuffer *misc_param, *misc_param_tmp; - VAEncMiscParameterRateControl *misc_rate_ctrl; - - seq_param.level_idc = 41 /*SH_LEVEL_3*/; - seq_param.picture_width_in_mbs = frame_width_mbaligned / 16; - seq_param.picture_height_in_mbs = frame_height_mbaligned / 16; - seq_param.bits_per_second = frame_bitrate; - - seq_param.intra_period = intra_period; - seq_param.intra_idr_period = intra_idr_period; - seq_param.ip_period = ip_period; - - seq_param.max_num_ref_frames = num_ref_frames; - seq_param.seq_fields.bits.frame_mbs_only_flag = 1; - seq_param.time_scale = 900; - seq_param.num_units_in_tick = 15; /* Tc = num_units_in_tick / time_sacle */ - seq_param.seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = Log2MaxPicOrderCntLsb - 4; - seq_param.seq_fields.bits.log2_max_frame_num_minus4 = Log2MaxFrameNum - 4;; - seq_param.seq_fields.bits.frame_mbs_only_flag = 1; - seq_param.seq_fields.bits.chroma_format_idc = 1; - seq_param.seq_fields.bits.direct_8x8_inference_flag = 1; - - if (frame_width != frame_width_mbaligned || - frame_height != frame_height_mbaligned) { - seq_param.frame_cropping_flag = 1; - seq_param.frame_crop_left_offset = 0; - seq_param.frame_crop_right_offset = (frame_width_mbaligned - frame_width)/2; - seq_param.frame_crop_top_offset = 0; - seq_param.frame_crop_bottom_offset = (frame_height_mbaligned - frame_height)/2; - } - - va_status = vaCreateBuffer(va_dpy, context_id, - VAEncSequenceParameterBufferType, - sizeof(seq_param),1,&seq_param,&seq_param_buf); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl), - 1,NULL,&rc_param_buf); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - vaMapBuffer(va_dpy, rc_param_buf,(void **)&misc_param); - misc_param->type = VAEncMiscParameterTypeRateControl; - misc_rate_ctrl = (VAEncMiscParameterRateControl *)misc_param->data; - memset(misc_rate_ctrl, 0, sizeof(*misc_rate_ctrl)); - misc_rate_ctrl->bits_per_second = frame_bitrate; - misc_rate_ctrl->target_percentage = 66; - misc_rate_ctrl->window_size = 1000; - misc_rate_ctrl->initial_qp = initial_qp; - misc_rate_ctrl->min_qp = minimal_qp; - misc_rate_ctrl->basic_unit_size = 0; - vaUnmapBuffer(va_dpy, rc_param_buf); - - render_id[0] = seq_param_buf; - render_id[1] = rc_param_buf; - - va_status = vaRenderPicture(va_dpy,context_id, &render_id[0], 2); - CHECK_VASTATUS(va_status,"vaRenderPicture");; - - if (misc_priv_type != 0) { - va_status = vaCreateBuffer(va_dpy, context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer), - 1, NULL, &misc_param_tmpbuf); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - vaMapBuffer(va_dpy, misc_param_tmpbuf,(void **)&misc_param_tmp); - misc_param_tmp->type = misc_priv_type; - misc_param_tmp->data[0] = misc_priv_value; - vaUnmapBuffer(va_dpy, misc_param_tmpbuf); - - va_status = vaRenderPicture(va_dpy,context_id, &misc_param_tmpbuf, 1); - } - - return 0; -} - -static int calc_poc(int pic_order_cnt_lsb) -{ - static int PicOrderCntMsb_ref = 0, pic_order_cnt_lsb_ref = 0; - int prevPicOrderCntMsb, prevPicOrderCntLsb; - int PicOrderCntMsb, TopFieldOrderCnt; - - if (current_frame_type == FRAME_IDR) - prevPicOrderCntMsb = prevPicOrderCntLsb = 0; - else { - prevPicOrderCntMsb = PicOrderCntMsb_ref; - prevPicOrderCntLsb = pic_order_cnt_lsb_ref; - } - - if ((pic_order_cnt_lsb < prevPicOrderCntLsb) && - ((prevPicOrderCntLsb - pic_order_cnt_lsb) >= (int)(MaxPicOrderCntLsb / 2))) - PicOrderCntMsb = prevPicOrderCntMsb + MaxPicOrderCntLsb; - else if ((pic_order_cnt_lsb > prevPicOrderCntLsb) && - ((pic_order_cnt_lsb - prevPicOrderCntLsb) > (int)(MaxPicOrderCntLsb / 2))) - PicOrderCntMsb = prevPicOrderCntMsb - MaxPicOrderCntLsb; - else - PicOrderCntMsb = prevPicOrderCntMsb; - - TopFieldOrderCnt = PicOrderCntMsb + pic_order_cnt_lsb; - - if (current_frame_type != FRAME_B) { - PicOrderCntMsb_ref = PicOrderCntMsb; - pic_order_cnt_lsb_ref = pic_order_cnt_lsb; - } - - return TopFieldOrderCnt; -} - -static int render_picture(void) -{ - VABufferID pic_param_buf; - VAStatus va_status; - int i = 0; - - pic_param.CurrPic.picture_id = ref_surface[current_slot]; - pic_param.CurrPic.frame_idx = current_frame_num; - pic_param.CurrPic.flags = 0; - pic_param.CurrPic.TopFieldOrderCnt = calc_poc((current_frame_display - current_IDR_display) % MaxPicOrderCntLsb); - pic_param.CurrPic.BottomFieldOrderCnt = pic_param.CurrPic.TopFieldOrderCnt; - CurrentCurrPic = pic_param.CurrPic; - - if (getenv("TO_DEL")) { /* set RefPicList into ReferenceFrames */ - update_RefPicList(); /* calc RefPicList */ - memset(pic_param.ReferenceFrames, 0xff, 16 * sizeof(VAPictureH264)); /* invalid all */ - if (current_frame_type == FRAME_P) { - pic_param.ReferenceFrames[0] = RefPicList0_P[0]; - } else if (current_frame_type == FRAME_B) { - pic_param.ReferenceFrames[0] = RefPicList0_B[0]; - pic_param.ReferenceFrames[1] = RefPicList1_B[0]; - } - } else { - memcpy(pic_param.ReferenceFrames, ReferenceFrames, numShortTerm*sizeof(VAPictureH264)); - for (i = numShortTerm; i < SURFACE_NUM; i++) { - pic_param.ReferenceFrames[i].picture_id = VA_INVALID_SURFACE; - pic_param.ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID; - } - } - - pic_param.pic_fields.bits.idr_pic_flag = (current_frame_type == FRAME_IDR); - pic_param.pic_fields.bits.reference_pic_flag = (current_frame_type != FRAME_B); - pic_param.pic_fields.bits.entropy_coding_mode_flag = h264_entropy_mode; - pic_param.pic_fields.bits.deblocking_filter_control_present_flag = 1; - pic_param.frame_num = current_frame_num; - pic_param.coded_buf = coded_buf[current_slot]; - pic_param.last_picture = (current_frame_encoding == frame_count); - pic_param.pic_init_qp = initial_qp; - - va_status = vaCreateBuffer(va_dpy, context_id,VAEncPictureParameterBufferType, - sizeof(pic_param),1,&pic_param, &pic_param_buf); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - - va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf, 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - return 0; -} - -static int render_packedsequence(void) -{ - VAEncPackedHeaderParameterBuffer packedheader_param_buffer; - VABufferID packedseq_para_bufid, packedseq_data_bufid, render_id[2]; - unsigned int length_in_bits; - unsigned char *packedseq_buffer = NULL; - VAStatus va_status; - - length_in_bits = build_packed_seq_buffer(&packedseq_buffer); - - packedheader_param_buffer.type = VAEncPackedHeaderSequence; - - packedheader_param_buffer.bit_length = length_in_bits; /*length_in_bits*/ - packedheader_param_buffer.has_emulation_bytes = 0; - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packedheader_param_buffer), 1, &packedheader_param_buffer, - &packedseq_para_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packedseq_buffer, - &packedseq_data_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - render_id[0] = packedseq_para_bufid; - render_id[1] = packedseq_data_bufid; - va_status = vaRenderPicture(va_dpy,context_id, render_id, 2); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - free(packedseq_buffer); - - return 0; -} - - -static int render_packedpicture(void) -{ - VAEncPackedHeaderParameterBuffer packedheader_param_buffer; - VABufferID packedpic_para_bufid, packedpic_data_bufid, render_id[2]; - unsigned int length_in_bits; - unsigned char *packedpic_buffer = NULL; - VAStatus va_status; - - length_in_bits = build_packed_pic_buffer(&packedpic_buffer); - packedheader_param_buffer.type = VAEncPackedHeaderPicture; - packedheader_param_buffer.bit_length = length_in_bits; - packedheader_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packedheader_param_buffer), 1, &packedheader_param_buffer, - &packedpic_para_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packedpic_buffer, - &packedpic_data_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - render_id[0] = packedpic_para_bufid; - render_id[1] = packedpic_data_bufid; - va_status = vaRenderPicture(va_dpy,context_id, render_id, 2); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - free(packedpic_buffer); - - return 0; -} - -static void render_packedsei(void) -{ - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - VABufferID packed_sei_header_param_buf_id, packed_sei_buf_id, render_id[2]; - unsigned int length_in_bits /*offset_in_bytes*/; - unsigned char *packed_sei_buffer = NULL; - VAStatus va_status; - int init_cpb_size, target_bit_rate, i_initial_cpb_removal_delay_length, i_initial_cpb_removal_delay; - int i_cpb_removal_delay, i_dpb_output_delay_length, i_cpb_removal_delay_length; - - /* it comes for the bps defined in SPS */ - target_bit_rate = frame_bitrate; - init_cpb_size = (target_bit_rate * 8) >> 10; - i_initial_cpb_removal_delay = init_cpb_size * 0.5 * 1024 / target_bit_rate * 90000; - - i_cpb_removal_delay = 2; - i_initial_cpb_removal_delay_length = 24; - i_cpb_removal_delay_length = 24; - i_dpb_output_delay_length = 24; - - - length_in_bits = build_packed_sei_buffer_timing( - i_initial_cpb_removal_delay_length, - i_initial_cpb_removal_delay, - 0, - i_cpb_removal_delay_length, - i_cpb_removal_delay * current_frame_encoding, - i_dpb_output_delay_length, - 0, - &packed_sei_buffer); - - //offset_in_bytes = 0; - packed_header_param_buffer.type = VAEncPackedHeaderH264_SEI; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &packed_sei_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_sei_buffer, - &packed_sei_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - - render_id[0] = packed_sei_header_param_buf_id; - render_id[1] = packed_sei_buf_id; - va_status = vaRenderPicture(va_dpy,context_id, render_id, 2); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - - free(packed_sei_buffer); - - return; -} - - -static int render_hrd(void) -{ - VABufferID misc_parameter_hrd_buf_id; - VAStatus va_status; - VAEncMiscParameterBuffer *misc_param; - VAEncMiscParameterHRD *misc_hrd_param; - - va_status = vaCreateBuffer(va_dpy, context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterHRD), - 1, - NULL, - &misc_parameter_hrd_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(va_dpy, - misc_parameter_hrd_buf_id, - (void **)&misc_param); - misc_param->type = VAEncMiscParameterTypeHRD; - misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data; - - if (frame_bitrate > 0) { - misc_hrd_param->initial_buffer_fullness = frame_bitrate * 1024 * 4; - misc_hrd_param->buffer_size = frame_bitrate * 1024 * 8; - } else { - misc_hrd_param->initial_buffer_fullness = 0; - misc_hrd_param->buffer_size = 0; - } - vaUnmapBuffer(va_dpy, misc_parameter_hrd_buf_id); - - va_status = vaRenderPicture(va_dpy,context_id, &misc_parameter_hrd_buf_id, 1); - CHECK_VASTATUS(va_status,"vaRenderPicture");; - - return 0; -} - -static void render_packedslice() -{ - VAEncPackedHeaderParameterBuffer packedheader_param_buffer; - VABufferID packedslice_para_bufid, packedslice_data_bufid, render_id[2]; - unsigned int length_in_bits; - unsigned char *packedslice_buffer = NULL; - VAStatus va_status; - - length_in_bits = build_packed_slice_buffer(&packedslice_buffer); - packedheader_param_buffer.type = VAEncPackedHeaderSlice; - packedheader_param_buffer.bit_length = length_in_bits; - packedheader_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packedheader_param_buffer), 1, &packedheader_param_buffer, - &packedslice_para_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packedslice_buffer, - &packedslice_data_bufid); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - render_id[0] = packedslice_para_bufid; - render_id[1] = packedslice_data_bufid; - va_status = vaRenderPicture(va_dpy,context_id, render_id, 2); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - free(packedslice_buffer); -} - -static int render_slice(void) -{ - VABufferID slice_param_buf; - VAStatus va_status; - int i; - - update_RefPicList(); - - /* one frame, one slice */ - slice_param.macroblock_address = 0; - slice_param.num_macroblocks = frame_width_mbaligned * frame_height_mbaligned/(16*16); /* Measured by MB */ - slice_param.slice_type = (current_frame_type == FRAME_IDR)?2:current_frame_type; - if (current_frame_type == FRAME_IDR) { - if (current_frame_encoding != 0) - ++slice_param.idr_pic_id; - } else if (current_frame_type == FRAME_P) { - int refpiclist0_max = h264_maxref & 0xffff; - memcpy(slice_param.RefPicList0, RefPicList0_P, refpiclist0_max*sizeof(VAPictureH264)); - - for (i = refpiclist0_max; i < 32; i++) { - slice_param.RefPicList0[i].picture_id = VA_INVALID_SURFACE; - slice_param.RefPicList0[i].flags = VA_PICTURE_H264_INVALID; - } - } else if (current_frame_type == FRAME_B) { - int refpiclist0_max = h264_maxref & 0xffff; - int refpiclist1_max = (h264_maxref >> 16) & 0xffff; - - memcpy(slice_param.RefPicList0, RefPicList0_B, refpiclist0_max*sizeof(VAPictureH264)); - for (i = refpiclist0_max; i < 32; i++) { - slice_param.RefPicList0[i].picture_id = VA_INVALID_SURFACE; - slice_param.RefPicList0[i].flags = VA_PICTURE_H264_INVALID; - } - - memcpy(slice_param.RefPicList1, RefPicList1_B, refpiclist1_max*sizeof(VAPictureH264)); - for (i = refpiclist1_max; i < 32; i++) { - slice_param.RefPicList1[i].picture_id = VA_INVALID_SURFACE; - slice_param.RefPicList1[i].flags = VA_PICTURE_H264_INVALID; - } - } - - slice_param.slice_alpha_c0_offset_div2 = 0; - slice_param.slice_beta_offset_div2 = 0; - slice_param.direct_spatial_mv_pred_flag = 1; - slice_param.pic_order_cnt_lsb = (current_frame_display - current_IDR_display) % MaxPicOrderCntLsb; - - - if (h264_packedheader && - config_attrib[enc_packed_header_idx].value & VA_ENC_PACKED_HEADER_SLICE) - render_packedslice(); - - va_status = vaCreateBuffer(va_dpy,context_id,VAEncSliceParameterBufferType, - sizeof(slice_param),1,&slice_param,&slice_param_buf); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - - va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf, 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - return 0; -} - - -static int upload_source_YUV_once_for_all() -{ - int box_width=8; - int row_shift=0; - int i; - - for (i = 0; i < SURFACE_NUM; i++) { - printf("\rLoading data into surface %d.....", i); - upload_surface(va_dpy, src_surface[i], box_width, row_shift, 0); - - row_shift++; - if (row_shift==(2*box_width)) row_shift= 0; - } - printf("Complete surface loading\n"); - - return 0; -} - -static int load_surface(VASurfaceID surface_id, unsigned long long display_order) -{ - unsigned char *srcyuv_ptr = NULL, *src_Y = NULL, *src_U = NULL, *src_V = NULL; - unsigned long long frame_start, mmap_start; - char *mmap_ptr = NULL; - int frame_size, mmap_size; - - if (srcyuv_fp == NULL) - return 0; - - /* allow encoding more than srcyuv_frames */ - display_order = display_order % srcyuv_frames; - frame_size = frame_width * frame_height * 3 / 2; /* for YUV420 */ - frame_start = display_order * frame_size; - - mmap_start = frame_start & (~0xfff); - mmap_size = (frame_size + (frame_start & 0xfff) + 0xfff) & (~0xfff); - mmap_ptr = mmap(0, mmap_size, PROT_READ, MAP_SHARED, - fileno(srcyuv_fp), mmap_start); - if (mmap_ptr == MAP_FAILED) { - printf("Failed to mmap YUV file (%s)\n", strerror(errno)); - return 1; - } - srcyuv_ptr = (unsigned char *)mmap_ptr + (frame_start & 0xfff); - if (srcyuv_fourcc == VA_FOURCC_NV12) { - src_Y = srcyuv_ptr; - src_U = src_Y + frame_width * frame_height; - src_V = NULL; - } else if (srcyuv_fourcc == VA_FOURCC_IYUV || - srcyuv_fourcc == VA_FOURCC_YV12) { - src_Y = srcyuv_ptr; - if (srcyuv_fourcc == VA_FOURCC_IYUV) { - src_U = src_Y + frame_width * frame_height; - src_V = src_U + (frame_width/2) * (frame_height/2); - } else { /* YV12 */ - src_V = src_Y + frame_width * frame_height; - src_U = src_V + (frame_width/2) * (frame_height/2); - } - } else { - printf("Unsupported source YUV format\n"); - exit(1); - } - - upload_surface_yuv(va_dpy, surface_id, - srcyuv_fourcc, frame_width, frame_height, - src_Y, src_U, src_V); - if (mmap_ptr) - munmap(mmap_ptr, mmap_size); - - return 0; -} - - -static int save_recyuv(VASurfaceID surface_id, - unsigned long long display_order, - unsigned long long encode_order) -{ - unsigned char *dst_Y = NULL, *dst_U = NULL, *dst_V = NULL; - - if (recyuv_fp == NULL) - return 0; - - if (srcyuv_fourcc == VA_FOURCC_NV12) { - int uv_size = 2 * (frame_width/2) * (frame_height/2); - dst_Y = malloc(2*uv_size); - if(dst_Y == NULL) { - printf("Failed to allocate memory for dst_Y\n"); - exit(1); - } - - dst_U = malloc(uv_size); - if(dst_U == NULL) { - printf("Failed to allocate memory for dst_U\n"); - free(dst_Y); - exit(1); - } - - memset(dst_Y, 0, 2*uv_size); - memset(dst_U, 0, uv_size); - } else if (srcyuv_fourcc == VA_FOURCC_IYUV || - srcyuv_fourcc == VA_FOURCC_YV12) { - int uv_size = (frame_width/2) * (frame_height/2); - dst_Y = malloc(4*uv_size); - if(dst_Y == NULL) { - printf("Failed to allocate memory for dst_Y\n"); - exit(1); - } - - dst_U = malloc(uv_size); - if(dst_U == NULL) { - printf("Failed to allocate memory for dst_U\n"); - free(dst_Y); - exit(1); - } - - dst_V = malloc(uv_size); - if(dst_V == NULL) { - printf("Failed to allocate memory for dst_V\n"); - free(dst_Y); - free(dst_U); - exit(1); - } - - memset(dst_Y, 0, 4*uv_size); - memset(dst_U, 0, uv_size); - memset(dst_V, 0, uv_size); - } else { - printf("Unsupported source YUV format\n"); - exit(1); - } - - download_surface_yuv(va_dpy, surface_id, - srcyuv_fourcc, frame_width, frame_height, - dst_Y, dst_U, dst_V); - fseek(recyuv_fp, display_order * frame_width * frame_height * 1.5, SEEK_SET); - - if (srcyuv_fourcc == VA_FOURCC_NV12) { - int uv_size = 2 * (frame_width/2) * (frame_height/2); - fwrite(dst_Y, uv_size * 2, 1, recyuv_fp); - fwrite(dst_U, uv_size, 1, recyuv_fp); - } else if (srcyuv_fourcc == VA_FOURCC_IYUV || - srcyuv_fourcc == VA_FOURCC_YV12) { - int uv_size = (frame_width/2) * (frame_height/2); - fwrite(dst_Y, uv_size * 4, 1, recyuv_fp); - - if (srcyuv_fourcc == VA_FOURCC_IYUV) { - fwrite(dst_U, uv_size, 1, recyuv_fp); - fwrite(dst_V, uv_size, 1, recyuv_fp); - } else { - fwrite(dst_V, uv_size, 1, recyuv_fp); - fwrite(dst_U, uv_size, 1, recyuv_fp); - } - } - - if (dst_Y) - free(dst_Y); - if (dst_U) - free(dst_U); - if (dst_V) - free(dst_V); - - fflush(recyuv_fp); - - return 0; -} - - -static int save_codeddata(unsigned long long display_order, unsigned long long encode_order) -{ - VACodedBufferSegment *buf_list = NULL; - VAStatus va_status; - unsigned int coded_size = 0; - - va_status = vaMapBuffer(va_dpy,coded_buf[display_order % SURFACE_NUM],(void **)(&buf_list)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - while (buf_list != NULL) { - coded_size += fwrite(buf_list->buf, 1, buf_list->size, coded_fp); - buf_list = (VACodedBufferSegment *) buf_list->next; - - frame_size += coded_size; - } - vaUnmapBuffer(va_dpy,coded_buf[display_order % SURFACE_NUM]); - - printf("\r "); /* return back to startpoint */ - switch (encode_order % 4) { - case 0: - printf("|"); - break; - case 1: - printf("/"); - break; - case 2: - printf("-"); - break; - case 3: - printf("\\"); - break; - } - printf("%08lld", encode_order); - printf("(%06d bytes coded)",coded_size); - - fflush(coded_fp); - - return 0; -} - - -static struct storage_task_t * storage_task_dequeue(void) -{ - struct storage_task_t *header; - - pthread_mutex_lock(&encode_mutex); - - header = storage_task_header; - if (storage_task_header != NULL) { - if (storage_task_tail == storage_task_header) - storage_task_tail = NULL; - storage_task_header = header->next; - } - - pthread_mutex_unlock(&encode_mutex); - - return header; -} - -static int storage_task_queue(unsigned long long display_order, unsigned long long encode_order) -{ - struct storage_task_t *tmp; - - tmp = calloc(1, sizeof(struct storage_task_t)); - tmp->display_order = display_order; - tmp->encode_order = encode_order; - - pthread_mutex_lock(&encode_mutex); - - if (storage_task_header == NULL) { - storage_task_header = tmp; - storage_task_tail = tmp; - } else { - storage_task_tail->next = tmp; - storage_task_tail = tmp; - } - - srcsurface_status[display_order % SURFACE_NUM] = SRC_SURFACE_IN_STORAGE; - pthread_cond_signal(&encode_cond); - - pthread_mutex_unlock(&encode_mutex); - - return 0; -} - -static void storage_task(unsigned long long display_order, unsigned long long encode_order) -{ - unsigned int tmp; - VAStatus va_status; - - tmp = GetTickCount(); - va_status = vaSyncSurface(va_dpy, src_surface[display_order % SURFACE_NUM]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - SyncPictureTicks += GetTickCount() - tmp; - tmp = GetTickCount(); - save_codeddata(display_order, encode_order); - SavePictureTicks += GetTickCount() - tmp; - - save_recyuv(ref_surface[display_order % SURFACE_NUM], display_order, encode_order); - - /* reload a new frame data */ - tmp = GetTickCount(); - if (srcyuv_fp != NULL) - load_surface(src_surface[display_order % SURFACE_NUM], display_order + SURFACE_NUM); - UploadPictureTicks += GetTickCount() - tmp; - - pthread_mutex_lock(&encode_mutex); - srcsurface_status[display_order % SURFACE_NUM] = SRC_SURFACE_IN_ENCODING; - pthread_mutex_unlock(&encode_mutex); -} - - -static void * storage_task_thread(void *t) -{ - while (1) { - struct storage_task_t *current; - - current = storage_task_dequeue(); - if (current == NULL) { - pthread_mutex_lock(&encode_mutex); - pthread_cond_wait(&encode_cond, &encode_mutex); - pthread_mutex_unlock(&encode_mutex); - continue; - } - - storage_task(current->display_order, current->encode_order); - - free(current); - - /* all frames are saved, exit the thread */ - if (++frame_coded >= frame_count) - break; - } - - return 0; -} - - -static int encode_frames(void) -{ - unsigned int i, tmp; - VAStatus va_status; - //VASurfaceStatus surface_status; - - /* upload RAW YUV data into all surfaces */ - tmp = GetTickCount(); - if (srcyuv_fp != NULL) { - for (i = 0; i < SURFACE_NUM; i++) - load_surface(src_surface[i], i); - } else - upload_source_YUV_once_for_all(); - UploadPictureTicks += GetTickCount() - tmp; - - /* ready for encoding */ - memset(srcsurface_status, SRC_SURFACE_IN_ENCODING, sizeof(srcsurface_status)); - - memset(&seq_param, 0, sizeof(seq_param)); - memset(&pic_param, 0, sizeof(pic_param)); - memset(&slice_param, 0, sizeof(slice_param)); - - if (encode_syncmode == 0) - pthread_create(&encode_thread, NULL, storage_task_thread, NULL); - - for (current_frame_encoding = 0; current_frame_encoding < frame_count; current_frame_encoding++) { - encoding2display_order(current_frame_encoding, intra_period, intra_idr_period, ip_period, - ¤t_frame_display, ¤t_frame_type); - if (current_frame_type == FRAME_IDR) { - numShortTerm = 0; - current_frame_num = 0; - current_IDR_display = current_frame_display; - } - - /* check if the source frame is ready */ - while (srcsurface_status[current_slot] != SRC_SURFACE_IN_ENCODING) { - usleep(1); - } - - tmp = GetTickCount(); - va_status = vaBeginPicture(va_dpy, context_id, src_surface[current_slot]); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - BeginPictureTicks += GetTickCount() - tmp; - - tmp = GetTickCount(); - if (current_frame_type == FRAME_IDR) { - render_sequence(); - render_picture(); - if (h264_packedheader) { - render_packedsequence(); - render_packedpicture(); - } - //if (rc_mode == VA_RC_CBR) - // render_packedsei(); - //render_hrd(); - } else { - //render_sequence(); - render_picture(); - //if (rc_mode == VA_RC_CBR) - // render_packedsei(); - //render_hrd(); - } - render_slice(); - RenderPictureTicks += GetTickCount() - tmp; - - tmp = GetTickCount(); - va_status = vaEndPicture(va_dpy,context_id); - CHECK_VASTATUS(va_status,"vaEndPicture");; - EndPictureTicks += GetTickCount() - tmp; - - if (encode_syncmode) - storage_task(current_frame_display, current_frame_encoding); - else /* queue the storage task queue */ - storage_task_queue(current_frame_display, current_frame_encoding); - - update_ReferenceFrames(); - } - - if (encode_syncmode == 0) { - int ret; - pthread_join(encode_thread, (void **)&ret); - } - - return 0; -} - - -static int release_encode() -{ - int i; - - vaDestroySurfaces(va_dpy,&src_surface[0],SURFACE_NUM); - vaDestroySurfaces(va_dpy,&ref_surface[0],SURFACE_NUM); - - for (i = 0; i < SURFACE_NUM; i++) - vaDestroyBuffer(va_dpy,coded_buf[i]); - - vaDestroyContext(va_dpy,context_id); - vaDestroyConfig(va_dpy,config_id); - - return 0; -} - -static int deinit_va() -{ - vaTerminate(va_dpy); - - va_close_display(va_dpy); - - return 0; -} - - -static int print_input() -{ - printf("\n\nINPUT:Try to encode H264...\n"); - if (rc_mode != -1) - printf("INPUT: RateControl : %s\n", rc_to_string(rc_mode)); - printf("INPUT: Resolution : %dx%d, %d frames\n", - frame_width, frame_height, frame_count); - printf("INPUT: FrameRate : %d\n", frame_rate); - printf("INPUT: Bitrate : %d\n", frame_bitrate); - printf("INPUT: Slieces : %d\n", frame_slices); - printf("INPUT: IntraPeriod : %d\n", intra_period); - printf("INPUT: IDRPeriod : %d\n", intra_idr_period); - printf("INPUT: IpPeriod : %d\n", ip_period); - printf("INPUT: Initial QP : %d\n", initial_qp); - printf("INPUT: Min QP : %d\n", minimal_qp); - printf("INPUT: Source YUV : %s", srcyuv_fp?"FILE":"AUTO generated"); - if (srcyuv_fp) - printf(":%s (fourcc %s)\n", srcyuv_fn, fourcc_to_string(srcyuv_fourcc)); - else - printf("\n"); - printf("INPUT: Coded Clip : %s\n", coded_fn); - if (recyuv_fp == NULL) - printf("INPUT: Rec Clip : %s\n", "Not save reconstructed frame"); - else - printf("INPUT: Rec Clip : Save reconstructed frame into %s (fourcc %s)\n", recyuv_fn, - fourcc_to_string(srcyuv_fourcc)); - - printf("\n\n"); /* return back to startpoint */ - - return 0; -} - -static int calc_PSNR(double *psnr) -{ - char *srcyuv_ptr = NULL, *recyuv_ptr = NULL, tmp; - unsigned long long min_size; - unsigned long long i, sse=0; - double ssemean; - int fourM = 0x400000; /* 4M */ - - min_size = MIN(srcyuv_frames, frame_count) * frame_width * frame_height * 1.5; - for (i=0; i q - * Currently supporting only I420/NV12/UYVY/YUY2/Y8 input file formats. - * - * NOTE: The intel-driver expects a packed header sent to it. So, the app is responsible to pack the header - * and send to the driver through LibVA. This unit test also showcases how to send the header to the driver. - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include "va_display.h" -#include "jpegenc_utils.h" - -#ifndef VA_FOURCC_I420 -#define VA_FOURCC_I420 0x30323449 -#endif - -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - - -void show_help() -{ - printf("Usage: ./jpegenc q \n"); - printf("Currently supporting only I420/NV12/UYVY/YUY2/Y8 input file formats.\n"); - printf("Example: ./jpegenc 1024 768 input_file.yuv output.jpeg 0 50\n\n"); - return; -} - - -void jpegenc_pic_param_init(VAEncPictureParameterBufferJPEG *pic_param,int width,int height,int quality, YUVComponentSpecs yuvComp) -{ - assert(pic_param); - - pic_param->picture_width = width; - pic_param->picture_height = height; - pic_param->quality = quality; - - pic_param->pic_flags.bits.profile = 0; //Profile = Baseline - pic_param->pic_flags.bits.progressive = 0; //Sequential encoding - pic_param->pic_flags.bits.huffman = 1; //Uses Huffman coding - pic_param->pic_flags.bits.interleaved = 0; //Input format is interleaved (YUV) - pic_param->pic_flags.bits.differential = 0; //non-Differential Encoding - - pic_param->sample_bit_depth = 8; //only 8 bit sample depth is currently supported - pic_param->num_scan = 1; - pic_param->num_components = yuvComp.num_components; // Supporting only upto 3 components maximum - //set component_id Ci and Tqi - if(yuvComp.fourcc_val == VA_FOURCC_Y800) { - pic_param->component_id[0] = 0; - pic_param->quantiser_table_selector[0] = 0; - } else { - pic_param->component_id[0] = pic_param->quantiser_table_selector[0] = 0; - pic_param->component_id[1] = pic_param->quantiser_table_selector[1] = 1; - pic_param->component_id[2] = 2; pic_param->quantiser_table_selector[2] = 1; - } - - pic_param->quality = quality; -} - -void jpegenc_qmatrix_init(VAQMatrixBufferJPEG *quantization_param, YUVComponentSpecs yuvComp) -{ - int i=0; - quantization_param->load_lum_quantiser_matrix = 1; - - //LibVA expects the QM in zigzag order - for(i=0; ilum_quantiser_matrix[i] = jpeg_luma_quant[jpeg_zigzag[i]]; - } - - - if(yuvComp.fourcc_val == VA_FOURCC_Y800) { - quantization_param->load_chroma_quantiser_matrix = 0; - } else { - quantization_param->load_chroma_quantiser_matrix = 1; - for(i=0; ichroma_quantiser_matrix[i] = jpeg_chroma_quant[jpeg_zigzag[i]]; - } - } - -} - -void jpegenc_hufftable_init(VAHuffmanTableBufferJPEGBaseline *hufftable_param, YUVComponentSpecs yuvComp) -{ - - hufftable_param->load_huffman_table[0] = 1; //Load Luma Hufftable - if(yuvComp.fourcc_val == VA_FOURCC_Y800) { - hufftable_param->load_huffman_table[1] = 0; //Do not load Chroma Hufftable for Y8 - } else { - hufftable_param->load_huffman_table[1] = 1; //Load Chroma Hufftable for other formats - } - - //Load Luma hufftable values - //Load DC codes - memcpy(hufftable_param->huffman_table[0].num_dc_codes, jpeg_hufftable_luma_dc+1, 16); - //Load DC Values - memcpy(hufftable_param->huffman_table[0].dc_values, jpeg_hufftable_luma_dc+17, 12); - //Load AC codes - memcpy(hufftable_param->huffman_table[0].num_ac_codes, jpeg_hufftable_luma_ac+1, 16); - //Load AC Values - memcpy(hufftable_param->huffman_table[0].ac_values, jpeg_hufftable_luma_ac+17, 162); - memset(hufftable_param->huffman_table[0].pad, 0, 2); - - - //Load Chroma hufftable values if needed - if(yuvComp.fourcc_val != VA_FOURCC_Y800) { - //Load DC codes - memcpy(hufftable_param->huffman_table[1].num_dc_codes, jpeg_hufftable_chroma_dc+1, 16); - //Load DC Values - memcpy(hufftable_param->huffman_table[1].dc_values, jpeg_hufftable_chroma_dc+17, 12); - //Load AC codes - memcpy(hufftable_param->huffman_table[1].num_ac_codes, jpeg_hufftable_chroma_ac+1, 16); - //Load AC Values - memcpy(hufftable_param->huffman_table[1].ac_values, jpeg_hufftable_chroma_ac+17, 162); - memset(hufftable_param->huffman_table[1].pad, 0, 2); - - } - -} - -void jpegenc_slice_param_init(VAEncSliceParameterBufferJPEG *slice_param, YUVComponentSpecs yuvComp) -{ - slice_param->restart_interval = 0; - - slice_param->num_components = yuvComp.num_components; - - slice_param->components[0].component_selector = 1; - slice_param->components[0].dc_table_selector = 0; - slice_param->components[0].ac_table_selector = 0; - - if(yuvComp.num_components > 1) { - slice_param->components[1].component_selector = 2; - slice_param->components[1].dc_table_selector = 1; - slice_param->components[1].ac_table_selector = 1; - - slice_param->components[2].component_selector = 3; - slice_param->components[2].dc_table_selector = 1; - slice_param->components[2].ac_table_selector = 1; - } -} - - -void populate_quantdata(JPEGQuantSection *quantVal, int type) -{ - uint8_t zigzag_qm[NUM_QUANT_ELEMENTS]; - int i; - - quantVal->DQT = DQT; - quantVal->Pq = 0; - quantVal->Tq = type; - if(type == 0) { - for(i=0; iQk, zigzag_qm, NUM_QUANT_ELEMENTS); - } else { - for(i=0; iQk, zigzag_qm, NUM_QUANT_ELEMENTS); - } - quantVal->Lq = 3 + NUM_QUANT_ELEMENTS; -} - -void populate_frame_header(JPEGFrameHeader *frameHdr, YUVComponentSpecs yuvComp, int picture_width, int picture_height) -{ - int i=0; - - frameHdr->SOF = SOF0; - frameHdr->Lf = 8 + (3 * yuvComp.num_components); //Size of FrameHeader in bytes without the Marker SOF - frameHdr->P = 8; - frameHdr->Y = picture_height; - frameHdr->X = picture_width; - frameHdr->Nf = yuvComp.num_components; - - for(i=0; iJPEGComponent[i].Ci = i+1; - - if(i == 0) { - frameHdr->JPEGComponent[i].Hi = yuvComp.y_h_subsample; - frameHdr->JPEGComponent[i].Vi = yuvComp.y_v_subsample; - frameHdr->JPEGComponent[i].Tqi = 0; - - } else { - //Analyzing the sampling factors for U/V, they are 1 for all formats except for Y8. - //So, it is okay to have the code below like this. For Y8, we wont reach this code. - frameHdr->JPEGComponent[i].Hi = yuvComp.u_h_subsample; - frameHdr->JPEGComponent[i].Vi = yuvComp.u_v_subsample; - frameHdr->JPEGComponent[i].Tqi = 1; - } - } -} - -void populate_huff_section_header(JPEGHuffSection *huffSectionHdr, int th, int tc) -{ - int i=0, totalCodeWords=0; - - huffSectionHdr->DHT = DHT; - huffSectionHdr->Tc = tc; - huffSectionHdr->Th = th; - - if(th == 0) { //If Luma - - //If AC - if(tc == 1) { - memcpy(huffSectionHdr->Li, jpeg_hufftable_luma_ac+1, NUM_AC_RUN_SIZE_BITS); - memcpy(huffSectionHdr->Vij, jpeg_hufftable_luma_ac+17, NUM_AC_CODE_WORDS_HUFFVAL); - } - - //If DC - if(tc == 0) { - memcpy(huffSectionHdr->Li, jpeg_hufftable_luma_dc+1, NUM_DC_RUN_SIZE_BITS); - memcpy(huffSectionHdr->Vij, jpeg_hufftable_luma_dc+17, NUM_DC_CODE_WORDS_HUFFVAL); - } - - for(i=0; iLi[i]; - } - - huffSectionHdr->Lh = 3 + 16 + totalCodeWords; - - } else { //If Chroma - //If AC - if(tc == 1) { - memcpy(huffSectionHdr->Li, jpeg_hufftable_chroma_ac+1, NUM_AC_RUN_SIZE_BITS); - memcpy(huffSectionHdr->Vij, jpeg_hufftable_chroma_ac+17, NUM_AC_CODE_WORDS_HUFFVAL); - } - - //If DC - if(tc == 0) { - memcpy(huffSectionHdr->Li, jpeg_hufftable_chroma_dc+1, NUM_DC_RUN_SIZE_BITS); - memcpy(huffSectionHdr->Vij, jpeg_hufftable_chroma_dc+17, NUM_DC_CODE_WORDS_HUFFVAL); - } - - } -} - -void populate_scan_header(JPEGScanHeader *scanHdr, YUVComponentSpecs yuvComp) -{ - - scanHdr->SOS = SOS; - scanHdr->Ns = yuvComp.num_components; - - //Y Component - scanHdr->ScanComponent[0].Csj = 1; - scanHdr->ScanComponent[0].Tdj = 0; - scanHdr->ScanComponent[0].Taj = 0; - - if(yuvComp.num_components > 1) { - //U Component - scanHdr->ScanComponent[1].Csj = 2; - scanHdr->ScanComponent[1].Tdj = 1; - scanHdr->ScanComponent[1].Taj = 1; - - //V Component - scanHdr->ScanComponent[2].Csj = 3; - scanHdr->ScanComponent[2].Tdj = 1; - scanHdr->ScanComponent[2].Taj = 1; - } - - scanHdr->Ss = 0; //0 for Baseline - scanHdr->Se = 63; //63 for Baseline - scanHdr->Ah = 0; //0 for Baseline - scanHdr->Al = 0; //0 for Baseline - - scanHdr->Ls = 3 + (yuvComp.num_components * 2) + 3; - -} - -// This method packs the header information which is to be sent to the driver through LibVA. -// All the information that needs to be inserted in the encoded buffer should be built and sent. -// It is the responsibility of the app talking to LibVA to build this header and send it. -// This includes Markers, Quantization tables (normalized with quality factor), Huffman tables,etc. -int build_packed_jpeg_header_buffer(unsigned char **header_buffer, YUVComponentSpecs yuvComp, int picture_width, int picture_height, uint16_t restart_interval, int quality) -{ - bitstream bs; - int i=0, j=0; - uint32_t temp=0; - - bitstream_start(&bs); - - //Add SOI - bitstream_put_ui(&bs, SOI, 16); - - //Add AppData - bitstream_put_ui(&bs, APP0, 16); //APP0 marker - bitstream_put_ui(&bs, 16, 16); //Length excluding the marker - bitstream_put_ui(&bs, 0x4A, 8); //J - bitstream_put_ui(&bs, 0x46, 8); //F - bitstream_put_ui(&bs, 0x49, 8); //I - bitstream_put_ui(&bs, 0x46, 8); //F - bitstream_put_ui(&bs, 0x00, 8); //0 - bitstream_put_ui(&bs, 1, 8); //Major Version - bitstream_put_ui(&bs, 1, 8); //Minor Version - bitstream_put_ui(&bs, 1, 8); //Density units 0:no units, 1:pixels per inch, 2: pixels per cm - bitstream_put_ui(&bs, 72, 16); //X density - bitstream_put_ui(&bs, 72, 16); //Y density - bitstream_put_ui(&bs, 0, 8); //Thumbnail width - bitstream_put_ui(&bs, 0, 8); //Thumbnail height - - // Regarding Quantization matrices: As per JPEG Spec ISO/IEC 10918-1:1993(E), Pg-19: - // "applications may specify values which customize picture quality for their particular - // image characteristics, display devices, and viewing conditions" - - - //Normalization of quality factor - quality = (quality < 50) ? (5000/quality) : (200 - (quality*2)); - - //Add QTable - Y - JPEGQuantSection quantLuma; - populate_quantdata(&quantLuma, 0); - - bitstream_put_ui(&bs, quantLuma.DQT, 16); - bitstream_put_ui(&bs, quantLuma.Lq, 16); - bitstream_put_ui(&bs, quantLuma.Pq, 4); - bitstream_put_ui(&bs, quantLuma.Tq, 4); - for(i=0; i 255) ? 255 : temp; - temp = (temp < 1) ? 1 : temp; - quantLuma.Qk[i] = (unsigned char)temp; - bitstream_put_ui(&bs, quantLuma.Qk[i], 8); - } - - //Add QTable - U/V - if(yuvComp.fourcc_val != VA_FOURCC_Y800) { - JPEGQuantSection quantChroma; - populate_quantdata(&quantChroma, 1); - - bitstream_put_ui(&bs, quantChroma.DQT, 16); - bitstream_put_ui(&bs, quantChroma.Lq, 16); - bitstream_put_ui(&bs, quantChroma.Pq, 4); - bitstream_put_ui(&bs, quantChroma.Tq, 4); - for(i=0; i 255) ? 255 : temp; - temp = (temp < 1) ? 1 : temp; - quantChroma.Qk[i] = (unsigned char)temp; - bitstream_put_ui(&bs, quantChroma.Qk[i], 8); - } - } - - //Add FrameHeader - JPEGFrameHeader frameHdr; - memset(&frameHdr,0,sizeof(JPEGFrameHeader)); - populate_frame_header(&frameHdr, yuvComp, picture_width, picture_height); - - bitstream_put_ui(&bs, frameHdr.SOF, 16); - bitstream_put_ui(&bs, frameHdr.Lf, 16); - bitstream_put_ui(&bs, frameHdr.P, 8); - bitstream_put_ui(&bs, frameHdr.Y, 16); - bitstream_put_ui(&bs, frameHdr.X, 16); - bitstream_put_ui(&bs, frameHdr.Nf, 8); - for(i=0; i> 1) * (picture_height >> 1)); - - memset(newImageBuffer,0,frame_size); - do { - n_items = fread(newImageBuffer, frame_size, 1, yuv_fp); - } while (n_items != 1); - - va_status = vaDeriveImage(va_dpy, surface_id, &surface_image); - CHECK_VASTATUS(va_status,"vaDeriveImage"); - - vaMapBuffer(va_dpy, surface_image.buf, &surface_p); - assert(VA_STATUS_SUCCESS == va_status); - - y_src = newImageBuffer; - u_src = newImageBuffer + y_size; /* UV offset for NV12 */ - v_src = newImageBuffer + y_size + u_size; - - y_dst = surface_p + surface_image.offsets[0]; - u_dst = surface_p + surface_image.offsets[1]; /* UV offset for NV12 */ - - if((yuvComp.fourcc_val == VA_FOURCC_NV12) || (yuvComp.fourcc_val == VA_FOURCC_I420) || - (yuvComp.fourcc_val == VA_FOURCC_Y800) ) { - - /* Y plane */ - for (row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width); - y_dst += surface_image.pitches[0]; - y_src += picture_width; - } - - if(yuvComp.num_components > 1) { - - switch(yuvComp.fourcc_val) { - case VA_FOURCC_NV12: { - for (row = 0; row < surface_image.height/2; row++) { - memcpy(u_dst, u_src, surface_image.width); - u_dst += surface_image.pitches[1]; - u_src += (picture_width); - } - break; - } - - case VA_FOURCC_I420: { - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col * 2] = u_src[col]; - u_dst[col * 2 + 1] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - u_src += (picture_width / 2); - v_src += (picture_width / 2); - } - break; - } - }//end of switch - }//end of if check - } else if((yuvComp.fourcc_val == VA_FOURCC_UYVY) || (yuvComp.fourcc_val == VA_FOURCC_YUY2)) { - - for(row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width*2); - y_dst += surface_image.pitches[0]; - y_src += picture_width*2; - } - - } else if(yuvComp.fourcc_val == VA_FOURCC_RGBA) { - - for (row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width*4); - y_dst += surface_image.pitches[0]; - y_src += picture_width*4; - } - } - - vaUnmapBuffer(va_dpy, surface_image.buf); - vaDestroyImage(va_dpy, surface_image.image_id); - -} - - - -void init_yuv_component(YUVComponentSpecs *yuvComponent, int yuv_type, int *surface_type, VASurfaceAttrib *fourcc) -{ - - // - switch(yuv_type) - { - case 0 : //I420 - case 1 : { //NV12 - yuvComponent->va_surface_format = (*surface_type) = VA_RT_FORMAT_YUV420; - if(yuv_type == 0) { - yuvComponent->fourcc_val = VA_FOURCC_I420; - fourcc->value.value.i = VA_FOURCC_NV12; - } else { - yuvComponent->fourcc_val = fourcc->value.value.i = VA_FOURCC_NV12; - } - yuvComponent->num_components = 3; - yuvComponent->y_h_subsample = 2; - yuvComponent->y_v_subsample = 2; - yuvComponent->u_h_subsample = 1; - yuvComponent->u_v_subsample = 1; - yuvComponent->v_h_subsample = 1; - yuvComponent->v_v_subsample = 1; - break; - } - - case 2: { //UYVY - yuvComponent->va_surface_format = (*surface_type) = VA_RT_FORMAT_YUV422; - yuvComponent->fourcc_val = fourcc->value.value.i = VA_FOURCC_UYVY; - yuvComponent->num_components = 3; - yuvComponent->y_h_subsample = 2; - yuvComponent->y_v_subsample = 1; - yuvComponent->u_h_subsample = 1; - yuvComponent->u_v_subsample = 1; - yuvComponent->v_h_subsample = 1; - yuvComponent->v_v_subsample = 1; - break; - } - - case 3: { //YUY2 - yuvComponent->va_surface_format = (*surface_type) = VA_RT_FORMAT_YUV422; - yuvComponent->fourcc_val = fourcc->value.value.i = VA_FOURCC_YUY2; - yuvComponent->num_components = 3; - yuvComponent->y_h_subsample = 2; - yuvComponent->y_v_subsample = 1; - yuvComponent->u_h_subsample = 1; - yuvComponent->u_v_subsample = 1; - yuvComponent->v_h_subsample = 1; - yuvComponent->v_v_subsample = 1; - break; - } - - case 4: { //Y8 - yuvComponent->va_surface_format = (*surface_type) = VA_RT_FORMAT_YUV400; - yuvComponent->fourcc_val = fourcc->value.value.i = VA_FOURCC_Y800; - yuvComponent->num_components = 1; - yuvComponent->y_h_subsample = 1; - yuvComponent->y_v_subsample = 1; - yuvComponent->u_h_subsample = 0; - yuvComponent->u_v_subsample = 0; - yuvComponent->v_h_subsample = 0; - yuvComponent->v_v_subsample = 0; - break; - } - - case 5: { //RGBA - yuvComponent->va_surface_format = (*surface_type) = VA_RT_FORMAT_RGB32; - yuvComponent->fourcc_val = fourcc->value.value.i = VA_FOURCC_RGBA; - yuvComponent->num_components = 3; - yuvComponent->y_h_subsample = 1; - yuvComponent->y_v_subsample = 1; - yuvComponent->u_h_subsample = 1; - yuvComponent->u_v_subsample = 1; - yuvComponent->v_h_subsample = 1; - yuvComponent->v_v_subsample = 1; - break; - } - - default: { - printf("Unsupported format:\n"); - show_help(); - break; - } - - } - -} - -int encode_input_image(FILE *yuv_fp, FILE *jpeg_fp, int picture_width, int picture_height, int frame_size, int yuv_type, int quality) -{ - int num_entrypoints,enc_entrypoint; - int major_ver, minor_ver; - int surface_type; - VAEntrypoint entrypoints[5]; - VASurfaceAttrib fourcc; - VAConfigAttrib attrib[2]; - VADisplay va_dpy; - VAStatus va_status; - VAConfigID config_id; - VASurfaceID surface_id; - VAContextID context_id; - VABufferID pic_param_buf_id; /* Picture parameter id*/ - VABufferID slice_param_buf_id; /* Slice parameter id, only 1 slice per frame in jpeg encode */ - VABufferID codedbuf_buf_id; /* Output buffer id, compressed data */ - VABufferID packed_raw_header_param_buf_id; /* Header parameter buffer id */ - VABufferID packed_raw_header_buf_id; /* Header buffer id */ - VABufferID qmatrix_buf_id; /* Quantization Matrix id */ - VABufferID huffmantable_buf_id; /* Huffman table id*/ - VAEncPictureParameterBufferJPEG pic_param; /* Picture parameter buffer */ - VAEncSliceParameterBufferJPEG slice_param; /* Slice parameter buffer */ - VAQMatrixBufferJPEG quantization_param; /* Quantization Matrix buffer */ - VAHuffmanTableBufferJPEGBaseline hufftable_param; /* Huffmantable buffer */ - YUVComponentSpecs yuvComponent; - int writeToFile = 1; - - //Clamp the quality factor value to [1,100] - if(quality >= 100) quality=100; - if(quality <= 0) quality=1; - - fourcc.type =VASurfaceAttribPixelFormat; - fourcc.flags=VA_SURFACE_ATTRIB_SETTABLE; - fourcc.value.type=VAGenericValueTypeInteger; - - init_yuv_component(&yuvComponent, yuv_type, &surface_type, &fourcc); - - /* 1. Initialize the va driver */ - va_dpy = va_open_display(); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - assert(va_status == VA_STATUS_SUCCESS); - - /* 2. Query for the entrypoints for the JPEGBaseline profile */ - va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileJPEGBaseline, entrypoints, &num_entrypoints); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - // We need picture level encoding (VAEntrypointEncPicture). Find if it is supported. - for (enc_entrypoint = 0; enc_entrypoint < num_entrypoints; enc_entrypoint++) { - if (entrypoints[enc_entrypoint] == VAEntrypointEncPicture) - break; - } - if (enc_entrypoint == num_entrypoints) { - /* No JPEG Encode (VAEntrypointEncPicture) entry point found */ - assert(0); - } - - /* 3. Query for the Render Target format supported */ - attrib[0].type = VAConfigAttribRTFormat; - attrib[1].type = VAConfigAttribEncJPEG; - vaGetConfigAttributes(va_dpy, VAProfileJPEGBaseline, VAEntrypointEncPicture, &attrib[0], 2); - - // RT should be one of below. - if(!((attrib[0].value & VA_RT_FORMAT_YUV420) || (attrib[0].value & VA_RT_FORMAT_YUV422) || (attrib[0].value & VA_RT_FORMAT_RGB32) - ||(attrib[0].value & VA_RT_FORMAT_YUV444) || (attrib[0].value & VA_RT_FORMAT_YUV400))) - { - /* Did not find the supported RT format */ - assert(0); - } - - VAConfigAttribValEncJPEG jpeg_attrib_val; - jpeg_attrib_val.value = attrib[1].value; - - /* Set JPEG profile attribs */ - jpeg_attrib_val.bits.arithmatic_coding_mode = 0; - jpeg_attrib_val.bits.progressive_dct_mode = 0; - jpeg_attrib_val.bits.non_interleaved_mode = 1; - jpeg_attrib_val.bits.differential_mode = 0; - - attrib[1].value = jpeg_attrib_val.value; - - /* 4. Create Config for the profile=VAProfileJPEGBaseline, entrypoint=VAEntrypointEncPicture, - * with RT format attribute */ - va_status = vaCreateConfig(va_dpy, VAProfileJPEGBaseline, VAEntrypointEncPicture, - &attrib[0], 2, &config_id); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - - /* 5. Create Surface for the input picture */ - va_status = vaCreateSurfaces(va_dpy, surface_type, picture_width, picture_height, - &surface_id, 1, &fourcc, 1); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - //Map the input yuv file to the input surface created with the surface_id - upload_yuv_to_surface(va_dpy, yuv_fp, surface_id, yuvComponent, picture_width, picture_height, frame_size); - - /* 6. Create Context for the encode pipe*/ - va_status = vaCreateContext(va_dpy, config_id, picture_width, picture_height, - VA_PROGRESSIVE, &surface_id, 1, &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - - /* Create buffer for Encoded data to be stored */ - va_status = vaCreateBuffer(va_dpy, context_id, VAEncCodedBufferType, - frame_size, 1, NULL, &codedbuf_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - //Initialize the picture parameter buffer - pic_param.coded_buf = codedbuf_buf_id; - jpegenc_pic_param_init(&pic_param, picture_width, picture_height, quality, yuvComponent); - - /* 7. Create buffer for the picture parameter */ - va_status = vaCreateBuffer(va_dpy, context_id, VAEncPictureParameterBufferType, - sizeof(VAEncPictureParameterBufferJPEG), 1, &pic_param, &pic_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - //Load the QMatrix - jpegenc_qmatrix_init(&quantization_param, yuvComponent); - - /* 8. Create buffer for Quantization Matrix */ - va_status = vaCreateBuffer(va_dpy, context_id, VAQMatrixBufferType, - sizeof(VAQMatrixBufferJPEG), 1, &quantization_param, &qmatrix_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - //Load the Huffman Tables - jpegenc_hufftable_init(&hufftable_param, yuvComponent); - - /* 9. Create buffer for Huffman Tables */ - va_status = vaCreateBuffer(va_dpy, context_id, VAHuffmanTableBufferType, - sizeof(VAHuffmanTableBufferJPEGBaseline), 1, &hufftable_param, &huffmantable_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - //Initialize the slice parameter buffer - jpegenc_slice_param_init(&slice_param, yuvComponent); - - /* 10. Create buffer for slice parameter */ - va_status = vaCreateBuffer(va_dpy, context_id, VAEncSliceParameterBufferType, - sizeof(slice_param), 1, &slice_param, &slice_param_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - //Pack headers and send using Raw data buffer - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_header_buffer = NULL; - - length_in_bits = build_packed_jpeg_header_buffer(&packed_header_buffer, yuvComponent, picture_width, picture_height, slice_param.restart_interval, quality); - packed_header_param_buffer.type = VAEncPackedHeaderRawData; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - /* 11. Create raw buffer for header */ - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &packed_raw_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(va_dpy, - context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_header_buffer, - &packed_raw_header_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - /* 12. Begin picture */ - va_status = vaBeginPicture(va_dpy, context_id, surface_id); - CHECK_VASTATUS(va_status, "vaBeginPicture"); - - /* 13. Render picture for all the VA buffers created */ - va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &qmatrix_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &huffmantable_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &packed_raw_header_param_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaRenderPicture(va_dpy,context_id, &packed_raw_header_buf_id, 1); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - - va_status = vaEndPicture(va_dpy,context_id); - CHECK_VASTATUS(va_status, "vaEndPicture"); - - if (writeToFile) { - VASurfaceStatus surface_status; - size_t w_items; - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int slice_data_length; - - va_status = vaSyncSurface(va_dpy, surface_id); - CHECK_VASTATUS(va_status, "vaSyncSurface"); - - surface_status = 0; - va_status = vaQuerySurfaceStatus(va_dpy, surface_id, &surface_status); - CHECK_VASTATUS(va_status,"vaQuerySurfaceStatus"); - - va_status = vaMapBuffer(va_dpy, codedbuf_buf_id, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - - coded_mem = coded_buffer_segment->buf; - - if (coded_buffer_segment->status & VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK) { - vaUnmapBuffer(va_dpy, codedbuf_buf_id); - printf("ERROR......Coded buffer too small\n"); - } - - - slice_data_length = coded_buffer_segment->size; - - do { - w_items = fwrite(coded_mem, slice_data_length, 1, jpeg_fp); - } while (w_items != 1); - - va_status = vaUnmapBuffer(va_dpy, codedbuf_buf_id); - CHECK_VASTATUS(va_status, "vaUnmapBuffer"); - } - - vaDestroyBuffer(va_dpy, pic_param_buf_id); - vaDestroyBuffer(va_dpy, qmatrix_buf_id); - vaDestroyBuffer(va_dpy, slice_param_buf_id); - vaDestroyBuffer(va_dpy, huffmantable_buf_id); - vaDestroyBuffer(va_dpy, codedbuf_buf_id); - vaDestroyBuffer(va_dpy, packed_raw_header_param_buf_id); - vaDestroyBuffer(va_dpy, packed_raw_header_buf_id); - vaDestroySurfaces(va_dpy,&surface_id,1); - vaDestroyContext(va_dpy,context_id); - vaDestroyConfig(va_dpy,config_id); - vaTerminate(va_dpy); - va_close_display(va_dpy); - - return 0; -} - - -int main(int argc, char *argv[]) -{ - FILE *yuv_fp; - FILE *jpeg_fp; - off_t file_size; - clock_t start_time, finish_time; - unsigned int duration; - unsigned int yuv_type = 0; - int quality = 0; - unsigned int picture_width = 0; - unsigned int picture_height = 0; - unsigned int frame_size = 0; - - va_init_display_args(&argc, argv); - - if(argc != 7) { - show_help(); - return -1; - } - - picture_width = atoi(argv[1]); - picture_height = atoi(argv[2]); - yuv_type = atoi(argv[5]); - quality = atoi(argv[6]); - - yuv_fp = fopen(argv[3],"rb"); - if ( yuv_fp == NULL){ - printf("Can't open input YUV file\n"); - return -1; - } - - fseeko(yuv_fp, (off_t)0, SEEK_END); - file_size = ftello(yuv_fp); - - // - switch(yuv_type) - { - case 0 : //I420 - case 1 : { //NV12 - frame_size = picture_width * picture_height + ((picture_width * picture_height) >> 1) ; - break; - } - - case 2: //UYVY - case 3: { //YUY2 - frame_size = 2 * (picture_width * picture_height); - break; - } - - case 4: { //Y8 - frame_size = picture_width * picture_height; - break; - } - - case 5: { //RGBA - frame_size = 4 * (picture_width * picture_height) ; - break; - } - - default: { - printf("Unsupported format:\n"); - show_help(); - return -1; - } - - } - - if ( (file_size < frame_size) || (file_size % frame_size) ) { - fclose(yuv_fp); - printf("The YUV file's size is not correct: file_size=%zd, frame_size=%d\n", file_size, frame_size); - return -1; - } - - fseeko(yuv_fp, (off_t)0, SEEK_SET); - - jpeg_fp = fopen(argv[4], "wb"); - if ( jpeg_fp == NULL) { - fclose(yuv_fp); - printf("Can't open output destination jpeg file\n"); - return -1; - } - - start_time = clock(); - encode_input_image(yuv_fp, jpeg_fp, picture_width, picture_height, frame_size, yuv_type, quality); - if(yuv_fp != NULL) fclose(yuv_fp); - if(jpeg_fp != NULL) fclose(jpeg_fp); - finish_time = clock(); - duration = finish_time - start_time; - printf("Encoding finished in %u ticks\n", duration); - - return 0; -} - diff --git a/test/encode/jpegenc_utils.h b/test/encode/jpegenc_utils.h deleted file mode 100644 index bb00c8b..0000000 --- a/test/encode/jpegenc_utils.h +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2014 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. - */ -/* - * This file is a utilities file which supports JPEG Encode process - */ - -#include -#include - -#define MAX_JPEG_COMPONENTS 3 //only for Y, U and V -#define JPEG_Y 0 -#define JPEG_U 1 -#define JPEG_V 2 -#define NUM_QUANT_ELEMENTS 64 -#define NUM_MAX_HUFFTABLE 2 -#define NUM_AC_RUN_SIZE_BITS 16 -#define NUM_AC_CODE_WORDS_HUFFVAL 162 -#define NUM_DC_RUN_SIZE_BITS 16 -#define NUM_DC_CODE_WORDS_HUFFVAL 12 - -#define BITSTREAM_ALLOCATE_STEPPING 4096 - -struct __bitstream { - unsigned int *buffer; - int bit_offset; - int max_size_in_dword; -}; - -typedef struct __bitstream bitstream; - -static unsigned int -swap32(unsigned int val) -{ - unsigned char *pval = (unsigned char *)&val; - - return ((pval[0] << 24) | - (pval[1] << 16) | - (pval[2] << 8) | - (pval[3] << 0)); -} - -static void -bitstream_start(bitstream *bs) -{ - bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); - assert(bs->buffer); - bs->bit_offset = 0; -} - -static void -bitstream_end(bitstream *bs) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (bit_offset) { - bs->buffer[pos] = swap32((bs->buffer[pos] << bit_left)); - } -} - -static void -bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (!size_in_bits) - return; - - if (size_in_bits < 32) - val &= ((1 << size_in_bits) - 1); - - bs->bit_offset += size_in_bits; - - if (bit_left > size_in_bits) { - bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); - } else { - size_in_bits -= bit_left; - bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); - bs->buffer[pos] = swap32(bs->buffer[pos]); - - if (pos + 1 == bs->max_size_in_dword) { - bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); - assert(bs->buffer); - } - - bs->buffer[pos + 1] = val; - } -} - -//As per Jpeg Spec ISO/IEC 10918-1, below values are assigned -enum jpeg_markers { - - //Define JPEG markers as 0xFFXX if you are adding the value directly to the buffer - //Else define marker as 0xXXFF if you are assigning the marker to a structure variable. - //This is needed because of the little-endedness of the IA - - SOI = 0xFFD8, //Start of Image - EOI = 0xFFD9, //End of Image - SOS = 0xFFDA, //Start of Scan - DQT = 0xFFDB, //Define Quantization Table - DRI = 0xFFDD, //Define restart interval - RST0 = 0xFFD0, //Restart interval termination - DHT = 0xFFC4, //Huffman table - SOF0 = 0xFFC0, //Baseline DCT - APP0 = 0xFFE0, //Application Segment - COM = 0xFFFE //Comment segment -}; - -typedef struct _JPEGFrameHeader { - - uint16_t SOF; //Start of Frame Header - uint16_t Lf; //Length of Frame Header - uint8_t P; //Sample precision - uint16_t Y; //Number of lines - uint16_t X; //Number of samples per line - uint8_t Nf; //Number of image components in frame - - struct _JPEGComponent { - uint8_t Ci; //Component identifier - uint8_t Hi:4; //Horizontal sampling factor - uint8_t Vi:4; //Vertical sampling factor - uint8_t Tqi; //Quantization table destination selector - } JPEGComponent[MAX_JPEG_COMPONENTS]; - -} JPEGFrameHeader; - - -typedef struct _JPEGScanHeader { - - uint16_t SOS; //Start of Scan - uint16_t Ls; //Length of Scan - uint8_t Ns; //Number of image components in the scan - - struct _ScanComponent { - uint8_t Csj; //Scan component selector - uint8_t Tdj:4; //DC Entropy coding table destination selector(Tdj:4 bits) - uint8_t Taj:4; //AC Entropy coding table destination selector(Taj:4 bits) - } ScanComponent[MAX_JPEG_COMPONENTS]; - - uint8_t Ss; //Start of spectral or predictor selection, 0 for Baseline - uint8_t Se; //End of spectral or predictor selection, 63 for Baseline - uint8_t Ah:4; //Successive approximation bit position high, 0 for Baseline - uint8_t Al:4; //Successive approximation bit position low, 0 for Baseline - -} JPEGScanHeader; - - -typedef struct _JPEGQuantSection { - - uint16_t DQT; //Quantization table marker - uint16_t Lq; //Length of Quantization table definition - uint8_t Tq:4; //Quantization table destination identifier - uint8_t Pq:4; //Quatization table precision. Should be 0 for 8-bit samples - uint8_t Qk[NUM_QUANT_ELEMENTS]; //Quantization table elements - -} JPEGQuantSection; - -typedef struct _JPEGHuffSection { - - uint16_t DHT; //Huffman table marker - uint16_t Lh; //Huffman table definition length - uint8_t Tc:4; //Table class- 0:DC, 1:AC - uint8_t Th:4; //Huffman table destination identifier - uint8_t Li[NUM_AC_RUN_SIZE_BITS]; //Number of Huffman codes of length i - uint8_t Vij[NUM_AC_CODE_WORDS_HUFFVAL]; //Value associated with each Huffman code - -} JPEGHuffSection; - - -typedef struct _JPEGRestartSection { - - uint16_t DRI; //Restart interval marker - uint16_t Lr; //Legth of restart interval segment - uint16_t Ri; //Restart interval - -} JPEGRestartSection; - - -typedef struct _JPEGCommentSection { - - uint16_t COM; //Comment marker - uint16_t Lc; //Comment segment length - uint8_t Cmi; //Comment byte - -} JPEGCommentSection; - - -typedef struct _JPEGAppSection { - - uint16_t APPn; //Application data marker - uint16_t Lp; //Application data segment length - uint8_t Api; //Application data byte - -} JPEGAppSection; - -//Luminance quantization table -//Source: Jpeg Spec ISO/IEC 10918-1, Annex K, Table K.1 -uint8_t jpeg_luma_quant[NUM_QUANT_ELEMENTS] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 -}; - -//Luminance quantization table -//Source: Jpeg Spec ISO/IEC 10918-1, Annex K, Table K.2 -uint8_t jpeg_chroma_quant[NUM_QUANT_ELEMENTS] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 -}; - - -//Zigzag scan order of the the Luma and Chroma components -//Note: Jpeg Spec ISO/IEC 10918-1, Figure A.6 shows the zigzag order differently. -//The Spec is trying to show the zigzag pattern with number positions. The below -//table will use the patter shown by A.6 and map the postion of the elements in the array -uint8_t jpeg_zigzag[] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -}; - - -//Huffman table for Luminance DC Coefficients -//Reference Jpeg Spec ISO/IEC 10918-1, K.3.3.1 -//K.3.3.1 is the summarized version of Table K.3 -uint8_t jpeg_hufftable_luma_dc[] = { - //TcTh (Tc=0 since 0:DC, 1:AC; Th=0) - 0x00, - //Li - 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //Vi - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B -}; - -//Huffman table for Chrominance DC Coefficients -//Reference Jpeg Spec ISO/IEC 10918-1, K.3.3.1 -//K.3.3.1 is the summarized version of Table K.4 -uint8_t jpeg_hufftable_chroma_dc[] = { - //TcTh (Tc=0 since 0:DC, 1:AC; Th=1) - 0x01, - //Li - 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - //Vi - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B -}; - - -//Huffman table for Luminance AC Coefficients -//Reference Jpeg Spec ISO/IEC 10918-1, K.3.3.2 -//K.3.3.2 is the summarized version of Table K.5 -uint8_t jpeg_hufftable_luma_ac[] = { - //TcTh (Tc=1 since 0:DC, 1:AC; Th=0) - 0x10, - //Li - 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7D, - //Vi - 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1, 0xF0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2A, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, - 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, - 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE1, 0xE2, - 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, - 0xF9, 0xFA -}; - -//Huffman table for Chrominance AC Coefficients -//Reference Jpeg Spec ISO/IEC 10918-1, K.3.3.2 -//K.3.3.2 is the summarized version of Table K.6 -uint8_t jpeg_hufftable_chroma_ac[] = { - //TcTh (Tc=1 since 0:DC, 1:AC; Th=1) - 0x11, - //Li - 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, - //Vi - 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0, - 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, - 0x27, 0x28, 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, - 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, - 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, - 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, - 0xF9, 0xFA -}; - -typedef struct _YUVComponentSpecs { - //One of 0(I420)/1(NV12)/2(UYVY)/3(YUY2)/4(Y8)/5(RGBA)> - unsigned int yuv_type; - // One of VA_RT_FORMAT_YUV420, VA_RT_FORMAT_YUV422, VA_RT_FORMAT_YUV400, VA_RT_FORMAT_YUV444, VA_RT_FORMAT_RGB32 - unsigned int va_surface_format; - //One of VA_FOURCC_I420, VA_FOURCC_NV12, VA_FOURCC_UYVY, VA_FOURCC_YUY2, VA_FOURCC_Y800, VA_FOURCC_444P, VA_FOURCC_RGBA - unsigned int fourcc_val; //Using this field to evaluate the input file type. - //no.of. components - unsigned int num_components; - //Y horizontal subsample - unsigned int y_h_subsample; - //Y vertical subsample - unsigned int y_v_subsample; - //U horizontal subsample - unsigned int u_h_subsample; - //U vertical subsample - unsigned int u_v_subsample; - //V horizontal subsample - unsigned int v_h_subsample; - //V vertical subsample - unsigned int v_v_subsample; -} YUVComponentSpecs; diff --git a/test/encode/mpeg2vaenc.c b/test/encode/mpeg2vaenc.c deleted file mode 100644 index fd9c5ca..0000000 --- a/test/encode/mpeg2vaenc.c +++ /dev/null @@ -1,1546 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -/* - * Simple MPEG-2 encoder based on libVA. - * - */ - -#include "sysdeps.h" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "va_display.h" - -#define START_CODE_PICUTRE 0x00000100 -#define START_CODE_SLICE 0x00000101 -#define START_CODE_USER 0x000001B2 -#define START_CODE_SEQ 0x000001B3 -#define START_CODE_EXT 0x000001B5 -#define START_CODE_GOP 0x000001B8 - -#define CHROMA_FORMAT_RESERVED 0 -#define CHROMA_FORMAT_420 1 -#define CHROMA_FORMAT_422 2 -#define CHROMA_FORMAT_444 3 - -#define MAX_SLICES 128 - -enum { - MPEG2_MODE_I = 0, - MPEG2_MODE_IP, - MPEG2_MODE_IPB, -}; - -enum { - MPEG2_LEVEL_LOW = 0, - MPEG2_LEVEL_MAIN, - MPEG2_LEVEL_HIGH, -}; - -#define CHECK_VASTATUS(va_status, func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr, "%s:%s (%d) failed, exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - -static VAProfile mpeg2_va_profiles[] = { - VAProfileMPEG2Simple, - VAProfileMPEG2Main -}; - -static struct _mpeg2_sampling_density -{ - int samplers_per_line; - int line_per_frame; - int frame_per_sec; -} mpeg2_upper_samplings[2][3] = { - { { 0, 0, 0 }, - { 720, 576, 30 }, - { 0, 0, 0 }, - }, - - { { 352, 288, 30 }, - { 720, 576, 30 }, - { 1920, 1152, 60 }, - } -}; - -struct mpeg2enc_context { - /* args */ - int rate_control_mode; - int fps; - int mode; /* 0:I, 1:I/P, 2:I/P/B */ - VAProfile profile; - int level; - int width; - int height; - int frame_size; - int num_pictures; - int qp; - FILE *ifp; - FILE *ofp; - unsigned char *frame_data_buffer; - int intra_period; - int ip_period; - int bit_rate; /* in kbps */ - VAEncPictureType next_type; - int next_display_order; - int next_bframes; - int new_sequence; - int new_gop_header; - int gop_header_in_display_order; - - /* VA resource */ - VADisplay va_dpy; - VAEncSequenceParameterBufferMPEG2 seq_param; - VAEncPictureParameterBufferMPEG2 pic_param; - VAEncSliceParameterBufferMPEG2 slice_param[MAX_SLICES]; - VAContextID context_id; - VAConfigID config_id; - VABufferID seq_param_buf_id; /* Sequence level parameter */ - VABufferID pic_param_buf_id; /* Picture level parameter */ - VABufferID slice_param_buf_id[MAX_SLICES]; /* Slice level parameter, multil slices */ - VABufferID codedbuf_buf_id; /* Output buffer, compressed data */ - VABufferID packed_seq_header_param_buf_id; - VABufferID packed_seq_buf_id; - VABufferID packed_pic_header_param_buf_id; - VABufferID packed_pic_buf_id; - int num_slice_groups; - int codedbuf_i_size; - int codedbuf_pb_size; - - /* thread */ - pthread_t upload_thread_id; - int upload_thread_value; - int current_input_surface; - int current_upload_surface; -}; - -/* - * mpeg2enc helpers - */ -#define BITSTREAM_ALLOCATE_STEPPING 4096 - -struct __bitstream { - unsigned int *buffer; - int bit_offset; - int max_size_in_dword; -}; - -typedef struct __bitstream bitstream; - -static unsigned int -swap32(unsigned int val) -{ - unsigned char *pval = (unsigned char *)&val; - - return ((pval[0] << 24) | - (pval[1] << 16) | - (pval[2] << 8) | - (pval[3] << 0)); -} - -static void -bitstream_start(bitstream *bs) -{ - bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); - bs->bit_offset = 0; -} - -static void -bitstream_end(bitstream *bs) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (bit_offset) { - bs->buffer[pos] = swap32((bs->buffer[pos] << bit_left)); - } -} - -static void -bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (!size_in_bits) - return; - - if (size_in_bits < 32) - val &= ((1 << size_in_bits) - 1); - - bs->bit_offset += size_in_bits; - - if (bit_left > size_in_bits) { - bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); - } else { - size_in_bits -= bit_left; - bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); - bs->buffer[pos] = swap32(bs->buffer[pos]); - - if (pos + 1 == bs->max_size_in_dword) { - bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); - } - - bs->buffer[pos + 1] = val; - } -} - -static void -bitstream_byte_aligning(bitstream *bs, int bit) -{ - int bit_offset = (bs->bit_offset & 0x7); - int bit_left = 8 - bit_offset; - int new_val; - - if (!bit_offset) - return; - - assert(bit == 0 || bit == 1); - - if (bit) - new_val = (1 << bit_left) - 1; - else - new_val = 0; - - bitstream_put_ui(bs, new_val, bit_left); -} - -static struct mpeg2_frame_rate { - int code; - float value; -} frame_rate_tab[] = { - {1, 23.976}, - {2, 24.0}, - {3, 25.0}, - {4, 29.97}, - {5, 30}, - {6, 50}, - {7, 59.94}, - {8, 60} -}; - -static int -find_frame_rate_code(const VAEncSequenceParameterBufferMPEG2 *seq_param) -{ - unsigned int delta = -1; - int code = 1, i; - float frame_rate_value = seq_param->frame_rate * - (seq_param->sequence_extension.bits.frame_rate_extension_d + 1) / - (seq_param->sequence_extension.bits.frame_rate_extension_n + 1); - - for (i = 0; i < sizeof(frame_rate_tab) / sizeof(frame_rate_tab[0]); i++) { - - if (abs(1000 * frame_rate_tab[i].value - 1000 * frame_rate_value) < delta) { - code = frame_rate_tab[i].code; - delta = abs(1000 * frame_rate_tab[i].value - 1000 * frame_rate_value); - } - } - - return code; -} - -static void -sps_rbsp(struct mpeg2enc_context *ctx, - const VAEncSequenceParameterBufferMPEG2 *seq_param, - bitstream *bs) -{ - int frame_rate_code = find_frame_rate_code(seq_param); - - if (ctx->new_sequence) { - bitstream_put_ui(bs, START_CODE_SEQ, 32); - bitstream_put_ui(bs, seq_param->picture_width, 12); - bitstream_put_ui(bs, seq_param->picture_height, 12); - bitstream_put_ui(bs, seq_param->aspect_ratio_information, 4); - bitstream_put_ui(bs, frame_rate_code, 4); /* frame_rate_code */ - bitstream_put_ui(bs, (seq_param->bits_per_second + 399) / 400, 18); /* the low 18 bits of bit_rate */ - bitstream_put_ui(bs, 1, 1); /* marker_bit */ - bitstream_put_ui(bs, seq_param->vbv_buffer_size, 10); - bitstream_put_ui(bs, 0, 1); /* constraint_parameter_flag, always 0 for MPEG-2 */ - bitstream_put_ui(bs, 0, 1); /* load_intra_quantiser_matrix */ - bitstream_put_ui(bs, 0, 1); /* load_non_intra_quantiser_matrix */ - - bitstream_byte_aligning(bs, 0); - - bitstream_put_ui(bs, START_CODE_EXT, 32); - bitstream_put_ui(bs, 1, 4); /* sequence_extension id */ - bitstream_put_ui(bs, seq_param->sequence_extension.bits.profile_and_level_indication, 8); - bitstream_put_ui(bs, seq_param->sequence_extension.bits.progressive_sequence, 1); - bitstream_put_ui(bs, seq_param->sequence_extension.bits.chroma_format, 2); - bitstream_put_ui(bs, seq_param->picture_width >> 12, 2); - bitstream_put_ui(bs, seq_param->picture_height >> 12, 2); - bitstream_put_ui(bs, ((seq_param->bits_per_second + 399) / 400) >> 18, 12); /* bit_rate_extension */ - bitstream_put_ui(bs, 1, 1); /* marker_bit */ - bitstream_put_ui(bs, seq_param->vbv_buffer_size >> 10, 8); - bitstream_put_ui(bs, seq_param->sequence_extension.bits.low_delay, 1); - bitstream_put_ui(bs, seq_param->sequence_extension.bits.frame_rate_extension_n, 2); - bitstream_put_ui(bs, seq_param->sequence_extension.bits.frame_rate_extension_d, 5); - - bitstream_byte_aligning(bs, 0); - } - - if (ctx->new_gop_header) { - bitstream_put_ui(bs, START_CODE_GOP, 32); - bitstream_put_ui(bs, seq_param->gop_header.bits.time_code, 25); - bitstream_put_ui(bs, seq_param->gop_header.bits.closed_gop, 1); - bitstream_put_ui(bs, seq_param->gop_header.bits.broken_link, 1); - - bitstream_byte_aligning(bs, 0); - } -} - -static void -pps_rbsp(const VAEncSequenceParameterBufferMPEG2 *seq_param, - const VAEncPictureParameterBufferMPEG2 *pic_param, - bitstream *bs) -{ - int chroma_420_type; - - if (seq_param->sequence_extension.bits.chroma_format == CHROMA_FORMAT_420) - chroma_420_type = pic_param->picture_coding_extension.bits.progressive_frame; - else - chroma_420_type = 0; - - bitstream_put_ui(bs, START_CODE_PICUTRE, 32); - bitstream_put_ui(bs, pic_param->temporal_reference, 10); - bitstream_put_ui(bs, - pic_param->picture_type == VAEncPictureTypeIntra ? 1 : - pic_param->picture_type == VAEncPictureTypePredictive ? 2 : 3, - 3); - bitstream_put_ui(bs, 0xFFFF, 16); /* vbv_delay, always 0xFFFF */ - - if (pic_param->picture_type == VAEncPictureTypePredictive || - pic_param->picture_type == VAEncPictureTypeBidirectional) { - bitstream_put_ui(bs, 0, 1); /* full_pel_forward_vector, always 0 for MPEG-2 */ - bitstream_put_ui(bs, 7, 3); /* forward_f_code, always 7 for MPEG-2 */ - } - - if (pic_param->picture_type == VAEncPictureTypeBidirectional) { - bitstream_put_ui(bs, 0, 1); /* full_pel_backward_vector, always 0 for MPEG-2 */ - bitstream_put_ui(bs, 7, 3); /* backward_f_code, always 7 for MPEG-2 */ - } - - bitstream_put_ui(bs, 0, 1); /* extra_bit_picture, 0 */ - - bitstream_byte_aligning(bs, 0); - - bitstream_put_ui(bs, START_CODE_EXT, 32); - bitstream_put_ui(bs, 8, 4); /* Picture Coding Extension ID: 8 */ - bitstream_put_ui(bs, pic_param->f_code[0][0], 4); - bitstream_put_ui(bs, pic_param->f_code[0][1], 4); - bitstream_put_ui(bs, pic_param->f_code[1][0], 4); - bitstream_put_ui(bs, pic_param->f_code[1][1], 4); - - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.intra_dc_precision, 2); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.picture_structure, 2); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.top_field_first, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.frame_pred_frame_dct, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.concealment_motion_vectors, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.q_scale_type, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.intra_vlc_format, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.alternate_scan, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.repeat_first_field, 1); - bitstream_put_ui(bs, chroma_420_type, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.progressive_frame, 1); - bitstream_put_ui(bs, pic_param->picture_coding_extension.bits.composite_display_flag, 1); - - bitstream_byte_aligning(bs, 0); -} - -static int -build_packed_pic_buffer(const VAEncSequenceParameterBufferMPEG2 *seq_param, - const VAEncPictureParameterBufferMPEG2 *pic_param, - unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - pps_rbsp(seq_param, pic_param, &bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_seq_buffer(struct mpeg2enc_context *ctx, - const VAEncSequenceParameterBufferMPEG2 *seq_param, - unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - sps_rbsp(ctx, seq_param, &bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -/* - * mpeg2enc - */ -#define SID_INPUT_PICTURE_0 0 -#define SID_INPUT_PICTURE_1 1 -#define SID_REFERENCE_PICTURE_L0 2 -#define SID_REFERENCE_PICTURE_L1 3 -#define SID_RECON_PICTURE 4 -#define SID_NUMBER SID_RECON_PICTURE + 1 - -static VASurfaceID surface_ids[SID_NUMBER]; - -/* - * upload thread function - */ -static void * -upload_yuv_to_surface(void *data) -{ - struct mpeg2enc_context *ctx = data; - VAImage surface_image; - VAStatus va_status; - void *surface_p = NULL; - unsigned char *y_src, *u_src, *v_src; - unsigned char *y_dst, *u_dst, *v_dst; - int y_size = ctx->width * ctx->height; - int u_size = (ctx->width >> 1) * (ctx->height >> 1); - int row, col; - size_t n_items; - - do { - n_items = fread(ctx->frame_data_buffer, ctx->frame_size, 1, ctx->ifp); - } while (n_items != 1); - - va_status = vaDeriveImage(ctx->va_dpy, surface_ids[ctx->current_upload_surface], &surface_image); - CHECK_VASTATUS(va_status,"vaDeriveImage"); - - vaMapBuffer(ctx->va_dpy, surface_image.buf, &surface_p); - assert(VA_STATUS_SUCCESS == va_status); - - y_src = ctx->frame_data_buffer; - u_src = ctx->frame_data_buffer + y_size; /* UV offset for NV12 */ - v_src = ctx->frame_data_buffer + y_size + u_size; - - y_dst = surface_p + surface_image.offsets[0]; - u_dst = surface_p + surface_image.offsets[1]; /* UV offset for NV12 */ - v_dst = surface_p + surface_image.offsets[2]; - - /* Y plane */ - for (row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width); - y_dst += surface_image.pitches[0]; - y_src += ctx->width; - } - - if (surface_image.format.fourcc == VA_FOURCC_NV12) { /* UV plane */ - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col * 2] = u_src[col]; - u_dst[col * 2 + 1] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - u_src += (ctx->width / 2); - v_src += (ctx->width / 2); - } - } else { - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col] = u_src[col]; - v_dst[col] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - v_dst += surface_image.pitches[2]; - u_src += (ctx->width / 2); - v_src += (ctx->width / 2); - } - } - - vaUnmapBuffer(ctx->va_dpy, surface_image.buf); - vaDestroyImage(ctx->va_dpy, surface_image.image_id); - - return NULL; -} - -static void -mpeg2enc_exit(struct mpeg2enc_context *ctx, int exit_code) -{ - if (ctx->frame_data_buffer) { - free(ctx->frame_data_buffer); - ctx->frame_data_buffer = NULL; - } - - if (ctx->ifp) { - fclose(ctx->ifp); - ctx->ifp = NULL; - } - - if (ctx->ofp) { - fclose(ctx->ofp); - ctx->ofp = NULL; - } - - exit(exit_code); -} - -static void -usage(char *program) -{ - fprintf(stderr, "Usage: %s --help\n", program); - fprintf(stderr, "\t--help print this message\n"); - fprintf(stderr, "Usage: %s [options]\n", program); - fprintf(stderr, "\t specifies the frame width\n"); - fprintf(stderr, "\t specifies the frame height\n"); - fprintf(stderr, "\t specifies the I420/IYUV YUV file\n"); - fprintf(stderr, "\t specifies the encoded MPEG-2 file\n"); - fprintf(stderr, "where options include:\n"); - fprintf(stderr, "\t--cqp const qp mode with specified \n"); - fprintf(stderr, "\t--fps specify the frame rate\n"); - fprintf(stderr, "\t--mode specify the mode 0 (I), 1 (I/P) and 2 (I/P/B)\n"); - fprintf(stderr, "\t--profile specify the profile 0(Simple), or 1(Main, default)\n"); - fprintf(stderr, "\t--level specify the level 0(Low), 1(Main, default) or 2(High)\n"); -} - -void -mpeg2_profile_level(struct mpeg2enc_context *ctx, - int profile, - int level) -{ - int l = 2, p; - - for (p = profile; p < 2; p++) { - for (l = level; l < 3; l++) { - if (ctx->width <= mpeg2_upper_samplings[p][l].samplers_per_line && - ctx->height <= mpeg2_upper_samplings[p][l].line_per_frame && - ctx->fps <= mpeg2_upper_samplings[p][l].frame_per_sec) { - - goto __find; - break; - } - } - } - - if (p == 2) { - fprintf(stderr, "Warning: can't find a proper profile and level for the specified width/height/fps\n"); - p = 1; - l = 2; - } - -__find: - ctx->profile = mpeg2_va_profiles[p]; - ctx->level = l; -} - -static void -parse_args(struct mpeg2enc_context *ctx, int argc, char **argv) -{ - int c, tmp; - int option_index = 0; - long file_size; - int profile = 1, level = 1; - - static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"cqp", required_argument, 0, 'c'}, - {"fps", required_argument, 0, 'f'}, - {"mode", required_argument, 0, 'm'}, - {"profile", required_argument, 0, 'p'}, - {"level", required_argument, 0, 'l'}, - { NULL, 0, NULL, 0 } - }; - - if ((argc == 2 && strcmp(argv[1], "--help") == 0) || - (argc < 5)) - goto print_usage; - - ctx->width = atoi(argv[1]); - ctx->height = atoi(argv[2]); - - if (ctx->width <= 0 || ctx->height <= 0) { - fprintf(stderr, " and must be greater than 0\n"); - goto err_exit; - } - - ctx->ifp = fopen(argv[3], "rb"); - - if (ctx->ifp == NULL) { - fprintf(stderr, "Can't open the input file\n"); - goto err_exit; - } - - fseek(ctx->ifp, 0l, SEEK_END); - file_size = ftell(ctx->ifp); - ctx->frame_size = ctx->width * ctx->height * 3 / 2; - - if ((file_size < ctx->frame_size) || - (file_size % ctx->frame_size)) { - fprintf(stderr, "The input file size %ld isn't a multiple of the frame size %d\n", file_size, ctx->frame_size); - goto err_exit; - } - - ctx->num_pictures = file_size / ctx->frame_size; - fseek(ctx->ifp, 0l, SEEK_SET); - - ctx->ofp = fopen(argv[4], "wb"); - - if (ctx->ofp == NULL) { - fprintf(stderr, "Can't create the output file\n"); - goto err_exit; - } - - opterr = 0; - ctx->fps = 30; - ctx->qp = 8; - ctx->rate_control_mode = VA_RC_CQP; - ctx->mode = MPEG2_MODE_IP; - ctx->profile = VAProfileMPEG2Main; - ctx->level = MPEG2_LEVEL_MAIN; - - optind = 5; - - while((c = getopt_long(argc, argv, - "", - long_options, - &option_index)) != -1) { - switch(c) { - case 'c': - tmp = atoi(optarg); - - /* only support q_scale_type = 0 */ - if (tmp > 62 || tmp < 2) { - fprintf(stderr, "Warning: QP must be in [2, 62]\n"); - - if (tmp > 62) - tmp = 62; - - if (tmp < 2) - tmp = 2; - } - - ctx->qp = tmp & 0xFE; - ctx->rate_control_mode = VA_RC_CQP; - - break; - - case 'f': - tmp = atoi(optarg); - - if (tmp <= 0) - fprintf(stderr, "Warning: FPS must be greater than 0\n"); - else - ctx->fps = tmp; - - ctx->rate_control_mode = VA_RC_CBR; - - break; - - case 'm': - tmp = atoi(optarg); - - if (tmp < MPEG2_MODE_I || tmp > MPEG2_MODE_IPB) - fprintf(stderr, "Waning: MODE must be 0, 1, or 2\n"); - else - ctx->mode = tmp; - - break; - - case 'p': - tmp = atoi(optarg); - - if (tmp < 0 || tmp > 1) - fprintf(stderr, "Waning: PROFILE must be 0 or 1\n"); - else - profile = tmp; - - break; - - case 'l': - tmp = atoi(optarg); - - if (tmp < MPEG2_LEVEL_LOW || tmp > MPEG2_LEVEL_HIGH) - fprintf(stderr, "Waning: LEVEL must be 0, 1, or 2\n"); - else - level = tmp; - - break; - - case '?': - fprintf(stderr, "Error: unkown command options\n"); - - case 'h': - goto print_usage; - } - } - - mpeg2_profile_level(ctx, profile, level); - - return; - -print_usage: - usage(argv[0]); -err_exit: - mpeg2enc_exit(ctx, 1); -} - -/* - * init - */ -void -mpeg2enc_init_sequence_parameter(struct mpeg2enc_context *ctx, - VAEncSequenceParameterBufferMPEG2 *seq_param) -{ - int profile = 4, level = 8; - - switch (ctx->profile) { - case VAProfileMPEG2Simple: - profile = 5; - break; - - case VAProfileMPEG2Main: - profile = 4; - break; - - default: - assert(0); - break; - } - - switch (ctx->level) { - case MPEG2_LEVEL_LOW: - level = 10; - break; - - case MPEG2_LEVEL_MAIN: - level = 8; - break; - - case MPEG2_LEVEL_HIGH: - level = 4; - break; - - default: - assert(0); - break; - } - - seq_param->intra_period = ctx->intra_period; - seq_param->ip_period = ctx->ip_period; /* FIXME: ??? */ - seq_param->picture_width = ctx->width; - seq_param->picture_height = ctx->height; - - if (ctx->bit_rate > 0) - seq_param->bits_per_second = 1024 * ctx->bit_rate; /* use kbps as input */ - else - seq_param->bits_per_second = 0x3FFFF * 400; - - seq_param->frame_rate = ctx->fps; - seq_param->aspect_ratio_information = 1; - seq_param->vbv_buffer_size = 3; /* B = 16 * 1024 * vbv_buffer_size */ - - seq_param->sequence_extension.bits.profile_and_level_indication = profile << 4 | level; - seq_param->sequence_extension.bits.progressive_sequence = 1; /* progressive frame-pictures */ - seq_param->sequence_extension.bits.chroma_format = CHROMA_FORMAT_420; /* 4:2:0 */ - seq_param->sequence_extension.bits.low_delay = 0; /* FIXME */ - seq_param->sequence_extension.bits.frame_rate_extension_n = 0; - seq_param->sequence_extension.bits.frame_rate_extension_d = 0; - - seq_param->gop_header.bits.time_code = (1 << 12); /* bit12: marker_bit */ - seq_param->gop_header.bits.closed_gop = 0; - seq_param->gop_header.bits.broken_link = 0; -} - -static void -mpeg2enc_init_picture_parameter(struct mpeg2enc_context *ctx, - VAEncPictureParameterBufferMPEG2 *pic_param) -{ - pic_param->forward_reference_picture = VA_INVALID_ID; - pic_param->backward_reference_picture = VA_INVALID_ID; - pic_param->reconstructed_picture = VA_INVALID_ID; - pic_param->coded_buf = VA_INVALID_ID; - pic_param->picture_type = VAEncPictureTypeIntra; - - pic_param->temporal_reference = 0; - pic_param->f_code[0][0] = 0xf; - pic_param->f_code[0][1] = 0xf; - pic_param->f_code[1][0] = 0xf; - pic_param->f_code[1][1] = 0xf; - - pic_param->picture_coding_extension.bits.intra_dc_precision = 0; /* 8bits */ - pic_param->picture_coding_extension.bits.picture_structure = 3; /* frame picture */ - pic_param->picture_coding_extension.bits.top_field_first = 0; - pic_param->picture_coding_extension.bits.frame_pred_frame_dct = 1; /* FIXME */ - pic_param->picture_coding_extension.bits.concealment_motion_vectors = 0; - pic_param->picture_coding_extension.bits.q_scale_type = 0; - pic_param->picture_coding_extension.bits.intra_vlc_format = 0; - pic_param->picture_coding_extension.bits.alternate_scan = 0; - pic_param->picture_coding_extension.bits.repeat_first_field = 0; - pic_param->picture_coding_extension.bits.progressive_frame = 1; - pic_param->picture_coding_extension.bits.composite_display_flag = 0; -} - -static void -mpeg2enc_alloc_va_resources(struct mpeg2enc_context *ctx) -{ - VAEntrypoint *entrypoint_list; - VAConfigAttrib attrib_list[2]; - VAStatus va_status; - int max_entrypoints, num_entrypoints, entrypoint; - int major_ver, minor_ver; - - ctx->va_dpy = va_open_display(); - va_status = vaInitialize(ctx->va_dpy, - &major_ver, - &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - max_entrypoints = vaMaxNumEntrypoints(ctx->va_dpy); - entrypoint_list = malloc(max_entrypoints * sizeof(VAEntrypoint)); - assert(entrypoint_list); - vaQueryConfigEntrypoints(ctx->va_dpy, - ctx->profile, - entrypoint_list, - &num_entrypoints); - - for (entrypoint = 0; entrypoint < num_entrypoints; entrypoint++) { - if (entrypoint_list[entrypoint] == VAEntrypointEncSlice) - break; - } - - free(entrypoint_list); - - if (entrypoint == num_entrypoints) { - /* not find Slice entry point */ - assert(0); - } - - /* find out the format for the render target, and rate control mode */ - attrib_list[0].type = VAConfigAttribRTFormat; - attrib_list[1].type = VAConfigAttribRateControl; - vaGetConfigAttributes(ctx->va_dpy, - ctx->profile, - VAEntrypointEncSlice, - &attrib_list[0], - 2); - - if ((attrib_list[0].value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - if ((attrib_list[1].value & ctx->rate_control_mode) == 0) { - /* Can't find matched RC mode */ - fprintf(stderr, "RC mode %d isn't found, exit\n", ctx->rate_control_mode); - assert(0); - } - - attrib_list[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */ - attrib_list[1].value = ctx->rate_control_mode; /* set to desired RC mode */ - - va_status = vaCreateConfig(ctx->va_dpy, - ctx->profile, - VAEntrypointEncSlice, - attrib_list, - 2, - &ctx->config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(ctx->va_dpy, - ctx->config_id, - ctx->width, - ctx->height, - VA_PROGRESSIVE, - 0, - 0, - &ctx->context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - - va_status = vaCreateSurfaces(ctx->va_dpy, - VA_RT_FORMAT_YUV420, - ctx->width, - ctx->height, - surface_ids, - SID_NUMBER, - NULL, - 0); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); -} - -static void -mpeg2enc_init(struct mpeg2enc_context *ctx) -{ - int i; - - ctx->frame_data_buffer = (unsigned char *)malloc(ctx->frame_size); - ctx->seq_param_buf_id = VA_INVALID_ID; - ctx->pic_param_buf_id = VA_INVALID_ID; - ctx->packed_seq_header_param_buf_id = VA_INVALID_ID; - ctx->packed_seq_buf_id = VA_INVALID_ID; - ctx->packed_pic_header_param_buf_id = VA_INVALID_ID; - ctx->packed_pic_buf_id = VA_INVALID_ID; - ctx->codedbuf_buf_id = VA_INVALID_ID; - ctx->codedbuf_i_size = ctx->frame_size; - ctx->codedbuf_pb_size = 0; - ctx->next_display_order = 0; - ctx->next_type = VAEncPictureTypeIntra; - - if (ctx->mode == MPEG2_MODE_I) { - ctx->intra_period = 1; - ctx->ip_period = 0; - } else if (ctx->mode == MPEG2_MODE_IP) { - ctx->intra_period = 16; - ctx->ip_period = 0; - } else { - ctx->intra_period = 16; - ctx->ip_period = 2; - } - - ctx->next_bframes = ctx->ip_period; - - ctx->new_sequence = 1; - ctx->new_gop_header = 1; - ctx->gop_header_in_display_order = 0; - - ctx->bit_rate = -1; - - for (i = 0; i < MAX_SLICES; i++) { - ctx->slice_param_buf_id[i] = VA_INVALID_ID; - } - - mpeg2enc_init_sequence_parameter(ctx, &ctx->seq_param); - mpeg2enc_init_picture_parameter(ctx, &ctx->pic_param); - mpeg2enc_alloc_va_resources(ctx); - - /* thread */ - ctx->current_input_surface = SID_INPUT_PICTURE_0; - ctx->current_upload_surface = SID_INPUT_PICTURE_1; - ctx->upload_thread_value = pthread_create(&ctx->upload_thread_id, - NULL, - upload_yuv_to_surface, - ctx); -} - -static int -mpeg2enc_time_code(VAEncSequenceParameterBufferMPEG2 *seq_param, - int num_frames) -{ - int fps = (int)(seq_param->frame_rate + 0.5); - int time_code = 0; - int time_code_pictures, time_code_seconds, time_code_minutes, time_code_hours; - int drop_frame_flag = 0; - - assert(fps <= 60); - - time_code_seconds = num_frames / fps; - time_code_pictures = num_frames % fps; - time_code |= time_code_pictures; - - time_code_minutes = time_code_seconds / 60; - time_code_seconds = time_code_seconds % 60; - time_code |= (time_code_seconds << 6); - - time_code_hours = time_code_minutes / 60; - time_code_minutes = time_code_minutes % 60; - - time_code |= (1 << 12); /* marker_bit */ - time_code |= (time_code_minutes << 13); - - time_code_hours = time_code_hours % 24; - time_code |= (time_code_hours << 19); - - time_code |= (drop_frame_flag << 24); - - return time_code; -} - -/* - * run - */ -static void -mpeg2enc_update_sequence_parameter(struct mpeg2enc_context *ctx, - VAEncPictureType picture_type, - int coded_order, - int display_order) -{ - VAEncSequenceParameterBufferMPEG2 *seq_param = &ctx->seq_param; - - /* update the time_code info for the new GOP */ - if (ctx->new_gop_header) { - seq_param->gop_header.bits.time_code = mpeg2enc_time_code(seq_param, display_order); - } -} - -static void -mpeg2enc_update_picture_parameter(struct mpeg2enc_context *ctx, - VAEncPictureType picture_type, - int coded_order, - int display_order) -{ - VAEncPictureParameterBufferMPEG2 *pic_param = &ctx->pic_param; - uint8_t f_code_x, f_code_y; - - pic_param->picture_type = picture_type; - pic_param->temporal_reference = (display_order - ctx->gop_header_in_display_order) & 0x3FF; - pic_param->reconstructed_picture = surface_ids[SID_RECON_PICTURE]; - pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0]; - pic_param->backward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L1]; - - f_code_x = 0xf; - f_code_y = 0xf; - if (pic_param->picture_type != VAEncPictureTypeIntra) { - if (ctx->level == MPEG2_LEVEL_LOW) { - f_code_x = 7; - f_code_y = 4; - } else if (ctx->level == MPEG2_LEVEL_MAIN) { - f_code_x = 8; - f_code_y = 5; - } else { - f_code_x = 9; - f_code_y = 5; - } - } - - if (pic_param->picture_type == VAEncPictureTypeIntra) { - pic_param->f_code[0][0] = 0xf; - pic_param->f_code[0][1] = 0xf; - pic_param->f_code[1][0] = 0xf; - pic_param->f_code[1][1] = 0xf; - pic_param->forward_reference_picture = VA_INVALID_SURFACE; - pic_param->backward_reference_picture = VA_INVALID_SURFACE; - - } else if (pic_param->picture_type == VAEncPictureTypePredictive) { - pic_param->f_code[0][0] = f_code_x; - pic_param->f_code[0][1] = f_code_y; - pic_param->f_code[1][0] = 0xf; - pic_param->f_code[1][1] = 0xf; - pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0]; - pic_param->backward_reference_picture = VA_INVALID_SURFACE; - } else if (pic_param->picture_type == VAEncPictureTypeBidirectional) { - pic_param->f_code[0][0] = f_code_x; - pic_param->f_code[0][1] = f_code_y; - pic_param->f_code[1][0] = f_code_x; - pic_param->f_code[1][1] = f_code_y; - pic_param->forward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L0]; - pic_param->backward_reference_picture = surface_ids[SID_REFERENCE_PICTURE_L1]; - } else { - assert(0); - } -} - -static void -mpeg2enc_update_picture_parameter_buffer(struct mpeg2enc_context *ctx, - VAEncPictureType picture_type, - int coded_order, - int display_order) -{ - VAEncPictureParameterBufferMPEG2 *pic_param = &ctx->pic_param; - VAStatus va_status; - - /* update the coded buffer id */ - pic_param->coded_buf = ctx->codedbuf_buf_id; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPictureParameterBufferType, - sizeof(*pic_param), - 1, - pic_param, - &ctx->pic_param_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); -} - -static void -mpeg2enc_update_slice_parameter(struct mpeg2enc_context *ctx, VAEncPictureType picture_type) -{ - VAEncSequenceParameterBufferMPEG2 *seq_param; - VAEncPictureParameterBufferMPEG2 *pic_param; - VAEncSliceParameterBufferMPEG2 *slice_param; - VAStatus va_status; - int i, width_in_mbs, height_in_mbs; - - pic_param = &ctx->pic_param; - assert(pic_param->picture_coding_extension.bits.q_scale_type == 0); - - seq_param = &ctx->seq_param; - width_in_mbs = (seq_param->picture_width + 15) / 16; - height_in_mbs = (seq_param->picture_height + 15) / 16; - ctx->num_slice_groups = 1; - - for (i = 0; i < height_in_mbs; i++) { - slice_param = &ctx->slice_param[i]; - slice_param->macroblock_address = i * width_in_mbs; - slice_param->num_macroblocks = width_in_mbs; - slice_param->is_intra_slice = (picture_type == VAEncPictureTypeIntra); - slice_param->quantiser_scale_code = ctx->qp / 2; - } - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncSliceParameterBufferType, - sizeof(*slice_param), - height_in_mbs, - ctx->slice_param, - ctx->slice_param_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer");; -} - -static int -begin_picture(struct mpeg2enc_context *ctx, - int coded_order, - int display_order, - VAEncPictureType picture_type) -{ - VAStatus va_status; - int tmp; - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_seq_buffer = NULL, *packed_pic_buffer = NULL; - - if (ctx->upload_thread_value != 0) { - fprintf(stderr, "FATAL error!!!\n"); - exit(1); - } - - pthread_join(ctx->upload_thread_id, NULL); - - ctx->upload_thread_value = -1; - tmp = ctx->current_input_surface; - ctx->current_input_surface = ctx->current_upload_surface; - ctx->current_upload_surface = tmp; - - mpeg2enc_update_sequence_parameter(ctx, picture_type, coded_order, display_order); - mpeg2enc_update_picture_parameter(ctx, picture_type, coded_order, display_order); - - if (ctx->new_sequence || ctx->new_gop_header) { - assert(picture_type == VAEncPictureTypeIntra); - length_in_bits = build_packed_seq_buffer(ctx, &ctx->seq_param, &packed_seq_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderMPEG2_SPS; - packed_header_param_buffer.has_emulation_bytes = 0; - packed_header_param_buffer.bit_length = length_in_bits; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &ctx->packed_seq_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_seq_buffer, - &ctx->packed_seq_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_seq_buffer); - } - - length_in_bits = build_packed_pic_buffer(&ctx->seq_param, &ctx->pic_param, &packed_pic_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderMPEG2_PPS; - packed_header_param_buffer.has_emulation_bytes = 0; - packed_header_param_buffer.bit_length = length_in_bits; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), 1, &packed_header_param_buffer, - &ctx->packed_pic_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, 1, packed_pic_buffer, - &ctx->packed_pic_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_pic_buffer); - - /* sequence parameter set */ - VAEncSequenceParameterBufferMPEG2 *seq_param = &ctx->seq_param; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncSequenceParameterBufferType, - sizeof(*seq_param), - 1, - seq_param, - &ctx->seq_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - - /* slice parameter */ - mpeg2enc_update_slice_parameter(ctx, picture_type); - - return 0; -} - -static int -mpeg2enc_render_picture(struct mpeg2enc_context *ctx) -{ - VAStatus va_status; - VABufferID va_buffers[16]; - unsigned int num_va_buffers = 0; - - va_buffers[num_va_buffers++] = ctx->seq_param_buf_id; - va_buffers[num_va_buffers++] = ctx->pic_param_buf_id; - - if (ctx->packed_seq_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_seq_header_param_buf_id; - - if (ctx->packed_seq_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_seq_buf_id; - - if (ctx->packed_pic_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_pic_header_param_buf_id; - - if (ctx->packed_pic_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_pic_buf_id; - - va_status = vaBeginPicture(ctx->va_dpy, - ctx->context_id, - surface_ids[ctx->current_input_surface]); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - va_buffers, - num_va_buffers); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->slice_param_buf_id[0], - ctx->num_slice_groups); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaEndPicture(ctx->va_dpy, ctx->context_id); - CHECK_VASTATUS(va_status,"vaEndPicture"); - - return 0; -} - -static int -mpeg2enc_destroy_buffers(struct mpeg2enc_context *ctx, VABufferID *va_buffers, unsigned int num_va_buffers) -{ - VAStatus va_status; - unsigned int i; - - for (i = 0; i < num_va_buffers; i++) { - if (va_buffers[i] != VA_INVALID_ID) { - va_status = vaDestroyBuffer(ctx->va_dpy, va_buffers[i]); - CHECK_VASTATUS(va_status,"vaDestroyBuffer"); - va_buffers[i] = VA_INVALID_ID; - } - } - - return 0; -} - -static void -end_picture(struct mpeg2enc_context *ctx, VAEncPictureType picture_type, int next_is_bpic) -{ - VABufferID tempID; - - /* Prepare for next picture */ - tempID = surface_ids[SID_RECON_PICTURE]; - - if (picture_type != VAEncPictureTypeBidirectional) { - if (next_is_bpic) { - surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE_L1]; - surface_ids[SID_REFERENCE_PICTURE_L1] = tempID; - } else { - surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE_L0]; - surface_ids[SID_REFERENCE_PICTURE_L0] = tempID; - } - } else { - if (!next_is_bpic) { - surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE_L0]; - surface_ids[SID_REFERENCE_PICTURE_L0] = surface_ids[SID_REFERENCE_PICTURE_L1]; - surface_ids[SID_REFERENCE_PICTURE_L1] = tempID; - } - } - - mpeg2enc_destroy_buffers(ctx, &ctx->seq_param_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->pic_param_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->packed_seq_header_param_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->packed_seq_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->packed_pic_header_param_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->packed_pic_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->slice_param_buf_id[0], ctx->num_slice_groups); - mpeg2enc_destroy_buffers(ctx, &ctx->codedbuf_buf_id, 1); - memset(ctx->slice_param, 0, sizeof(ctx->slice_param)); - ctx->num_slice_groups = 0; -} - -static int -store_coded_buffer(struct mpeg2enc_context *ctx, VAEncPictureType picture_type) -{ - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int slice_data_length; - VAStatus va_status; - VASurfaceStatus surface_status; - size_t w_items; - - va_status = vaSyncSurface(ctx->va_dpy, surface_ids[ctx->current_input_surface]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - - surface_status = 0; - va_status = vaQuerySurfaceStatus(ctx->va_dpy, surface_ids[ctx->current_input_surface], &surface_status); - CHECK_VASTATUS(va_status,"vaQuerySurfaceStatus"); - - va_status = vaMapBuffer(ctx->va_dpy, ctx->codedbuf_buf_id, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - coded_mem = coded_buffer_segment->buf; - - if (coded_buffer_segment->status & VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK) { - if (picture_type == VAEncPictureTypeIntra) - ctx->codedbuf_i_size *= 2; - else - ctx->codedbuf_pb_size *= 2; - - vaUnmapBuffer(ctx->va_dpy, ctx->codedbuf_buf_id); - return -1; - } - - slice_data_length = coded_buffer_segment->size; - - do { - w_items = fwrite(coded_mem, slice_data_length, 1, ctx->ofp); - } while (w_items != 1); - - if (picture_type == VAEncPictureTypeIntra) { - if (ctx->codedbuf_i_size > slice_data_length * 3 / 2) { - ctx->codedbuf_i_size = slice_data_length * 3 / 2; - } - - if (ctx->codedbuf_pb_size < slice_data_length) { - ctx->codedbuf_pb_size = slice_data_length; - } - } else { - if (ctx->codedbuf_pb_size > slice_data_length * 3 / 2) { - ctx->codedbuf_pb_size = slice_data_length * 3 / 2; - } - } - - vaUnmapBuffer(ctx->va_dpy, ctx->codedbuf_buf_id); - - return 0; -} - -static void -encode_picture(struct mpeg2enc_context *ctx, - int coded_order, - int display_order, - VAEncPictureType picture_type, - int next_is_bpic, - int next_display_order) -{ - VAStatus va_status; - int ret = 0, codedbuf_size; - - begin_picture(ctx, coded_order, display_order, picture_type); - - if (1) { - /* upload YUV data to VA surface for next frame */ - if (next_display_order >= ctx->num_pictures) - next_display_order = ctx->num_pictures - 1; - - fseek(ctx->ifp, ctx->frame_size * next_display_order, SEEK_SET); - ctx->upload_thread_value = pthread_create(&ctx->upload_thread_id, - NULL, - upload_yuv_to_surface, - ctx); - } - - do { - mpeg2enc_destroy_buffers(ctx, &ctx->codedbuf_buf_id, 1); - mpeg2enc_destroy_buffers(ctx, &ctx->pic_param_buf_id, 1); - - - if (VAEncPictureTypeIntra == picture_type) { - codedbuf_size = ctx->codedbuf_i_size; - } else { - codedbuf_size = ctx->codedbuf_pb_size; - } - - /* coded buffer */ - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncCodedBufferType, - codedbuf_size, 1, NULL, - &ctx->codedbuf_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - /* picture parameter set */ - mpeg2enc_update_picture_parameter_buffer(ctx, picture_type, coded_order, display_order); - - mpeg2enc_render_picture(ctx); - - ret = store_coded_buffer(ctx, picture_type); - } while (ret); - - end_picture(ctx, picture_type, next_is_bpic); -} - -static void -update_next_frame_info(struct mpeg2enc_context *ctx, - VAEncPictureType curr_type, - int curr_coded_order, - int curr_display_order) -{ - if (((curr_coded_order + 1) % ctx->intra_period) == 0) { - ctx->next_type = VAEncPictureTypeIntra; - ctx->next_display_order = curr_coded_order + 1; - - return; - } - - if (curr_type == VAEncPictureTypeIntra) { - assert(curr_display_order == curr_coded_order); - ctx->next_type = VAEncPictureTypePredictive; - ctx->next_bframes = ctx->ip_period; - ctx->next_display_order = curr_display_order + ctx->next_bframes + 1; - } else if (curr_type == VAEncPictureTypePredictive) { - if (ctx->ip_period == 0) { - assert(curr_display_order == curr_coded_order); - ctx->next_type = VAEncPictureTypePredictive; - ctx->next_display_order = curr_display_order + 1; - } else { - ctx->next_type = VAEncPictureTypeBidirectional; - ctx->next_display_order = curr_display_order - ctx->next_bframes; - ctx->next_bframes--; - } - } else if (curr_type == VAEncPictureTypeBidirectional) { - if (ctx->next_bframes == 0) { - ctx->next_type = VAEncPictureTypePredictive; - ctx->next_bframes = ctx->ip_period; - ctx->next_display_order = curr_display_order + ctx->next_bframes + 2; - } else { - ctx->next_type = VAEncPictureTypeBidirectional; - ctx->next_display_order = curr_display_order + 1; - ctx->next_bframes--; - } - } - - if (ctx->next_display_order >= ctx->num_pictures) { - int rtmp = ctx->next_display_order - (ctx->num_pictures - 1); - ctx->next_display_order = ctx->num_pictures - 1; - ctx->next_bframes -= rtmp; - } -} - -static void -mpeg2enc_run(struct mpeg2enc_context *ctx) -{ - int display_order = 0, coded_order = 0; - VAEncPictureType type; - - ctx->new_sequence = 1; - ctx->new_gop_header = 1; - ctx->gop_header_in_display_order = display_order; - - while (coded_order < ctx->num_pictures) { - type = ctx->next_type; - display_order = ctx->next_display_order; - /* follow the IPBxxBPBxxB mode */ - update_next_frame_info(ctx, type, coded_order, display_order); - encode_picture(ctx, - coded_order, - display_order, - type, - ctx->next_type == VAEncPictureTypeBidirectional, - ctx->next_display_order); - - /* update gop_header */ - ctx->new_sequence = 0; - ctx->new_gop_header = ctx->next_type == VAEncPictureTypeIntra; - - if (ctx->new_gop_header) - ctx->gop_header_in_display_order += ctx->intra_period; - - coded_order++; - - fprintf(stderr, "\r %d/%d ...", coded_order, ctx->num_pictures); - fflush(stdout); - } -} - -/* - * end - */ -static void -mpeg2enc_release_va_resources(struct mpeg2enc_context *ctx) -{ - vaDestroySurfaces(ctx->va_dpy, surface_ids, SID_NUMBER); - vaDestroyContext(ctx->va_dpy, ctx->context_id); - vaDestroyConfig(ctx->va_dpy, ctx->config_id); - vaTerminate(ctx->va_dpy); - va_close_display(ctx->va_dpy); -} - -static void -mpeg2enc_end(struct mpeg2enc_context *ctx) -{ - pthread_join(ctx->upload_thread_id, NULL); - mpeg2enc_release_va_resources(ctx); -} - -int -main(int argc, char *argv[]) -{ - struct mpeg2enc_context ctx; - struct timeval tpstart, tpend; - float timeuse; - - gettimeofday(&tpstart, NULL); - - memset(&ctx, 0, sizeof(ctx)); - parse_args(&ctx, argc, argv); - mpeg2enc_init(&ctx); - mpeg2enc_run(&ctx); - mpeg2enc_end(&ctx); - - gettimeofday(&tpend, NULL); - timeuse = 1000000 * (tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; - timeuse /= 1000000; - fprintf(stderr, "\ndone!\n"); - fprintf(stderr, "encode %d frames in %f secondes, FPS is %.1f\n", ctx.num_pictures, timeuse, ctx.num_pictures / timeuse); - - mpeg2enc_exit(&ctx, 0); - - return 0; -} diff --git a/test/encode/svctenc.c b/test/encode/svctenc.c deleted file mode 100644 index f7406c5..0000000 --- a/test/encode/svctenc.c +++ /dev/null @@ -1,3104 +0,0 @@ -/* - * Copyright (c) 2016 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. - */ - -/* - * Simple H.264/AVC temporal scalability encoder based on libVA. - * - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "va_display.h" - -#define SLICE_TYPE_P 0 -#define SLICE_TYPE_B 1 -#define SLICE_TYPE_I 2 - -#define IS_I_SLICE(type) (SLICE_TYPE_I == (type) || SLICE_TYPE_I == (type - 5)) -#define IS_P_SLICE(type) (SLICE_TYPE_P == (type) || SLICE_TYPE_P == (type - 5)) -#define IS_B_SLICE(type) (SLICE_TYPE_B == (type) || SLICE_TYPE_B == (type - 5)) - -#define NAL_REF_IDC_NONE 0 -#define NAL_REF_IDC_LOW 1 -#define NAL_REF_IDC_MEDIUM 2 -#define NAL_REF_IDC_HIGH 3 - -#define NAL_NON_IDR 1 -#define NAL_IDR 5 -#define NAL_SEI 6 -#define NAL_SPS 7 -#define NAL_PPS 8 -#define NAL_PREFIX 14 -#define NAL_SUBSET_SPS 15 - -#define ENTROPY_MODE_CAVLC 0 -#define ENTROPY_MODE_CABAC 1 - -#define PROFILE_IDC_BASELINE 66 -#define PROFILE_IDC_MAIN 77 -#define PROFILE_IDC_SCALABLE_BASELINE 83 -#define PROFILE_IDC_SCALABLE_HIGH 86 -#define PROFILE_IDC_HIGH 100 - -#define SRC_SURFACE_IN_ENCODING 0 -#define SRC_SURFACE_IN_STORAGE 1 - -#define NUM_SURFACES 32 - -#define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) - -#define CHECK_VASTATUS(va_status, func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed, exit\n", __func__, func, __LINE__); \ - exit(1); \ - } - -#define MAX_SLICES 32 -#define MAX_LAYERS 4 - -#define MIN(a, b) ((a) > (b) ? (b) : (a)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -static VASurfaceID src_surfaces[NUM_SURFACES]; -static VASurfaceID rec_surfaces[NUM_SURFACES]; -static int src_surface_status[NUM_SURFACES]; - -static int temporal_ids_in_bgop[16] = { // index is (encoding order) % gop_size - 1, available from the 2nd encoded frame - 0, /* temporal 0 */ - 1, /* temporal 1 */ - 2, 2, /* temporal 2 */ - 3, 3, 3, 3, /* temporal 3 */ - 4, 4, 4, 4, 4, 4, 4, 4 /* temporal 4 */ -}; - -static int temporal_ids_in_pgop[16] = { // index is (encoding order) % gop_size - 1, available from the 2nd encoded frame - 1, 2, 1, 3, // each element is (the number of temporal layers - temporal id) - 1, 2, 1, 3, - 1, 2, 1, 3, - 1, 2, 1, 3, -}; - -static int gop_factors_in_bgop[16] = { - 1, - 1, - 1, 3, - 1, 3, 5, 7, - 1, 3, 5, 7, 9, 11, 13, 15 -}; - -static float frame_rates[4] = { - 7.5, - 15, - 30, - 60, -}; - -static VAProfile g_va_profiles[] = { - VAProfileH264High, - VAProfileH264Baseline, - VAProfileH264ConstrainedBaseline, -}; - -typedef struct _svcenc_surface -{ - int slot_in_surfaces; /* index in src_surfaces and rec_surfaces */ - int coding_order; - int display_order; - int temporal_id; - int frame_num; - int poc; - unsigned int is_intra : 1; - unsigned int is_idr : 1; - unsigned int is_ref : 1; - VAEncPictureType picture_type; - VASurfaceID rec_surface; -} svcenc_surface; - -static svcenc_surface ref_frames[16], ref_list0[32], ref_list1[32]; - -static pthread_mutex_t upload_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t upload_cond = PTHREAD_COND_INITIALIZER; - -struct upload_task_t { - void *next; - unsigned int display_order; - unsigned int surface; -}; - -struct svcenc_context -{ - /* parameter info */ - FILE *ifp; /* a FILE pointer for source YUV file */ - FILE *ofp; /* a FILE pointer for output SVC file */ - int width; - int height; - int frame_size; - int num_pictures; - int num_slices; - int qp; /* quantisation parameter, default value is 26 */ - unsigned char *frame_data_buffer; /* buffer for input surface, the length is the maximum frame_size */ - int gop_size; - int max_num_ref_frames; - int num_ref_frames; - int hierarchical_levels; - int layer_brc; - - /* the info for next picture in encoding order */ - svcenc_surface next_svcenc_surface; - - /* GOP info */ - int intra_idr_period; - int intra_period; - int ip_period; - int num_remainder_bframes; - int gop_type; /* 0: p hierarchical, 1: B hierarchical, default is 0 */ - - /* bitrate info */ - int rate_control_mode; - int bits_per_kbps; - int framerate_per_100s; - int i_initial_cpb_removal_delay; - int i_initial_cpb_removal_delay_offset; - int i_initial_cpb_removal_delay_length; - int i_cpb_removal_delay; - int i_cpb_removal_delay_length; - int i_dpb_output_delay_length; - int time_offset_length; - - unsigned long long idr_frame_num; - unsigned long long prev_idr_cpb_removal; - unsigned long long current_idr_cpb_removal; - unsigned long long current_cpb_removal; - - /* This is relative to the current_cpb_removal */ - unsigned int current_dpb_removal_delta; - - int profile_idc; - int constraint_set_flag; - - int svc_profile_idc; - int svc_constraint_set_flag; - - /* reordering info for l0/l1, - * bit0-3: ref_pic_list_modification_flag_lX (X=0,1), - * bit4-7: modification_of_pic_nums_idc, - * bit8-15: abs_diff_pic_num_minus1 - * bit16-23: num_ref_idx_active_override_flag - * bit24-31: num_ref_idx_lX_active_minus1 (X=0,1), - */ - unsigned int reordering_info[2]; - - /* VA info */ - VADisplay va_dpy; - VAProfile profile; - VAEncSequenceParameterBufferH264 seq_param; - VAEncPictureParameterBufferH264 pic_param; - VAEncSliceParameterBufferH264 slice_param[MAX_SLICES]; - VAContextID context_id; - VAConfigID config_id; - VABufferID seq_param_buf_id; /* Sequence level parameter */ - VABufferID pic_param_buf_id; /* Picture level parameter */ - VABufferID slice_param_buf_id[MAX_SLICES]; /* Slice level parameter, multil slices */ - VABufferID codedbuf_buf_id; /* Output buffer, compressed data */ - VABufferID packed_sei_scalability_info_header_param_buf_id; - VABufferID packed_sei_scalability_info_buf_id; - VABufferID packed_seq_header_param_buf_id; - VABufferID packed_seq_buf_id; - VABufferID packed_svc_seq_header_param_buf_id; - VABufferID packed_svc_seq_buf_id; - VABufferID packed_pic_header_param_buf_id; - VABufferID packed_pic_buf_id; - VABufferID packed_sei_header_param_buf_id; /* the SEI buffer */ - VABufferID packed_sei_buf_id; - VABufferID misc_parameter_layer_structure_buf_id; - VABufferID misc_parameter_ratecontrol_buf_id[MAX_LAYERS]; - VABufferID misc_parameter_framerate_buf_id[MAX_LAYERS]; - VABufferID misc_parameter_hrd_buf_id; - VABufferID packed_slice_header_param_buf_id[MAX_SLICES]; - VABufferID packed_slice_header_data_buf_id[MAX_SLICES]; - VABufferID packed_prefix_nal_unit_param_buf_id[MAX_SLICES]; - VABufferID packed_prefix_nal_unit_data_buf_id[MAX_SLICES]; - - /* thread info */ - pthread_t upload_thread; - struct upload_task_t *upload_task_header; - struct upload_task_t *upload_task_tail; -}; - -/* bitstream */ -#define BITSTREAM_ALLOCATE_STEPPING 4096 - -struct __bitstream { - unsigned int *buffer; - int bit_offset; - int max_size_in_dword; -}; - -typedef struct __bitstream bitstream; - -static unsigned int -va_swap32(unsigned int val) -{ - unsigned char *pval = (unsigned char *)&val; - - return ((pval[0] << 24) | - (pval[1] << 16) | - (pval[2] << 8) | - (pval[3] << 0)); -} - -static void -bitstream_start(bitstream *bs) -{ - bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1); - bs->bit_offset = 0; -} - -static void -bitstream_end(bitstream *bs) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (bit_offset) { - bs->buffer[pos] = va_swap32((bs->buffer[pos] << bit_left)); - } -} - -static void -bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits) -{ - int pos = (bs->bit_offset >> 5); - int bit_offset = (bs->bit_offset & 0x1f); - int bit_left = 32 - bit_offset; - - if (!size_in_bits) - return; - - bs->bit_offset += size_in_bits; - - if (bit_left > size_in_bits) { - bs->buffer[pos] = (bs->buffer[pos] << size_in_bits | val); - } else { - size_in_bits -= bit_left; - bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits); - bs->buffer[pos] = va_swap32(bs->buffer[pos]); - - if (pos + 1 == bs->max_size_in_dword) { - bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING; - bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int)); - } - - bs->buffer[pos + 1] = val; - } -} - -static void -bitstream_put_ue(bitstream *bs, unsigned int val) -{ - int size_in_bits = 0; - int tmp_val = ++val; - - while (tmp_val) { - tmp_val >>= 1; - size_in_bits++; - } - - bitstream_put_ui(bs, 0, size_in_bits - 1); // leading zero - bitstream_put_ui(bs, val, size_in_bits); -} - -static void -bitstream_put_se(bitstream *bs, int val) -{ - unsigned int new_val; - - if (val <= 0) - new_val = -2 * val; - else - new_val = 2 * val - 1; - - bitstream_put_ue(bs, new_val); -} - -static void -bitstream_byte_aligning(bitstream *bs, int bit) -{ - int bit_offset = (bs->bit_offset & 0x7); - int bit_left = 8 - bit_offset; - int new_val; - - if (!bit_offset) - return; - - assert(bit == 0 || bit == 1); - - if (bit) - new_val = (1 << bit_left) - 1; - else - new_val = 0; - - bitstream_put_ui(bs, new_val, bit_left); -} - -static void -rbsp_trailing_bits(bitstream *bs) -{ - bitstream_put_ui(bs, 1, 1); - bitstream_byte_aligning(bs, 0); -} - -static void -nal_start_code_prefix(bitstream *bs) -{ - bitstream_put_ui(bs, 0x00000001, 32); -} - -static void -nal_header(bitstream *bs, int nal_ref_idc, int nal_unit_type) -{ - bitstream_put_ui(bs, 0, 1); /* forbidden_zero_bit: 0 */ - bitstream_put_ui(bs, nal_ref_idc, 2); - bitstream_put_ui(bs, nal_unit_type, 5); -} - -static void -sps_data(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - bitstream *bs) -{ - bitstream_put_ui(bs, ctx->profile_idc, 8); /* profile_idc */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 1), 1); /* constraint_set0_flag */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 2), 1); /* constraint_set1_flag */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 4), 1); /* constraint_set2_flag */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 8), 1); /* constraint_set3_flag */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 16), 1); /* constraint_set4_flag */ - bitstream_put_ui(bs, !!(ctx->constraint_set_flag & 32), 1); /* constraint_set5_flag */ - bitstream_put_ui(bs, 0, 2); /* reserved_zero_2bits */ - bitstream_put_ui(bs, seq_param->level_idc, 8); /* level_idc */ - bitstream_put_ue(bs, seq_param->seq_parameter_set_id); /* seq_parameter_set_id */ - - if (ctx->profile_idc == PROFILE_IDC_HIGH || - ctx->profile_idc == PROFILE_IDC_SCALABLE_HIGH || - ctx->profile_idc == PROFILE_IDC_SCALABLE_BASELINE) { - bitstream_put_ue(bs, 1); /* chroma_format_idc = 1, 4:2:0 */ - bitstream_put_ue(bs, 0); /* bit_depth_luma_minus8 */ - bitstream_put_ue(bs, 0); /* bit_depth_chroma_minus8 */ - bitstream_put_ui(bs, 0, 1); /* qpprime_y_zero_transform_bypass_flag */ - bitstream_put_ui(bs, 0, 1); /* seq_scaling_matrix_present_flag */ - } - - bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_frame_num_minus4); /* log2_max_frame_num_minus4 */ - bitstream_put_ue(bs, seq_param->seq_fields.bits.pic_order_cnt_type); /* pic_order_cnt_type */ - - if (seq_param->seq_fields.bits.pic_order_cnt_type == 0) - bitstream_put_ue(bs, seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4); /* log2_max_pic_order_cnt_lsb_minus4 */ - else { - assert(0); - } - - bitstream_put_ue(bs, seq_param->max_num_ref_frames); /* num_ref_frames */ - bitstream_put_ui(bs, 0, 1); /* gaps_in_frame_num_value_allowed_flag */ - - bitstream_put_ue(bs, seq_param->picture_width_in_mbs - 1); /* pic_width_in_mbs_minus1 */ - bitstream_put_ue(bs, seq_param->picture_height_in_mbs - 1); /* pic_height_in_map_units_minus1 */ - bitstream_put_ui(bs, seq_param->seq_fields.bits.frame_mbs_only_flag, 1); /* frame_mbs_only_flag */ - - if (!seq_param->seq_fields.bits.frame_mbs_only_flag) { - assert(0); - } - - bitstream_put_ui(bs, seq_param->seq_fields.bits.direct_8x8_inference_flag, 1); /* direct_8x8_inference_flag */ - bitstream_put_ui(bs, seq_param->frame_cropping_flag, 1); /* frame_cropping_flag */ - - if (seq_param->frame_cropping_flag) { - bitstream_put_ue(bs, seq_param->frame_crop_left_offset); /* frame_crop_left_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_right_offset); /* frame_crop_right_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_top_offset); /* frame_crop_top_offset */ - bitstream_put_ue(bs, seq_param->frame_crop_bottom_offset); /* frame_crop_bottom_offset */ - } - - if (ctx->bits_per_kbps < 0) { - bitstream_put_ui(bs, 0, 1); /* vui_parameters_present_flag */ - } else { - bitstream_put_ui(bs, 1, 1); /* vui_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* aspect_ratio_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* overscan_info_present_flag */ - bitstream_put_ui(bs, 0, 1); /* video_signal_type_present_flag */ - bitstream_put_ui(bs, 0, 1); /* chroma_loc_info_present_flag */ - bitstream_put_ui(bs, 1, 1); /* timing_info_present_flag */ - { - bitstream_put_ui(bs, seq_param->num_units_in_tick, 32); - bitstream_put_ui(bs, seq_param->time_scale, 32); - bitstream_put_ui(bs, 1, 1); - } - bitstream_put_ui(bs, 1, 1); /* nal_hrd_parameters_present_flag */ - { - // hrd_parameters - bitstream_put_ue(bs, 0); /* cpb_cnt_minus1 */ - bitstream_put_ui(bs, 0, 4); /* bit_rate_scale */ - bitstream_put_ui(bs, 2, 4); /* cpb_size_scale */ - - /* the bits_per_kbps is in kbps */ - bitstream_put_ue(bs, (((ctx->bits_per_kbps * 1024) >> 6) - 1)); /* bit_rate_value_minus1[0] */ - bitstream_put_ue(bs, ((ctx->bits_per_kbps * 8 * 1024) >> 6) - 1); /* cpb_size_value_minus1[0] */ - bitstream_put_ui(bs, 1, 1); /* cbr_flag[0] */ - - /* initial_cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, (ctx->i_initial_cpb_removal_delay_length - 1), 5); - /* cpb_removal_delay_length_minus1 */ - bitstream_put_ui(bs, (ctx->i_cpb_removal_delay_length - 1), 5); - /* dpb_output_delay_length_minus1 */ - bitstream_put_ui(bs, (ctx->i_dpb_output_delay_length - 1), 5); - /* time_offset_length */ - bitstream_put_ui(bs, (ctx->time_offset_length - 1), 5); - } - - bitstream_put_ui(bs, 0, 1); /* vcl_hrd_parameters_present_flag */ - bitstream_put_ui(bs, 0, 1); /* low_delay_hrd_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_struct_present_flag */ - bitstream_put_ui(bs, 0, 1); /* bitstream_restriction_flag */ - } -} - -static void -sps_svc_extension(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *sps_param, - bitstream *bs) -{ - bitstream_put_ui(bs, 0, 1); /* inter_layer_deblocking_filter_control_present_flag */ - bitstream_put_ui(bs, 0, 2); /* extended_spatial_scalability_idc */ - - /* if (ChromaArrayType == 1) */ - bitstream_put_ui(bs, 0, 1); /* chroma_phase_x_plus1_flag */ - bitstream_put_ui(bs, 1, 2); /* chroma_phase_y_plus1 */ - -#if 0 - if (extended_spatial_scalability_idc == 1) { - /* if (ChromaArrayType > 0) */ - bitstream_put_ui(bs, 0, 1); /* seq_ref_layer_chroma_phase_x_plus1_flag */ - bitstream_put_ui(bs, 0, 2); /* seq_ref_layer_chroma_phase_y_plus1 */ - - bitstream_put_se(bs, 0); /* seq_scaled_ref_layer_left_offset */ - bitstream_put_se(bs, 0); /* seq_scaled_ref_layer_top_offset */ - bitstream_put_se(bs, 0); /* seq_scaled_ref_layer_right_offset */ - bitstream_put_se(bs, 0); /* seq_scaled_ref_layer_bottom_offset */ - } -#endif - - bitstream_put_ui(bs, 0, 1); /* seq_tcoeff_level_prediction_flag */ - -#if 0 - if (seq_tcoeff_level_prediction_flag) - bitstream_put_ui(bs, 0, 1); /* adaptive_tcoeff_level_prediction_flag */ -#endif - - bitstream_put_ui(bs, 0, 1); /* slice_header_restriction_flag */ -} - -static void -sps_svc_vui_parameters_extension(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *sps_param, - bitstream *bs) -{ - bitstream_put_ui(bs, 0, 1); /* svc_vui_parameters_present_flag */ -} - -static void -sps_additional_extension2(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *sps_param, - bitstream *bs) -{ - bitstream_put_ui(bs, 0, 1); /* additional_extension2_flag */ -} - -static void -pps_rbsp(struct svcenc_context *ctx, - const VAEncPictureParameterBufferH264 *pic_param, - bitstream *bs) -{ - bitstream_put_ue(bs, pic_param->pic_parameter_set_id); /* pic_parameter_set_id */ - bitstream_put_ue(bs, pic_param->seq_parameter_set_id); /* seq_parameter_set_id */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.entropy_coding_mode_flag, 1); /* entropy_coding_mode_flag */ - - bitstream_put_ui(bs, 0, 1); /* pic_order_present_flag: 0 */ - - bitstream_put_ue(bs, 0); /* num_slice_groups_minus1 */ - - bitstream_put_ue(bs, pic_param->num_ref_idx_l0_active_minus1); /* num_ref_idx_l0_active_minus1 */ - bitstream_put_ue(bs, pic_param->num_ref_idx_l1_active_minus1); /* num_ref_idx_l1_active_minus1 1 */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.weighted_pred_flag, 1); /* weighted_pred_flag: 0 */ - bitstream_put_ui(bs, pic_param->pic_fields.bits.weighted_bipred_idc, 2); /* weighted_bipred_idc: 0 */ - - bitstream_put_se(bs, pic_param->pic_init_qp - 26); /* pic_init_qp_minus26 */ - bitstream_put_se(bs, 0); /* pic_init_qs_minus26 */ - bitstream_put_se(bs, 0); /* chroma_qp_index_offset */ - - bitstream_put_ui(bs, pic_param->pic_fields.bits.deblocking_filter_control_present_flag, 1); /* deblocking_filter_control_present_flag */ - bitstream_put_ui(bs, 0, 1); /* constrained_intra_pred_flag */ - bitstream_put_ui(bs, 0, 1); /* redundant_pic_cnt_present_flag */ - - /* more_rbsp_data */ - bitstream_put_ui(bs, pic_param->pic_fields.bits.transform_8x8_mode_flag, 1); /*transform_8x8_mode_flag */ - bitstream_put_ui(bs, 0, 1); /* pic_scaling_matrix_present_flag */ - bitstream_put_se(bs, pic_param->second_chroma_qp_index_offset ); /*second_chroma_qp_index_offset */ - - rbsp_trailing_bits(bs); -} - -static int -build_packed_seq_buffer(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_SPS); - - sps_data(ctx, seq_param, &bs); - rbsp_trailing_bits(&bs); /* rbsp_trailing_bits */ - - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_subset_seq_buffer(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_SUBSET_SPS); - - sps_data(ctx, seq_param, &bs); - sps_svc_extension(ctx, seq_param, &bs); - sps_svc_vui_parameters_extension(ctx, seq_param, &bs); - sps_additional_extension2(ctx, seq_param, &bs); - rbsp_trailing_bits(&bs); /* rbsp_trailing_bits */ - - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_pic_buffer(struct svcenc_context *ctx, - const VAEncPictureParameterBufferH264 *pic_param, - unsigned char **header_buffer) -{ - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - nal_header(&bs, NAL_REF_IDC_HIGH, NAL_PPS); - pps_rbsp(ctx, pic_param, &bs); - bitstream_end(&bs); - - *header_buffer = (unsigned char *)bs.buffer; - return bs.bit_offset; -} - -static int -build_packed_sei_buffering_period_buffer(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - int frame_num, - unsigned char **sei_buffer) -{ - bitstream sei_bp_bs; - - if (ctx->rate_control_mode & VA_RC_CQP || - frame_num) { - *sei_buffer = NULL; - return 0; - } - - bitstream_start(&sei_bp_bs); - bitstream_put_ue(&sei_bp_bs, seq_param->seq_parameter_set_id); /* seq_parameter_set_id */ - /* SEI buffer period info */ - /* NALHrdBpPresentFlag == 1 */ - bitstream_put_ui(&sei_bp_bs, ctx->i_initial_cpb_removal_delay, ctx->i_initial_cpb_removal_delay_length); - bitstream_put_ui(&sei_bp_bs, ctx->i_initial_cpb_removal_delay_offset, ctx->i_initial_cpb_removal_delay_length); - - if (sei_bp_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_bp_bs, 1, 1); - } - - bitstream_end(&sei_bp_bs); - - *sei_buffer = (unsigned char *)sei_bp_bs.buffer; - - return (sei_bp_bs.bit_offset + 7) / 8; -} - -static int -build_packed_sei_pic_timing_buffer(struct svcenc_context *ctx, int frame_num, unsigned char **sei_buffer) -{ - bitstream sei_pic_bs; - unsigned int cpb_removal_delay; - - if (ctx->rate_control_mode & VA_RC_CQP) { - *sei_buffer = 0; - return 0; - } - - /* SEI pic timing info */ - bitstream_start(&sei_pic_bs); - - /* The info of CPB and DPB delay is controlled by CpbDpbDelaysPresentFlag, - * which is derived as 1 if one of the following conditions is true: - * nal_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - * vcl_hrd_parameters_present_flag is present in the bitstream and is equal to 1, - */ - cpb_removal_delay = (ctx->current_cpb_removal - ctx->prev_idr_cpb_removal); - bitstream_put_ui(&sei_pic_bs, cpb_removal_delay, ctx->i_cpb_removal_delay_length); - bitstream_put_ui(&sei_pic_bs, ctx->current_dpb_removal_delta, ctx->i_dpb_output_delay_length); - - if (sei_pic_bs.bit_offset & 0x7) { - bitstream_put_ui(&sei_pic_bs, 1, 1); - } - - /* The pic_structure_present_flag determines whether the pic_structure - * info is written into the SEI pic timing info. - * Currently it is set to zero. - */ - bitstream_end(&sei_pic_bs); - - *sei_buffer = (unsigned char *)sei_pic_bs.buffer; - - return (sei_pic_bs.bit_offset + 7) / 8; -} - -static int -build_packed_sei_scalability_info_buffer(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - const VAEncPictureParameterBufferH264 *pic_param, - int frame_num, - unsigned char **sei_buffer) -{ - bitstream scalability_info_bs; - int i; - - if (frame_num) { // non IDR - *sei_buffer = NULL; - return 0; - } - - /* Write scalability_info */ - bitstream_start(&scalability_info_bs); - - bitstream_put_ui(&scalability_info_bs, 0, 1); // temporal_id_nesting_flag: false - bitstream_put_ui(&scalability_info_bs, 0, 1); // priority_layer_info_present_flag: false - bitstream_put_ui(&scalability_info_bs, 0, 1); // priority_id_setting_flag: false - bitstream_put_ue(&scalability_info_bs, ctx->hierarchical_levels - 1); // num_layers_minus1 - - for (i = 0; i < ctx->hierarchical_levels; i++) { - bitstream_put_ue(&scalability_info_bs, i); // layer_id[i] - bitstream_put_ui(&scalability_info_bs, 0, 6); // priority_id[i[ - bitstream_put_ui(&scalability_info_bs, 0, 1); // discardable_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 3); // dependency_id[i] - bitstream_put_ui(&scalability_info_bs, 0, 4); // quality_id[i] - bitstream_put_ui(&scalability_info_bs, i, 3); // temporal_id[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // sub_pic_layer_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // sub_region_layer_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // iroi_division_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // profile_level_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // bitrate_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 1, 1); // frm_rate_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 1, 1); // frm_size_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // layer_dependency_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // parameter_sets_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // bitstream_restriction_info_present_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // exact_interlayer_pred_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // layer_conversion_flag[i] - bitstream_put_ui(&scalability_info_bs, 0, 1); // layer_output_flag[i] - - bitstream_put_ui(&scalability_info_bs, 0, 2); // constant_frm_bitrate_idc[i] - bitstream_put_ui(&scalability_info_bs, (int)floor(frame_rates[i] * 256 + 0.5), 16); // avg_frm_rate - - bitstream_put_ue(&scalability_info_bs, seq_param->picture_width_in_mbs - 1); // frm_width_in_mbs_minus1 - bitstream_put_ue(&scalability_info_bs, seq_param->picture_height_in_mbs - 1); // frm_height_in_mbs_minus1 - - bitstream_put_ue(&scalability_info_bs, 0); // layer_dependency_info_src_layer_id_delta[i] - bitstream_put_ue(&scalability_info_bs, 0); // parameter_sets_info_src_layer_id_delta[i] - } - - rbsp_trailing_bits(&scalability_info_bs); - bitstream_end(&scalability_info_bs); - - *sei_buffer = (unsigned char *)scalability_info_bs.buffer; - - return (scalability_info_bs.bit_offset + 7) / 8; -} - -static void -svcenc_update_sei_info(struct svcenc_context *ctx, svcenc_surface *current_surface) -{ - unsigned long long frame_interval; - - if (!(ctx->rate_control_mode & VA_RC_CBR)) { - return; - } - - frame_interval = current_surface->coding_order - ctx->idr_frame_num; - - if (current_surface->is_idr) { - ctx->current_cpb_removal = ctx->prev_idr_cpb_removal + frame_interval * 2; - ctx->idr_frame_num = current_surface->coding_order; - ctx->current_idr_cpb_removal = ctx->current_cpb_removal; - - if (ctx->ip_period) - ctx->current_dpb_removal_delta = (ctx->ip_period + 1) * 2; - else - ctx->current_dpb_removal_delta = 2; - } else { - ctx->current_cpb_removal = ctx->current_idr_cpb_removal + frame_interval * 2; - - if (current_surface->picture_type == VAEncPictureTypeIntra || - current_surface->picture_type == VAEncPictureTypePredictive) { - if (ctx->ip_period) - ctx->current_dpb_removal_delta = (ctx->ip_period + 1) * 2; - else - ctx->current_dpb_removal_delta = 2; - } else - ctx->current_dpb_removal_delta = 2; - } -} - -static int -build_packed_sei_buffer(struct svcenc_context *ctx, - const VAEncSequenceParameterBufferH264 *seq_param, - const VAEncPictureParameterBufferH264 *pic_param, - svcenc_surface *current_surface, - unsigned char **sei_buffer) -{ - unsigned char *scalability_info_buffer = NULL, *buffering_period_buffer = NULL, *pic_timing_buffer = NULL; - int scalability_info_size = 0, buffering_period_size = 0, pic_timing_size = 0; - bitstream nal_bs; - int i; - - svcenc_update_sei_info(ctx, current_surface); - - buffering_period_size = build_packed_sei_buffering_period_buffer(ctx, seq_param, current_surface->frame_num, &buffering_period_buffer); - pic_timing_size = build_packed_sei_pic_timing_buffer(ctx, current_surface->frame_num, &pic_timing_buffer); - scalability_info_size = build_packed_sei_scalability_info_buffer(ctx, seq_param, pic_param, current_surface->frame_num, &scalability_info_buffer); - - if (!buffering_period_buffer && - !pic_timing_buffer && - !scalability_info_buffer) { - *sei_buffer = NULL; - return 0; - } - - bitstream_start(&nal_bs); - nal_start_code_prefix(&nal_bs); - nal_header(&nal_bs, NAL_REF_IDC_NONE, NAL_SEI); - - /* Write the SEI buffer */ - if (buffering_period_buffer) { - assert(buffering_period_size); - - bitstream_put_ui(&nal_bs, 0, 8); // last_payload_type_byte: 0 - bitstream_put_ui(&nal_bs, buffering_period_size, 8); // last_payload_size_byte - - for (i = 0; i < buffering_period_size; i++) { - bitstream_put_ui(&nal_bs, buffering_period_buffer[i], 8); - } - - free(buffering_period_buffer); - } - - if (pic_timing_buffer) { - assert(pic_timing_size); - - bitstream_put_ui(&nal_bs, 1, 8); // last_payload_type_byte: 1 - bitstream_put_ui(&nal_bs, pic_timing_size, 8); // last_payload_size_byte - - for (i = 0; i < pic_timing_size; i++) { - bitstream_put_ui(&nal_bs, pic_timing_buffer[i], 8); - } - - free(pic_timing_buffer); - } - - if (scalability_info_buffer) { - assert(scalability_info_size); - - bitstream_put_ui(&nal_bs, 24, 8); // last_payload_type_byte: 24 - bitstream_put_ui(&nal_bs, scalability_info_size, 8); // last_payload_size_byte - - for (i = 0; i < scalability_info_size; i++) { - bitstream_put_ui(&nal_bs, scalability_info_buffer[i], 8); - } - - free(scalability_info_buffer); - } - - rbsp_trailing_bits(&nal_bs); - bitstream_end(&nal_bs); - - *sei_buffer = (unsigned char *)nal_bs.buffer; - - return nal_bs.bit_offset; -} - -static void -slice_header(bitstream *bs, - VAEncSequenceParameterBufferH264 *sps_param, - VAEncPictureParameterBufferH264 *pic_param, - VAEncSliceParameterBufferH264 *slice_param, - unsigned int reordering_info[2]) -{ - int first_mb_in_slice = slice_param->macroblock_address; - int i; - - bitstream_put_ue(bs, first_mb_in_slice); /* first_mb_in_slice: 0 */ - bitstream_put_ue(bs, slice_param->slice_type); /* slice_type */ - bitstream_put_ue(bs, slice_param->pic_parameter_set_id); /* pic_parameter_set_id: 0 */ - bitstream_put_ui(bs, pic_param->frame_num, sps_param->seq_fields.bits.log2_max_frame_num_minus4 + 4); /* frame_num */ - - /* frame_mbs_only_flag == 1 */ - if (!sps_param->seq_fields.bits.frame_mbs_only_flag) { - /* FIXME: */ - assert(0); - } - - if (pic_param->pic_fields.bits.idr_pic_flag) - bitstream_put_ue(bs, slice_param->idr_pic_id); /* idr_pic_id: 0 */ - - if (sps_param->seq_fields.bits.pic_order_cnt_type == 0) { - bitstream_put_ui(bs, pic_param->CurrPic.TopFieldOrderCnt, sps_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 + 4); - /* pic_order_present_flag == 0 */ - } else { - /* FIXME: */ - assert(0); - } - - /* redundant_pic_cnt_present_flag == 0 */ - /* slice type */ - if (IS_P_SLICE(slice_param->slice_type)) { - bitstream_put_ui(bs, !!((reordering_info[0] >> 16) & 0xFF), 1); /* num_ref_idx_active_override_flag: */ - - if ((reordering_info[0] >> 16) & 0xFF) - bitstream_put_ue(bs, (reordering_info[0] >> 24) & 0xFF); /* num_ref_idx_l0_active_minus1 */ - - /* ref_pic_list_reordering */ - if (!reordering_info || !(reordering_info[0] & 0x0F)) - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0: 0 */ - else { - bitstream_put_ui(bs, 1, 1); /* ref_pic_list_reordering_flag_l0: 1 */ - bitstream_put_ue(bs, (reordering_info[0] >> 4) & 0x0F); - bitstream_put_ue(bs, (reordering_info[0] >> 8) & 0xFF); - bitstream_put_ue(bs, 3); /* modification_of_pic_nums_idc: 3 */ - } - } else if (IS_B_SLICE(slice_param->slice_type)) { - bitstream_put_ui(bs, slice_param->direct_spatial_mv_pred_flag, 1); /* direct_spatial_mv_pred: 1 */ - - bitstream_put_ui(bs, ((reordering_info[0] >> 16) & 0xFF) || ((reordering_info[1] >> 16) & 0xFF) , 1); /* num_ref_idx_active_override_flag: */ - - if (((reordering_info[0] >> 16) & 0xFF) || ((reordering_info[1] >> 16) & 0xFF)) { - bitstream_put_ue(bs, (reordering_info[0] >> 24) & 0xFF); /* num_ref_idx_l0_active_minus1 */ - bitstream_put_ue(bs, (reordering_info[1] >> 24) & 0xFF); /* num_ref_idx_l0_active_minus1 */ - } - - /* ref_pic_list_reordering */ - - for (i = 0; i < 2; i++) { - if (!reordering_info || !(reordering_info[i] & 0x0F)) - bitstream_put_ui(bs, 0, 1); /* ref_pic_list_reordering_flag_l0/l1: 0 */ - else { - bitstream_put_ui(bs, 1, 1); /* ref_pic_list_reordering_flag_l0/l1: 1 */ - bitstream_put_ue(bs, (reordering_info[i] >> 4) & 0x0F); - bitstream_put_ue(bs, (reordering_info[i] >> 8) & 0xFF); - bitstream_put_ue(bs, 3); /* modification_of_pic_nums_idc: 3 */ - } - } - } - - if ((pic_param->pic_fields.bits.weighted_pred_flag && - IS_P_SLICE(slice_param->slice_type)) || - ((pic_param->pic_fields.bits.weighted_bipred_idc == 1) && - IS_B_SLICE(slice_param->slice_type))) { - /* FIXME: fill weight/offset table */ - assert(0); - } - - /* dec_ref_pic_marking */ - if (pic_param->pic_fields.bits.reference_pic_flag) { /* nal_ref_idc != 0 */ - unsigned char no_output_of_prior_pics_flag = 0; - unsigned char long_term_reference_flag = 0; - unsigned char adaptive_ref_pic_marking_mode_flag = 0; - - if (pic_param->pic_fields.bits.idr_pic_flag) { - bitstream_put_ui(bs, no_output_of_prior_pics_flag, 1); /* no_output_of_prior_pics_flag: 0 */ - bitstream_put_ui(bs, long_term_reference_flag, 1); /* long_term_reference_flag: 0 */ - } else { - bitstream_put_ui(bs, adaptive_ref_pic_marking_mode_flag, 1); /* adaptive_ref_pic_marking_mode_flag: 0 */ - } - } - - if (pic_param->pic_fields.bits.entropy_coding_mode_flag && - !IS_I_SLICE(slice_param->slice_type)) - bitstream_put_ue(bs, slice_param->cabac_init_idc); /* cabac_init_idc: 0 */ - - bitstream_put_se(bs, slice_param->slice_qp_delta); /* slice_qp_delta: 0 */ - - /* ignore for SP/SI */ - - if (pic_param->pic_fields.bits.deblocking_filter_control_present_flag) { - bitstream_put_ue(bs, slice_param->disable_deblocking_filter_idc); /* disable_deblocking_filter_idc: 0 */ - - if (slice_param->disable_deblocking_filter_idc != 1) { - bitstream_put_se(bs, slice_param->slice_alpha_c0_offset_div2); /* slice_alpha_c0_offset_div2: 2 */ - bitstream_put_se(bs, slice_param->slice_beta_offset_div2); /* slice_beta_offset_div2: 2 */ - } - } - - if (pic_param->pic_fields.bits.entropy_coding_mode_flag) { - bitstream_byte_aligning(bs, 1); - } -} - -static void -nal_header_extension(bitstream *bs, - VAEncPictureParameterBufferH264 *pic_param, - unsigned int temporal_id) -{ - int is_idr = !!pic_param->pic_fields.bits.idr_pic_flag; - - /* 3 bytes */ - bitstream_put_ui(bs, 1, 1); /* svc_extension_flag */ - bitstream_put_ui(bs, !!is_idr, 1); - bitstream_put_ui(bs, 0, 6); /* priority_id */ - bitstream_put_ui(bs, 1, 1); /* no_inter_layer_pred_flag */ - bitstream_put_ui(bs, 0, 3); /* dependency_id */ - bitstream_put_ui(bs, 0, 4); /* quality_id */ - bitstream_put_ui(bs, temporal_id, 3); /* temporal_id */ - bitstream_put_ui(bs, 0, 1); /* use_ref_base_pic_flag */ - bitstream_put_ui(bs, 1, 1); /* discardable_flag */ - bitstream_put_ui(bs, 1, 1); /* output_flag */ - bitstream_put_ui(bs, 3, 2); /* reserved_three_2bits */ -} - -static void -nal_unit_svc_prefix_rbsp(bitstream *bs, int is_ref) -{ - if (is_ref) { - bitstream_put_ui(bs, 0, 1); /* store_ref_base_pic_flag */ - bitstream_put_ui(bs, 0, 1); /* additional_prefix_nal_unit_extension_flag*/ - } else { - /* no more rbsp data */ - } - - rbsp_trailing_bits(bs); -} - -static int -build_packed_svc_prefix_nal_unit(VAEncPictureParameterBufferH264 *pic_param, - unsigned int temporal_id, - unsigned char **nal_unit_buffer) -{ - int is_ref = !!pic_param->pic_fields.bits.reference_pic_flag; - bitstream bs; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - - nal_header(&bs, is_ref ? NAL_REF_IDC_LOW : NAL_REF_IDC_NONE, NAL_PREFIX); - nal_header_extension(&bs, pic_param, temporal_id); - nal_unit_svc_prefix_rbsp(&bs, is_ref); - - bitstream_end(&bs); - *nal_unit_buffer = (unsigned char *)bs.buffer; - - return bs.bit_offset; -} - -static int -build_packed_slice_header_buffer(struct svcenc_context *ctx, - VAEncSequenceParameterBufferH264 *sps_param, - VAEncPictureParameterBufferH264 *pic_param, - VAEncSliceParameterBufferH264 *slice_param, - unsigned int reordering_info[2], - unsigned char **header_buffer) -{ - bitstream bs; - int is_idr = !!pic_param->pic_fields.bits.idr_pic_flag; - int is_ref = !!pic_param->pic_fields.bits.reference_pic_flag; - - bitstream_start(&bs); - nal_start_code_prefix(&bs); - - if (IS_I_SLICE(slice_param->slice_type)) { - nal_header(&bs, NAL_REF_IDC_HIGH, is_idr ? NAL_IDR : NAL_NON_IDR); - } else if (IS_P_SLICE(slice_param->slice_type)) { - assert(!is_idr); - nal_header(&bs, is_ref ? NAL_REF_IDC_MEDIUM : NAL_REF_IDC_NONE, NAL_NON_IDR); - } else { - assert(IS_B_SLICE(slice_param->slice_type)); - assert(!is_idr); - nal_header(&bs, is_ref ? NAL_REF_IDC_LOW : NAL_REF_IDC_NONE, NAL_NON_IDR); - } - - slice_header(&bs, sps_param, pic_param, slice_param, reordering_info); - - bitstream_end(&bs); - *header_buffer = (unsigned char *)bs.buffer; - - return bs.bit_offset; -} - -/* upload thread */ -static struct upload_task_t * -upload_task_dequeue(struct svcenc_context *ctx) -{ - struct upload_task_t *task; - - pthread_mutex_lock(&upload_mutex); - - task = ctx->upload_task_header; - - if (task) { - ctx->upload_task_header = task->next; - - if (!ctx->upload_task_header) - ctx->upload_task_tail = NULL; - } - - pthread_mutex_unlock(&upload_mutex); - - return task; -} - -static int -upload_task_queue(struct svcenc_context *ctx, unsigned int display_order, int surface) -{ - struct upload_task_t *task; - - task = calloc(1, sizeof(struct upload_task_t)); - task->display_order = display_order; - task->surface = surface; - task->next = NULL; - - pthread_mutex_lock(&upload_mutex); - - if (!ctx->upload_task_header) - ctx->upload_task_header = task; - - if (ctx->upload_task_tail) - ctx->upload_task_tail->next = task; - - ctx->upload_task_tail = task; - src_surface_status[surface] = SRC_SURFACE_IN_STORAGE; - pthread_cond_signal(&upload_cond); - - pthread_mutex_unlock(&upload_mutex); - - return 0; -} - -static void -upload_task(struct svcenc_context *ctx, unsigned int display_order, int surface) -{ - VAStatus va_status; - VAImage surface_image; - void *surface_p = NULL; - size_t n_items; - unsigned char *y_src, *u_src, *v_src; - unsigned char *y_dst, *u_dst, *v_dst; - int row, col; - int y_size = ctx->width * ctx->height; - int u_size = (ctx->width >> 1) * (ctx->height >> 1); - - fseek(ctx->ifp, ctx->frame_size * display_order, SEEK_SET); - - do { - n_items = fread(ctx->frame_data_buffer, ctx->frame_size, 1, ctx->ifp); - } while (n_items != 1); - - va_status = vaDeriveImage(ctx->va_dpy, src_surfaces[surface], &surface_image); - CHECK_VASTATUS(va_status,"vaDeriveImage"); - - vaMapBuffer(ctx->va_dpy, surface_image.buf, &surface_p); - assert(VA_STATUS_SUCCESS == va_status); - - y_src = ctx->frame_data_buffer; - u_src = ctx->frame_data_buffer + y_size; /* UV offset for NV12 */ - v_src = ctx->frame_data_buffer + y_size + u_size; - - y_dst = surface_p + surface_image.offsets[0]; - u_dst = surface_p + surface_image.offsets[1]; /* UV offset for NV12 */ - v_dst = surface_p + surface_image.offsets[2]; - - /* Y plane */ - for (row = 0; row < surface_image.height; row++) { - memcpy(y_dst, y_src, surface_image.width); - y_dst += surface_image.pitches[0]; - y_src += ctx->width; - } - - if (surface_image.format.fourcc == VA_FOURCC_NV12) { /* UV plane */ - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col * 2] = u_src[col]; - u_dst[col * 2 + 1] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - u_src += (ctx->width / 2); - v_src += (ctx->width / 2); - } - } else { - for (row = 0; row < surface_image.height / 2; row++) { - for (col = 0; col < surface_image.width / 2; col++) { - u_dst[col] = u_src[col]; - v_dst[col] = v_src[col]; - } - - u_dst += surface_image.pitches[1]; - v_dst += surface_image.pitches[2]; - u_src += (ctx->width / 2); - v_src += (ctx->width / 2); - } - } - - vaUnmapBuffer(ctx->va_dpy, surface_image.buf); - vaDestroyImage(ctx->va_dpy, surface_image.image_id); - - pthread_mutex_lock(&upload_mutex); - src_surface_status[surface] = SRC_SURFACE_IN_ENCODING; - pthread_mutex_unlock(&upload_mutex); -} - -static void * -upload_task_thread(void *data) -{ - struct svcenc_context *ctx = (struct svcenc_context *)data; - int num = 0; - - while (1) { - struct upload_task_t *task; - - task = upload_task_dequeue(ctx); - if (!task) { - pthread_mutex_lock(&upload_mutex); - pthread_cond_wait(&upload_cond, &upload_mutex); - pthread_mutex_unlock(&upload_mutex); - - continue; - } - - upload_task(ctx, task->display_order, task->surface); - free(task); - - if (++num >= ctx->num_pictures) - break; - } - - return 0; -} - -/* main thread */ -static void -usage(char *program) -{ - fprintf(stderr, "Usage: %s --help\n", program); - fprintf(stderr, "\t--help print this message\n"); - fprintf(stderr, "Usage: %s [options] \n", program); - fprintf(stderr, "\t\t\tThe base picture width\n"); - fprintf(stderr, "\t\tThe base picture height\n"); - fprintf(stderr, "\t\tThe input YUV I420 file\n"); - fprintf(stderr, "\t\t\tThe output H.264/SVC file\n\n"); - fprintf(stderr, "\tAvailable options:\n"); - fprintf(stderr, "\t--gop \t\tGOP size, default is 8\n"); - fprintf(stderr, "\t--goptype \tGOP hierarchical type, 0 is P hierarchical GOP, 1 is B hierarchical GOP, default is 0\n"); - fprintf(stderr, "\t--brcmode \tBRC mode, 0 is CQP mode, otherwise CBR mode, default mode is CQP\n"); - fprintf(stderr, "\t--brclayer\tDisable/Enalbe BRC per temporal layer, default is disable(0)\n"); - fprintf(stderr, "\t--bitrate \tbit rate in Kbps(1024 bits). It is available for CBR mode only and default value is 2000\n"); -} - -static void -svcenc_exit(struct svcenc_context *ctx, int exit_code) -{ - if (ctx->ifp) { - fclose(ctx->ifp); - ctx->ifp = NULL; - } - - if (ctx->ofp) { - fclose(ctx->ofp); - ctx->ofp = NULL; - } - - exit(exit_code); -} - -static void -parse_args(struct svcenc_context *ctx, int argc, char **argv) -{ - int c, tmp; - int option_index = 0; - long file_size; - - static struct option long_options[] = { - {"gop", required_argument, 0, 'g'}, - {"goptype", required_argument, 0, 't'}, - {"bitrate", required_argument, 0, 'b'}, - {"brcmode", required_argument, 0, 'm'}, - {"brclayer", required_argument, 0, 'l'}, - {"help", no_argument, 0, 'h'}, - { NULL, 0, NULL, 0 } - }; - - va_init_display_args(&argc, argv); - - if ((argc == 2 && strcmp(argv[1], "--help") == 0) || - (argc < 5)) - goto print_usage; - - ctx->width = atoi(argv[1]); - ctx->height = atoi(argv[2]); - - if (ctx->width <= 0 || ctx->height <= 0) { - fprintf(stderr, " and must be greater than 0\n"); - goto err_exit; - } - - ctx->frame_size = ctx->width * ctx->height * 3 / 2; - ctx->ifp = fopen(argv[3], "rb"); - - if (ctx->ifp == NULL) { - fprintf(stderr, "Can't open the input file\n"); - goto err_exit; - } - - fseek(ctx->ifp, 0l, SEEK_END); - file_size = ftell(ctx->ifp); - - if ((file_size < ctx->frame_size) || - (file_size % ctx->frame_size)) { - fprintf(stderr, "The input file size %ld isn't a multiple of the frame size %d\n", file_size, ctx->frame_size); - goto err_exit; - } - - assert(ctx->num_pictures == 0); - ctx->num_pictures = file_size / ctx->frame_size; - fseek(ctx->ifp, 0l, SEEK_SET); - - ctx->ofp = fopen(argv[4], "wb"); - - if (ctx->ofp == NULL) { - fprintf(stderr, "Can't create the output file\n"); - goto err_exit; - } - - opterr = 0; - optind = 5; - ctx->gop_size = 8; - ctx->gop_type = 0; - ctx->bits_per_kbps = -1; - ctx->rate_control_mode = VA_RC_CQP; - ctx->layer_brc = 0; - - while ((c = getopt_long(argc, argv, - "", - long_options, - &option_index)) != -1) { - switch(c) { - case 'g': - tmp = atoi(optarg); - - if ((tmp & (tmp - 1)) || - tmp > 8) { - fprintf(stderr, "Warning: invalid GOP size\n"); - tmp = 8; - } - - ctx->gop_size = tmp; - - break; - - case 't': - tmp = atoi(optarg); - - ctx->gop_type = !!tmp; - - break; - - case 'b': - tmp = atoi(optarg); - - if (tmp <= 0) - ctx->bits_per_kbps = -1; - else { - if (tmp >= 30000) - tmp = 30000; - - ctx->bits_per_kbps = tmp; - } - - break; - - case 'm': - tmp = atoi(optarg); - - if (tmp == 0) - ctx->rate_control_mode = VA_RC_CQP; - else - ctx->rate_control_mode = VA_RC_CBR; - - break; - - case 'l': - tmp = atoi(optarg); - - ctx->layer_brc = !!tmp; - - break; - - case '?': - fprintf(stderr, "Error: unkown command options\n"); - - case 'h': - goto print_usage; - } - } - - ctx->num_pictures = ((ctx->num_pictures - 1) & ~(ctx->gop_size - 1)) + 1; - - if (ctx->rate_control_mode == VA_RC_CQP) - ctx->bits_per_kbps = -1; - else { - if (ctx->bits_per_kbps == -1) - ctx->bits_per_kbps = 2000; - } - - return; - -print_usage: - usage(argv[0]); -err_exit: - svcenc_exit(ctx, 1); -} - -void -svcenc_update_ref_frames(struct svcenc_context *ctx, svcenc_surface *current_surface) -{ - int i; - - if (!current_surface->is_ref) - return; - - if (current_surface->is_idr) - ctx->num_ref_frames = 1; - else - ctx->num_ref_frames++; - - if (ctx->num_ref_frames > ctx->max_num_ref_frames) - ctx->num_ref_frames = ctx->max_num_ref_frames; - - for (i = ctx->num_ref_frames - 1; i > 0; i--) - ref_frames[i] = ref_frames[i - 1]; - - ref_frames[0] = *current_surface; -} - -static int -svcenc_coding_order_to_display_order(struct svcenc_context *ctx, int coding_order) -{ - int n, m; - int level; - - assert(coding_order > 0); - - n = (coding_order - 1) / ctx->gop_size; - m = (coding_order - 1) % ctx->gop_size; - level = ctx->hierarchical_levels - temporal_ids_in_bgop[m] - 1; - - return n * ctx->gop_size + gop_factors_in_bgop[m] * (int)pow(2.00, level); -} - -static void -update_next_picture_info(struct svcenc_context *ctx) -{ - svcenc_surface *current_surface = NULL; - svcenc_surface next_surface; - int current_frame_num; - - current_surface = &ctx->next_svcenc_surface; - current_frame_num = current_surface->frame_num; - - next_surface.coding_order = current_surface->coding_order + 1; - next_surface.display_order = svcenc_coding_order_to_display_order(ctx, next_surface.coding_order); - next_surface.slot_in_surfaces = (current_surface->slot_in_surfaces + 1) % NUM_SURFACES; - next_surface.temporal_id = temporal_ids_in_bgop[current_surface->coding_order % ctx->gop_size]; - next_surface.is_ref = (next_surface.temporal_id != ctx->hierarchical_levels - 1); - - if (next_surface.temporal_id == 0) { - if (!(next_surface.display_order % ctx->intra_period)) - next_surface.picture_type = VAEncPictureTypeIntra; - else - next_surface.picture_type = VAEncPictureTypePredictive; - } else - next_surface.picture_type = VAEncPictureTypeBidirectional; - - if (current_surface->temporal_id == ctx->hierarchical_levels - 1) - next_surface.frame_num = current_frame_num; - else - next_surface.frame_num = current_frame_num + 1; - - next_surface.is_intra = (next_surface.picture_type == VAEncPictureTypeIntra); - next_surface.is_idr = 0; - next_surface.rec_surface = rec_surfaces[next_surface.slot_in_surfaces]; - next_surface.poc = next_surface.display_order; - - if (next_surface.is_idr) - next_surface.frame_num = 0; - - *current_surface = next_surface; -} - -static int -svcenc_coding_order_to_level_pgop(struct svcenc_context *ctx, int coding_order) -{ - int m; - int level; - - assert(coding_order > 0); - - m = coding_order % ctx->gop_size; - - if (m == 0) - return 0; - - level = ctx->hierarchical_levels - temporal_ids_in_pgop[m - 1]; - - assert(level > 0 && level < 5); - - return level; -} - -static void -update_next_picture_info_pgop(struct svcenc_context *ctx) -{ - svcenc_surface *current_surface = NULL; - svcenc_surface next_surface; - int current_frame_num; - - current_surface = &ctx->next_svcenc_surface; - current_frame_num = current_surface->frame_num; - - next_surface.coding_order = current_surface->coding_order + 1; - next_surface.display_order = next_surface.coding_order; - next_surface.slot_in_surfaces = (current_surface->slot_in_surfaces + 1) % NUM_SURFACES; - next_surface.temporal_id = svcenc_coding_order_to_level_pgop(ctx, next_surface.coding_order); - next_surface.is_ref = (next_surface.temporal_id != ctx->hierarchical_levels - 1); - - if (next_surface.temporal_id == 0) { - if (!(next_surface.display_order % ctx->intra_period)) - next_surface.picture_type = VAEncPictureTypeIntra; - else - next_surface.picture_type = VAEncPictureTypePredictive; - } else { - next_surface.picture_type = VAEncPictureTypePredictive; - } - - next_surface.frame_num = current_frame_num + 1; - next_surface.is_intra = (next_surface.picture_type == VAEncPictureTypeIntra); - next_surface.is_idr = !(next_surface.display_order % ctx->intra_idr_period); - next_surface.rec_surface = rec_surfaces[next_surface.slot_in_surfaces]; - next_surface.poc = next_surface.display_order % ctx->intra_idr_period; - - if (next_surface.is_idr) { - next_surface.frame_num = 0; - assert(next_surface.poc == 0); - } - - *current_surface = next_surface; -} - -static int -svcenc_seq_parameter_set_id(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - return 0; -} - -static int -svcenc_pic_parameter_set_id(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - return 0; -} - -void -svcenc_update_sequence_parameter_buffer(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VAEncSequenceParameterBufferH264 *seq_param = &ctx->seq_param; - VAStatus va_status; - int width_in_mbs = (ctx->width + 15) / 16; - int height_in_mbs = (ctx->height + 15) / 16; - int frame_cropping_flag = 0; - int frame_crop_bottom_offset = 0; - - memset(seq_param, 0, sizeof(*seq_param)); - seq_param->seq_parameter_set_id = svcenc_seq_parameter_set_id(ctx, current_surface); - seq_param->level_idc = 41; - seq_param->intra_period = ctx->intra_period; - seq_param->ip_period = ctx->ip_period; - seq_param->intra_idr_period = ctx->intra_idr_period; - seq_param->max_num_ref_frames = ctx->max_num_ref_frames; - seq_param->picture_width_in_mbs = width_in_mbs; - seq_param->picture_height_in_mbs = height_in_mbs; - seq_param->seq_fields.bits.frame_mbs_only_flag = 1; - - if (ctx->bits_per_kbps > 0) - seq_param->bits_per_second = 1024 * ctx->bits_per_kbps; - else - seq_param->bits_per_second = 0; - - seq_param->time_scale = ctx->framerate_per_100s * 2; - seq_param->num_units_in_tick = 100; - - if (height_in_mbs * 16 - ctx->height) { - frame_cropping_flag = 1; - frame_crop_bottom_offset = - (height_in_mbs * 16 - ctx->height) / (2 * (!seq_param->seq_fields.bits.frame_mbs_only_flag + 1)); - } - - seq_param->frame_cropping_flag = frame_cropping_flag; - seq_param->frame_crop_left_offset = 0; - seq_param->frame_crop_right_offset = 0; - seq_param->frame_crop_top_offset = 0; - seq_param->frame_crop_bottom_offset = frame_crop_bottom_offset; - - seq_param->seq_fields.bits.pic_order_cnt_type = 0; - - if ((ctx->profile_idc == PROFILE_IDC_SCALABLE_HIGH && - ctx->constraint_set_flag & (1 << 3)) || - (ctx->profile_idc == PROFILE_IDC_SCALABLE_BASELINE && - ctx->constraint_set_flag & (1 << 5))) - seq_param->seq_fields.bits.direct_8x8_inference_flag = 0; - else - seq_param->seq_fields.bits.direct_8x8_inference_flag = 1; - - seq_param->seq_fields.bits.log2_max_frame_num_minus4 = 10; - seq_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = 10; - - if (ctx->bits_per_kbps > 0) - seq_param->vui_parameters_present_flag = 1; //HRD info located in vui - else - seq_param->vui_parameters_present_flag = 0; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncSequenceParameterBufferType, - sizeof(*seq_param), - 1, - seq_param, - &ctx->seq_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); -} - -void -svcenc_update_picture_parameter_buffer(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VAEncPictureParameterBufferH264 *pic_param; - VAStatus va_status; - int i; - - /* Allocate the new coded buffer */ - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncCodedBufferType, - ctx->frame_size, - 1, - NULL, - &ctx->codedbuf_buf_id); - assert(ctx->codedbuf_buf_id != VA_INVALID_ID); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - /* H.264 picture parameter */ - pic_param = &ctx->pic_param; - memset(pic_param, 0, sizeof(*pic_param)); - - pic_param->seq_parameter_set_id = svcenc_seq_parameter_set_id(ctx, current_surface); - pic_param->pic_parameter_set_id = svcenc_pic_parameter_set_id(ctx, current_surface); - pic_param->last_picture = 0; - pic_param->pic_init_qp = 34; - - pic_param->num_ref_idx_l0_active_minus1 = ctx->hierarchical_levels - 1; - pic_param->num_ref_idx_l1_active_minus1 = ctx->hierarchical_levels - 1; - - pic_param->coded_buf = ctx->codedbuf_buf_id; - pic_param->frame_num = current_surface->frame_num; - - pic_param->CurrPic.picture_id = current_surface->rec_surface; - pic_param->CurrPic.TopFieldOrderCnt = current_surface->poc * 2; - pic_param->CurrPic.BottomFieldOrderCnt = pic_param->CurrPic.TopFieldOrderCnt; - pic_param->CurrPic.frame_idx = current_surface->frame_num; - pic_param->CurrPic.flags = 0; /* frame */ - - for (i = 0; i < ctx->num_ref_frames; i++) { - assert(pic_param->CurrPic.picture_id != ref_frames[i].rec_surface); - - pic_param->ReferenceFrames[i].picture_id = ref_frames[i].rec_surface; - pic_param->ReferenceFrames[i].TopFieldOrderCnt = ref_frames[i].poc * 2; - pic_param->ReferenceFrames[i].BottomFieldOrderCnt = pic_param[i].ReferenceFrames[i].TopFieldOrderCnt; - pic_param->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; - } - - for (; i < 16; i++) { - pic_param->ReferenceFrames[i].picture_id = VA_INVALID_ID; - pic_param->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID; - } - - pic_param->pic_fields.bits.entropy_coding_mode_flag = ENTROPY_MODE_CAVLC; - pic_param->pic_fields.bits.weighted_pred_flag = 0; - pic_param->pic_fields.bits.weighted_bipred_idc = 0; - pic_param->pic_fields.bits.idr_pic_flag = !!current_surface->is_idr; - pic_param->pic_fields.bits.reference_pic_flag = !!current_surface->is_ref; - pic_param->pic_fields.bits.deblocking_filter_control_present_flag = 1; - - if (ctx->profile_idc == PROFILE_IDC_BASELINE || - ctx->profile_idc == PROFILE_IDC_MAIN || - ctx->profile_idc == PROFILE_IDC_SCALABLE_BASELINE) - pic_param->pic_fields.bits.transform_8x8_mode_flag = 0; - else - pic_param->pic_fields.bits.transform_8x8_mode_flag = 0; - - /* Allocate the new picture parameter buffer */ - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPictureParameterBufferType, - sizeof(*pic_param), - 1, - pic_param, - &ctx->pic_param_buf_id); - assert(ctx->pic_param_buf_id != VA_INVALID_ID); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); -} - -#define partition(ref, field, key, ascending) \ - while (i <= j) { \ - if (ascending) { \ - while (ref[i].field < key) \ - i++; \ - while (ref[j].field > key) \ - j--; \ - } else { \ - while (ref[i].field > key) \ - i++; \ - while (ref[j].field < key) \ - j--; \ - } \ - if (i <= j) { \ - tmp = ref[i]; \ - ref[i] = ref[j]; \ - ref[j] = tmp; \ - i++; \ - j--; \ - } \ - } \ - -static void -sort_one(svcenc_surface ref[], - int left, int right, - int ascending, int is_frame_num) -{ - int i = left, j = right; - int key; - svcenc_surface tmp; - - if (is_frame_num) { - key = ref[(left + right) / 2].frame_num; - partition(ref, frame_num, key, ascending); - } else { - key = ref[(left + right) / 2].display_order; - partition(ref, display_order, (signed int)key, ascending); - } - - /* recursion */ - if (left < j) - sort_one(ref, left, j, ascending, is_frame_num); - - if (i < right) - sort_one(ref, i, right, ascending, is_frame_num); -} - -static void -sort_two(svcenc_surface ref[], - int left, int right, - int key, int is_frame_num, - int partition_ascending, - int list0_ascending, int list1_ascending) -{ - int i = left, j = right; - svcenc_surface tmp; - - if (is_frame_num) { - partition(ref, frame_num, key, partition_ascending); - } else { - partition(ref, display_order, key, partition_ascending); - } - - sort_one(ref, left, i - 1, list0_ascending, is_frame_num); - sort_one(ref, j + 1, right, list1_ascending, is_frame_num); -} - -static void -svcenc_update_ref_lists(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - if (current_surface->picture_type == VAEncPictureTypePredictive) { - memcpy(ref_list0, ref_frames, ctx->num_ref_frames * sizeof(svcenc_surface)); - sort_one(ref_list0, 0, ctx->num_ref_frames - 1, 0, 1); - } else if (current_surface->picture_type == VAEncPictureTypeBidirectional) { - memcpy(ref_list0, ref_frames, ctx->num_ref_frames * sizeof(svcenc_surface)); - sort_two(ref_list0, - 0, ctx->num_ref_frames - 1, - current_surface->display_order, 0, - 1, - 0, 1); - memcpy(ref_list1, ref_frames, ctx->num_ref_frames * sizeof(svcenc_surface)); - sort_two(ref_list1, - 0, ctx->num_ref_frames - 1, - current_surface->display_order, 0, - 0, - 1, 0); - } -} - -static int -avc_temporal_find_surface(VAPictureH264 *curr_pic, - VAPictureH264 *ref_list, - int num_pictures, - int dir) -{ - int i, found = -1, min = 0x7FFFFFFF; - - for (i = 0; i < num_pictures; i++) { - int tmp; - - if ((ref_list[i].flags & VA_PICTURE_H264_INVALID) || - (ref_list[i].picture_id == VA_INVALID_SURFACE)) - break; - - tmp = curr_pic->TopFieldOrderCnt - ref_list[i].TopFieldOrderCnt; - - if (dir) - tmp = -tmp; - - if (tmp > 0 && tmp < min) { - min = tmp; - found = i; - } - } - - return found; -} - -static int -avc_temporal_find_surface_pgop(svcenc_surface *curr_pic, - svcenc_surface *ref_list, - int num_pictures) -{ - int i, found = -1, min = 0x7FFFFFFF; - - for (i = 0; i < num_pictures; i++) { - int tmp; - - if (ref_list[i].rec_surface == VA_INVALID_SURFACE) - break; - - if (curr_pic->temporal_id < ref_list[i].temporal_id) - continue; - - tmp = curr_pic->display_order - ref_list[i].display_order; - - if (tmp > 0 && tmp < min) { - min = tmp; - found = i; - } - } - - assert(found != -1); - - return found; -} - -void -svcenc_update_slice_parameter_buffer(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VAEncPictureParameterBufferH264 *pic_param = &ctx->pic_param; - VAEncSliceParameterBufferH264 *slice_param; - VAStatus va_status; - int i, width_in_mbs, height_in_mbs; - int slice_type; - int num_ref_idx_active_override_flag = 0, num_ref_l0 = 1, num_ref_l1 = 1; - VAPictureH264 RefPicList0[32]; - VAPictureH264 RefPicList1[32]; - VAPictureH264 *curr_pic; - int ref_idx; - - svcenc_update_ref_lists(ctx, current_surface); - - switch (current_surface->picture_type) { - case VAEncPictureTypeBidirectional: - slice_type = SLICE_TYPE_B; - break; - - case VAEncPictureTypePredictive: - slice_type = SLICE_TYPE_P; - break; - - case VAEncPictureTypeIntra: - default: - slice_type = SLICE_TYPE_I; - break; - } - - width_in_mbs = (ctx->width + 15) / 16; - height_in_mbs = (ctx->height + 15) / 16; - - // Slice level - i = 0; - slice_param = &ctx->slice_param[i]; - memset(slice_param, 0, sizeof(*slice_param)); - - slice_param->macroblock_address = 0; - slice_param->num_macroblocks = height_in_mbs * width_in_mbs; - slice_param->pic_parameter_set_id = svcenc_pic_parameter_set_id(ctx, current_surface); - slice_param->slice_type = slice_type; - - slice_param->direct_spatial_mv_pred_flag = 1; /* - * It is required for the slice layer extension and the base - * layer bitstream - * See G.7.4.3 j), G.10.1.2 a), G.10.1.2.1 a) - */ - slice_param->num_ref_idx_active_override_flag = 0; - slice_param->num_ref_idx_l0_active_minus1 = 0; - slice_param->num_ref_idx_l1_active_minus1 = 0; - slice_param->cabac_init_idc = 0; - slice_param->slice_qp_delta = 0; - slice_param->disable_deblocking_filter_idc = 0; - slice_param->slice_alpha_c0_offset_div2 = 2; - slice_param->slice_beta_offset_div2 = 2; - slice_param->idr_pic_id = 0; - - ctx->reordering_info[0] = ctx->reordering_info[1] = 0; - - /* FIXME: fill other fields */ - if ((slice_type == SLICE_TYPE_P) || (slice_type == SLICE_TYPE_B)) { - int j; - num_ref_l0 = MIN((pic_param->num_ref_idx_l0_active_minus1 + 1), ctx->num_ref_frames); - - for (j = 0; j < num_ref_l0; j++) { - RefPicList0[j].picture_id = ref_list0[j].rec_surface; - RefPicList0[j].TopFieldOrderCnt = ref_list0[j].poc * 2; - RefPicList0[j].BottomFieldOrderCnt = RefPicList0[j].TopFieldOrderCnt; - RefPicList0[j].frame_idx = ref_list0[j].frame_num; - RefPicList0[j].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; - } - - for (; j < 32; j++) { - RefPicList0[j].picture_id = VA_INVALID_SURFACE; - RefPicList0[j].flags = VA_PICTURE_H264_INVALID; - } - - if (num_ref_l0 != pic_param->num_ref_idx_l0_active_minus1 + 1) - num_ref_idx_active_override_flag = 1; - } - - if ((slice_type == SLICE_TYPE_B)) { - int j; - num_ref_l1 = MIN((pic_param->num_ref_idx_l1_active_minus1 + 1), ctx->num_ref_frames); - - for (j = 0; j < num_ref_l1; j++) { - RefPicList1[j].picture_id = ref_list1[j].rec_surface; - RefPicList1[j].TopFieldOrderCnt = ref_list1[j].poc * 2; - RefPicList1[j].BottomFieldOrderCnt = RefPicList1[j].TopFieldOrderCnt; - RefPicList1[j].frame_idx = ref_list1[j].frame_num; - RefPicList1[j].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; - } - - for (; j < 32; j++) { - RefPicList1[j].picture_id = VA_INVALID_SURFACE; - RefPicList1[j].flags = VA_PICTURE_H264_INVALID; - } - - if (num_ref_l1 != pic_param->num_ref_idx_l1_active_minus1 + 1) - num_ref_idx_active_override_flag = 1; - } - - if (num_ref_l0 != 1 || num_ref_l1 != 1) { - curr_pic = &pic_param->CurrPic; - - /* select the reference frame in temporal space */ - if ((slice_type == SLICE_TYPE_P) || (slice_type == SLICE_TYPE_B)) { - if (ctx->gop_type == 1) - ref_idx = avc_temporal_find_surface(curr_pic, RefPicList0, num_ref_l0, 0); - else - ref_idx = avc_temporal_find_surface_pgop(current_surface, ref_list0, num_ref_l0); - - if (ref_idx != 0) { - ctx->reordering_info[0] |= (1 << 0); - - if (curr_pic->frame_idx > RefPicList0[ref_idx].frame_idx) { - ctx->reordering_info[0] |= (0 << 4); - ctx->reordering_info[0] |= ((curr_pic->frame_idx - RefPicList0[ref_idx].frame_idx - 1) << 8); - } else { - ctx->reordering_info[0] |= (1 << 4); - ctx->reordering_info[0] |= ((RefPicList0[ref_idx].frame_idx - curr_pic->frame_idx - 1) << 8); - } - } - - slice_param->RefPicList0[0] = RefPicList0[ref_idx]; - } - - if (slice_type == SLICE_TYPE_B) { - assert(ctx->gop_type == 1); - ref_idx = avc_temporal_find_surface(curr_pic, RefPicList1, num_ref_l1, 1); - - if (ref_idx != 0) { - ctx->reordering_info[1] |= (1 << 0); - - if (curr_pic->frame_idx > RefPicList1[ref_idx].frame_idx) { - ctx->reordering_info[1] |= (0 << 4); - ctx->reordering_info[1] |= ((curr_pic->frame_idx - RefPicList1[ref_idx].frame_idx - 1) << 8); - } else { - ctx->reordering_info[1] |= (1 << 4); - ctx->reordering_info[1] |= ((RefPicList1[ref_idx].frame_idx - curr_pic->frame_idx - 1) << 8); - } - } - - slice_param->RefPicList1[0] = RefPicList1[ref_idx]; - } - - slice_param->num_ref_idx_active_override_flag = 1; - slice_param->num_ref_idx_l0_active_minus1 = 0; - slice_param->num_ref_idx_l1_active_minus1 = 0; - ctx->reordering_info[0] |= ((1 << 16) | (0 << 24)); - ctx->reordering_info[1] |= ((1 << 16) | (0 << 24)); - } else { - if (num_ref_idx_active_override_flag == 1) { - slice_param->num_ref_idx_active_override_flag = 1; - slice_param->num_ref_idx_l0_active_minus1 = 0; - slice_param->num_ref_idx_l1_active_minus1 = 0; - ctx->reordering_info[0] |= ((1 << 16) | (0 << 24)); - ctx->reordering_info[1] |= ((1 << 16) | (0 << 24)); - } - - if ((slice_type == SLICE_TYPE_P) || (slice_type == SLICE_TYPE_B)) { - slice_param->RefPicList0[0] = RefPicList0[0]; - } - - if (slice_type == SLICE_TYPE_B) { - slice_param->RefPicList1[0] = RefPicList1[0]; - } - } - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncSliceParameterBufferType, - sizeof(*slice_param), - 1, - slice_param, - &ctx->slice_param_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - - ctx->num_slices = ++i; -} - -void -svcenc_update_misc_parameter_buffer(struct svcenc_context *ctx, svcenc_surface *current_surface) -{ - VAStatus va_status; - VAEncMiscParameterBuffer *misc_param; - VAEncMiscParameterTemporalLayerStructure *misc_layer_structure_param; - VAEncMiscParameterRateControl *misc_ratecontrol_param; - VAEncMiscParameterFrameRate *misc_framerate_param; - VAEncMiscParameterHRD *misc_hrd_param; - - if (current_surface->frame_num != 0) - return; - - if (ctx->rate_control_mode & VA_RC_CQP) - return; - - assert(ctx->bits_per_kbps > 0); - - if (!ctx->layer_brc) { - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl), - 1, - NULL, - &ctx->misc_parameter_ratecontrol_buf_id[0]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_ratecontrol_buf_id[0], - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeRateControl; - misc_ratecontrol_param = (VAEncMiscParameterRateControl *)misc_param->data; - - misc_ratecontrol_param->bits_per_second = 1024 * ctx->bits_per_kbps; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_ratecontrol_buf_id[0]); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterFrameRate), - 1, - NULL, - &ctx->misc_parameter_framerate_buf_id[0]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_framerate_buf_id[0], - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeFrameRate; - misc_framerate_param = (VAEncMiscParameterFrameRate *)misc_param->data; - misc_framerate_param->framerate = ((100 << 16) | ctx->framerate_per_100s); - - misc_ratecontrol_param->bits_per_second = 1024 * ctx->bits_per_kbps; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_ratecontrol_buf_id[0]); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterHRD), - 1, - NULL, - &ctx->misc_parameter_hrd_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_hrd_buf_id, - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeHRD; - misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data; - - misc_hrd_param->initial_buffer_fullness = ctx->bits_per_kbps * 1024 * 4; - misc_hrd_param->buffer_size = ctx->bits_per_kbps * 1024 * 8; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_hrd_buf_id); - } else { - int i, j, nlayers = 0; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterTemporalLayerStructure), - 1, - NULL, - &ctx->misc_parameter_layer_structure_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_layer_structure_buf_id, - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeTemporalLayerStructure; - misc_layer_structure_param = (VAEncMiscParameterTemporalLayerStructure *)misc_param->data; - - misc_layer_structure_param->number_of_layers = ctx->hierarchical_levels; - misc_layer_structure_param->periodicity = ctx->gop_size; - - for (i = 0; i < ctx->gop_size; i++) { - if (ctx->gop_type == 1) { // B - misc_layer_structure_param->layer_id[i] = temporal_ids_in_bgop[i]; - } else { - misc_layer_structure_param->layer_id[i] = svcenc_coding_order_to_level_pgop(ctx, i + 1); - } - } - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_layer_structure_buf_id); - - for (i = 1; i <= ctx->hierarchical_levels; i++) { - nlayers += i; - } - - for (i = 0; i < ctx->hierarchical_levels; i++) { - int framerate_per_100s = frame_rates[i] * 100; - int numerator = 0; - - for (j = 0; j < ctx->gop_size; j++) { - if (misc_layer_structure_param->layer_id[j] <= i) - numerator++; - } - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl), - 1, - NULL, - &ctx->misc_parameter_ratecontrol_buf_id[i]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_ratecontrol_buf_id[i], - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeRateControl; - misc_ratecontrol_param = (VAEncMiscParameterRateControl *)misc_param->data; - misc_ratecontrol_param->bits_per_second = 1024 * ctx->bits_per_kbps * ((float)numerator / ctx->gop_size); - misc_ratecontrol_param->rc_flags.bits.temporal_id = i; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_ratecontrol_buf_id[i]); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterFrameRate), - 1, - NULL, - &ctx->misc_parameter_framerate_buf_id[i]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_framerate_buf_id[i], - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeFrameRate; - misc_framerate_param = (VAEncMiscParameterFrameRate *)misc_param->data; - misc_framerate_param->framerate = ((100 << 16) | framerate_per_100s); - misc_framerate_param->framerate_flags.bits.temporal_id = i; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_ratecontrol_buf_id[i]); - } - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncMiscParameterBufferType, - sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterHRD), - 1, - NULL, - &ctx->misc_parameter_hrd_buf_id); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - - vaMapBuffer(ctx->va_dpy, - ctx->misc_parameter_hrd_buf_id, - (void **)&misc_param); - - misc_param->type = VAEncMiscParameterTypeHRD; - misc_hrd_param = (VAEncMiscParameterHRD *)misc_param->data; - - misc_hrd_param->initial_buffer_fullness = ctx->bits_per_kbps * 1024 * 4; - misc_hrd_param->buffer_size = ctx->bits_per_kbps * 1024 * 8; - - vaUnmapBuffer(ctx->va_dpy, ctx->misc_parameter_hrd_buf_id); - } -} - -static void -svcenc_update_packed_slice_header_buffer(struct svcenc_context *ctx, unsigned int temporal_id) -{ - VAStatus va_status; - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_header_data_buffer = NULL; - int i; - - for (i = 0; i < ctx->num_slices; i++) { - length_in_bits = build_packed_svc_prefix_nal_unit(&ctx->pic_param, - temporal_id, - &packed_header_data_buffer); - - packed_header_param_buffer.type = VAEncPackedHeaderRawData; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_prefix_nal_unit_param_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_header_data_buffer, - &ctx->packed_prefix_nal_unit_data_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_header_data_buffer); - - length_in_bits = build_packed_slice_header_buffer(ctx, - &ctx->seq_param, - &ctx->pic_param, - &ctx->slice_param[i], - ctx->reordering_info, - &packed_header_data_buffer); - - packed_header_param_buffer.type = VAEncPackedHeaderSlice; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_slice_header_param_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_header_data_buffer, - &ctx->packed_slice_header_data_buf_id[i]); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_header_data_buffer); - } -} - -void -svcenc_update_packed_buffers(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VAStatus va_status; - VAEncPackedHeaderParameterBuffer packed_header_param_buffer; - unsigned int length_in_bits; - unsigned char *packed_seq_buffer = NULL, *packed_pic_buffer = NULL, *packed_sei_buffer = NULL; - - length_in_bits = build_packed_sei_buffer(ctx, - &ctx->seq_param, - &ctx->pic_param, - current_surface, - &packed_sei_buffer); - - if (packed_sei_buffer) { - assert(length_in_bits); - - packed_header_param_buffer.type = VAEncPackedHeaderH264_SEI; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_sei_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_sei_buffer, - &ctx->packed_sei_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_sei_buffer); - } - - if (current_surface->frame_num == 0) { - int save_profile_idc, save_constraint_set_flag; - unsigned char *packed_svc_seq_buffer = NULL; - - length_in_bits = build_packed_seq_buffer(ctx, - &ctx->seq_param, - &packed_seq_buffer); - - packed_header_param_buffer.type = VAEncPackedHeaderH264_SPS; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_seq_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_seq_buffer, - &ctx->packed_seq_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - save_profile_idc = ctx->profile_idc; - save_constraint_set_flag = ctx->constraint_set_flag; - ctx->profile_idc = ctx->svc_profile_idc; - ctx->constraint_set_flag = ctx->svc_constraint_set_flag; - - length_in_bits = build_packed_subset_seq_buffer(ctx, - &ctx->seq_param, - &packed_svc_seq_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderRawData; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_svc_seq_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_svc_seq_buffer, - &ctx->packed_svc_seq_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - ctx->profile_idc = save_profile_idc; - ctx->constraint_set_flag = save_constraint_set_flag; - - free(packed_svc_seq_buffer); - - length_in_bits = build_packed_pic_buffer(ctx, - &ctx->pic_param, - &packed_pic_buffer); - packed_header_param_buffer.type = VAEncPackedHeaderH264_PPS; - packed_header_param_buffer.bit_length = length_in_bits; - packed_header_param_buffer.has_emulation_bytes = 0; - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderParameterBufferType, - sizeof(packed_header_param_buffer), - 1, - &packed_header_param_buffer, - &ctx->packed_pic_header_param_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - va_status = vaCreateBuffer(ctx->va_dpy, - ctx->context_id, - VAEncPackedHeaderDataBufferType, - (length_in_bits + 7) / 8, - 1, - packed_pic_buffer, - &ctx->packed_pic_buf_id); - CHECK_VASTATUS(va_status,"vaCreateBuffer"); - - free(packed_seq_buffer); - free(packed_pic_buffer); - } - - svcenc_update_packed_slice_header_buffer(ctx, current_surface->temporal_id); -} - -void -svcenc_update_profile_idc(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - ctx->profile_idc = PROFILE_IDC_HIGH; - ctx->constraint_set_flag = 0; - - switch (ctx->profile) { - case VAProfileH264High: - ctx->profile_idc = PROFILE_IDC_HIGH; - ctx->constraint_set_flag |= (1 << 1); - break; - - case VAProfileH264ConstrainedBaseline: - case VAProfileH264Baseline: - ctx->profile_idc = PROFILE_IDC_BASELINE; - ctx->constraint_set_flag |= (1 << 0 | - 1 << 1 | - 1 << 2); - break; - - default: - /* Never get here !!! */ - assert(0); - break; - } - - ctx->svc_profile_idc = PROFILE_IDC_SCALABLE_HIGH; - ctx->svc_constraint_set_flag = 0; - - switch (ctx->profile) { - case VAProfileH264High: - ctx->svc_profile_idc = PROFILE_IDC_SCALABLE_HIGH; - ctx->svc_constraint_set_flag |= (1 << 1); - break; - - case VAProfileH264ConstrainedBaseline: - ctx->svc_profile_idc = PROFILE_IDC_SCALABLE_BASELINE; - ctx->svc_constraint_set_flag |= (1 << 0 | 1 << 1 | 1 << 5); - break; - - case VAProfileH264Baseline: - ctx->svc_profile_idc = PROFILE_IDC_SCALABLE_BASELINE; - ctx->svc_constraint_set_flag |= (1 << 0); - break; - - default: - /* Never get here !!! */ - assert(0); - break; - } -} - -int -begin_picture(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - svcenc_update_profile_idc(ctx, current_surface); - svcenc_update_sequence_parameter_buffer(ctx, current_surface); - svcenc_update_picture_parameter_buffer(ctx, current_surface); - svcenc_update_slice_parameter_buffer(ctx, current_surface); - svcenc_update_misc_parameter_buffer(ctx, current_surface); - svcenc_update_packed_buffers(ctx, current_surface); - - return 0; -} - -static int -svcenc_store_coded_buffer(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int slice_data_length; - VAStatus va_status; - size_t w_items; - - va_status = vaSyncSurface(ctx->va_dpy, src_surfaces[current_surface->slot_in_surfaces]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - - va_status = vaMapBuffer(ctx->va_dpy, ctx->codedbuf_buf_id, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - - coded_mem = coded_buffer_segment->buf; - - if (coded_buffer_segment->status & VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK) { - /* Fatal error !!! */ - assert(0); - } - - slice_data_length = coded_buffer_segment->size; - - do { - w_items = fwrite(coded_mem, slice_data_length, 1, ctx->ofp); - } while (w_items != 1); - - vaUnmapBuffer(ctx->va_dpy, ctx->codedbuf_buf_id); - - return 0; -} - -int -render_picture(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - VAStatus va_status; - VABufferID va_buffers[32]; - unsigned int num_va_buffers = 0; - int i; - - va_buffers[num_va_buffers++] = ctx->seq_param_buf_id; - va_buffers[num_va_buffers++] = ctx->pic_param_buf_id; - - if (ctx->packed_sei_scalability_info_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_sei_scalability_info_header_param_buf_id; - - if (ctx->packed_sei_scalability_info_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_sei_scalability_info_buf_id; - - if (ctx->packed_seq_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_seq_header_param_buf_id; - - if (ctx->packed_seq_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_seq_buf_id; - - if (ctx->packed_svc_seq_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_svc_seq_header_param_buf_id; - - if (ctx->packed_svc_seq_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_svc_seq_buf_id; - - if (ctx->packed_pic_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_pic_header_param_buf_id; - - if (ctx->packed_pic_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_pic_buf_id; - - if (ctx->packed_sei_header_param_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_sei_header_param_buf_id; - - if (ctx->packed_sei_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->packed_sei_buf_id; - - if (ctx->misc_parameter_layer_structure_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->misc_parameter_layer_structure_buf_id; - - for (i = 0; i < MAX_LAYERS; i++) { - if (ctx->misc_parameter_ratecontrol_buf_id[i] != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->misc_parameter_ratecontrol_buf_id[i]; - - if (ctx->misc_parameter_framerate_buf_id[i] != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->misc_parameter_framerate_buf_id[i]; - } - - if (ctx->misc_parameter_hrd_buf_id != VA_INVALID_ID) - va_buffers[num_va_buffers++] = ctx->misc_parameter_hrd_buf_id; - - va_status = vaBeginPicture(ctx->va_dpy, - ctx->context_id, - src_surfaces[current_surface->slot_in_surfaces]); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - va_buffers, - num_va_buffers); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - for (i = 0; i < ctx->num_slices; i++) { - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->packed_prefix_nal_unit_param_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->packed_prefix_nal_unit_data_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->packed_slice_header_param_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->packed_slice_header_data_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - va_status = vaRenderPicture(ctx->va_dpy, - ctx->context_id, - &ctx->slice_param_buf_id[i], - 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - } - - va_status = vaEndPicture(ctx->va_dpy, ctx->context_id); - CHECK_VASTATUS(va_status,"vaEndPicture"); - - svcenc_store_coded_buffer(ctx, current_surface); - - return 0; -} - -static int -svcenc_destroy_buffers(struct svcenc_context *ctx, - VABufferID *va_buffers, - unsigned int num_va_buffers) -{ - VAStatus va_status; - unsigned int i; - - for (i = 0; i < num_va_buffers; i++) { - if (va_buffers[i] != VA_INVALID_ID) { - va_status = vaDestroyBuffer(ctx->va_dpy, va_buffers[i]); - CHECK_VASTATUS(va_status,"vaDestroyBuffer"); - va_buffers[i] = VA_INVALID_ID; - } - } - - return 0; -} - -int -end_picture(struct svcenc_context *ctx, - svcenc_surface *current_surface) -{ - svcenc_destroy_buffers(ctx, &ctx->seq_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->pic_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_sei_scalability_info_header_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_sei_scalability_info_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_seq_header_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_seq_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_svc_seq_header_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_svc_seq_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_pic_header_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_pic_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->slice_param_buf_id[0], ctx->num_slices); - svcenc_destroy_buffers(ctx, &ctx->codedbuf_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->misc_parameter_layer_structure_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->misc_parameter_ratecontrol_buf_id[0], MAX_LAYERS); - svcenc_destroy_buffers(ctx, &ctx->misc_parameter_framerate_buf_id[0], MAX_LAYERS); - svcenc_destroy_buffers(ctx, &ctx->misc_parameter_hrd_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_sei_header_param_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_sei_buf_id, 1); - svcenc_destroy_buffers(ctx, &ctx->packed_slice_header_param_buf_id[0], ctx->num_slices); - svcenc_destroy_buffers(ctx, &ctx->packed_slice_header_data_buf_id[0], ctx->num_slices); - svcenc_destroy_buffers(ctx, &ctx->packed_prefix_nal_unit_param_buf_id[0], ctx->num_slices); - svcenc_destroy_buffers(ctx, &ctx->packed_prefix_nal_unit_data_buf_id[0], ctx->num_slices); - - memset(ctx->slice_param, 0, sizeof(ctx->slice_param)); - ctx->num_slices = 0; - - return 0; -} - -void -encode_picture(struct svcenc_context *ctx, svcenc_surface *current_surface) -{ - begin_picture(ctx, current_surface); - render_picture(ctx, current_surface); - end_picture(ctx, current_surface); - - svcenc_update_ref_frames(ctx, current_surface); - - if ((current_surface->is_idr) && - (ctx->rate_control_mode & VA_RC_CBR)) { - ctx->prev_idr_cpb_removal = ctx->current_idr_cpb_removal; - } -} - -static void -svcenc_va_init(struct svcenc_context *ctx) -{ - VAProfile *profile_list; - VAEntrypoint *entrypoint_list; - VAConfigAttrib attrib_list[4]; - VAStatus va_status; - int max_profiles, num_profiles = 0, profile = VAProfileNone; - int max_entrypoints, num_entrypoints = 0, entrypoint; - int major_ver, minor_ver; - int i, j; - - ctx->va_dpy = va_open_display(); - va_status = vaInitialize(ctx->va_dpy, - &major_ver, - &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - max_profiles = vaMaxNumProfiles(ctx->va_dpy); - profile_list = malloc(max_profiles * sizeof(VAProfile)); - vaQueryConfigProfiles(ctx->va_dpy, - profile_list, - &num_profiles); - - for (i = 0; i < ARRAY_ELEMS(g_va_profiles); i++) { - for (j = 0; j < num_profiles; j++) { - if (g_va_profiles[i] == profile_list[j]) { - profile = g_va_profiles[i]; - break; - } - } - - if (profile != VAProfileNone) - break; - } - - free(profile_list); - - if (profile == VAProfileNone) { - fprintf(stderr, "Can't find a supported profile\n"); - exit(-1); - } - - ctx->profile = profile; - - max_entrypoints = vaMaxNumEntrypoints(ctx->va_dpy); - entrypoint_list = malloc(max_entrypoints * sizeof(VAEntrypoint)); - vaQueryConfigEntrypoints(ctx->va_dpy, - ctx->profile, - entrypoint_list, - &num_entrypoints); - - for (entrypoint = 0; entrypoint < num_entrypoints; entrypoint++) { - if (entrypoint_list[entrypoint] == VAEntrypointEncSlice) - break; - } - - free(entrypoint_list); - - if (entrypoint == num_entrypoints) { - /* not find Slice entry point */ - fprintf(stderr, "Can't find the supported entrypoint\n"); - exit(-1); - } - - /* find out the format for the render target, and rate control mode */ - attrib_list[0].type = VAConfigAttribRTFormat; - attrib_list[1].type = VAConfigAttribRateControl; - attrib_list[2].type = VAConfigAttribEncPackedHeaders; - attrib_list[3].type = VAConfigAttribEncRateControlExt; - - vaGetConfigAttributes(ctx->va_dpy, - ctx->profile, - VAEntrypointEncSlice, - &attrib_list[0], - 4); - - if ((attrib_list[0].value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - if ((attrib_list[1].value & ctx->rate_control_mode) == 0) { - /* Can't find matched RC mode */ - fprintf(stderr, "RC mode %d isn't found, exit\n", ctx->rate_control_mode); - assert(0); - } - - if ((attrib_list[2].value & (VA_ENC_PACKED_HEADER_SEQUENCE | - VA_ENC_PACKED_HEADER_PICTURE | - VA_ENC_PACKED_HEADER_SLICE | - VA_ENC_PACKED_HEADER_RAW_DATA)) == 0) { - /* Can't find matched PACKED HEADER mode */ - assert(0); - } - - if (attrib_list[3].value == VA_ATTRIB_NOT_SUPPORTED) { - ctx->layer_brc = 0; // force to 0 - } else { - VAConfigAttribValEncRateControlExt *val = (VAConfigAttribValEncRateControlExt *)&attrib_list[3].value; - - if (!val->bits.max_num_temporal_layers_minus1) { - fprintf(stderr, "Do not support temporal layer\n"); - assert(0); - } - - if (ctx->hierarchical_levels > (val->bits.max_num_temporal_layers_minus1 + 1)) { - fprintf(stderr, "Over the maximum number of the supported layers\n"); - assert(0); - } - - if (!val->bits.temporal_layer_bitrate_control_flag) - ctx->layer_brc = 0; // force to 0 - } - - attrib_list[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */ - attrib_list[1].value = ctx->rate_control_mode; /* set to desired RC mode */ - attrib_list[2].value = (VA_ENC_PACKED_HEADER_SEQUENCE | - VA_ENC_PACKED_HEADER_PICTURE | - VA_ENC_PACKED_HEADER_SLICE | - VA_ENC_PACKED_HEADER_RAW_DATA); - - va_status = vaCreateConfig(ctx->va_dpy, - ctx->profile, - VAEntrypointEncSlice, - attrib_list, - 3, - &ctx->config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(ctx->va_dpy, - ctx->config_id, - ctx->width, - ctx->height, - VA_PROGRESSIVE, - 0, - 0, - &ctx->context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - - va_status = vaCreateSurfaces(ctx->va_dpy, - VA_RT_FORMAT_YUV420, - ctx->width, - ctx->height, - src_surfaces, - NUM_SURFACES, - NULL, - 0); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - - va_status = vaCreateSurfaces(ctx->va_dpy, - VA_RT_FORMAT_YUV420, - ctx->width, - ctx->height, - rec_surfaces, - NUM_SURFACES, - NULL, - 0); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); -} - -static void -svcenc_sei_init(struct svcenc_context *ctx) -{ - if (!(ctx->rate_control_mode & VA_RC_CBR)) - return; - - /* it comes for the bps defined in SPS */ - ctx->i_initial_cpb_removal_delay = 2 * 90000; - ctx->i_initial_cpb_removal_delay_offset = 2 * 90000; - - ctx->i_cpb_removal_delay = 2; - ctx->i_initial_cpb_removal_delay_length = 24; - ctx->i_cpb_removal_delay_length = 24; - ctx->i_dpb_output_delay_length = 24; - ctx->time_offset_length = 24; - - ctx->prev_idr_cpb_removal = ctx->i_initial_cpb_removal_delay / 90000; - ctx->current_idr_cpb_removal = ctx->prev_idr_cpb_removal; - ctx->current_cpb_removal = 0; - ctx->idr_frame_num = 0; -} - -static void -svcenc_init(struct svcenc_context *ctx) -{ - int i; - - ctx->frame_data_buffer = (unsigned char *)malloc(ctx->frame_size); - ctx->num_remainder_bframes = 0; - ctx->max_num_ref_frames = ctx->gop_size; - ctx->num_ref_frames = 0; - - switch (ctx->gop_size) { - case 1: - ctx->hierarchical_levels = 1; - break; - - case 2: - ctx->hierarchical_levels = 2; - break; - - case 4: - ctx->hierarchical_levels = 3; - break; - - case 8: - ctx->hierarchical_levels = 4; - break; - - default: - /* Never get here !!! */ - assert(0); - break; - } - - if (ctx->gop_type == 1) { // B - ctx->intra_period = 2 * ctx->gop_size; - ctx->ip_period = ctx->gop_size; - ctx->intra_idr_period = 0; // 0 means infinite - } else { - ctx->intra_period = 2 * ctx->gop_size; - ctx->ip_period = 1; - ctx->intra_idr_period = 8 * ctx->intra_period; - } - - ctx->framerate_per_100s = frame_rates[ctx->hierarchical_levels - 1] * 100; - - ctx->upload_task_header = NULL; - ctx->upload_task_tail = NULL; - - ctx->reordering_info[0] = ctx->reordering_info[1] = 0; - - ctx->seq_param_buf_id = VA_INVALID_ID; - ctx->pic_param_buf_id = VA_INVALID_ID; - ctx->packed_sei_scalability_info_header_param_buf_id = VA_INVALID_ID; - ctx->packed_sei_scalability_info_buf_id = VA_INVALID_ID; - ctx->packed_seq_header_param_buf_id = VA_INVALID_ID; - ctx->packed_seq_buf_id = VA_INVALID_ID; - ctx->packed_svc_seq_header_param_buf_id = VA_INVALID_ID; - ctx->packed_svc_seq_buf_id = VA_INVALID_ID; - ctx->packed_pic_header_param_buf_id = VA_INVALID_ID; - ctx->packed_pic_buf_id = VA_INVALID_ID; - ctx->codedbuf_buf_id = VA_INVALID_ID; - ctx->misc_parameter_layer_structure_buf_id = VA_INVALID_ID; - - for (i = 0; i < MAX_LAYERS; i++) { - ctx->misc_parameter_ratecontrol_buf_id[i] = VA_INVALID_ID; - ctx->misc_parameter_framerate_buf_id[i] = VA_INVALID_ID; - } - - ctx->misc_parameter_hrd_buf_id = VA_INVALID_ID; - ctx->packed_sei_header_param_buf_id = VA_INVALID_ID; - ctx->packed_sei_buf_id = VA_INVALID_ID; - - for (i = 0; i < MAX_SLICES; i++) { - ctx->packed_slice_header_param_buf_id[i] = VA_INVALID_ID; - ctx->packed_slice_header_data_buf_id[i] = VA_INVALID_ID; - ctx->packed_prefix_nal_unit_param_buf_id[i] = VA_INVALID_ID; - ctx->packed_prefix_nal_unit_data_buf_id[i] = VA_INVALID_ID; - } - - svcenc_va_init(ctx); - - /* update the next surface status */ - ctx->next_svcenc_surface.slot_in_surfaces = 0; - ctx->next_svcenc_surface.coding_order = 0; - ctx->next_svcenc_surface.display_order = 0; - ctx->next_svcenc_surface.temporal_id = 0; - ctx->next_svcenc_surface.frame_num = 0; - ctx->next_svcenc_surface.poc = 0; - ctx->next_svcenc_surface.picture_type = VAEncPictureTypeIntra; - ctx->next_svcenc_surface.is_intra = 1; - ctx->next_svcenc_surface.is_idr = 1; - ctx->next_svcenc_surface.is_ref = 1; - ctx->next_svcenc_surface.rec_surface = rec_surfaces[ctx->next_svcenc_surface.slot_in_surfaces]; - memset(src_surface_status, SRC_SURFACE_IN_STORAGE, sizeof(src_surface_status)); - - svcenc_sei_init(ctx); -} - -static void -svcenc_run(struct svcenc_context *ctx) -{ - int coding_order = 0; - svcenc_surface current_surface; - - pthread_create(&ctx->upload_thread, NULL, upload_task_thread, ctx); - current_surface = ctx->next_svcenc_surface; - upload_task_queue(ctx, current_surface.display_order, current_surface.slot_in_surfaces); - - while (coding_order < ctx->num_pictures) { - if (coding_order < (ctx->num_pictures - 1)) { - if (ctx->gop_type == 1) { - update_next_picture_info(ctx); - } else { - update_next_picture_info_pgop(ctx); - } - - assert(current_surface.display_order != ctx->next_svcenc_surface.display_order); - upload_task_queue(ctx, ctx->next_svcenc_surface.display_order, ctx->next_svcenc_surface.slot_in_surfaces); - } - - while (src_surface_status[current_surface.slot_in_surfaces] != SRC_SURFACE_IN_ENCODING) - usleep(1); - - encode_picture(ctx, ¤t_surface); - - if (coding_order < (ctx->num_pictures - 1)) - current_surface = ctx->next_svcenc_surface; - - coding_order++; - fprintf(stderr, "\r %d/%d ...", coding_order, ctx->num_pictures); - fflush(stdout); - } - - pthread_join(ctx->upload_thread, NULL); -} - -static void -svcenc_va_end(struct svcenc_context *ctx) -{ - vaDestroySurfaces(ctx->va_dpy, src_surfaces, NUM_SURFACES); - vaDestroySurfaces(ctx->va_dpy, rec_surfaces, NUM_SURFACES); - - vaDestroyContext(ctx->va_dpy, ctx->context_id); - vaDestroyConfig(ctx->va_dpy, ctx->config_id); - vaTerminate(ctx->va_dpy); - va_close_display(ctx->va_dpy); -} - -static void -svcenc_end(struct svcenc_context *ctx) -{ - free(ctx->frame_data_buffer); - ctx->frame_data_buffer = NULL; - svcenc_va_end(ctx); -} - -int -main(int argc, char *argv[]) -{ - struct svcenc_context ctx; - struct timeval tpstart, tpend; - float timeuse; - - gettimeofday(&tpstart, NULL); - - memset(&ctx, 0, sizeof(ctx)); - parse_args(&ctx, argc, argv); - - svcenc_init(&ctx); - svcenc_run(&ctx); - svcenc_end(&ctx); - - gettimeofday(&tpend, NULL); - timeuse = 1000000 * (tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; - timeuse /= 1000000; - fprintf(stderr, "\ndone!\n"); - fprintf(stderr, "encode %d frames in %f secondes, FPS is %.1f\n", ctx.num_pictures, timeuse, ctx.num_pictures / timeuse); - - svcenc_exit(&ctx, 0); - - return 0; -} diff --git a/test/loadsurface.h b/test/loadsurface.h deleted file mode 100755 index 82cf61c..0000000 --- a/test/loadsurface.h +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright (c) 2008-2009 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. - */ -#include "loadsurface_yuv.h" - -static int scale_2dimage(unsigned char *src_img, int src_imgw, int src_imgh, - unsigned char *dst_img, int dst_imgw, int dst_imgh) -{ - int row=0, col=0; - - for (row=0; row -#include -#include -#include -#include -#include -#include -#include - -using namespace android; - -static int android_display=0; - -static sp client0 = NULL; -static sp surface_ctrl0 = NULL; -static sp anw0 = NULL; - -static sp client1 = NULL; -static sp surface_ctrl1 = NULL; -static sp anw1 = NULL; - -static void *open_display(void); -static void close_display(void *win_display); -static int create_window(void *win_display, int x, int y, int width, int height); -static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit); - -#define CAST_DRAWABLE(a) static_cast((void *)(*(unsigned int *)a)) -#include "putsurface_common.c" - -static void *open_display() -{ - return &android_display; -} - -static void close_display(void *win_display) -{ - return; -} - -static int create_window(void *win_display, int x, int y, int width, int height) -{ - client0 = new SurfaceComposerClient(); - - surface_ctrl0 = client1->createSurface( - String8("Test Surface"), - width, height, - PIXEL_FORMAT_RGB_888, 0); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl0->setLayer(0x7FFFFFFF); - surface_ctrl0->show(); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl0->setPosition(x, y); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl0->setSize(width, height); - SurfaceComposerClient::closeGlobalTransaction(); - - anw0 = surface_ctrl0->getSurface(); - - drawable_thread0 = static_cast(&anw0); - if (multi_thread == 0) - return 0; - - printf("Create window1 for thread1\n"); - client1 = new SurfaceComposerClient(); - - surface_ctrl1 = client1->createSurface( - String8("Test Surface"), - width, height, - PIXEL_FORMAT_RGB_888, 0); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl1->setLayer(0x7FFFFFFF); - surface_ctrl1->show(); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl1->setPosition(x*2, y*2); - SurfaceComposerClient::closeGlobalTransaction(); - - SurfaceComposerClient::openGlobalTransaction(); - surface_ctrl1->setSize(width, height); - SurfaceComposerClient::closeGlobalTransaction(); - - anw1 = surface_ctrl1->getSurface(); - - drawable_thread1 = static_cast(&anw1); - - return 0; -} - -int check_window_event(void *win_display, void *drawble, int *width, int *height, int *quit) -{ - return 0; -} - - diff --git a/test/putsurface/putsurface_common.c b/test/putsurface/putsurface_common.c deleted file mode 100755 index fa0249a..0000000 --- a/test/putsurface/putsurface_common.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * Copyright (c) 2008-2009 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. - */ - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -/*currently, if XCheckWindowEvent was called in more than one thread, it would cause - * XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" - * after 87 requests (83 known processed) with 0 events remaining. - * - * X Error of failed request: BadGC (invalid GC parameter) - * Major opcode of failed request: 60 (X_FreeGC) - * Resource id in failed request: 0x600034 - * Serial number of failed request: 398 - * Current serial number in output stream: 399 - * The root cause is unknown. */ - -#define CHECK_VASTATUS(va_status,func) \ -if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ -} -#include "../loadsurface.h" - -#define SURFACE_NUM 16 - -static void *win_display; -static VADisplay va_dpy; -static VAImageFormat *va_image_formats; -static int va_num_image_formats = -1; -static VAConfigID vpp_config_id = VA_INVALID_ID; -static VASurfaceAttrib *va_surface_attribs; -static int va_num_surface_attribs = -1; -static VASurfaceID surface_id[SURFACE_NUM]; -static pthread_mutex_t surface_mutex[SURFACE_NUM]; - -static void *drawable_thread0, *drawable_thread1; -static int surface_width = 352, surface_height = 288; -static int win_x = 0, win_y = 0; -static int win_width = 352, win_height = 288; -static int frame_rate = 0; -static unsigned long long frame_num_total = ~0; -static int check_event = 1; -static int put_pixmap = 0; -static int test_clip = 0; -static int display_field = VA_FRAME_PICTURE; -static pthread_mutex_t gmutex; -static int box_width = 32; -static int multi_thread = 0; -static int verbose = 0; -static int test_color_conversion = 0; -static int csc_src_fourcc = 0, csc_dst_fourcc = 0; -static VAImage csc_dst_fourcc_image; -static VASurfaceID csc_render_surface; - - -typedef struct { - char* fmt_str; - unsigned int fourcc; -} fourcc_map; -fourcc_map va_fourcc_map[] = { - {"YUYV", VA_FOURCC_YUY2}, - {"YUY2", VA_FOURCC_YUY2}, - {"NV12", VA_FOURCC_NV12}, - {"YV12", VA_FOURCC_YV12}, - {"BGRA", VA_FOURCC_BGRA}, - {"RGBA", VA_FOURCC_RGBA}, - {"BGRX", VA_FOURCC_BGRX}, - {"RGBX", VA_FOURCC_RGBX}, -}; -unsigned int map_str_to_vafourcc (char * str) -{ - int i; - for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) { - if (!strcmp(va_fourcc_map[i].fmt_str, str)) { - return va_fourcc_map[i].fourcc; - } - } - - return 0; - -} -char* map_vafourcc_to_str (unsigned int format) -{ - static char unknown_format[] = "unknown-format"; - int i; - for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) { - if (va_fourcc_map[i].fourcc == format) { - return va_fourcc_map[i].fmt_str; - } - } - - return unknown_format; - -} - -static int -va_value_equals(const VAGenericValue *v1, const VAGenericValue *v2) -{ - if (v1->type != v2->type) - return 0; - - switch (v1->type) { - case VAGenericValueTypeInteger: - return v1->value.i == v2->value.i; - case VAGenericValueTypeFloat: - return v1->value.f == v2->value.f; - case VAGenericValueTypePointer: - return v1->value.p == v2->value.p; - case VAGenericValueTypeFunc: - return v1->value.fn == v2->value.fn; - } - return 0; -} - -static int -ensure_image_formats(void) -{ - VAStatus va_status; - VAImageFormat *image_formats; - int num_image_formats; - - if (va_num_image_formats >= 0) - return va_num_image_formats; - - num_image_formats = vaMaxNumImageFormats(va_dpy); - if (num_image_formats == 0) - return 0; - - image_formats = malloc(num_image_formats * sizeof(*image_formats)); - if (!image_formats) - return 0; - - va_status = vaQueryImageFormats(va_dpy, image_formats, &num_image_formats); - CHECK_VASTATUS(va_status, "vaQuerySurfaceAttributes()"); - - va_image_formats = image_formats; - va_num_image_formats = num_image_formats; - return num_image_formats; -} - -static const VAImageFormat * -lookup_image_format(uint32_t fourcc) -{ - int i; - - if (!ensure_image_formats()) - return NULL; - - for (i = 0; i < va_num_image_formats; i++) { - const VAImageFormat * const image_format = &va_image_formats[i]; - if (image_format->fourcc == fourcc) - return image_format; - } - return NULL; -} - -static int -ensure_surface_attribs(void) -{ - VAStatus va_status; - VASurfaceAttrib *surface_attribs; - unsigned int num_image_formats, num_surface_attribs; - - if (va_num_surface_attribs >= 0) - return va_num_surface_attribs; - - num_image_formats = vaMaxNumImageFormats(va_dpy); - if (num_image_formats == 0) - return 0; - - va_status = vaCreateConfig(va_dpy, VAProfileNone, VAEntrypointVideoProc, - NULL, 0, &vpp_config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig()"); - - /* Guess the number of surface attributes, thus including any - pixel-format supported by the VA driver */ - num_surface_attribs = VASurfaceAttribCount + num_image_formats; - surface_attribs = malloc(num_surface_attribs * sizeof(*surface_attribs)); - if (!surface_attribs) - return 0; - - va_status = vaQuerySurfaceAttributes(va_dpy, vpp_config_id, - surface_attribs, &num_surface_attribs); - if (va_status == VA_STATUS_SUCCESS) - va_surface_attribs = surface_attribs; - else if (va_status == VA_STATUS_ERROR_MAX_NUM_EXCEEDED) { - va_surface_attribs = realloc(surface_attribs, - num_surface_attribs * sizeof(*va_surface_attribs)); - if (!va_surface_attribs) { - free(surface_attribs); - return 0; - } - va_status = vaQuerySurfaceAttributes(va_dpy, vpp_config_id, - va_surface_attribs, &num_surface_attribs); - } - CHECK_VASTATUS(va_status, "vaQuerySurfaceAttributes()"); - va_num_surface_attribs = num_surface_attribs; - return num_surface_attribs; -} - -static const VASurfaceAttrib * -lookup_surface_attrib(VASurfaceAttribType type, const VAGenericValue *value) -{ - int i; - - if (!ensure_surface_attribs()) - return NULL; - - for (i = 0; i < va_num_surface_attribs; i++) { - const VASurfaceAttrib * const surface_attrib = &va_surface_attribs[i]; - if (surface_attrib->type != type) - continue; - if (!(surface_attrib->flags & VA_SURFACE_ATTRIB_SETTABLE)) - continue; - if (va_value_equals(&surface_attrib->value, value)) - return surface_attrib; - } - return NULL; -} - -int csc_preparation () -{ - VAStatus va_status; - - // 1. make sure dst fourcc is supported for vaImage - if (!lookup_image_format(csc_dst_fourcc)) { - test_color_conversion = 0; - printf("VA driver doesn't support %s image, skip additional color conversion\n", map_vafourcc_to_str(csc_dst_fourcc)); - goto cleanup; - } - - // 2. make sure src_fourcc is supported for vaSurface - VASurfaceAttrib surface_attribs[1], * const s_attrib = &surface_attribs[0]; - s_attrib->type = VASurfaceAttribPixelFormat; - s_attrib->flags = VA_SURFACE_ATTRIB_SETTABLE; - s_attrib->value.type = VAGenericValueTypeInteger; - s_attrib->value.value.i = csc_src_fourcc; - - if (!lookup_surface_attrib(VASurfaceAttribPixelFormat, &s_attrib->value)) { - printf("VA driver doesn't support %s surface, skip additional color conversion\n", map_vafourcc_to_str(csc_src_fourcc)); - test_color_conversion = 0; - goto cleanup; - } - - // 3 create all objs required by csc - // 3.1 vaSurface with src fourcc - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, surface_width, surface_height, - &surface_id[0], SURFACE_NUM, - surface_attribs, 1 - ); - CHECK_VASTATUS(va_status,"vaCreateSurfaces"); - - // 3.2 vaImage with dst fourcc - VAImageFormat image_format; - image_format.fourcc = csc_dst_fourcc; - image_format.byte_order = VA_LSB_FIRST; - image_format.bits_per_pixel = 16; - - va_status = vaCreateImage(va_dpy, &image_format, - surface_width, surface_height, - &csc_dst_fourcc_image); - CHECK_VASTATUS(va_status,"vaCreateImage"); - - - // 3.3 create a temp VASurface for final rendering(vaPutSurface) - s_attrib->value.value.i = VA_FOURCC_NV12; - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, - surface_width, surface_height, - &csc_render_surface, 1, - surface_attribs, 1); - CHECK_VASTATUS(va_status,"vaCreateSurfaces"); - - -cleanup: - return test_color_conversion; -} - -static VASurfaceID get_next_free_surface(int *index) -{ - VASurfaceStatus surface_status; - int i; - - assert(index); - - if (multi_thread == 0) { - i = *index; - i++; - if (i == SURFACE_NUM) - i = 0; - *index = i; - - return surface_id[i]; - } - - for (i=0; i= frame_num_total) - quit = 1; - } - - if (drawable == drawable_thread1) - pthread_exit(NULL); - - return 0; -} -int main(int argc,char **argv) -{ - int major_ver, minor_ver; - VAStatus va_status; - pthread_t thread1; - int ret; - int c; - int i; - char str_src_fmt[5], str_dst_fmt[5]; - - static struct option long_options[] = - { - {"fmt1", required_argument, NULL, '1'}, - {"fmt2", required_argument, NULL, '2'}, - {0, 0, 0, 0} - }; - - while ((c =getopt_long(argc,argv,"w:h:g:r:d:f:tcep?n:1:2:v", long_options, NULL)) != EOF) { - switch (c) { - case '?': - printf("putsurface \n"); - printf(" -g window geometry\n"); - printf(" -w/-h resolution of surface\n"); - printf(" -r \n"); - printf(" -d the dimension of black/write square box, default is 32\n"); - printf(" -t multi-threads\n"); - printf(" -c test clipbox\n"); - printf(" -f <1/2> top field, or bottom field\n"); - printf(" -1 source format (fourcc) for color conversion test\n"); - printf(" -2 dest format (fourcc) for color conversion test\n"); - printf(" --fmt1 same to -1\n"); - printf(" --fmt2 same to -2\n"); - printf(" -v verbose output\n"); - exit(0); - break; - case 'g': - ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y); - if (ret != 4) { - printf("invalid window geometry, must be widthxheight+x_location+y_location\n"); - exit(0); - } else - printf("Create window at (%d, %d), width = %d, height = %d\n", - win_x, win_y, win_width, win_height); - break; - case 'r': - frame_rate = atoi(optarg); - break; - case 'w': - surface_width = atoi(optarg); - break; - case 'h': - surface_height = atoi(optarg); - break; - case 'n': - frame_num_total = atoi(optarg); - break; - case 'd': - box_width = atoi(optarg); - break; - case 't': - multi_thread = 1; - printf("Two threads to do vaPutSurface\n"); - break; - case 'e': - check_event = 0; - break; - case 'p': - put_pixmap = 1; - break; - case 'c': - test_clip = 1; - break; - case 'f': - if (atoi(optarg) == 1) { - printf("Display TOP field\n"); - display_field = VA_TOP_FIELD; - } else if (atoi(optarg) == 2) { - printf("Display BOTTOM field\n"); - display_field = VA_BOTTOM_FIELD; - } else - printf("The validate input for -f is: 1(top field)/2(bottom field)\n"); - break; - case '1': - sscanf(optarg, "%s", str_src_fmt); - csc_src_fourcc = map_str_to_vafourcc (str_src_fmt); - - if (!csc_src_fourcc) { - printf("invalid fmt1: %s\n", str_src_fmt ); - exit(0); - } - break; - case '2': - sscanf(optarg, "%s", str_dst_fmt); - csc_dst_fourcc = map_str_to_vafourcc (str_dst_fmt); - - if (!csc_dst_fourcc) { - printf("invalid fmt1: %s\n", str_dst_fmt ); - exit(0); - } - break; - case 'v': - verbose = 1; - printf("Enable verbose output\n"); - break; - } - } - - if (csc_src_fourcc && csc_dst_fourcc) { - test_color_conversion = 1; - } - - win_display = (void *)open_display(); - if (win_display == NULL) { - fprintf(stderr, "Can't open the connection of display!\n"); - exit(-1); - } - create_window(win_display, win_x, win_y, win_width, win_height); - - va_dpy = vaGetDisplay(win_display); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - if (test_color_conversion) { - ret = csc_preparation(); - } - if (!test_color_conversion || !ret ) { - va_status = vaCreateSurfaces( - va_dpy, - VA_RT_FORMAT_YUV420, surface_width, surface_height, - &surface_id[0], SURFACE_NUM, - NULL, 0 - ); - } - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - if (multi_thread == 0) /* upload the content for all surfaces */ - upload_source_YUV_once_for_all(); - - if (check_event) - pthread_mutex_init(&gmutex, NULL); - - for(i = 0; i< SURFACE_NUM; i++) - pthread_mutex_init(&surface_mutex[i], NULL); - - if (multi_thread == 1) - ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1); - - putsurface_thread((void *)drawable_thread0); - - if (multi_thread == 1) - pthread_join(thread1, (void **)&ret); - printf("thread1 is free\n"); - - if (test_color_conversion) { - // destroy temp surface/image - va_status = vaDestroySurfaces(va_dpy, &csc_render_surface, 1); - CHECK_VASTATUS(va_status,"vaDestroySurfaces"); - - va_status = vaDestroyImage(va_dpy, csc_dst_fourcc_image.image_id); - CHECK_VASTATUS(va_status,"vaDestroyImage"); - } - - if (vpp_config_id != VA_INVALID_ID) { - vaDestroyConfig (va_dpy, vpp_config_id); - vpp_config_id = VA_INVALID_ID; - } - - vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); - vaTerminate(va_dpy); - - free(va_image_formats); - free(va_surface_attribs); - close_display(win_display); - - return 0; -} diff --git a/test/putsurface/putsurface_wayland.c b/test/putsurface/putsurface_wayland.c deleted file mode 100644 index ad3c4e6..0000000 --- a/test/putsurface/putsurface_wayland.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2011 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. - */ - -#include -#include -#include -#include -#ifdef IN_LIBVA -# include "va/wayland/va_wayland.h" -#else -# include -#endif -#include - -static void *open_display(void); -static void close_display(void *win_display); -static int create_window(void *win_display, - int x, int y, int width, int height); -static int check_window_event(void *win_display, void *drawable, - int *width, int *height, int *quit); - -struct display; -struct drawable; - -static VAStatus -va_put_surface( - VADisplay dpy, - struct drawable *wl_drawable, - VASurfaceID va_surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects, - unsigned int flags -); - -/* Glue code for the current PutSurface test design */ -#define CAST_DRAWABLE(a) (struct drawable *)(a) - -static inline VADisplay -vaGetDisplay(VANativeDisplay native_dpy) -{ - return vaGetDisplayWl(native_dpy); -} - -static VAStatus -vaPutSurface( - VADisplay dpy, - VASurfaceID surface, - struct drawable *wl_drawable, - short src_x, - short src_y, - unsigned short src_w, - unsigned short src_h, - short dst_x, - short dst_y, - unsigned short dst_w, - unsigned short dst_h, - const VARectangle *cliprects, - unsigned int num_cliprects, - unsigned int flags -) -{ - VARectangle src_rect, dst_rect; - - src_rect.x = src_x; - src_rect.y = src_y; - src_rect.width = src_w; - src_rect.height = src_h; - - dst_rect.x = src_x; - dst_rect.y = src_y; - dst_rect.width = src_w; - dst_rect.height = src_h; - return va_put_surface(dpy, wl_drawable, surface, &src_rect, &dst_rect, - cliprects, num_cliprects, flags); -} - -#include "putsurface_common.c" - -struct display { - struct wl_display *display; - struct wl_compositor *compositor; - struct wl_shell *shell; - struct wl_registry *registry; - int event_fd; -}; - -struct drawable { - struct wl_display *display; - struct wl_surface *surface; - unsigned int redraw_pending : 1; -}; - -static void -frame_redraw_callback(void *data, struct wl_callback *callback, uint32_t time) -{ - struct drawable * const drawable = data; - - drawable->redraw_pending = 0; - wl_callback_destroy(callback); -} - -static const struct wl_callback_listener frame_callback_listener = { - frame_redraw_callback -}; - -static VAStatus -va_put_surface( - VADisplay dpy, - struct drawable *wl_drawable, - VASurfaceID va_surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects, - unsigned int flags -) -{ - struct display *d; - struct wl_callback *callback; - VAStatus va_status; - struct wl_buffer *buffer; - int ret = 0; - - if (!wl_drawable) - return VA_STATUS_ERROR_INVALID_SURFACE; - - d = wl_display_get_user_data(wl_drawable->display); - if (!d) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - /* Wait for the previous frame to complete redraw */ - if (wl_drawable->redraw_pending) { - wl_display_flush(d->display); - while (wl_drawable->redraw_pending && ret >=0) - ret = wl_display_dispatch(wl_drawable->display); - } - - va_status = vaGetSurfaceBufferWl(va_dpy, va_surface, VA_FRAME_PICTURE, &buffer); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - wl_surface_attach(wl_drawable->surface, buffer, 0, 0); - wl_surface_damage( - wl_drawable->surface, - dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height - ); - - wl_display_flush(d->display); - wl_drawable->redraw_pending = 1; - callback = wl_surface_frame(wl_drawable->surface); - wl_surface_commit(wl_drawable->surface); - wl_callback_add_listener(callback, &frame_callback_listener, wl_drawable); - return VA_STATUS_SUCCESS; -} - -static void -registry_handle_global( - void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version -) -{ - struct display * const d = data; - - if (strcmp(interface, "wl_compositor") == 0) - d->compositor = - wl_registry_bind(registry, id, &wl_compositor_interface, 1); - else if (strcmp(interface, "wl_shell") == 0) - d->shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); -} - -static const struct wl_registry_listener registry_listener = { - registry_handle_global, - NULL, -}; - -static void * -open_display(void) -{ - struct display *d; - - d = calloc(1, sizeof *d); - if (!d) - return NULL; - - d->display = wl_display_connect(NULL); - if (!d->display){ - free(d); - return NULL; - } - - wl_display_set_user_data(d->display, d); - d->registry = wl_display_get_registry(d->display); - wl_registry_add_listener(d->registry, ®istry_listener, d); - d->event_fd = wl_display_get_fd(d->display); - wl_display_dispatch(d->display); - return d->display; -} - -static void -close_display(void *win_display) -{ - struct display * const d = wl_display_get_user_data(win_display); - - if (d->shell) { - wl_shell_destroy(d->shell); - d->shell = NULL; - } - - if (d->compositor) { - wl_compositor_destroy(d->compositor); - d->compositor = NULL; - } - - if (d->display) { - wl_display_disconnect(d->display); - d->display = NULL; - } - free(d); -} - -static int -create_window(void *win_display, int x, int y, int width, int height) -{ - struct wl_display * const display = win_display; - struct display * const d = wl_display_get_user_data(display); - struct wl_surface *surface1, *surface2; - struct wl_shell_surface *shell_surface; - struct wl_shell_surface *shell_surface_2; - struct drawable *drawable1, *drawable2; - - surface1 = wl_compositor_create_surface(d->compositor); - shell_surface = wl_shell_get_shell_surface(d->shell, surface1); - wl_shell_surface_set_toplevel(shell_surface); - - drawable1 = malloc(sizeof(*drawable1)); - assert(drawable1); - drawable1->display = display; - drawable1->surface = surface1; - drawable1->redraw_pending = 0; - - /* global out */ - drawable_thread0 = drawable1; - - if (multi_thread == 0) - return 0; - - surface2 = wl_compositor_create_surface(d->compositor); - shell_surface_2 = wl_shell_get_shell_surface(d->shell, surface2); - wl_shell_surface_set_toplevel(shell_surface_2); - - drawable2 = malloc(sizeof(*drawable2)); - assert(drawable2); - drawable2->display = display; - drawable1->surface = surface2; - drawable2->redraw_pending = 0; - - /* global out */ - drawable_thread1 = drawable2; - return 0; -} - -static int -check_window_event( - void *win_display, - void *drawable, - int *width, - int *height, - int *quit -) -{ - struct wl_display * const display = win_display; - struct display * const d = wl_display_get_user_data(display); - struct timeval tv; - fd_set rfds; - int retval; - - if (check_event == 0) - return 0; - - tv.tv_sec = 0; - tv.tv_usec = 0; - do { - FD_ZERO(&rfds); - FD_SET(d->event_fd, &rfds); - - retval = select(d->event_fd + 1, &rfds, NULL, NULL, &tv); - if (retval < 0) { - perror("select"); - break; - } - if (retval == 1) - wl_display_dispatch(d->display); - } while (retval > 0); - -#if 0 - /* bail on any focused key press */ - if(event.type == KeyPress) { - *quit = 1; - return 0; - } -#endif - -#if 0 - /* rescale the video to fit the window */ - if(event.type == ConfigureNotify) { - *width = event.xconfigure.width; - *height = event.xconfigure.height; - printf("Scale window to %dx%d\n", width, height); - } -#endif - return 0; -} diff --git a/test/putsurface/putsurface_x11.c b/test/putsurface/putsurface_x11.c deleted file mode 100644 index db765af..0000000 --- a/test/putsurface/putsurface_x11.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2008-2009 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. - */ - -#include -#include -#include - -static Window window_thread0, window_thread1; -static GC context_thread0, context_thread1; -static pthread_mutex_t gmutex; - -static void *open_display(void); -static void close_display(void *win_display); -static int create_window(void *win_display, int x, int y, int width, int height); -static int check_window_event(void *x11_display, void *drawable, int *width, int *height, int *quit); - -#define CAST_DRAWABLE(a) (Drawable)(a) - -#include "putsurface_common.c" - -static void *open_display(void) -{ - return XOpenDisplay(NULL); -} - -static void close_display(void *win_display) -{ - XCloseDisplay(win_display); -} - -static Pixmap create_pixmap(void *win_display, int width, int height) -{ - Display *x11_display = (Display *)win_display; - int screen = DefaultScreen(x11_display); - Window root; - Pixmap pixmap; - XWindowAttributes attr; - - root = RootWindow(x11_display, screen); - - XGetWindowAttributes (x11_display, root, &attr); - - printf("Create a pixmap from ROOT window %dx%d, pixmap size %dx%d\n\n", attr.width, attr.height, width, height); - pixmap = XCreatePixmap(x11_display, root, width, height, - DefaultDepth(x11_display, DefaultScreen(x11_display))); - - return pixmap; -} - -static int create_window(void *win_display, int x, int y, int width, int height) -{ - Display *x11_display = (Display *)win_display; - int screen = DefaultScreen(x11_display); - Window root, win; - - root = RootWindow(x11_display, screen); - - printf("Create window0 for thread0\n"); - drawable_thread0 = (void *)XCreateSimpleWindow(x11_display, root, x, y, width, height, - 0, 0, WhitePixel(x11_display, 0)); - - win = (Window)drawable_thread0; - if (drawable_thread0) { - XSizeHints sizehints; - sizehints.width = width; - sizehints.height = height; - sizehints.flags = USSize; - XSetNormalHints(x11_display, win, &sizehints); - XSetStandardProperties(x11_display, win, "Thread 0", "Thread 0", - None, (char **)NULL, 0, &sizehints); - - XMapWindow(x11_display, win); - } - context_thread0 = XCreateGC(x11_display, win, 0, 0); - XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); - XSync(x11_display, False); - - if (put_pixmap) { - window_thread0 = (Window)drawable_thread0; - drawable_thread0 = (void *)create_pixmap(x11_display, width, height); - } - - if (multi_thread == 0) - return 0; - - printf("Create window1 for thread1\n"); - - drawable_thread1 = (void *)XCreateSimpleWindow(x11_display, root, width, 0, width, height, - 0, 0, WhitePixel(x11_display, 0)); - win = (Window)drawable_thread1; - if (drawable_thread1) { - XSizeHints sizehints; - sizehints.width = width; - sizehints.height = height; - sizehints.flags = USSize; - XSetNormalHints(x11_display, win, &sizehints); - XSetStandardProperties(x11_display, win, "Thread 1", "Thread 1", - None, (char **)NULL, 0, &sizehints); - - XMapWindow(x11_display, win); - } - if (put_pixmap) { - window_thread1 = (Window)drawable_thread1; - drawable_thread1 = (void *)create_pixmap(x11_display, width, height); - } - - context_thread1 = XCreateGC(x11_display, win, 0, 0); - XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); - XSync(x11_display, False); - - return 0; -} - -static int check_window_event(void *win_display, void *drawable, int *width, int *height, int *quit) -{ - int is_event = 0; - XEvent event; - Window win = (Window)drawable; - Display *x11_display = (Display *)win_display; - - - if (check_event == 0) - return 0; - - pthread_mutex_lock(&gmutex); - is_event = XCheckWindowEvent(x11_display, win, StructureNotifyMask|KeyPressMask,&event); - pthread_mutex_unlock(&gmutex); - - if (is_event == 0) - return 0; - - /* bail on any focused key press */ - if(event.type == KeyPress) { - *quit = 1; - return 0; - } - -#if 0 - /* rescale the video to fit the window */ - if(event.type == ConfigureNotify) { - *width = event.xconfigure.width; - *height = event.xconfigure.height; - printf("Scale window to %dx%d\n", width, height); - } -#endif - - return 0; -} - - - diff --git a/test/v4l_h264/Makefile.am b/test/v4l_h264/Makefile.am deleted file mode 100644 index 377850a..0000000 --- a/test/v4l_h264/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2012 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 NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - -SUBDIRS = encode decode - -EXTRA_DIST = \ - README.txt \ - $(NULL) diff --git a/test/v4l_h264/README.txt b/test/v4l_h264/README.txt deleted file mode 100644 index cbb0f10..0000000 --- a/test/v4l_h264/README.txt +++ /dev/null @@ -1,23 +0,0 @@ -V4L-H264 -======== -The goal of the sample code is to demonstrate the H264 encoding and decoding capabilities of Intel GPU, Sandy Bridge and successor, using libva API under X11. - -Encoder part is based on http://cgit.freedesktop.org/libva/tree/test/encode/avcenc.c -V4L-Capture part is based on http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html - - -Running it locally: It's mandatory to start the `decode' first. -./decode -> will wait for a connection -./encode -> will try to open /dev/video0, configure it and stream it out - -Specifying the port, ip and video input parameters - -Window A (first): -./decode -p 9999 - -Window B (second): -./encode -p 9999 -I 192.168.1.144 -d /dev/video0 -W 1280 -H 960 - -For more info: -./encode -? -./decode -? diff --git a/test/v4l_h264/decode/Makefile.am b/test/v4l_h264/decode/Makefile.am deleted file mode 100644 index 4e77dd5..0000000 --- a/test/v4l_h264/decode/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2012 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 NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - -noinst_PROGRAMS = decode - -decode_SOURCES = decode_x11.cpp TCPSocketServer.cpp -decode_CFLAGS = -I$(top_srcdir) $(X11_CFLAGS) -decode_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/va/libva-x11.la \ - $(X11_LIBS) - -valgrind: $(bin_PROGRAMS) - for a in $(bin_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done - -EXTRA_DIST = \ - TCPSocketServer.h \ - $(NULL) diff --git a/test/v4l_h264/decode/TCPSocketServer.cpp b/test/v4l_h264/decode/TCPSocketServer.cpp deleted file mode 100644 index ad33d77..0000000 --- a/test/v4l_h264/decode/TCPSocketServer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* -* C++ wrapper around an TCP socket -*/ - -#include -#include -#include // for data types -#include // for socket(), connect(), send(), recv() -#include // for IPPROTO_TCP, sockadd_in -#include // for inet_ntoa() -#include // for close() -#include // for hostent, gethostbyname() -#include // for fcntl() -#include - -#include // for memset - -#include "TCPSocketServer.h" - -using std::string; - - -TCPSocketServer::TCPSocketServer(unsigned short localPort) throw(std::runtime_error) : -sockDesc(-1), - connSockDesc(-1) -{ - // create new socket - if ((sockDesc = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - throw std::runtime_error("Socket creation failed (socket())"); - } - - ::memset(&sockAddr, 0, sizeof(sockAddr)); - ::memset(&connSockAddr, 0, sizeof(connSockAddr)); - - sockAddr.sin_family = AF_INET; - sockAddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockAddr.sin_port = htons(localPort); - - if (bind(sockDesc, (sockaddr *) &sockAddr, sizeof(sockAddr)) < 0) - { - throw std::runtime_error("Bind to local port failed (bind())"); - } - - if (listen(sockDesc, 2) < 0) - { - throw std::runtime_error("Socket initialization failed (listen())"); - } -} - - -/* Destructor */ -TCPSocketServer::~TCPSocketServer() -{ - if (connSockDesc > 0) { - ::close(connSockDesc); - } - - ::close(sockDesc); -} - - -/* Listen for an incoming connection */ -void TCPSocketServer::accept(string &remoteAddr, unsigned short &remotePort) throw (std::runtime_error) -{ - if (connSockDesc > 0) { - throw std::runtime_error("accept() called, but socket is already connected"); - } - - socklen_t connSockLen = sizeof(connSockAddr); - if ((connSockDesc = ::accept(sockDesc, (sockaddr *) &connSockAddr, &connSockLen)) < 0) { - throw std::runtime_error("Connection accept failed (accept())"); - } - - remoteAddr = inet_ntoa(connSockAddr.sin_addr); - remotePort = ntohs(connSockAddr.sin_port); -} - - -/* Communication over socket */ -/* Receive data */ -ssize_t TCPSocketServer::recv(void *buffer, const size_t &bufferLen) throw (std::runtime_error) -{ - if (connSockDesc <= 0) { - throw std::runtime_error("recv() called, but socket is not connected. Call accept() first"); - } - - int rval = ::read(connSockDesc, buffer, bufferLen); - - if (rval <= 0) { - // EOF (connection closed by remote host) or error: - // reset state, so a new accept() call will succeed - connSockDesc = -1; - ::memset(&connSockAddr, 0, sizeof(connSockAddr)); - } - - if (rval == -1) { - throw std::runtime_error("Error reading from socket (read())"); - } - - return rval; -} - - -/* Send data */ -ssize_t TCPSocketServer::send(const void *buffer, const int &bufferLen) throw (std::runtime_error) -{ - if (connSockDesc <= 0) { - throw std::runtime_error("send() called, but socket is not connected. Call accept() first"); - } - - int rval = ::write(connSockDesc, buffer, bufferLen); - - if (rval <= 0) { - // EOF (connection closed by remote host) or error: - // reset state, so a new accept() call will succeed - connSockDesc = -1; - ::memset(&connSockAddr, 0, sizeof(connSockAddr)); - } - - if (rval == -1) { - throw std::runtime_error("Error reading from socket (read())"); - } - - return rval; -} - -ssize_t TCPSocketServer::send(const string &message) throw (std::runtime_error) -{ - send(message.c_str(), message.length()); -} - - -int TCPSocketServer::recv_data(unsigned char *data, int size) -{ - int total = 0; - try { - int pos = 0; - int recvMsgSize; - for (;;) { - // try to receive a message - recvMsgSize = recv(&data[pos], size); - if ((recvMsgSize < 0) && (errno == EWOULDBLOCK)) { - // no data received on non-blocking socket - usleep(100); - } else { - total += recvMsgSize; - if (recvMsgSize != size) { - pos += recvMsgSize; - size -= recvMsgSize; - } else { - break; - } - } - } - } - catch (const std::exception& e) { - printf("%s\n", e.what()); - exit(1); - } - return total; -} - -unsigned int TCPSocketServer::recv_uint32() -{ - unsigned int buffer; - recv_data((unsigned char*)&buffer, 4); - return buffer; -} diff --git a/test/v4l_h264/decode/TCPSocketServer.h b/test/v4l_h264/decode/TCPSocketServer.h deleted file mode 100644 index 6ed2d6c..0000000 --- a/test/v4l_h264/decode/TCPSocketServer.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* -* C++ wrapper around an TCP socket -*/ - -#ifndef __TCP_SOCKET_H__ -#define __TCP_SOCKET_H__ - -#include - -#include // for IPPROTO_TCP, sockadd_in - -#ifndef SERVER_ADDR -#define SERVER_ADDR "localhost" -#endif -#ifndef SERVER_PORT -#define SERVER_PORT 8888 -#endif - - -class TCPSocketServer -{ -public: - /* Constructors */ - /** - * Construct generic TCPSocket - * XXX: Don't use, use the constructor with explicit port specification instead - **/ - //TCPSocketServer() throw(std::runtime_error); - - /** - * Construct TCPSocket that binds to the given local port - * parameters: - * - localPort: port to bind to - **/ - TCPSocketServer(unsigned short localPort) throw(std::runtime_error); - - - /* Destructor */ - ~TCPSocketServer(); - - - /* Handle incoming connections */ - /** - * Listen for an incoming connection. - * This call blocks until a connection with a remote peer has been established. - * parameters: - * - remoteAddr: (OUT) contains address of peer - * - remotePort: (OUT) contains port of peer - * return value: - * none - **/ - void accept(std::string &remoteAddr, unsigned short &remotePort) throw(std::runtime_error); - - - /* Communication over socket */ - /** - * Receive data from remote peer. - * parameters: - * - buffer: buffer to receive data - * - bufferLen: maximum number of bytes to receive - * return value: - * number of bytes received, 0 means connection closed by peer - **/ - ssize_t recv(void *buffer, const size_t &bufferLen) throw (std::runtime_error); - - /** - * Send data to remote peer. - * parameters: - * - buffer: buffer to send - * - bufferLen: number of bytes in buffer - * return value: - * number of bytes actually written - **/ - ssize_t send(const void *buffer, const int &bufferLen) throw (std::runtime_error); - - /** - * Sends the given string over the TCP connection. - * This is a convenience method which calls the previous method with the correct - * length parameter. - * parameters: - * - message: message to send - * return value: - * number of bytes actually written - **/ - ssize_t send(const std::string &message) throw (std::runtime_error); - - - int recv_data(unsigned char *data, int size); - unsigned int recv_uint32(); - - -private: - // don't allow value semantics on this object - TCPSocketServer(const TCPSocketServer &sock); - void operator=(const TCPSocketServer &sock); - - int sockDesc; // listening socket descriptor - sockaddr_in sockAddr; // structure keeping IP and port of peer - - int connSockDesc; // connected socket descriptor - sockaddr_in connSockAddr; -}; - -#endif // __TCP_SOCKET_H__ diff --git a/test/v4l_h264/decode/decode_x11.cpp b/test/v4l_h264/decode/decode_x11.cpp deleted file mode 100644 index 418cf00..0000000 --- a/test/v4l_h264/decode/decode_x11.cpp +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -//#define XT_DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "TCPSocketServer.h" -using std::string; - -#define MYPROF VAProfileH264High - -int g_Debug = 0; -int ip_port = 8888; -TCPSocketServer *sock_ptr = NULL; -#define SURFACE_NUM 7 -static Display *win_display; -static VADisplay va_dpy; -Window win; -int g_PX = 50; -int g_PY = 0; -bool g_LiveView = true; -int pwm; -int phm; -VAContextID context_id; -VASurfaceID surface_id[SURFACE_NUM]; -int win_width = 0, win_height = 0; -int surface_width = 0, surface_height = 0; -static int time_to_quit = 0; - -static void SignalHandler(int a_Signal) -{ - time_to_quit = 1; - signal(SIGINT, SIG_DFL); -} - - -void InitSock() -{ - try { - sock_ptr = new TCPSocketServer(ip_port); - } - catch (const std::exception& e) - { - std::cerr << e.what() << '\n'; - exit(1); - } -} - - - - -/*currently, if XCheckWindowEvent was called in more than one thread, it would cause -* XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" -* after 87 requests (83 known processed) with 0 events remaining. -* -* X Error of failed request: BadGC (invalid GC parameter) -* Major opcode of failed request: 60 (X_FreeGC) -* Resource id in failed request: 0x600034 -* Serial number of failed request: 398 -* Current serial number in output stream: 399 -* The root cause is unknown. */ - -VAStatus gva_status; -VASurfaceStatus gsurface_status; -#define CHECK_SURF(X) \ - gva_status = vaQuerySurfaceStatus(va_dpy, X, &gsurface_status); \ - if (gsurface_status != 4) printf("ss: %d\n", gsurface_status); - - - -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ - exit(1); \ - } else { \ - /* fprintf(stderr,">> SUCCESS for: %s:%s (%d)\n", __func__, func, __LINE__); */ \ - } - -void SetWindowTitle(const char* title, ...) -{ - char buf[256]; - va_list args; - va_start(args, title); - vsprintf(buf, title, args); - va_end(args); - XSetStandardProperties(win_display,win, buf, buf, None, NULL, 0, NULL); -} - - -#ifdef XT_DEBUG -static inline void PrintFlagIfNotZero( - const char *name, /* in */ - unsigned int flag /* in */ - ) -{ - if (flag != 0) { - printf("%s = %x\n", name, flag); - } -} - -void DumpVAPictureH264(VAPictureH264 *p, char *s) -{ - printf("%s:\n", s); - printf(" picture_id=0x%x\n", p->picture_id); - printf(" frame_idx=%d\n", p->frame_idx); - printf(" flags=%d\n", p->flags); - printf(" TopFieldOrderCnt=%d\n", p->TopFieldOrderCnt); - printf(" BottomFieldOrderCnt=%d\n", p->BottomFieldOrderCnt); -} - - -void DumpVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p) -{ - int i; - printf("VAPictureParameterBufferH264\n"); - printf("\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id); - printf("\tCurrPic.frame_idx = %d\n", p->CurrPic.frame_idx); - printf("\tCurrPic.flags = %d\n", p->CurrPic.flags); - printf("\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt); - printf("\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt); - printf("\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx:\n"); - for (i = 0; i < 16; i++) { - if (p->ReferenceFrames[i].flags != VA_PICTURE_H264_INVALID) { - printf("\t\t%d-%d-0x%08x-%d\n", - p->ReferenceFrames[i].TopFieldOrderCnt, - p->ReferenceFrames[i].BottomFieldOrderCnt, - p->ReferenceFrames[i].picture_id, - p->ReferenceFrames[i].frame_idx); - } else { -#ifdef EXTRA_LOGS - printf("\t\tinv-inv-inv-inv\n"); -#endif - } - } - printf("\n"); - printf("\tpicture_width_in_mbs_minus1 = %d\n", p->picture_width_in_mbs_minus1); - printf("\tpicture_height_in_mbs_minus1 = %d\n", p->picture_height_in_mbs_minus1); - printf("\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8); - printf("\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8); - printf("\tnum_ref_frames = %d\n", p->num_ref_frames); - printf("\tseq fields = %d\n", p->seq_fields.value); - printf("\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc); - printf("\tresidual_colour_transform_flag = %d\n", p->seq_fields.bits.residual_colour_transform_flag); - printf("\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag); - printf("\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag); - printf("\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag); - printf("\tMinLumaBiPredSize8x8 = %d\n", p->seq_fields.bits.MinLumaBiPredSize8x8); - printf("\tnum_slice_groups_minus1 = %d\n", p->num_slice_groups_minus1); - printf("\tslice_group_map_type = %d\n", p->slice_group_map_type); - printf("\tslice_group_change_rate_minus1 = %d\n", p->slice_group_change_rate_minus1); - printf("\tpic_init_qp_minus26 = %d\n", p->pic_init_qp_minus26); - printf("\tpic_init_qs_minus26 = %d\n", p->pic_init_qs_minus26); - printf("\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset); - printf("\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset); - printf("\tpic_fields = 0x%03x\n", p->pic_fields.value); -#ifdef EXTRA_LOGS - PrintFlagIfNotZero("\t\tentropy_coding_mode_flag", p->pic_fields.bits.entropy_coding_mode_flag); - PrintFlagIfNotZero("\t\tweighted_pred_flag", p->pic_fields.bits.weighted_pred_flag); - PrintFlagIfNotZero("\t\tweighted_bipred_idc", p->pic_fields.bits.weighted_bipred_idc); - PrintFlagIfNotZero("\t\ttransform_8x8_mode_flag", p->pic_fields.bits.transform_8x8_mode_flag); - PrintFlagIfNotZero("\t\tfield_pic_flag", p->pic_fields.bits.field_pic_flag); - PrintFlagIfNotZero("\t\tconstrained_intra_pred_flag", p->pic_fields.bits.constrained_intra_pred_flag); - PrintFlagIfNotZero("\t\tpic_order_present_flag", p->pic_fields.bits.pic_order_present_flag); - PrintFlagIfNotZero("\t\tdeblocking_filter_control_present_flag", p->pic_fields.bits.deblocking_filter_control_present_flag); - PrintFlagIfNotZero("\t\tredundant_pic_cnt_present_flag", p->pic_fields.bits.redundant_pic_cnt_present_flag); - PrintFlagIfNotZero("\t\treference_pic_flag", p->pic_fields.bits.reference_pic_flag); -#endif - printf("\tframe_num = %d\n", p->frame_num); -} -#endif - - -void SetVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p) -{ - int i; - memset(p, 0, sizeof(VAPictureParameterBufferH264)); - p->picture_width_in_mbs_minus1 = pwm; - p->picture_height_in_mbs_minus1 = phm; - p->num_ref_frames = 1; - p->seq_fields.value = 145; - /* - p->seq_fields.bits.chroma_format_idc = 1; - p->seq_fields.bits.frame_mbs_only_flag = 1; - p->seq_fields.bits.MinLumaBiPredSize8x8 = 1; - */ - p->pic_fields.value = 0x501; - for (i = 0; i < 16; i++) { - p->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID; - p->ReferenceFrames[i].picture_id = 0xffffffff; - - } -} - - - -void SetVASliceParameterBufferH264(VASliceParameterBufferH264 *p) -{ - int i; - memset(p, 0, sizeof(VASliceParameterBufferH264)); - p->slice_data_size = 0; - p->slice_data_bit_offset = 64; - p->slice_alpha_c0_offset_div2 = 2; - p->slice_beta_offset_div2 = 2; - p->chroma_weight_l0_flag = 1; - p->chroma_weight_l0[0][0]=1; - p->chroma_offset_l0[0][0]=0; - p->chroma_weight_l0[0][1]=1; - p->chroma_offset_l0[0][1]=0; - p->luma_weight_l1_flag = 1; - p->chroma_weight_l1_flag = 1; - p->luma_weight_l0[0]=0x01; - for (i = 0; i < 32; i++) { - p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID; - p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID; - // p->ReferenceFrames[i].picture_id = 0xffffffff; - } - p->RefPicList1[0].picture_id = 0xffffffff; //0xaa0000bb; -} - - - -void SetVASliceParameterBufferH264_T2(VASliceParameterBufferH264 *p, int first) -{ - int i; - memset(p, 0, sizeof(VASliceParameterBufferH264)); - p->slice_data_size = 0; - p->slice_data_bit_offset = 64; - p->slice_alpha_c0_offset_div2 = 2; - p->slice_beta_offset_div2 = 2; - p->slice_type = 2; - if (first) { - p->luma_weight_l0_flag = 1; - p->chroma_weight_l0_flag = 1; - p->luma_weight_l1_flag = 1; - p->chroma_weight_l1_flag = 1; - } else { - p->chroma_weight_l0_flag = 1; - p->chroma_weight_l0[0][0]=1; - p->chroma_offset_l0[0][0]=0; - p->chroma_weight_l0[0][1]=1; - p->chroma_offset_l0[0][1]=0; - p->luma_weight_l1_flag = 1; - p->chroma_weight_l1_flag = 1; - p->luma_weight_l0[0]=0x01; - } - for (i = 0; i < 32; i++) { - p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID; - p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID; - // p->ReferenceFrames[i].picture_id = 0xffffffff; - } - p->RefPicList1[0].picture_id = 0xffffffff; - p->RefPicList0[0].picture_id = 0xffffffff; -} - - -unsigned char m_MatrixBufferH264[]= { - //ScalingList4x4[6][16] - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - //ScalingList8x8[2][64] - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -}; - -#ifdef XT_DEBUG -void DumpVASliceParameterBufferH264(VASliceParameterBufferH264 *p) -{ - int i; - printf("\telement[0] = VASliceParameterBufferH264\n"); - printf("\tslice_data_size = %d\n", p->slice_data_size); - printf("\tslice_data_offset = %d\n", p->slice_data_offset); - printf("\tslice_data_flag = %d\n", p->slice_data_flag); - printf("\tslice_data_bit_offset = %d\n", p->slice_data_bit_offset); - printf("\tfirst_mb_in_slice = %d\n", p->first_mb_in_slice); - printf("\tslice_type = %d\n", p->slice_type); - printf("\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag); - printf("\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1); - printf("\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - printf("\tcabac_init_idc = %d\n", p->cabac_init_idc); - printf("\tslice_qp_delta = %d\n", p->slice_qp_delta); - printf("\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc); - printf("\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2); - printf("\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - if (p->slice_type == 0 || p->slice_type == 1) { - printf("\tRefPicList0 ="); - for (i = 0; i < p->num_ref_idx_l0_active_minus1 + 1; i++) { - printf("%d-%d-0x%08x-%d\n", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt, p->RefPicList0[i].picture_id, p->RefPicList0[i].frame_idx); - } - if (p->slice_type == 1) { - printf("\tRefPicList1 ="); - for (i = 0; i < p->num_ref_idx_l1_active_minus1 + 1; i++) - { - printf("%d-%d-0x%08x-%d\n", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt, p->RefPicList1[i].picture_id, p->RefPicList1[i].frame_idx); - } - } - } - printf("\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom); - printf("\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom); - printf("\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag); - if (p->luma_weight_l0_flag) { - for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) { - printf("\t%d ", p->luma_weight_l0[i]); - printf("\t%d ", p->luma_offset_l0[i]); - } - printf("\n"); - } - printf("\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag); - if (p->chroma_weight_l0_flag) { - for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) { - printf("\t\t%d ", p->chroma_weight_l0[i][0]); - printf("\t\t%d ", p->chroma_offset_l0[i][0]); - printf("\t\t%d ", p->chroma_weight_l0[i][1]); - printf("\t\t%d ", p->chroma_offset_l0[i][1]); - } - printf("\n"); - } - printf("\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag); - if (p->luma_weight_l1_flag) { - for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) { - printf("\t\t%d ", p->luma_weight_l1[i]); - printf("\t\t%d ", p->luma_offset_l1[i]); - } - printf("\n"); - } - printf("\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag); - if (p->chroma_weight_l1_flag) { - for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) { - printf("\t\t%d ", p->chroma_weight_l1[i][0]); - printf("\t\t%d ", p->chroma_offset_l1[i][0]); - printf("\t\t%d ", p->chroma_weight_l1[i][1]); - printf("\t\t%d ", p->chroma_offset_l1[i][1]); - } - printf("\n"); - } -} -#endif - - -static void usage (FILE * fp, int argc, char ** argv) -{ - fprintf (fp, - "Usage: %s [options]\n" - "\n" - "Options:\n" - "-?, --help Print this message\n" - "-p, --port=PORT Listen port [%d]\n" - "-l, --liveview-off Live View off\n" - "-x, --posx=POS_X X position [WM handles placement]\n" - "-y, --posy=POS_Y Y position [WM handles placement]\n" - "-w, --width=WIDTH Window width [same as Surface]\n" - "-h, --height=HEIGHT Window height [same as Surface]\n" - "-d, --debug=LEVEL Debug level [%d]\n" - "\n", - argv[0], ip_port, g_Debug); -} - -static const char short_options [] = "?p:lx:y:w:h:d:"; - -static const struct option - long_options [] = { - { "help", no_argument, NULL, '?' }, - { "port", required_argument, NULL, 'p' }, - { "liveview-off", no_argument, NULL, 'l' }, - { "posx", required_argument, NULL, 'x' }, - { "posy", required_argument, NULL, 'y' }, - { "width", required_argument, NULL, 'w' }, - { "height", required_argument, NULL, 'h' }, - { "debug", required_argument, NULL, 'd' }, - { 0, 0, 0, 0 } -}; - - -int main(int argc,char **argv) -{ - int t2first = 1; - int real_frame = 0; - int slice_type = 2; - int FieldOrderCnt = 0; - int major_ver, minor_ver; - int i; - unsigned char frid = 0; - int z; - int sid = 0; - int newsid = 0; - unsigned int data_size = 0; - unsigned int frame_count = 0; - std::string remoteAddr; - unsigned short remotePort; - char *dh264 = NULL; - int num_entrypoints,vld_entrypoint; - VAStatus va_status; - VAIQMatrixBufferH264 *mh264 = NULL; - VAPictureParameterBufferH264 *ph264 = NULL; - VASliceParameterBufferH264 *sh264 = NULL; - VABufferID bufids[10]; - VAEntrypoint entrypoints[5]; - VAConfigAttrib attrib; - VAConfigID config_id; - VABufferID pic_param_buf_id[SURFACE_NUM]; - VABufferID mat_param_buf_id[SURFACE_NUM]; - VABufferID sp_param_buf_id[SURFACE_NUM]; - VABufferID d_param_buf_id[SURFACE_NUM]; - VAPictureH264 my_VAPictureH264; - VAPictureH264 my_old_VAPictureH264; - - - for (;;) { - int index; - int c; - - c = getopt_long (argc, argv, - short_options, long_options, - &index); - - if (-1 == c) - break; - - switch (c) { - case 0: /* getopt_long() flag */ - break; - - case '?': - usage (stdout, argc, argv); - exit (EXIT_SUCCESS); - case 'p': - ip_port = atoi(optarg); - break; - case 'l': - g_LiveView = false; - break; - case 'x': - g_PX = atoi(optarg); - break; - case 'y': - g_PY = atoi(optarg); - break; - case 'w': - win_width = atoi(optarg); - break; - case 'h': - win_height = atoi(optarg); - break; - case 'd': - g_Debug = atoi(optarg); - break; - default: - usage (stderr, argc, argv); - exit (EXIT_FAILURE); - } - } - - InitSock(); - - printf("Accept - start\n"); - sock_ptr->accept(remoteAddr, remotePort); - printf("Accept - done (%s:%d)\n", remoteAddr.c_str(), remotePort); - - surface_width = sock_ptr->recv_uint32(); - surface_height = sock_ptr->recv_uint32(); - if (!win_width) { - win_width = surface_width; - } - if (!win_height) { - win_height = surface_height; - } - pwm = sock_ptr->recv_uint32(); - phm = sock_ptr->recv_uint32(); - - win_display = (Display *)XOpenDisplay(":0.0"); - if (win_display == NULL) { - fprintf(stderr, "Can't open the connection of display!\n"); - exit(-1); - } - if (g_LiveView) { - win = XCreateSimpleWindow(win_display, RootWindow(win_display, 0), 0, 0, win_width, win_height, 0, 0, WhitePixel(win_display, 0)); - XMapWindow(win_display, win); - SetWindowTitle("Decode H264 (%dx%d in %dx%d) TCP", surface_width,surface_height, win_width, win_height); - if ((g_PX !=-1) && (g_PY !=-1)) { - XMoveWindow(win_display, win, g_PX, g_PY); - } - XSync(win_display, False); - } - if(signal(SIGINT, SignalHandler) == SIG_ERR) { - printf("signal() failed\n"); - time_to_quit = 1; - exit(-1); - } - va_dpy = vaGetDisplay(win_display); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - - va_status = vaQueryConfigEntrypoints(va_dpy, MYPROF, entrypoints, &num_entrypoints); - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); - for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { - if (entrypoints[vld_entrypoint] == VAEntrypointVLD) - break; - } - if (vld_entrypoint == num_entrypoints) { - /* not find VLD entry point */ - assert(0); - } - /* Assuming finding VLD, find out the format for the render target */ - attrib.type = VAConfigAttribRTFormat; - vaGetConfigAttributes(va_dpy, MYPROF, VAEntrypointVLD, &attrib, 1); - if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - CHECK_VASTATUS(va_status, "vaGetConfigAttributes"); - va_status = vaCreateConfig(va_dpy, MYPROF, VAEntrypointVLD, &attrib, 1,&config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig"); - va_status = vaCreateSurfaces(va_dpy,surface_width,surface_height,VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - va_status = vaCreateContext(va_dpy, config_id, surface_width,surface_height, 0/*VA_PROGRESSIVE*/, &surface_id[0], SURFACE_NUM, &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); - for(i=0; irecv_uint32(); - slice_type = sock_ptr->recv_uint32(); - switch(slice_type) { - case 0: - case 2: - break; - default: - printf("Wrong type: %d\n", slice_type); - exit(-1); - break; - } - data_size = sock_ptr->recv_uint32(); - if (g_Debug) { - printf("T=%d S=%8d [%8d]\n", slice_type, data_size, frame_count); - } - my_VAPictureH264.picture_id = surface_id[sid]; - my_VAPictureH264.frame_idx = frid; - my_VAPictureH264.flags = 0; - my_VAPictureH264.BottomFieldOrderCnt = FieldOrderCnt; - my_VAPictureH264.TopFieldOrderCnt = FieldOrderCnt; - if (pic_param_buf_id[sid] == VA_INVALID_ID) { - va_status = vaCreateBuffer(va_dpy, context_id, VAPictureParameterBufferType, sizeof(VAPictureParameterBufferH264), 1, NULL, &pic_param_buf_id[sid]); - } - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - CHECK_SURF(surface_id[sid]); - va_status = vaMapBuffer(va_dpy,pic_param_buf_id[sid],(void **)&ph264); - CHECK_VASTATUS(va_status, "vaMapBuffer"); - SetVAPictureParameterBufferH264(ph264); - memcpy(&ph264->CurrPic, &my_VAPictureH264, sizeof(VAPictureH264)); - if (slice_type == 2) { - } else { - memcpy(&ph264->ReferenceFrames[0], &my_old_VAPictureH264, sizeof(VAPictureH264)); - ph264->ReferenceFrames[0].flags = 0; - } - ph264->frame_num = frid; - -#ifdef XT_DEBUG - DumpVAPictureParameterBufferH264(ph264); -#endif - va_status = vaUnmapBuffer(va_dpy,pic_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaUnmapBuffer"); - - if (mat_param_buf_id[sid] == VA_INVALID_ID) { - va_status = vaCreateBuffer(va_dpy, context_id, VAIQMatrixBufferType, sizeof(VAIQMatrixBufferH264), 1, NULL, &mat_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - } - CHECK_SURF(surface_id[sid]); - va_status = vaMapBuffer(va_dpy, mat_param_buf_id[sid], (void **)&mh264); - CHECK_VASTATUS(va_status, "vaMapBuffer"); - memcpy(mh264, m_MatrixBufferH264, 224); - va_status = vaUnmapBuffer(va_dpy, mat_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaUnmapBuffer"); - bufids[0] = pic_param_buf_id[sid]; - bufids[1] = mat_param_buf_id[sid]; - CHECK_SURF(surface_id[sid]); - va_status = vaRenderPicture(va_dpy, context_id, bufids, 2); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - if (sp_param_buf_id[sid] == VA_INVALID_ID) { - va_status = vaCreateBuffer(va_dpy, context_id, VASliceParameterBufferType, sizeof(VASliceParameterBufferH264), 1, NULL, &sp_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - } - CHECK_SURF(surface_id[sid]); - va_status = vaMapBuffer(va_dpy, sp_param_buf_id[sid], (void **)&sh264); - CHECK_VASTATUS(va_status, "vaMapBuffer"); - if (slice_type == 2) { - SetVASliceParameterBufferH264_T2(sh264, t2first); - t2first = 0; - } else { - SetVASliceParameterBufferH264(sh264); - memcpy(&sh264->RefPicList0[0], &my_old_VAPictureH264, sizeof(VAPictureH264)); - sh264->RefPicList0[0].flags = 0; - } - sh264->slice_data_bit_offset = 0; - sh264->slice_data_size = data_size; -#ifdef XT_DEBUG - DumpVASliceParameterBufferH264(sh264); -#endif - va_status = vaUnmapBuffer(va_dpy, sp_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaUnmapBuffer"); - CHECK_SURF(surface_id[sid]); - if (d_param_buf_id[sid] == VA_INVALID_ID) { - va_status = vaCreateBuffer(va_dpy, context_id, VASliceDataBufferType, 4177920, 1, NULL, &d_param_buf_id[sid]); // 1080p size - CHECK_VASTATUS(va_status, "vaCreateBuffer"); - } - va_status = vaMapBuffer(va_dpy, d_param_buf_id[sid], (void **)&dh264); - CHECK_VASTATUS(va_status, "vaMapBuffer"); - sock_ptr->recv_data((unsigned char*)dh264, data_size); - CHECK_SURF(surface_id[sid]); - va_status = vaUnmapBuffer(va_dpy, d_param_buf_id[sid]); - CHECK_VASTATUS(va_status, "vaUnmapBuffer"); - bufids[0] = sp_param_buf_id[sid]; - bufids[1] = d_param_buf_id[sid]; - CHECK_SURF(surface_id[sid]); - va_status = vaRenderPicture(va_dpy, context_id, bufids, 2); - CHECK_VASTATUS(va_status, "vaRenderPicture"); - va_status = vaEndPicture(va_dpy, context_id); - CHECK_VASTATUS(va_status, "vaEndPicture"); - newsid = sid+1; - if (newsid==SURFACE_NUM) { - newsid = 0; - } - va_status = vaBeginPicture(va_dpy, context_id, surface_id[newsid]); - CHECK_VASTATUS(va_status, "vaBeginPicture"); - va_status = vaSyncSurface(va_dpy, surface_id[sid]); - CHECK_VASTATUS(va_status, "vaSyncSurface"); - CHECK_SURF(surface_id[sid]); - if (g_LiveView) { - va_status = vaPutSurface(va_dpy, surface_id[sid], win, 0, 0, surface_width, surface_height, 0, 0, win_width, win_height, NULL, 0, VA_FRAME_PICTURE); - CHECK_VASTATUS(va_status, "vaPutSurface"); - } - sid = newsid; - frid++; - if (frid>15) frid = 0; - FieldOrderCnt+=2; - memcpy(&my_old_VAPictureH264, &my_VAPictureH264, sizeof(VAPictureH264)); - real_frame ++; - } - if (g_Debug) { - printf("Final !\n"); - } - vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); - vaTerminate(va_dpy); - XCloseDisplay(win_display); - delete sock_ptr; - - return 0; -} diff --git a/test/v4l_h264/encode/Makefile.am b/test/v4l_h264/encode/Makefile.am deleted file mode 100644 index 7d3a9d4..0000000 --- a/test/v4l_h264/encode/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2012 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 NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - -noinst_PROGRAMS = encode - -encode_SOURCES = capture.cpp avcenc.cpp TCPSocketClient.cpp -encode_CFLAGS = -I$(top_srcdir) $(X11_CFLAGS) -encode_LDADD = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/va/libva-x11.la \ - $(X11_LIBS) - -valgrind: $(bin_PROGRAMS) - for a in $(bin_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done - -EXTRA_DIST = \ - TCPSocketClient.h \ - $(NULL) diff --git a/test/v4l_h264/encode/TCPSocketClient.cpp b/test/v4l_h264/encode/TCPSocketClient.cpp deleted file mode 100644 index 93573a8..0000000 --- a/test/v4l_h264/encode/TCPSocketClient.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* -* C++ wrapper around an TCP socket -*/ - -#include "TCPSocketClient.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -using std::string; - -TCPSocketClient::TCPSocketClient(const std::string &remoteAddr, const unsigned short &remotePort) throw(std::runtime_error) : -sockDesc(-1) -{ - ::memset(&sockAddr, 0, sizeof(sockAddr)); - sockAddr.sin_family = AF_INET; - struct hostent* hp; - if ((hp = gethostbyname(remoteAddr.c_str())) == NULL) { - throw std::runtime_error("Unknown host " + remoteAddr); - } - bcopy(hp->h_addr, &sockAddr.sin_addr, hp->h_length); - sockAddr.sin_port = htons(remotePort); - if ((sockDesc = socket(PF_INET, SOCK_STREAM, 0)) < 0) { - throw std::runtime_error("Socket creation failed (socket())"); - } - /* Try to connect */ - if (connect(sockDesc, (struct sockaddr *) &sockAddr, sizeof(sockAddr)) < 0) { - throw std::runtime_error("Error connecting to remote host (connect())"); - } -} - -/* Destructor */ -TCPSocketClient::~TCPSocketClient() -{ - if (sockDesc >= 0) { - ::close(sockDesc); - } -} - -/* Communication over socket */ -/* Receive data */ -ssize_t TCPSocketClient::recv(void *buffer, const size_t &bufferLen) throw (std::runtime_error) -{ - if (sockDesc < 0) { - throw std::runtime_error("socket is not connected (recv())"); - } - int rval = ::read(sockDesc, buffer, bufferLen); - if (rval <= 0) { - // EOF (connection closed by remote host) or error: - // reset state, so a new accept() call will succeed - sockDesc = -1; - ::memset(&sockAddr, 0, sizeof(sockAddr)); - } - if (rval == -1) { - throw std::runtime_error("Error reading from socket (read())"); - } - return rval; -} - -/* Send data */ -ssize_t TCPSocketClient::send(const void *buffer, const int &bufferLen) throw (std::runtime_error) -{ - if (sockDesc <= 0) { - throw std::runtime_error("socket is not connected (send())"); - } - - int rval = ::write(sockDesc, buffer, bufferLen); - - if (rval <= 0) { - // EOF (connection closed by remote host) or error: - // reset state, so a new accept() call will succeed - sockDesc = -1; - ::memset(&sockAddr, 0, sizeof(sockAddr)); - } - - if (rval == -1) { - throw std::runtime_error("Error reading from socket (read())"); - } - - return rval; -} - -ssize_t TCPSocketClient::send(const string &message) throw (std::runtime_error) -{ - return send(message.c_str(), message.length()); -} - - -ssize_t TCPSocketClient::send(unsigned int val) throw (std::runtime_error) -{ - return send(&val, 4); -} - diff --git a/test/v4l_h264/encode/TCPSocketClient.h b/test/v4l_h264/encode/TCPSocketClient.h deleted file mode 100644 index 897c91d..0000000 --- a/test/v4l_h264/encode/TCPSocketClient.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* -* C++ wrapper around an TCP socket -*/ - -#ifndef __TCP_SOCKET_H__ -#define __TCP_SOCKET_H__ - -#include -#include // for IPPROTO_TCP, sockadd_in - - -class TCPSocketClient -{ -public: - /* Constructors */ - /** - * Construct generic TCPSocket - * XXX: Don't use, use the constructor with explicit port specification instead - **/ - //TCPSocketClient() throw(std::runtime_error); - - /** - * Construct TCPSocket that connects to the given remote server. - * parameters: - * - remoteAddr: address of server to connect to - * - remotePort: port of server to connect to - **/ - TCPSocketClient(const std::string &remoteAddr, const unsigned short &remotePort) throw(std::runtime_error); - - - /* Destructor */ - ~TCPSocketClient(); - - - /* Communication over socket */ - /** - * Receive data from remote peer. - * parameters: - * - buffer: buffer to receive data - * - bufferLen: maximum number of bytes to receive - * return value: - * number of bytes received, 0 means connection closed by peer - **/ - ssize_t recv(void *buffer, const size_t &bufferLen) throw (std::runtime_error); - - /** - * Send data to remote peer. - * parameters: - * - buffer: buffer to send - * - bufferLen: number of bytes in buffer - * return value: - * number of bytes actually written - **/ - ssize_t send(const void *buffer, const int &bufferLen) throw (std::runtime_error); - - /** - * Sends the given string over the TCP connection. - * This is a convenience method which calls the previous method with the correct - * length parameter. - * parameters: - * - message: message to send - * return value: - * number of bytes actually written - **/ - ssize_t send(const std::string &message) throw (std::runtime_error); - - ssize_t send(unsigned int val) throw (std::runtime_error); - -private: - // don't allow value semantics on this object - TCPSocketClient(const TCPSocketClient &sock); - void operator=(const TCPSocketClient &sock); - - int sockDesc; // socket descriptor - sockaddr_in sockAddr; // structure keeping IP and port of peer -}; - -#endif // __TCP_SOCKET_H__ diff --git a/test/v4l_h264/encode/avcenc.cpp b/test/v4l_h264/encode/avcenc.cpp deleted file mode 100644 index 8a7bcb1..0000000 --- a/test/v4l_h264/encode/avcenc.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* -* Example based on Simple AVC encoder. -* http://cgit.freedesktop.org/libva/tree/test/encode/avcenc.c -* -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "TCPSocketClient.h" - -#define MY_Y 0x22 -#define MY_U 0xff -#define MY_V 0x55 - - -extern TCPSocketClient *sock_ptr; -extern int g_Debug; -extern char *device_settings; -Window win2; -int win2_width = 640; -int win2_height = 480; -int g_PX = -1; -int g_PY = -1; - - -bool g_LiveView = true; -bool g_Force_P_Only = false; -bool g_ShowNumber = true; - - - - -#define SLICE_TYPE_P 0 -#define SLICE_TYPE_B 1 -#define SLICE_TYPE_I 2 - -#define ENTROPY_MODE_CAVLC 0 -#define ENTROPY_MODE_CABAC 1 - -#define PROFILE_IDC_BASELINE 66 -#define PROFILE_IDC_MAIN 77 -#define PROFILE_IDC_HIGH 100 - -#define CHECK_VASTATUS(va_status,func) \ - if (va_status != VA_STATUS_SUCCESS) { \ - std::cerr << __func__ << ':' << func << '(' << __LINE__ << ") failed, exit\n"; \ - exit(1); \ - } - -static Display *x11_display; -static VADisplay va_dpy; -static VAContextID context_id; -static VAConfigID config_id; - -static int picture_width, picture_width_in_mbs; -static int picture_height, picture_height_in_mbs; -static int frame_size; -static int codedbuf_size; - -static int qp_value = 26; - -static int log2_max_frame_num_minus4 = 0; -static int pic_order_cnt_type = 0; -static int log2_max_pic_order_cnt_lsb_minus4 = 0; -static int entropy_coding_mode_flag = ENTROPY_MODE_CABAC; -static int deblocking_filter_control_present_flag = 1; -static int frame_mbs_only_flag = 1; - -static void create_encode_pipe() -{ - VAEntrypoint entrypoints[5]; - int num_entrypoints,slice_entrypoint; - VAConfigAttrib attrib[2]; - int major_ver, minor_ver; - VAStatus va_status; - - x11_display = XOpenDisplay(":0.0"); - assert(x11_display); - - va_dpy = vaGetDisplay(x11_display); - va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); - CHECK_VASTATUS(va_status, "vaInitialize"); - vaQueryConfigEntrypoints(va_dpy, VAProfileH264Baseline, entrypoints, &num_entrypoints); - - for (slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) { - if (entrypoints[slice_entrypoint] == VAEntrypointEncSlice) - break; - } - - if (slice_entrypoint == num_entrypoints) { - /* not find Slice entry point */ - assert(0); - } - - /* find out the format for the render target, and rate control mode */ - attrib[0].type = VAConfigAttribRTFormat; - attrib[1].type = VAConfigAttribRateControl; - vaGetConfigAttributes(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice, &attrib[0], 2); - - if ((attrib[0].value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - assert(0); - } - - if ((attrib[1].value & VA_RC_VBR) == 0) { - /* Can't find matched RC mode */ - std::cerr << "VBR mode not found, exit\n"; - assert(0); - } - - attrib[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */ - attrib[1].value = VA_RC_VBR; /* set to desired RC mode */ - - va_status = vaCreateConfig(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice, &attrib[0], 2,&config_id); - CHECK_VASTATUS(va_status, "vaCreateConfig"); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(va_dpy, config_id, picture_width, picture_height, VA_PROGRESSIVE, 0, 0, &context_id); - CHECK_VASTATUS(va_status, "vaCreateContext"); -} - -static void destory_encode_pipe() -{ - vaDestroyContext(va_dpy,context_id); - vaDestroyConfig(va_dpy,config_id); - vaTerminate(va_dpy); - XCloseDisplay(x11_display); -} - -/*************************************************** -* -* The encode pipe resource define -* -***************************************************/ -static VABufferID seq_parameter = VA_INVALID_ID; /*Sequence level parameter*/ -static VABufferID pic_parameter = VA_INVALID_ID; /*Picture level parameter*/ -static VABufferID slice_parameter = VA_INVALID_ID; /*Slice level parameter, multil slices*/ -static VABufferID coded_buf = VA_INVALID_ID; /*Output buffer, compressed data*/ - -#define SID_NUMBER 3 -#define SID_INPUT_PICTURE 0 -#define SID_REFERENCE_PICTURE 1 -#define SID_RECON_PICTURE 2 -static VASurfaceID surface_ids[SID_NUMBER]; - -/***************************************************/ - -static void alloc_encode_resource() -{ - VAStatus va_status; - seq_parameter = VA_INVALID_ID; - pic_parameter = VA_INVALID_ID; - slice_parameter = VA_INVALID_ID; - - //1. Create sequence parameter set - { - VAEncSequenceParameterBufferH264 seq_h264 = {0}; - seq_h264.level_idc = 30; - seq_h264.picture_width_in_mbs = picture_width_in_mbs; - seq_h264.picture_height_in_mbs = picture_height_in_mbs; - seq_h264.bits_per_second = 384*1000; - seq_h264.initial_qp = qp_value; - seq_h264.min_qp = 3; - va_status = vaCreateBuffer(va_dpy, context_id, VAEncSequenceParameterBufferType, - sizeof(seq_h264),1,&seq_h264,&seq_parameter); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - } - //2. Create surface - va_status = vaCreateSurfaces(va_dpy, picture_width, picture_height, VA_RT_FORMAT_YUV420, SID_NUMBER, &surface_ids[0]); - CHECK_VASTATUS(va_status, "vaCreateSurfaces"); - //3. Create coded buffer - { - va_status = vaCreateBuffer(va_dpy,context_id,VAEncCodedBufferType, codedbuf_size, 1, NULL, &coded_buf); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - } -} - -static void release_encode_resource() -{ - //-3 Relese coded buffer - if (coded_buf != VA_INVALID_ID) - vaDestroyBuffer(va_dpy, coded_buf); - //-2 Release all the surfaces resource - vaDestroySurfaces(va_dpy, &surface_ids[0], SID_NUMBER); - //-1 Destory the sequence level parameter - if (seq_parameter != VA_INVALID_ID) - vaDestroyBuffer(va_dpy, seq_parameter); -} - - -static int get_coded_bitsteam_length(unsigned char *buffer, int buffer_length) -{ - int i; - for (i = buffer_length - 1; i >= 0; i--) { - if (buffer[i]) - break; - } - return i + 1; -} - - - -void SetWindowTitle(const char* title, ...) -{ - va_list args; - va_start(args, title); - char buf[256]; - vsprintf(buf, title, args); - va_end(args); - XSetStandardProperties(x11_display,win2, buf, buf, None, NULL, 0, NULL); -} - - - -int encoder_init(int width, int height) -{ - picture_width = width; - picture_height = height; - picture_width_in_mbs = (picture_width + 15) / 16; - picture_height_in_mbs = (picture_height + 15) / 16; - qp_value = 26; - frame_size = picture_width * picture_height + ((picture_width * picture_height) >> 1) ; - codedbuf_size = picture_width * picture_height * 1.5; - create_encode_pipe(); - alloc_encode_resource(); - sock_ptr->send(picture_width); - sock_ptr->send(picture_height); - sock_ptr->send(picture_width_in_mbs-1); - sock_ptr->send(picture_height_in_mbs-1); - if (g_LiveView) { - win2 = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0, win2_width, win2_height, 0, 0, WhitePixel(x11_display, 0)); - XMapWindow(x11_display, win2); - if ((g_PX !=-1) && (g_PY !=-1)) { - XMoveWindow(x11_display, win2, g_PX, g_PY); - } - SetWindowTitle("Input: %dx%d [TCP] %s",picture_width,picture_height, device_settings); - XSync(x11_display, False); - } - return 0; -} - -void encoder_close() -{ - release_encode_resource(); - destory_encode_pipe(); -} - - -/* 8x8 font 0-9 only - asm type format */ -unsigned char mydigits[80] = { - // 0 - 0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00, - // 1 - 0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00, - // 2 - 0x0E,0x11,0x01,0x02,0x04,0x08,0x1F,0x00, - // 3 - 0x1F,0x02,0x04,0x02,0x01,0x11,0x0E,0x00, - // 4 - 0x02,0x06,0x0A,0x12,0x1F,0x02,0x02,0x00, - // 5 - 0x1F,0x10,0x1E,0x01,0x01,0x11,0x0E,0x00, - // 6 - 0x06,0x08,0x10,0x1E,0x11,0x11,0x0E,0x00, - // 7 - 0x1F,0x01,0x02,0x04,0x04,0x04,0x04,0x00, - // 8 - 0x1E,0x11,0x11,0x0E,0x11,0x11,0x0E,0x00, - //9 - 0x0E,0x11,0x11,0x0F,0x01,0x02,0x0C,0x00 -}; - -#define INTERSIZE 16 - -static void ShowNumber(int num, unsigned char *buffer, VAImage *image) -{ - int j; - char buf[20]; - unsigned char *dst_y; - unsigned char *dst_uv_line; - unsigned char *digits_ptr; - assert(image); - int maxlen = sprintf(buf, "%d", num); - assert(maxlen<20); - for (int a=0; aoffsets[0]) + ((i*2)*image->pitches[0])+(a*INTERSIZE); - dst_uv_line = (buffer + image->offsets[1]) + (i*image->pitches[1])+(a*INTERSIZE); - for (j=7; j>=0;j--) { - if ((current >>j) & 1) { - *dst_y ++ = MY_Y; - *dst_y ++ = MY_Y; - *dst_uv_line++ = MY_U; - *dst_uv_line++ = MY_V; - } else { - dst_y += 2; - dst_uv_line +=2; - } - } - dst_y = (buffer+ image->offsets[0]) + (((i*2)+1)*image->pitches[0])+(a*INTERSIZE); - for (j=7; j>=0;j--) { - if ((current >>j) & 1) { - *dst_y ++ = MY_Y; - *dst_y ++ = MY_Y; - } else { - dst_y += 2; - } - } - } - } -} - - - -static void upload_yuv_to_surface(unsigned char *inbuf, VASurfaceID surface_id, unsigned int frame) -{ - VAImage image; - VAStatus va_status; - void *pbuffer=NULL; - unsigned char *psrc = inbuf; - unsigned char *pdst = NULL; - unsigned char *dst_y, *dst_uv; - unsigned char *src_u, *src_v; - unsigned char *dst_uv_line = NULL; - int i,j; - va_status = vaDeriveImage(va_dpy, surface_id, &image); - va_status = vaMapBuffer(va_dpy, image.buf, &pbuffer); - pdst = (unsigned char *)pbuffer; - dst_uv_line = pdst + image.offsets[1]; - dst_uv = dst_uv_line; - for (i=0; ibuf; - memset(coded_mem, 0, coded_buffer_segment->size); - vaUnmapBuffer(va_dpy, coded_buf); - // Slice level - slice_h264.start_row_number = 0; - slice_h264.slice_height = picture_height/16; /* Measured by MB */ - slice_h264.slice_flags.bits.is_intra = intra_slice; - slice_h264.slice_flags.bits.disable_deblocking_filter_idc = 0; - if ( slice_parameter != VA_INVALID_ID) { - vaDestroyBuffer(va_dpy, slice_parameter); - } - va_status = vaCreateBuffer(va_dpy,context_id,VAEncSliceParameterBufferType, - sizeof(slice_h264),1,&slice_h264,&slice_parameter); - CHECK_VASTATUS(va_status,"vaCreateBuffer");; - va_status = vaRenderPicture(va_dpy,context_id, &slice_parameter, 1); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - - // Prepare for next picture - tempID = surface_ids[SID_RECON_PICTURE]; - surface_ids[SID_RECON_PICTURE] = surface_ids[SID_REFERENCE_PICTURE]; - surface_ids[SID_REFERENCE_PICTURE] = tempID; -} - -static void send_slice_data(unsigned int frcount, int slice_type) -{ - VACodedBufferSegment *coded_buffer_segment; - unsigned char *coded_mem; - int i, slice_data_length; - int mm; - VAStatus va_status; - VASurfaceStatus surface_status; - int is_cabac = (entropy_coding_mode_flag == ENTROPY_MODE_CABAC); - va_status = vaSyncSurface(va_dpy, surface_ids[SID_INPUT_PICTURE]); - CHECK_VASTATUS(va_status,"vaSyncSurface"); - surface_status = (VASurfaceStatus)0; - va_status = vaQuerySurfaceStatus(va_dpy, surface_ids[SID_INPUT_PICTURE], &surface_status); - CHECK_VASTATUS(va_status,"vaQuerySurfaceStatus"); - va_status = vaMapBuffer(va_dpy, coded_buf, (void **)(&coded_buffer_segment)); - CHECK_VASTATUS(va_status,"vaMapBuffer"); - coded_mem = (unsigned char*)coded_buffer_segment->buf; - sock_ptr->send(frcount); - sock_ptr->send(slice_type); - - if (is_cabac) { - if (!coded_buffer_segment->next) { - slice_data_length = get_coded_bitsteam_length(coded_mem, codedbuf_size); - } else { - /* Fixme me - to do: loop to each block and calculate the real data_lenght */ - assert(0); - } - if (g_Debug) { - printf("T=%d BS=%8d SZ=%8d C=%d\n", slice_type, codedbuf_size, slice_data_length, frcount); - }sock_ptr->send(slice_data_length); - sock_ptr->send((unsigned char*)coded_mem, slice_data_length); - } else { - /* FIXME */ - assert(0); - } - vaUnmapBuffer(va_dpy, coded_buf); -} - - -int encode_frame(unsigned char *inbuf) -{ - static unsigned int framecount = 0; - int is_intra = (framecount % 30 == 0); - if (g_Force_P_Only) { - is_intra = 1; - } - VAStatus va_status; - va_status = vaBeginPicture(va_dpy, context_id, surface_ids[SID_INPUT_PICTURE]); - CHECK_VASTATUS(va_status,"vaBeginPicture"); - prepare_input(inbuf, is_intra, framecount); - va_status = vaEndPicture(va_dpy,context_id); - CHECK_VASTATUS(va_status,"vaRenderPicture"); - send_slice_data(framecount, is_intra ? SLICE_TYPE_I : SLICE_TYPE_P); - framecount++; - return 1; -} - diff --git a/test/v4l_h264/encode/capture.cpp b/test/v4l_h264/encode/capture.cpp deleted file mode 100644 index dc3c221..0000000 --- a/test/v4l_h264/encode/capture.cpp +++ /dev/null @@ -1,851 +0,0 @@ -/* - * Copyright (c) 2012 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 NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -/* - * This example is based on: http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html - * V4L2 video capture example - * This program is provided with the V4L2 API - * see http://linuxtv.org/docs.php for more information -*/ - -#include /* EXIT_FAILURE, EXIT_SUCCESS */ -#include -#include /* strerror() */ -#include -#include /* getopt_long() */ -#include /* low-level i/o */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using std::string; - -#include "TCPSocketClient.h" - - -extern bool g_Force_P_Only; -extern bool g_ShowNumber; -extern bool g_LiveView; -char device_settings_buffer[255]; -char *device_settings = NULL; -int g_Debug = 0; -int g_Numerator = 0; -int g_FrameRate = 0; -TCPSocketClient *sock_ptr = NULL; -std::string ip_name = "localhost"; -int ip_port = 8888; -extern int g_PX; -extern int g_PY; -extern int win2_width; -extern int win2_height; - - - - -int encoder_init(int width, int height); -int encode_frame(unsigned char *inbuf); -void encoder_close(); - -#define CLEAR(x) memset (&(x), 0, sizeof (x)) - -typedef enum { - IO_METHOD_READ, - IO_METHOD_MMAP, - IO_METHOD_USERPTR, -} io_method; - -struct buffer { - void * start; - size_t length; -}; - -static char * dev_name = NULL; -static io_method io = IO_METHOD_MMAP; -static int fd = -1; -struct buffer * buffers = NULL; -static unsigned int n_buffers = 0; -static unsigned int width = 176; -static unsigned int height = 144; -static unsigned int pixelformat = V4L2_PIX_FMT_YUYV; - -static int time_to_quit = 0; -static void SignalHandler(int a_Signal) -{ - time_to_quit = 1; - signal(SIGINT, SIG_DFL); -} - -static void - errno_exit (const char * s) -{ - std::cerr << s << " error " << errno << ", " << strerror(errno) << '\n'; - exit (EXIT_FAILURE); -} - -static int xioctl (int fd, int request, void * arg) -{ - int r; - do r = ioctl (fd, request, arg); - while (-1 == r && EINTR == errno); - return r; -} - - -static void - process_image (const void * p, ssize_t size) -{ - const size_t src_frame_size = (width*height) + height*(width >> 1) + height*(width >> 1); - if (size != src_frame_size){ - std::cerr << "wrong buffer size: " << size << "; expect: " << src_frame_size << '\n'; - return; - } - if (!encode_frame((unsigned char *)p)) - time_to_quit = 1; -} - -static int - read_frame (void) -{ - struct v4l2_buffer buf; - unsigned int i; - switch (io) { - case IO_METHOD_READ: - if (-1 == read (fd, buffers[0].start, buffers[0].length)) { - switch (errno) { - case EAGAIN: - return 0; - case EIO: - /* Could ignore EIO, see spec. */ - /* fall through */ - default: - errno_exit ("read"); - } - } - process_image (buffers[0].start, buffers[0].length); - break; - - case IO_METHOD_MMAP: - CLEAR (buf); - - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_MMAP; - - if (-1 == xioctl (fd, VIDIOC_DQBUF, &buf)) { - switch (errno) { - case EAGAIN: - return 0; - - case EIO: - /* Could ignore EIO, see spec. */ - /* fall through */ - default: - errno_exit ("VIDIOC_DQBUF"); - } - } - - assert (buf.index < n_buffers); - - process_image (buffers[buf.index].start, buf.length); - - if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) - errno_exit ("VIDIOC_QBUF"); - - break; - - case IO_METHOD_USERPTR: - CLEAR (buf); - - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_USERPTR; - - if (-1 == xioctl (fd, VIDIOC_DQBUF, &buf)) { - switch (errno) { - case EAGAIN: - return 0; - - case EIO: - /* Could ignore EIO, see spec. */ - /* fall through */ - default: - errno_exit ("VIDIOC_DQBUF"); - } - } - - for (i = 0; i < n_buffers; ++i) - if (buf.m.userptr == (unsigned long) buffers[i].start && buf.length == buffers[i].length) - break; - - assert (i < n_buffers); - process_image ((void *) buf.m.userptr, buf.length); - if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) - errno_exit ("VIDIOC_QBUF"); - - break; - } - - return 1; -} - -static void - mainloop (void) -{ - while (!time_to_quit) { - for (;;) { - fd_set fds; - struct timeval tv; - int r; - - FD_ZERO (&fds); - FD_SET (fd, &fds); - - /* Timeout. */ - tv.tv_sec = 5; - tv.tv_usec = 0; - - r = select (fd + 1, &fds, NULL, NULL, &tv); - - if (-1 == r) { - if (EINTR == errno) - continue; - - errno_exit ("select"); - } - - if (0 == r) { - std::cerr << "select timeout\n"; - exit (EXIT_FAILURE); - } - - if (read_frame ()) - break; - - /* EAGAIN - continue select loop. */ - } - } -} - -static void - stop_capturing (void) -{ - enum v4l2_buf_type type; - - switch (io) { - case IO_METHOD_READ: - /* Nothing to do. */ - break; - - case IO_METHOD_MMAP: - case IO_METHOD_USERPTR: - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - if (-1 == xioctl (fd, VIDIOC_STREAMOFF, &type)) - errno_exit ("VIDIOC_STREAMOFF"); - - break; - } -} - -static void - start_capturing (void) -{ - unsigned int i; - enum v4l2_buf_type type; - - switch (io) { - case IO_METHOD_READ: - /* Nothing to do. */ - break; - - case IO_METHOD_MMAP: - for (i = 0; i < n_buffers; ++i) { - struct v4l2_buffer buf; - - CLEAR (buf); - - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_MMAP; - buf.index = i; - - if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) - errno_exit ("VIDIOC_QBUF"); - } - - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - if (-1 == xioctl (fd, VIDIOC_STREAMON, &type)) - errno_exit ("VIDIOC_STREAMON"); - - break; - - case IO_METHOD_USERPTR: - for (i = 0; i < n_buffers; ++i) { - struct v4l2_buffer buf; - - CLEAR (buf); - - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_USERPTR; - buf.index = i; - buf.m.userptr = (unsigned long) buffers[i].start; - buf.length = buffers[i].length; - - if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) - errno_exit ("VIDIOC_QBUF"); - } - - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - if (-1 == xioctl (fd, VIDIOC_STREAMON, &type)) - errno_exit ("VIDIOC_STREAMON"); - - break; - } -} - -static void uninit_device (void) -{ - unsigned int i; - - switch (io) { - case IO_METHOD_READ: - free (buffers[0].start); - break; - - case IO_METHOD_MMAP: - for (i = 0; i < n_buffers; ++i) - if (-1 == munmap (buffers[i].start, buffers[i].length)) - errno_exit ("munmap"); - break; - - case IO_METHOD_USERPTR: - for (i = 0; i < n_buffers; ++i) - free (buffers[i].start); - break; - } - - free (buffers); -} - -static void init_read (unsigned int buffer_size) -{ - buffers = (buffer*)calloc (1, sizeof (*buffers)); - - if (!buffers) { - std::cerr << "Out of memory\n"; - exit (EXIT_FAILURE); - } - - buffers[0].length = buffer_size; - buffers[0].start = malloc (buffer_size); - - if (!buffers[0].start) { - std::cerr << "Out of memory\n"; - exit (EXIT_FAILURE); - } -} - -static void init_mmap (void) -{ - struct v4l2_requestbuffers req; - - CLEAR (req); - - req.count = 4; - req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - req.memory = V4L2_MEMORY_MMAP; - - if (-1 == xioctl (fd, VIDIOC_REQBUFS, &req)) { - if (EINVAL == errno) { - std::cerr << dev_name << " does not support " - << "memory mapping\n"; - exit (EXIT_FAILURE); - } else { - errno_exit ("VIDIOC_REQBUFS"); - } - } - - if (req.count < 2) { - std::cerr << "Insufficient buffer memory on " << dev_name << '\n'; - exit (EXIT_FAILURE); - } - - buffers = (buffer*)calloc (req.count, sizeof (*buffers)); - - if (!buffers) { - std::cerr << "Out of memory\n"; - exit (EXIT_FAILURE); - } - - for (n_buffers = 0; n_buffers < req.count; ++n_buffers) { - struct v4l2_buffer buf; - CLEAR (buf); - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.memory = V4L2_MEMORY_MMAP; - buf.index = n_buffers; - if (-1 == xioctl (fd, VIDIOC_QUERYBUF, &buf)) - errno_exit ("VIDIOC_QUERYBUF"); - buffers[n_buffers].length = buf.length; - buffers[n_buffers].start = - mmap (NULL /* start anywhere */, - buf.length, - PROT_READ | PROT_WRITE /* required */, - MAP_SHARED /* recommended */, - fd, buf.m.offset); - - if (MAP_FAILED == buffers[n_buffers].start) - errno_exit ("mmap"); - } -} - -static void init_userp (unsigned int buffer_size) -{ - struct v4l2_requestbuffers req; - unsigned int page_size; - page_size = getpagesize (); - buffer_size = (buffer_size + page_size - 1) & ~(page_size - 1); - CLEAR (req); - req.count = 4; - req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - req.memory = V4L2_MEMORY_USERPTR; - if (-1 == xioctl (fd, VIDIOC_REQBUFS, &req)) { - if (EINVAL == errno) { - std::cerr << dev_name << " does not support " - << "user pointer i/o\n"; - exit (EXIT_FAILURE); - } else { - errno_exit ("VIDIOC_REQBUFS"); - } - } - buffers = (buffer*) calloc (4, sizeof (*buffers)); - if (!buffers) { - std::cerr << "Out of memory\n"; - exit (EXIT_FAILURE); - } - for (n_buffers = 0; n_buffers < 4; ++n_buffers) { - buffers[n_buffers].length = buffer_size; - buffers[n_buffers].start = memalign (/* boundary */ page_size, - buffer_size); - - if (!buffers[n_buffers].start) { - std::cerr << "Out of memory\n"; - exit (EXIT_FAILURE); - } - } -} - -static void init_device (void) -{ - struct v4l2_capability cap; - struct v4l2_cropcap cropcap; - struct v4l2_crop crop; - struct v4l2_format fmt; - unsigned int min; - if (-1 == xioctl (fd, VIDIOC_QUERYCAP, &cap)) { - if (EINVAL == errno) { - std::cerr << dev_name << " is no V4L2 device\n"; - exit (EXIT_FAILURE); - } else { - errno_exit ("VIDIOC_QUERYCAP"); - } - } - - if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { - std::cerr << dev_name << " is no video capture device\n"; - exit (EXIT_FAILURE); - } - - switch (io) { - case IO_METHOD_READ: - if (!(cap.capabilities & V4L2_CAP_READWRITE)) { - std::cerr << dev_name << " does not support read i/o\n"; - exit (EXIT_FAILURE); - } - - break; - case IO_METHOD_MMAP: - case IO_METHOD_USERPTR: - if (!(cap.capabilities & V4L2_CAP_STREAMING)) { - std::cerr << dev_name << " does not support streaming i/o\n"; - exit (EXIT_FAILURE); - } - break; - } - /* Select video input, video standard and tune here. */ - CLEAR (cropcap); - cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (0 == xioctl (fd, VIDIOC_CROPCAP, &cropcap)) { - crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - crop.c = cropcap.defrect; /* reset to default */ - if (-1 == xioctl (fd, VIDIOC_S_CROP, &crop)) { - switch (errno) { - case EINVAL: - /* Cropping not supported. */ - break; - default: - /* Errors ignored. */ - break; - } - } - } else { - /* Errors ignored. */ - } - struct v4l2_fmtdesc fmtdesc; - printf("video capture\n"); - for (int i = 0;; i++) { - memset(&fmtdesc,0,sizeof(fmtdesc)); - fmtdesc.index = i; - fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (-1 == xioctl (fd, VIDIOC_ENUM_FMT,&fmtdesc)) - break; - printf(" VIDIOC_ENUM_FMT(%d,VIDEO_CAPTURE)\n",i); - printf("pfmt: 0x%x %s\n",fmtdesc.pixelformat,fmtdesc.description); - if (fmtdesc.pixelformat != 0x56595559) { - printf(" => don't list not supported format\n"); - continue; - } - for (int k = 0;; k++) { - struct v4l2_frmsizeenum frmsize; - memset(&frmsize,0,sizeof(frmsize)); - frmsize.index = k; - frmsize.pixel_format = fmtdesc.pixelformat; - if (-1 == xioctl (fd, VIDIOC_ENUM_FRAMESIZES,&frmsize)) - break; - if (frmsize.type== V4L2_FRMSIZE_TYPE_DISCRETE) { - printf(" VIDIOC_ENUM_FRAMESIZES(%d,0x%x) %dx%d @",k, frmsize.type, frmsize.discrete.width, frmsize.discrete.height); - for (int l = 0;; l++) { - struct v4l2_frmivalenum frmrate; - memset(&frmrate, 0, sizeof(frmrate)); - frmrate.index = l; - frmrate.pixel_format = fmtdesc.pixelformat; - frmrate.width = frmsize.discrete.width; - frmrate.height = frmsize.discrete.height; - if (-1 == xioctl (fd, VIDIOC_ENUM_FRAMEINTERVALS,&frmrate)) - break; - if (frmrate.type == V4L2_FRMIVAL_TYPE_DISCRETE) { - printf(" %u/%u ", frmrate.discrete.numerator, frmrate.discrete.denominator); - } - } - printf("\n"); - } - } - } - CLEAR (fmt); - fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (-1 == xioctl (fd, VIDIOC_G_FMT, &fmt)) - errno_exit ("VIDIOC_G_FMT"); - printf("video: %dx%d; fourcc:0x%x\n", fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.pixelformat); - if (fmt.fmt.pix.width != width || fmt.fmt.pix.height != height || (fmt.fmt.pix.pixelformat != pixelformat)){ - struct v4l2_pix_format def_format; - memcpy(&def_format, &fmt.fmt.pix, sizeof(struct v4l2_pix_format)); - fmt.fmt.pix.width = width; - fmt.fmt.pix.height = height; - fmt.fmt.pix.pixelformat = pixelformat; - if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)){ - std::cerr << "failed to set resolution " << fmt.fmt.pix.width << "x" << fmt.fmt.pix.height << '\n'; - errno_exit ("VIDIOC_S_FMT"); - } - } - if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) - errno_exit ("VIDIOC_S_FMT"); - - CLEAR (fmt); - fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (-1 == xioctl (fd, VIDIOC_G_FMT, &fmt)) - errno_exit ("VIDIOC_G_FMT"); - printf("video: %dx%d; fourcc:0x%x\n", fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.pixelformat); - if (fmt.fmt.pix.width != width || fmt.fmt.pix.height != height || fmt.fmt.pix.pixelformat != pixelformat){ - errno_exit ("VIDIOC_S_FMT not set !"); - } - - /* Buggy driver paranoia. */ - min = fmt.fmt.pix.width * 2; - if (fmt.fmt.pix.bytesperline < min) - fmt.fmt.pix.bytesperline = min; - min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height; - if (fmt.fmt.pix.sizeimage < min) - fmt.fmt.pix.sizeimage = min; - struct v4l2_streamparm capp; - CLEAR(capp); - capp.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (g_FrameRate) { - if (-1 == xioctl (fd, VIDIOC_G_PARM, &capp) == -1) { - errno_exit ("VIDIOC_G_PARM"); - } - printf("vidioc_s_parm called frate=%d/%d\n", capp.parm.capture.timeperframe.numerator, capp.parm.capture.timeperframe.denominator); - capp.parm.capture.timeperframe.numerator = g_Numerator; - capp.parm.capture.timeperframe.denominator = g_FrameRate; - printf("vidioc_s_parm set: frate=%d/%d\n", capp.parm.capture.timeperframe.numerator, capp.parm.capture.timeperframe.denominator); - if (-1 == xioctl (fd, VIDIOC_S_PARM, &capp) == -1) { - errno_exit ("VIDIOC_S_PARM"); - } - if (-1 == xioctl (fd, VIDIOC_G_PARM, &capp) == -1) { - errno_exit ("VIDIOC_G_PARM"); - } - if ((capp.parm.capture.timeperframe.numerator != g_Numerator) || ( - capp.parm.capture.timeperframe.denominator != g_FrameRate)) { - errno_exit ("VIDIOC_S_PARM NOT SET"); - } - } else { - if (-1 == xioctl (fd, VIDIOC_G_PARM, &capp) == -1) { - errno_exit ("VIDIOC_G_PARM"); - } - } - sprintf(device_settings_buffer,"%dx%d@%d/%d", width, height, capp.parm.capture.timeperframe.numerator, capp.parm.capture.timeperframe.denominator); - device_settings = &device_settings_buffer[0]; - printf("INFO: %s\n", device_settings); - - - switch (io) { - case IO_METHOD_READ: - init_read (fmt.fmt.pix.sizeimage); - break; - - case IO_METHOD_MMAP: - init_mmap (); - break; - - case IO_METHOD_USERPTR: - init_userp (fmt.fmt.pix.sizeimage); - break; - } -} - -static void - close_device (void) -{ - if (-1 == close (fd)) - errno_exit ("close"); - - fd = -1; -} - -static void open_device (void) -{ - struct stat st; - - if (-1 == stat (dev_name, &st)) { - std::cerr << "Cannot identify '" << dev_name << "': " << errno << ", " << strerror(errno) << '\n'; - exit (EXIT_FAILURE); - } - - if (!S_ISCHR (st.st_mode)) { - std::cerr << dev_name << " is no device\n"; - exit (EXIT_FAILURE); - } - - fd = open (dev_name, O_RDWR /* required */ | O_NONBLOCK, 0); - - if (-1 == fd) { - std::cerr << "Cannot open '" << dev_name << "': " << errno << ", " << strerror(errno) << '\n'; - exit (EXIT_FAILURE); - } -} - -static void usage (std::ostream &o, int argc, char ** argv) -{ - o << "Usage: " << argv[0] << " [options]\n" - "\n" - "Options:\n" - "-?, --help Print this message\n" - "-d, --device=NAME Video device name ["<< dev_name<< "]\n" - "-i, --ip=IP Target ip [localhost]\n" - "-p, --port=PORT Target port [" << ip_port << "]\n" - "-m, --mmap Use memory mapped buffers\n" - "-r, --read Use read() calls\n" - "-u, --userp Use application allocated buffers\n" - "-N, --no-number Disable OSD\n" - "-P, --progressive Force P frames only\n" - "-l, --liveview-off Live View off\n" - "-f, --framerate=FPS Framerate [no limit]\n" - "-w, --width=WIDTH Window width [" << win2_width << "]\n" - "-h, --height=HEIGHT Window height [" << win2_height << "]\n" - "-x, --posx=POS_X X position [WM handles placement]\n" - "-y, --posy=POS_Y Y position [WM handles placement]\n" - "-n, --numerator=NUM Numerator [no limit]\n" - "-W, --dev-width=WIDTH Device width ["<< width << "]\n" - "-H, --dev-height=HEIGHT Device height [" << height << "]\n" - "-D, --debug=LEVEL Debug level [" << g_Debug << "]\n" - "\n"; -} - -void InitSock() -{ - printf("Using: %s:%d\n", ip_name.c_str(), ip_port); - try { - sock_ptr = new TCPSocketClient(ip_name, ip_port); - } - catch (const std::exception& e) - { - printf("%s\n", e.what()); - exit(1); - } -} - - -static const char short_options [] = "d:i:p:?mruNPlf:w:h:x:y:n:W:H:D:"; - -static const struct option - long_options [] = { - { "device", required_argument, NULL, 'd' }, - { "ip", required_argument, NULL, 'i' }, - { "port", required_argument, NULL, 'p' }, - { "help", no_argument, NULL, '?' }, - { "mmap", no_argument, NULL, 'm' }, - { "read", no_argument, NULL, 'r' }, - { "userp", no_argument, NULL, 'u' }, - { "no-number", no_argument, NULL, 'N' }, - { "progressive", no_argument, NULL, 'P' }, - { "liveview-off", no_argument, NULL, 'l' }, - { "framerate", required_argument, NULL, 'f' }, - { "width", required_argument, NULL, 'w' }, - { "height", required_argument, NULL, 'h' }, - { "posx", required_argument, NULL, 'x' }, - { "posy", required_argument, NULL, 'y' }, - { "numerator", required_argument, NULL, 'n' }, - { "dev-width", required_argument, NULL, 'W' }, - { "dev-height", required_argument, NULL, 'H' }, - { "debug", required_argument, NULL, 'D' }, - { 0, 0, 0, 0 } -}; - -int - main (int argc, char ** argv) -{ - width = 640; - height = 480; - dev_name = (char*)"/dev/video0"; - - for (;;) { - int index; - int c; - - c = getopt_long (argc, argv, - short_options, long_options, - &index); - - if (-1 == c) - break; - - switch (c) { - case 0: /* getopt_long() flag */ - break; - - case 'd': - dev_name = optarg; - break; - case 'i': - ip_name = optarg; - break; - case 'p': - ip_port = atoi(optarg); - break; - case '?': - usage (std::cout, argc, argv); - exit (EXIT_SUCCESS); - case 'm': - io = IO_METHOD_MMAP; - break; - case 'r': - io = IO_METHOD_READ; - break; - case 'u': - io = IO_METHOD_USERPTR; - break; - case 'N': - g_ShowNumber = false; - break; - case 'P': - g_Force_P_Only = true; - break; - case 'l': - g_LiveView = false; - break; - case 'f': - g_FrameRate = atoi(optarg); - if (!g_Numerator) g_Numerator = 1; - break; - case 'w': - win2_width = atoi(optarg); - break; - case 'h': - win2_height = atoi(optarg); - break; - case 'x': - g_PX = atoi(optarg); - break; - case 'y': - g_PY = atoi(optarg); - break; - case 'n': - g_Numerator = atoi(optarg); - break; - case 'W': - width = atoi(optarg); - break; - case 'H': - height = atoi(optarg); - break; - case 'D': - g_Debug = atoi(optarg); - break; - default: - usage (std::cerr, argc, argv); - exit (EXIT_FAILURE); - } - } - if (g_Debug) { - printf("Capture: %dx%d %d/%d\n", width, height, g_Numerator, g_FrameRate); - printf("Win: %dx%d (%d,%d)\n", win2_width, win2_height, g_PX, g_PY); - } - - if(signal(SIGINT, SignalHandler) == SIG_ERR){ - printf("signal() failed\n"); - time_to_quit = 1; - } - InitSock(); - open_device(); - pixelformat = V4L2_PIX_FMT_YUYV; - init_device (); - printf("negotiated frame resolution: %dx%d\n", width, height); - - if (!encoder_init(width, height)) { - start_capturing (); - mainloop (); - stop_capturing (); - encoder_close(); - } else { - printf("Error: encoder init !\n"); - } - uninit_device (); - close_device (); - delete sock_ptr; - return 0; -} diff --git a/test/vainfo/Android.mk b/test/vainfo/Android.mk deleted file mode 100644 index 5c97388..0000000 --- a/test/vainfo/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -# For vainfo -# ===================================================== - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - vainfo.c \ - ../common/va_display.c \ - ../common/va_display_android.cpp - -LOCAL_CFLAGS += \ - -DANDROID - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../../va \ - $(LOCAL_PATH)/../common \ - $(LOCAL_PATH)/../.. \ - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := vainfo - -LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui - -include $(BUILD_EXECUTABLE) - diff --git a/test/vainfo/Makefile.am b/test/vainfo/Makefile.am deleted file mode 100644 index 680d099..0000000 --- a/test/vainfo/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# 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. - -bin_PROGRAMS = vainfo - -vainfo_cflags = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - -I$(top_srcdir)/test/common \ - -I$(top_builddir) \ - -DLIBVA_VERSION_S="\"$(LIBVA_VERSION)\"" \ - $(NULL) - -vainfo_libs = \ - $(top_builddir)/va/libva.la \ - $(top_builddir)/test/common/libva-display.la \ - $(NULL) - -vainfo_SOURCES = vainfo.c -noinst_HEADERS = $(source_h) -vainfo_CFLAGS = $(vainfo_cflags) -vainfo_LDADD = $(vainfo_libs) - -valgrind: vainfo - valgrind --leak-check=full --show-reachable=yes .libs/vainfo; diff --git a/test/vainfo/vainfo.c b/test/vainfo/vainfo.c deleted file mode 100644 index c7082ae..0000000 --- a/test/vainfo/vainfo.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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. - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include "va_display.h" -#include "va/sysdeps.h" - -#define CHECK_VASTATUS(va_status,func, ret) \ -if (va_status != VA_STATUS_SUCCESS) { \ - fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, va_status, vaErrorStr(va_status)); \ - ret_val = ret; \ - goto error; \ -} - -static char * profile_string(VAProfile profile) -{ - switch (profile) { - case VAProfileNone: return "VAProfileNone"; - case VAProfileMPEG2Simple: return "VAProfileMPEG2Simple"; - case VAProfileMPEG2Main: return "VAProfileMPEG2Main"; - case VAProfileMPEG4Simple: return "VAProfileMPEG4Simple"; - case VAProfileMPEG4AdvancedSimple: return "VAProfileMPEG4AdvancedSimple"; - case VAProfileMPEG4Main: return "VAProfileMPEG4Main"; - case VAProfileH264Baseline: return "VAProfileH264Baseline"; - case VAProfileH264Main: return "VAProfileH264Main"; - case VAProfileH264High: return "VAProfileH264High"; - case VAProfileVC1Simple: return "VAProfileVC1Simple"; - case VAProfileVC1Main: return "VAProfileVC1Main"; - case VAProfileVC1Advanced: return "VAProfileVC1Advanced"; - case VAProfileH263Baseline: return "VAProfileH263Baseline"; - case VAProfileH264ConstrainedBaseline: return "VAProfileH264ConstrainedBaseline"; - case VAProfileJPEGBaseline: return "VAProfileJPEGBaseline"; - case VAProfileVP8Version0_3: return "VAProfileVP8Version0_3"; - case VAProfileH264MultiviewHigh: return "VAProfileH264MultiviewHigh"; - case VAProfileH264StereoHigh: return "VAProfileH264StereoHigh"; - case VAProfileHEVCMain: return "VAProfileHEVCMain"; - case VAProfileHEVCMain10: return "VAProfileHEVCMain10"; - case VAProfileVP9Profile0: return "VAProfileVP9Profile0"; - case VAProfileVP9Profile1: return "VAProfileVP9Profile1"; - case VAProfileVP9Profile2: return "VAProfileVP9Profile2"; - case VAProfileVP9Profile3: return "VAProfileVP9Profile3"; - - default: - break; - } - return ""; -} - - -static char * entrypoint_string(VAEntrypoint entrypoint) -{ - switch (entrypoint) { - case VAEntrypointVLD:return "VAEntrypointVLD"; - case VAEntrypointIZZ:return "VAEntrypointIZZ"; - case VAEntrypointIDCT:return "VAEntrypointIDCT"; - case VAEntrypointMoComp:return "VAEntrypointMoComp"; - case VAEntrypointDeblocking:return "VAEntrypointDeblocking"; - case VAEntrypointEncSlice:return "VAEntrypointEncSlice"; - case VAEntrypointEncPicture:return "VAEntrypointEncPicture"; - case VAEntrypointEncSliceLP:return "VAEntrypointEncSliceLP"; - case VAEntrypointVideoProc:return "VAEntrypointVideoProc"; - default: - break; - } - return ""; -} - -int main(int argc, const char* argv[]) -{ - VADisplay va_dpy; - VAStatus va_status; - int major_version, minor_version; - const char *driver; - const char *name = strrchr(argv[0], '/'); - VAProfile profile, *profile_list = NULL; - int num_profiles, max_num_profiles, i; - VAEntrypoint entrypoint, entrypoints[10]; - int num_entrypoint; - int ret_val = 0; - - if (name) - name++; - else - name = argv[0]; - - va_init_display_args(&argc, (char **)argv); - - va_dpy = va_open_display(); - if (NULL == va_dpy) - { - fprintf(stderr, "%s: vaGetDisplay() failed\n", name); - return 2; - } - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - CHECK_VASTATUS(va_status, "vaInitialize", 3); - - 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 : ""); - - printf("%s: Supported profile and entrypoints\n", name); - max_num_profiles = vaMaxNumProfiles(va_dpy); - profile_list = malloc(max_num_profiles * sizeof(VAProfile)); - - if (!profile_list) { - printf("Failed to allocate memory for profile list\n"); - ret_val = 5; - goto error; - } - - va_status = vaQueryConfigProfiles(va_dpy, profile_list, &num_profiles); - CHECK_VASTATUS(va_status, "vaQueryConfigProfiles", 6); - - for (i = 0; i < num_profiles; i++) { - char *profile_str; - - profile = profile_list[i]; - va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, - &num_entrypoint); - if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE) - continue; - - CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4); - - profile_str = profile_string(profile); - for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++) - printf(" %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint])); - } - -error: - free(profile_list); - vaTerminate(va_dpy); - va_close_display(va_dpy); - - return ret_val; -} diff --git a/va/Android.mk b/va/Android.mk deleted file mode 100755 index b6f6f4f..0000000 --- a/va/Android.mk +++ /dev/null @@ -1,178 +0,0 @@ -# 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. - -# For libva -# ===================================================== - -LOCAL_PATH:= $(call my-dir) - -LIBVA_DRIVERS_PATH_32 = /system/lib -LIBVA_DRIVERS_PATH_64 = /system/lib64 - -# Version set to Android Jelly Bean -ALOG_VERSION_REQ := 4.1 -ALOG_VERSION := $(filter $(ALOG_VERSION_REQ),$(firstword $(sort $(PLATFORM_VERSION) \ - $(ALOG_VERSION_REQ)))) - -include $(CLEAR_VARS) - -#LIBVA_MINOR_VERSION := 31 -#LIBVA_MAJOR_VERSION := 0 - -LOCAL_SRC_FILES := \ - va.c \ - va_trace.c \ - va_fool.c - -LOCAL_CFLAGS_32 += \ - -DANDROID \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH_32)\"" \ - -DLOG_TAG=\"libva\" - -LOCAL_CFLAGS_64 += \ - -DANDROID \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH_64)\"" \ - -DLOG_TAG=\"libva\" - -# Android Jelly Bean defined ALOGx, older versions use LOGx -ifeq ($(ALOG_VERSION), $(ALOG_VERSION_REQ)) -LOCAL_CFLAGS += -DANDROID_ALOG -else -LOCAL_CFLAGS += -DANDROID_LOG -endif - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(LOCAL_PATH)/x11 \ - $(LOCAL_PATH)/.. - -LOCAL_COPY_HEADERS := \ - va.h \ - va_backend.h \ - va_dec_hevc.h \ - va_dec_jpeg.h \ - va_drmcommon.h \ - va_enc_hevc.h \ - va_enc_jpeg.h \ - va_enc_vp8.h \ - va_enc_vp9.h \ - va_dec_vp9.h \ - va_version.h - -LOCAL_COPY_HEADERS_TO := libva/va - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libva - -LOCAL_SHARED_LIBRARIES := libdl libdrm libcutils liblog - -include $(BUILD_SHARED_LIBRARY) - -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 -# ===================================================== - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - android/va_android.cpp \ - drm/va_drm_utils.c - -LOCAL_CFLAGS += \ - -DANDROID -DLOG_TAG=\"libva-android\" - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(TARGET_OUT_HEADERS)/libdrm \ - $(LOCAL_PATH)/drm - -LOCAL_COPY_HEADERS_TO := libva/va - -LOCAL_COPY_HEADERS := va_android.h - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libva-android - -LOCAL_SHARED_LIBRARIES := libva libdrm - -include $(BUILD_SHARED_LIBRARY) - - -# For libva-egl -# ===================================================== - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - egl/va_egl.c - -LOCAL_CFLAGS += \ - -DANDROID -DLOG_TAG=\"libva-egl\" - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(LOCAL_PATH)/x11 - -LOCAL_COPY_HEADERS_TO := libva/va - -LOCAL_COPY_HEADERS := egl/va_egl.h egl/va_backend_egl.h - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libva-egl - -LOCAL_SHARED_LIBRARIES := libva - -include $(BUILD_SHARED_LIBRARY) - - -# For libva-tpi -# ===================================================== - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := va_tpi.c - -LOCAL_CFLAGS += -DANDROID -DLOG_TAG=\"libva-tpi\" - -LOCAL_C_INCLUDES += \ - $(TARGET_OUT_HEADERS)/libva \ - $(LOCAL_PATH)/.. - -LOCAL_COPY_HEADERS_TO := libva/va - -LOCAL_COPY_HEADERS := \ - va_tpi.h \ - va_backend_tpi.h - -LOCAL_SHARED_LIBRARIES := libva - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libva-tpi - -include $(BUILD_SHARED_LIBRARY) diff --git a/va/Makefile.am b/va/Makefile.am deleted file mode 100644 index 1be4214..0000000 --- a/va/Makefile.am +++ /dev/null @@ -1,147 +0,0 @@ -# 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. - -SUBDIRS = - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" - -LDADD = \ - $(LIBVA_LT_LDFLAGS) - -libva_source_c = \ - va.c \ - va_compat.c \ - va_fool.c \ - va_trace.c \ - $(NULL) - -libva_source_h = \ - va.h \ - va_backend.h \ - va_backend_tpi.h \ - va_backend_vpp.h \ - va_compat.h \ - va_dec_hevc.h \ - va_dec_jpeg.h \ - va_dec_vp8.h \ - va_dec_vp9.h \ - va_drmcommon.h \ - va_enc_hevc.h \ - va_enc_h264.h \ - va_enc_jpeg.h \ - va_enc_vp8.h \ - va_enc_mpeg2.h \ - va_enc_vp9.h \ - va_tpi.h \ - va_version.h \ - va_vpp.h \ - $(NULL) - -libva_source_h_priv = \ - sysdeps.h \ - va_fool.h \ - va_trace.h \ - $(NULL) - -libva_ldflags = \ - $(LDADD) -no-undefined \ - -Wl,-version-script,${srcdir}/libva.syms \ - $(NULL) - -lib_LTLIBRARIES = libva.la -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = $(libva_source_h) -noinst_HEADERS = $(libva_source_h_priv) -libva_la_SOURCES = $(libva_source_c) -libva_la_LDFLAGS = $(libva_ldflags) -libva_la_DEPENDENCIES = libva.syms -libva_la_LIBADD = $(LIBVA_LIBS) -ldl - -lib_LTLIBRARIES += libva-tpi.la -libva_tpi_la_SOURCES = va_tpi.c -libva_tpi_la_LDFLAGS = $(LDADD) -no-undefined -libva_tpi_la_DEPENDENCIES = libva.la -libva_tpi_la_LIBADD = libva.la -ldl - -if USE_DRM -SUBDIRS += drm -lib_LTLIBRARIES += libva-drm.la -libva_drm_la_SOURCES = -libva_drm_la_LDFLAGS = $(LDADD) -libva_drm_la_DEPENDENCIES = libva.la drm/libva_drm.la -libva_drm_la_LIBADD = libva.la drm/libva_drm.la \ - $(LIBVA_LIBS) $(DRM_LIBS) -ldl -endif - -if USE_X11 -SUBDIRS += x11 -lib_LTLIBRARIES += libva-x11.la -libva_source_h += va_x11.h -libva_x11_la_SOURCES = -libva_x11_la_LDFLAGS = $(LDADD) -libva_x11_la_DEPENDENCIES = libva.la x11/libva_x11.la -libva_x11_la_LIBADD = libva.la x11/libva_x11.la \ - $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) $(DRM_LIBS) -ldl -endif - -if USE_GLX -SUBDIRS += glx -lib_LTLIBRARIES += libva-glx.la -libva_glx_la_SOURCES = -libva_glx_la_LDFLAGS = $(LDADD) -libva_glx_la_DEPENDENCIES = libva.la glx/libva_glx.la libva-x11.la -libva_glx_la_LIBADD = libva.la glx/libva_glx.la libva-x11.la \ - $(GLX_LIBS) -ldl -endif - -if USE_EGL -SUBDIRS += egl -lib_LTLIBRARIES += libva-egl.la -libva_egl_la_SOURCES = -libva_egl_la_LDFLAGS = $(LDADD) -libva_egl_la_DEPENDENCIES = libva.la egl/libva_egl.la -libva_egl_la_LIBADD = libva.la egl/libva_egl.la \ - $(EGL_LIBS) -ldl -endif - -if USE_WAYLAND -SUBDIRS += wayland -lib_LTLIBRARIES += libva-wayland.la -libva_wayland_la_SOURCES = -libva_wayland_la_LDFLAGS = $(LDADD) -libva_wayland_la_DEPENDENCIES = libva.la wayland/libva_wayland.la -libva_wayland_la_LIBADD = libva.la wayland/libva_wayland.la \ - $(WAYLAND_LIBS) $(DRM_LIBS) -ldl -endif - -DIST_SUBDIRS = x11 glx egl drm wayland - -DISTCLEANFILES = \ - va_version.h \ - $(NULL) - -EXTRA_DIST = \ - libva.syms \ - va_version.h.in \ - $(NULL) diff --git a/va/android/Makefile.am b/va/android/Makefile.am deleted file mode 100644 index 26f63df..0000000 --- a/va/android/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp deleted file mode 100644 index ebbfbd3..0000000 --- a/va/android/va_android.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_trace.h" -#include "va_fool.h" -#include "va_android.h" -#include "va_drmcommon.h" -#include "va_drm_utils.h" -#include -#include -#include -#include -#include -#include -#include - - -#define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; } -#define DEVICE_NAME "/dev/dri/card0" - -static int open_device (char *dev_name) -{ - struct stat st; - int fd; - - if (-1 == stat (dev_name, &st)) - { - printf ("Cannot identify '%s': %d, %s\n", - dev_name, errno, strerror (errno)); - return -1; - } - - if (!S_ISCHR (st.st_mode)) - { - printf ("%s is no device\n", dev_name); - return -1; - } - - fd = open (dev_name, O_RDWR); - - if (-1 == fd) - { - fprintf (stderr, "Cannot open '%s': %d, %s\n", - dev_name, errno, strerror (errno)); - return -1; - } - - return fd; -} - -static int va_DisplayContextIsValid ( - VADisplayContextP pDisplayContext - ) -{ - return (pDisplayContext != NULL && - pDisplayContext->pDriverContext != NULL); -} - -static void va_DisplayContextDestroy ( - VADisplayContextP pDisplayContext -) -{ - struct drm_state *drm_state; - - if (pDisplayContext == NULL) - return; - - /* close the open-ed DRM fd */ - drm_state = (struct drm_state *)pDisplayContext->pDriverContext->drm_state; - close(drm_state->fd); - - free(pDisplayContext->pDriverContext->drm_state); - free(pDisplayContext->pDriverContext); - free(pDisplayContext); -} - -static VAStatus va_DisplayContextGetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - struct drm_state * drm_state = (struct drm_state *)ctx->drm_state; - - memset(drm_state, 0, sizeof(*drm_state)); - drm_state->fd = open_device((char *)DEVICE_NAME); - - if (drm_state->fd < 0) { - fprintf(stderr,"can't open DRM devices\n"); - return VA_STATUS_ERROR_UNKNOWN; - } - drm_state->auth_type = VA_DRM_AUTH_CUSTOM; - - return VA_DRM_GetDriverName(ctx, driver_name); -} - - -VADisplay vaGetDisplay ( - void *native_dpy /* implementation specific */ -) -{ - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext; - - if (!native_dpy) - return NULL; - - if (!dpy) - { - /* create new entry */ - VADriverContextP pDriverContext = 0; - struct drm_state *drm_state = 0; - pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext)); - pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext)); - drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state)); - if (pDisplayContext && pDriverContext && drm_state) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - pDriverContext->native_dpy = (void *)native_dpy; - pDriverContext->display_type = VA_DISPLAY_ANDROID; - pDisplayContext->pDriverContext = pDriverContext; - pDisplayContext->vaIsValid = va_DisplayContextIsValid; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - pDriverContext->drm_state = drm_state; - dpy = (VADisplay)pDisplayContext; - } - else - { - if (pDisplayContext) - free(pDisplayContext); - if (pDriverContext) - free(pDriverContext); - if (drm_state) - free(drm_state); - } - } - - return dpy; -} - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } - - -extern "C" { - extern int fool_postp; /* do nothing for vaPutSurface if set */ - extern int trace_flag; /* trace vaPutSurface parameters */ - - void va_TracePutSurface ( - VADisplay dpy, - VASurfaceID surface, - void *draw, /* the target Drawable */ - 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 vaPutSurface ( - VADisplay dpy, - VASurfaceID surface, - sp draw, /* Android Surface/Window */ - 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 */ -) -{ - VADriverContextP ctx; - - if (fool_postp) - return VA_STATUS_SUCCESS; - - if (draw == NULL) - return VA_STATUS_ERROR_UNKNOWN; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_TRACE_LOG(va_TracePutSurface, dpy, surface, static_cast(&draw), srcx, srcy, srcw, srch, - destx, desty, destw, desth, - cliprects, number_cliprects, flags ); - - return ctx->vtable->vaPutSurface( ctx, surface, static_cast(&draw), srcx, srcy, srcw, srch, - destx, desty, destw, desth, - cliprects, number_cliprects, flags ); -} diff --git a/va/drm/Makefile.am b/va/drm/Makefile.am deleted file mode 100644 index c7ba3f6..0000000 --- a/va/drm/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (C) 2012 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. - -AM_CPPFLAGS = \ - -DLINUX \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - $(DRM_CFLAGS) \ - $(NULL) - -source_c = \ - va_drm.c \ - va_drm_auth.c \ - va_drm_utils.c \ - $(NULL) - -source_h = \ - va_drm.h \ - $(NULL) - -source_h_priv = \ - va_drm_auth.h \ - va_drm_auth_x11.h \ - va_drm_utils.h \ - $(NULL) - -if USE_X11 -source_c += va_drm_auth_x11.c -AM_CPPFLAGS += $(X11_CFLAGS) -endif - -noinst_LTLIBRARIES = libva_drm.la -libva_drmincludedir = ${includedir}/va -libva_drminclude_HEADERS = $(source_h) -libva_drm_la_SOURCES = $(source_c) -noinst_HEADERS = $(source_h_priv) - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/va/drm/va_drm.c b/va/drm/va_drm.c deleted file mode 100644 index 59e33fa..0000000 --- a/va/drm/va_drm.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include "sysdeps.h" -#include -#include "va_drm.h" -#include "va_backend.h" -#include "va_drmcommon.h" -#include "va_drm_auth.h" -#include "va_drm_utils.h" - -static int -va_DisplayContextIsValid(VADisplayContextP pDisplayContext) -{ - VADriverContextP const pDriverContext = pDisplayContext->pDriverContext; - - return (pDriverContext && - ((pDriverContext->display_type & VA_DISPLAY_MAJOR_MASK) == - VA_DISPLAY_DRM)); -} - -static void -va_DisplayContextDestroy(VADisplayContextP pDisplayContext) -{ - if (!pDisplayContext) - return; - - free(pDisplayContext->pDriverContext->drm_state); - free(pDisplayContext->pDriverContext); - free(pDisplayContext); -} - -static VAStatus -va_DisplayContextGetDriverName( - VADisplayContextP pDisplayContext, - char **driver_name_ptr -) -{ - - VADriverContextP const ctx = pDisplayContext->pDriverContext; - struct drm_state * const drm_state = ctx->drm_state; - drm_magic_t magic; - VAStatus status; - int ret; - - status = VA_DRM_GetDriverName(ctx, driver_name_ptr); - if (status != VA_STATUS_SUCCESS) - return status; - - /* Authentication is only needed for a legacy DRM device */ - if (ctx->display_type != VA_DISPLAY_DRM_RENDERNODES) { - ret = drmGetMagic(drm_state->fd, &magic); - if (ret < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - if (!va_drm_authenticate(drm_state->fd, magic)) - return VA_STATUS_ERROR_OPERATION_FAILED; - } - - drm_state->auth_type = VA_DRM_AUTH_CUSTOM; - - return VA_STATUS_SUCCESS; -} - -VADisplay -vaGetDisplayDRM(int fd) -{ - VADisplayContextP pDisplayContext = NULL; - VADriverContextP pDriverContext = NULL; - struct drm_state *drm_state = NULL; - int is_render_nodes; - - if (fd < 0 || (is_render_nodes = VA_DRM_IsRenderNodeFd(fd)) < 0) - return NULL; - - /* Create new entry */ - /* XXX: handle cache? */ - drm_state = calloc(1, sizeof(*drm_state)); - if (!drm_state) - goto error; - drm_state->fd = fd; - - pDriverContext = calloc(1, sizeof(*pDriverContext)); - if (!pDriverContext) - goto error; - pDriverContext->native_dpy = NULL; - pDriverContext->display_type = is_render_nodes ? - VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM; - pDriverContext->drm_state = drm_state; - - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); - if (!pDisplayContext) - goto error; - - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - pDisplayContext->pDriverContext = pDriverContext; - pDisplayContext->vaIsValid = va_DisplayContextIsValid; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - return pDisplayContext; - -error: - free(pDisplayContext); - free(pDriverContext); - free(drm_state); - return NULL; -} diff --git a/va/drm/va_drm.h b/va/drm/va_drm.h deleted file mode 100644 index 9af3cc8..0000000 --- a/va/drm/va_drm.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * va_drm.h - Raw DRM API - * - * Copyright (c) 2012 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 INTEL 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_DRM_H -#define VA_DRM_H - -#include - -/** - * \file va_drm.h - * \brief The raw DRM API - * - * This file contains the \ref api_drm "Raw DRM API". - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Returns a VA display derived from the specified DRM connection. - * - * This function returns a (possibly cached) VA display from the - * specified DRM connection @fd. - * - * @param[in] fd the DRM connection descriptor - * @return the VA display - */ -VADisplay -vaGetDisplayDRM(int fd); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DRM_H */ diff --git a/va/drm/va_drm_auth.c b/va/drm/va_drm_auth.c deleted file mode 100644 index 592381d..0000000 --- a/va/drm/va_drm_auth.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#include "sysdeps.h" -#include -#include -#include "va_drm_auth.h" -#include "va_drm_auth_x11.h" - -/* Try to authenticate the DRM connection with the supplied magic id */ -bool -va_drm_authenticate(int fd, uint32_t magic) -{ - /* XXX: try to authenticate through Wayland, etc. */ -#ifdef HAVE_VA_X11 - if (va_drm_authenticate_x11(fd, magic)) - return true; -#endif - - /* Default: root + master privs are needed for the following call */ - return drmAuthMagic(fd, magic) == 0; -} diff --git a/va/drm/va_drm_auth.h b/va/drm/va_drm_auth.h deleted file mode 100644 index a8ca794..0000000 --- a/va/drm/va_drm_auth.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#ifndef VA_DRM_AUTH_H -#define VA_DRM_AUTH_H - -#include -#include - -DLL_HIDDEN -bool -va_drm_authenticate(int fd, uint32_t magic); - -#endif /* VA_DRM_AUTH_H */ diff --git a/va/drm/va_drm_auth_x11.c b/va/drm/va_drm_auth_x11.c deleted file mode 100644 index 54e7402..0000000 --- a/va/drm/va_drm_auth_x11.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include -#include -#include "va_drm_auth_x11.h" - -#define LIBVA_MAJOR_VERSION 1 - -typedef struct drm_auth_x11 DRMAuthX11; -typedef struct drm_auth_x11_vtable DRMAuthX11VTable; - -typedef void (*VAGenericFunc)(void); -typedef Display *(*X11OpenDisplayFunc)(const char *display_name); -typedef int (*X11CloseDisplayFunc)(Display *display); -typedef Bool (*VADRI2QueryExtensionFunc)( - Display *display, int *event_base, int *error_base); -typedef Bool (*VADRI2QueryVersionFunc)( - Display *display, int *major, int *minor); -typedef Bool (*VADRI2AuthenticateFunc)( - Display *display, XID window, uint32_t magic); - -struct drm_auth_x11_vtable { - X11OpenDisplayFunc x11_open_display; - X11CloseDisplayFunc x11_close_display; - VADRI2QueryExtensionFunc va_dri2_query_extension; - VADRI2QueryVersionFunc va_dri2_query_version; - VADRI2AuthenticateFunc va_dri2_authenticate; -}; - -struct drm_auth_x11 { - void *handle; /* libva-x11.so.1 */ - DRMAuthX11VTable vtable; - Display *display; - Window window; -}; - -static bool -get_symbol(void *handle, void *func_vptr, const char *name) -{ - VAGenericFunc func, *func_ptr = func_vptr; - const char *error; - - dlerror(); - func = (VAGenericFunc)dlsym(handle, name); - error = dlerror(); - - if (error) { - fprintf(stderr, "error: failed to resolve %s() function: %s\n", - name, error); - return false; - } - - *func_ptr = func; - return true; -} - -static bool -drm_auth_x11_init(DRMAuthX11 *auth) -{ - struct drm_auth_x11_vtable *vtable; - char libva_x11_name[16]; - int ret; - - ret = snprintf( - libva_x11_name, sizeof(libva_x11_name), - "libva-x11.so.%d", LIBVA_MAJOR_VERSION - ); - if (ret < 0 || ret >= sizeof(libva_x11_name)) - return false; - - auth->handle = dlopen(libva_x11_name, RTLD_LAZY | RTLD_GLOBAL); - if (!auth->handle) { - perror("open lib"); - return false; - } - - vtable = &auth->vtable; - if (!get_symbol(RTLD_DEFAULT, &vtable->x11_open_display, "XOpenDisplay")) - return false; - if (!get_symbol(RTLD_DEFAULT, &vtable->x11_close_display, "XCloseDisplay")) - return false; - if (!get_symbol(auth->handle, &vtable->va_dri2_query_extension, - "VA_DRI2QueryExtension")) - return false; - if (!get_symbol(auth->handle, &vtable->va_dri2_query_version, - "VA_DRI2QueryVersion")) - return false; - if (!get_symbol(auth->handle, &vtable->va_dri2_authenticate, - "VA_DRI2Authenticate")) - return false; - - auth->display = vtable->x11_open_display(NULL); - if (!auth->display) - return false; - - auth->window = DefaultRootWindow(auth->display); - return true; -} - -static void -drm_auth_x11_terminate(DRMAuthX11 *auth) -{ - if (!auth) - return; - - if (auth->display) { - auth->vtable.x11_close_display(auth->display); - auth->display = NULL; - auth->window = None; - } - - if (auth->handle) { - dlclose(auth->handle); - auth->handle = NULL; - } -} - -static bool -drm_auth_x11_authenticate(DRMAuthX11 *auth, int fd, uint32_t magic) -{ - DRMAuthX11VTable * const vtable = &auth->vtable; - int evt_base, err_base, v_major, v_minor; - - if (!vtable->va_dri2_query_extension(auth->display, &evt_base, &err_base)) - return false; - if (!vtable->va_dri2_query_version(auth->display, &v_major, &v_minor)) - return false; - if (!vtable->va_dri2_authenticate(auth->display, auth->window, magic)) - return false; - return true; -} - -/* Try to authenticate the DRM connection with the supplied magic through X11 */ -bool -va_drm_authenticate_x11(int fd, uint32_t magic) -{ - DRMAuthX11 auth; - bool success = false; - - memset(&auth, 0, sizeof(auth)); - if (!drm_auth_x11_init(&auth)) - goto end; - success = drm_auth_x11_authenticate(&auth, fd, magic); - -end: - drm_auth_x11_terminate(&auth); - return success; -} diff --git a/va/drm/va_drm_auth_x11.h b/va/drm/va_drm_auth_x11.h deleted file mode 100644 index 530eeed..0000000 --- a/va/drm/va_drm_auth_x11.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#ifndef VA_DRM_AUTH_X11_H -#define VA_DRM_AUTH_X11_H - -#include -#include - -DLL_HIDDEN -bool -va_drm_authenticate_x11(int fd, uint32_t magic); - -#endif /* VA_DRM_AUTH_X11_H */ diff --git a/va/drm/va_drm_utils.c b/va/drm/va_drm_utils.c deleted file mode 100644 index 041be79..0000000 --- a/va/drm/va_drm_utils.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * va_drm_utils.c - VA/DRM Utilities - * - * Copyright (c) 2012 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 INTEL 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. - */ - -#include "sysdeps.h" -#include -#include -#include "va_drm_utils.h" -#include "va_drmcommon.h" - -struct driver_name_map { - const char *key; - int key_len; - const char *name; -}; - -static const struct driver_name_map g_driver_name_map[] = { - { "i915", 4, "i965" }, // Intel OTC GenX driver - { "pvrsrvkm", 8, "pvr" }, // Intel UMG PVR driver - { "emgd", 4, "emgd" }, // Intel ECG PVR driver - { "hybrid", 6, "hybrid" }, // Intel OTC Hybrid driver - { "nouveau", 7, "gallium" }, // Mesa Gallium driver - { "radeon", 6, "gallium" }, // Mesa Gallium driver - { NULL, } -}; - -/* Returns the VA driver name for the active display */ -VAStatus -VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr) -{ - struct drm_state * const drm_state = ctx->drm_state; - drmVersionPtr drm_version; - char *driver_name = NULL; - const struct driver_name_map *m; - - *driver_name_ptr = NULL; - - if (!drm_state || drm_state->fd < 0) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - drm_version = drmGetVersion(drm_state->fd); - if (!drm_version) - return VA_STATUS_ERROR_UNKNOWN; - - for (m = g_driver_name_map; m->key != NULL; m++) { - if (drm_version->name_len >= m->key_len && - strncmp(drm_version->name, m->key, m->key_len) == 0) - break; - } - drmFreeVersion(drm_version); - - if (!m->name) - return VA_STATUS_ERROR_UNKNOWN; - - driver_name = strdup(m->name); - if (!driver_name) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - - *driver_name_ptr = driver_name; - return VA_STATUS_SUCCESS; -} - -/* Checks whether the file descriptor is a DRM Render-Nodes one */ -int -VA_DRM_IsRenderNodeFd(int fd) -{ - struct stat st; - const char *name; - - /* Check by device node */ - if (fstat(fd, &st) == 0) - return S_ISCHR(st.st_mode) && (st.st_rdev & 0x80); - - /* Check by device name */ - name = drmGetDeviceNameFromFd(fd); - if (name) - return strncmp(name, "/dev/dri/renderD", 16) == 0; - - /* Unrecoverable error */ - return -1; -} diff --git a/va/drm/va_drm_utils.h b/va/drm/va_drm_utils.h deleted file mode 100644 index b468c59..0000000 --- a/va/drm/va_drm_utils.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * va_drm_utils.h - VA/DRM Utilities - * - * Copyright (c) 2012 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 INTEL 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_DRM_UTILS_H -#define VA_DRM_UTILS_H - -#include - -/** - * \file va_drm_utils.h - * \brief VA/DRM Utilities - * - * This file contains VA/DRM utility functions. The API herein defined is - * internal to libva. Users include the VA/DRM API itself or VA/Android, - * should it be based on DRM. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Returns the VA driver name for the active display. - * - * This functions returns a newly allocated buffer in @driver_name_ptr that - * contains the VA driver name for the active display. Active display means - * the display obtained with any of the vaGetDisplay*() functions. - * - * The VADriverContext.drm_state structure must be valid, i.e. allocated - * and containing an open DRM connection descriptor. The DRM connection - * does *not* need to be authenticated as it only performs a call to - * drmGetVersion(). - * - * @param[in] ctx the pointer to a VADriverContext - * @param[out] driver_name_ptr the newly allocated buffer containing - * the VA driver name - * @return VA_STATUS_SUCCESS if operation is successful, or another - * #VAStatus value otherwise. - */ -DLL_HIDDEN -VAStatus -VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr); - -/** - * \brief Checks whether the file descriptor is a DRM Render-Nodes one - * - * This functions checks whether the supplied file descriptor @fd - * falls into the set of DRM Render-Nodes. - */ -DLL_HIDDEN -int -VA_DRM_IsRenderNodeFd(int fd); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DRM_UTILS_H */ diff --git a/va/egl/Makefile.am b/va/egl/Makefile.am deleted file mode 100644 index aee4975..0000000 --- a/va/egl/Makefile.am +++ /dev/null @@ -1,43 +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. - -AM_CPPFLAGS = \ - -DLINUX \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - $(EGL_CFLAGS) \ - $(NULL) - -source_c = \ - va_egl.c - -source_h = \ - va_egl.h \ - va_backend_egl.h - -source_h_priv = - -noinst_LTLIBRARIES = libva_egl.la -libva_eglincludedir = ${includedir}/va -libva_eglinclude_HEADERS = $(source_h) -libva_egl_la_SOURCES = $(source_c) -noinst_HEADERS = $(source_h_priv) diff --git a/va/egl/va_backend_egl.h b/va/egl/va_backend_egl.h deleted file mode 100644 index 925d933..0000000 --- a/va/egl/va_backend_egl.h +++ /dev/null @@ -1,41 +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_BACKEND_EGL_H -#define VA_BACKEND_EGL_H - -#include -#include - -struct VADriverVTableEGL { - /* Get EGL ClientBufer buffer index and device id from surface id*/ - VAStatus (*vaGetEGLClientBufferFromSurface) ( - VADriverContextP ctx, - VASurfaceID surface, - void **buffer - ); - /* TBD: more APIs for EGL */ -}; - -#endif /* VA_BACKEND_EGL_H */ diff --git a/va/egl/va_egl.c b/va/egl/va_egl.c deleted file mode 100644 index 36e5504..0000000 --- a/va/egl/va_egl.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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. - */ - -/* - * Initial EGL backend, and subject to change - * - * Gstreamer gst-gltexture has a framework to support associating a buffer - * to a texture via EGL_KHR_image_base and GL_OES_EGL_image_external. - * - * EGL_KHR_image_base: - * EGLImageKHR eglCreateImageKHR( - * EGLDisplay dpy, - * EGLContext ctx, - * EGLenum target, - * EGLClientBuffer buffer, - * const EGLint *attrib_list) - * - * GL_OES_EGL_image_external: - * This extension provides a mechanism for creating EGLImage texture targets - * from EGLImages. This extension defines a new texture target TEXTURE_EXTERNAL_OES. - * This texture target can only be specified using an EGLImage. - * The first eglCreateImageKHR will create an EGLImage from an EGLClientBufferm, and with - * an EGLImage, gst-gltexture can use GL_OES_EGL_image_external extension to create textures. - * - * eglCreateImageKHR and GL_OES_EGL_image_external are all called directly from gst-gltexture, - * thus the simplest way to support gst-gltexture is defining a new API to pass EGLClientBuffer - * to gst-gltexture. - * - * EGLClientBuffer is gfx/video driver implementation specific (?). It means we need to pass up - * the low-level buffer ID (or handle) of the decoded surface to gst-gltexture, and gst-gltexture - * then pass down it to gfx driver. - * - * Bellow API vaGetEGLClientBufferFromSurface is for this purpose - */ - -#include "va.h" -#include "va_backend_egl.h" -#include "va_egl.h" - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } - -VAStatus vaGetEGLClientBufferFromSurface ( - VADisplay dpy, - VASurfaceID surface, - EGLClientBuffer *buffer /* out*/ -) -{ - VADriverContextP ctx; - struct VADriverVTableEGL *va_egl; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl; - if (va_egl && va_egl->vaGetEGLClientBufferFromSurface) { - return va_egl->vaGetEGLClientBufferFromSurface(ctx, surface, buffer); - } else - return VA_STATUS_ERROR_UNIMPLEMENTED; -} - - diff --git a/va/egl/va_egl.h b/va/egl/va_egl.h deleted file mode 100644 index 4243d0b..0000000 --- a/va/egl/va_egl.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _VA_EGL_H_ -#define _VA_EGL_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* EGLClientBuffer; - -/*This function is used to get EGLClientBuffer - * (lower 16bits is buffer index, upper 16bits - * is BC device id.) from surface id. Application - * should maintain EGLClientBuffer itself.*/ - -VAStatus vaGetEGLClientBufferFromSurface ( - VADisplay dpy, - VASurfaceID surface, - EGLClientBuffer *buffer /* out*/ -); - -#ifdef __cplusplus -} -#endif - -#endif /* _VA_EGL_H_ */ diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am deleted file mode 100644 index 8ff8ae9..0000000 --- a/va/glx/Makefile.am +++ /dev/null @@ -1,51 +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. - -AM_CPPFLAGS = \ - -DLINUX \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - -I$(top_srcdir)/va/x11 \ - $(X11_CFLAGS) \ - $(GLX_CFLAGS) \ - $(NULL) - -source_c = \ - va_glx.c \ - va_glx_impl.c \ - $(NULL) - -source_h = \ - va_backend_glx.h \ - va_glx.h \ - $(NULL) - -source_h_priv = \ - va_glx_impl.h \ - va_glx_private.h \ - $(NULL) - -noinst_LTLIBRARIES = libva_glx.la -libva_glxincludedir = ${includedir}/va -libva_glxinclude_HEADERS = $(source_h) -libva_glx_la_SOURCES = $(source_c) -noinst_HEADERS = $(source_h_priv) diff --git a/va/glx/va_backend_glx.h b/va/glx/va_backend_glx.h deleted file mode 100644 index d110485..0000000 --- a/va/glx/va_backend_glx.h +++ /dev/null @@ -1,54 +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_BACKEND_GLX_H -#define VA_BACKEND_GLX_H - -struct VADriverContext; - -struct VADriverVTableGLX { - /* Optional: create a surface used for display to OpenGL */ - VAStatus (*vaCreateSurfaceGLX)( - struct VADriverContext *ctx, - unsigned int gl_target, - unsigned int gl_texture, - void **gl_surface - ); - - /* Optional: destroy a VA/GLX surface */ - VAStatus (*vaDestroySurfaceGLX)( - struct VADriverContext *ctx, - void *gl_surface - ); - - /* Optional: copy a VA surface to a VA/GLX surface */ - VAStatus (*vaCopySurfaceGLX)( - struct VADriverContext *ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags - ); -}; - -#endif /* VA_BACKEND_GLX_H */ diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c deleted file mode 100644 index 25ef005..0000000 --- a/va/glx/va_glx.c +++ /dev/null @@ -1,167 +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. - */ - -#include "sysdeps.h" -#include -#include "va_glx_private.h" -#include "va_glx_impl.h" - -#define INIT_CONTEXT(ctx, dpy) do { \ - if (!vaDisplayIsValid(dpy)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - ctx = ((VADisplayContextP)(dpy))->pDriverContext; \ - if (!(ctx)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - VAStatus status = va_glx_init_context(ctx); \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - -#define INVOKE(ctx, func, args) do { \ - VADriverVTableGLXP vtable; \ - vtable = &VA_DRIVER_CONTEXT_GLX(ctx)->vtable; \ - if (!vtable->va##func##GLX) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - status = vtable->va##func##GLX args; \ - } while (0) - - -// Destroy VA/GLX display context -static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) -{ - VADisplayContextGLXP pDisplayContextGLX; - VADriverContextP pDriverContext; - VADriverContextGLXP pDriverContextGLX; - - if (!pDisplayContext) - return; - - pDriverContext = pDisplayContext->pDriverContext; - pDriverContextGLX = pDriverContext->glx; - if (pDriverContextGLX) { - free(pDriverContextGLX); - pDriverContext->glx = NULL; - } - - pDisplayContextGLX = pDisplayContext->opaque; - if (pDisplayContextGLX) { - vaDestroyFunc vaDestroy = pDisplayContextGLX->vaDestroy; - free(pDisplayContextGLX); - pDisplayContext->opaque = NULL; - if (vaDestroy) - vaDestroy(pDisplayContext); - } -} - -// Return a suitable VADisplay for VA API -VADisplay vaGetDisplayGLX(Display *native_dpy) -{ - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext = NULL; - VADisplayContextGLXP pDisplayContextGLX = NULL; - VADriverContextP pDriverContext; - VADriverContextGLXP pDriverContextGLX = NULL; - - dpy = vaGetDisplay(native_dpy); - if (!dpy) - return NULL; - pDisplayContext = (VADisplayContextP)dpy; - pDriverContext = pDisplayContext->pDriverContext; - - pDisplayContextGLX = calloc(1, sizeof(*pDisplayContextGLX)); - if (!pDisplayContextGLX) - goto error; - - pDriverContextGLX = calloc(1, sizeof(*pDriverContextGLX)); - if (!pDriverContextGLX) - goto error; - - pDriverContext->display_type = VA_DISPLAY_GLX; - pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->opaque = pDisplayContextGLX; - pDriverContext->glx = pDriverContextGLX; - return dpy; - -error: - free(pDriverContextGLX); - free(pDisplayContextGLX); - pDisplayContext->vaDestroy(pDisplayContext); - return NULL; -} - -// Create a surface used for display to OpenGL -VAStatus vaCreateSurfaceGLX( - VADisplay dpy, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - /* Make sure it is a valid GL texture object */ - if (!glIsTexture(texture)) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); - return status; -} - -// Destroy a VA/GLX surface -VAStatus vaDestroySurfaceGLX( - VADisplay dpy, - void *gl_surface -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, DestroySurface, (ctx, gl_surface)); - return status; -} - -// Copy a VA surface to a VA/GLX surface -VAStatus vaCopySurfaceGLX( - VADisplay dpy, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VADriverContextP ctx; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - - INVOKE(ctx, CopySurface, (ctx, gl_surface, surface, flags)); - return status; -} diff --git a/va/glx/va_glx.h b/va/glx/va_glx.h deleted file mode 100644 index 1a0624d..0000000 --- a/va/glx/va_glx.h +++ /dev/null @@ -1,109 +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_GLX_H -#define VA_GLX_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Return a suitable VADisplay for VA API - * - * @param[in] dpy the X11 display - * @return a VADisplay - */ -VADisplay vaGetDisplayGLX( - Display *dpy -); - -/** - * Create a surface used for display to OpenGL - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] target the GL target to which the texture needs to be bound - * @param[in] texture the GL texture - * @param[out] gl_surface the VA/GLX surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaCreateSurfaceGLX( - VADisplay dpy, - GLenum target, - GLuint texture, - void **gl_surface -); - -/** - * Destroy a VA/GLX surface - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] gl_surface the VA surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaDestroySurfaceGLX( - VADisplay dpy, - void *gl_surface -); - -/** - * Copy a VA surface to a VA/GLX surface - * - * This function will not return until the copy is completed. At this - * point, the underlying GL texture will contain the surface pixels - * in an RGB format defined by the user. - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] gl_surface the VA/GLX destination surface - * @param[in] surface the VA source surface - * @param[in] flags the PutSurface flags - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaCopySurfaceGLX( - VADisplay dpy, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -); - -#ifdef __cplusplus -} -#endif - -#endif /* VA_GLX_H */ diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c deleted file mode 100644 index 621f6c1..0000000 --- a/va/glx/va_glx_impl.c +++ /dev/null @@ -1,1127 +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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va_glx_private.h" -#include "va_glx_impl.h" -#include -#include -#include -#include -#include -#include - -static void va_glx_error_message(const char *format, ...) -{ - va_list args; - va_start(args, format); - fprintf(stderr, "libva-glx error: "); - vfprintf(stderr, format, args); - va_end(args); -} - -// X error trap -static int x11_error_code = 0; -static int (*old_error_handler)(Display *, XErrorEvent *); - -static int error_handler(Display *dpy, XErrorEvent *error) -{ - x11_error_code = error->error_code; - return 0; -} - -static void x11_trap_errors(void) -{ - x11_error_code = 0; - old_error_handler = XSetErrorHandler(error_handler); -} - -static int x11_untrap_errors(void) -{ - XSetErrorHandler(old_error_handler); - return x11_error_code; -} - -// Returns a string representation of an OpenGL error -static const char *gl_get_error_string(GLenum error) -{ - static const struct { - GLenum val; - const char *str; - } - gl_errors[] = { - { GL_NO_ERROR, "no error" }, - { GL_INVALID_ENUM, "invalid enumerant" }, - { GL_INVALID_VALUE, "invalid value" }, - { GL_INVALID_OPERATION, "invalid operation" }, - { GL_STACK_OVERFLOW, "stack overflow" }, - { GL_STACK_UNDERFLOW, "stack underflow" }, - { GL_OUT_OF_MEMORY, "out of memory" }, -#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT - { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, -#endif - { ~0, NULL } - }; - - int i; - for (i = 0; gl_errors[i].str; i++) { - if (gl_errors[i].val == error) - return gl_errors[i].str; - } - return "unknown"; -} - -static inline int gl_do_check_error(int report) -{ - GLenum error; - int is_error = 0; - while ((error = glGetError()) != GL_NO_ERROR) { - if (report) - va_glx_error_message("glError: %s caught\n", - gl_get_error_string(error)); - is_error = 1; - } - return is_error; -} - -static inline void gl_purge_errors(void) -{ - gl_do_check_error(0); -} - -static inline int gl_check_error(void) -{ - return gl_do_check_error(1); -} - -// glGetTexLevelParameteriv() wrapper -static int gl_get_texture_param(GLenum param, unsigned int *pval) -{ - GLint val; - - gl_purge_errors(); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, param, &val); - if (gl_check_error()) - return 0; - if (pval) - *pval = val; - return 1; -} - -// Returns the OpenGL VTable -static inline VAOpenGLVTableP gl_get_vtable(VADriverContextP ctx) -{ - return &VA_DRIVER_CONTEXT_GLX(ctx)->gl_vtable; -} - -// Lookup for a GLX function -typedef void (*GLFuncPtr)(void); -typedef GLFuncPtr (*GLXGetProcAddressProc)(const char *); - -static GLFuncPtr get_proc_address_default(const char *name) -{ - return NULL; -} - -static GLXGetProcAddressProc get_proc_address_func(void) -{ - GLXGetProcAddressProc get_proc_func; - - dlerror(); - get_proc_func = (GLXGetProcAddressProc) - dlsym(RTLD_DEFAULT, "glXGetProcAddress"); - if (!dlerror()) - return get_proc_func; - - get_proc_func = (GLXGetProcAddressProc) - dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"); - if (!dlerror()) - return get_proc_func; - - return get_proc_address_default; -} - -static inline GLFuncPtr get_proc_address(const char *name) -{ - static GLXGetProcAddressProc get_proc_func = NULL; - if (!get_proc_func) - get_proc_func = get_proc_address_func(); - return get_proc_func(name); -} - -// Check for GLX extensions (TFP, FBO) -static int check_extension(const char *name, const char *ext) -{ - const char *end; - int name_len, n; - - if (!name || !ext) - return 0; - - end = ext + strlen(ext); - name_len = strlen(name); - while (ext < end) { - n = strcspn(ext, " "); - if (n == name_len && strncmp(name, ext, n) == 0) - return 1; - ext += (n + 1); - } - return 0; -} - -static int check_extension3(const char *name) -{ - int nbExtensions, i; - PFNGLGETSTRINGIPROC glGetStringi = 0; - - glGetStringi = (PFNGLGETSTRINGIPROC) get_proc_address("glGetStringi"); - if(!glGetStringi) - return 0; - - - glGetIntegerv(GL_NUM_EXTENSIONS, &nbExtensions); - for(i = 0; i < nbExtensions; i++) - { - const GLubyte *strExtension = glGetStringi(GL_EXTENSIONS, i); - if(strcmp(strExtension, (const GLubyte *)name) == 0) - return 1; - } - - return 0; -} - -static int check_tfp_extensions(VADriverContextP ctx) -{ - const char *gl_extensions; - const char *glx_extensions; - - gl_extensions = (const char *)glGetString(GL_EXTENSIONS); - if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions) && !check_extension3("GL_ARB_texture_non_power_of_two")) - return 0; - - glx_extensions = glXQueryExtensionsString(ctx->native_dpy, ctx->x11_screen); - if (!check_extension("GLX_EXT_texture_from_pixmap", glx_extensions)) - return 0; - - return 1; -} - -static int check_fbo_extensions(VADriverContextP ctx) -{ - const char *gl_extensions; - - gl_extensions = (const char *)glGetString(GL_EXTENSIONS); - if (check_extension("GL_ARB_framebuffer_object", gl_extensions) || check_extension3("GL_ARB_framebuffer_object")) - return 1; - if (check_extension("GL_EXT_framebuffer_object", gl_extensions) || check_extension3("GL_EXT_framebuffer_object")) - return 1; - - return 0; -} - -// Load GLX extensions -static int load_tfp_extensions(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - pOpenGLVTable->glx_create_pixmap = (PFNGLXCREATEPIXMAPPROC) - get_proc_address("glXCreatePixmap"); - if (!pOpenGLVTable->glx_create_pixmap) - return 0; - pOpenGLVTable->glx_destroy_pixmap = (PFNGLXDESTROYPIXMAPPROC) - get_proc_address("glXDestroyPixmap"); - if (!pOpenGLVTable->glx_destroy_pixmap) - return 0; - pOpenGLVTable->glx_bind_tex_image = (PFNGLXBINDTEXIMAGEEXTPROC) - get_proc_address("glXBindTexImageEXT"); - if (!pOpenGLVTable->glx_bind_tex_image) - return 0; - pOpenGLVTable->glx_release_tex_image = (PFNGLXRELEASETEXIMAGEEXTPROC) - get_proc_address("glXReleaseTexImageEXT"); - if (!pOpenGLVTable->glx_release_tex_image) - return 0; - return 1; -} - -static int load_fbo_extensions(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - pOpenGLVTable->gl_gen_framebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) - get_proc_address("glGenFramebuffersEXT"); - if (!pOpenGLVTable->gl_gen_framebuffers) - return 0; - pOpenGLVTable->gl_delete_framebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) - get_proc_address("glDeleteFramebuffersEXT"); - if (!pOpenGLVTable->gl_delete_framebuffers) - return 0; - pOpenGLVTable->gl_bind_framebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) - get_proc_address("glBindFramebufferEXT"); - if (!pOpenGLVTable->gl_bind_framebuffer) - return 0; - pOpenGLVTable->gl_gen_renderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC) - get_proc_address("glGenRenderbuffersEXT"); - if (!pOpenGLVTable->gl_gen_renderbuffers) - return 0; - pOpenGLVTable->gl_delete_renderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC) - get_proc_address("glDeleteRenderbuffersEXT"); - if (!pOpenGLVTable->gl_delete_renderbuffers) - return 0; - pOpenGLVTable->gl_bind_renderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC) - get_proc_address("glBindRenderbufferEXT"); - if (!pOpenGLVTable->gl_bind_renderbuffer) - return 0; - pOpenGLVTable->gl_renderbuffer_storage = (PFNGLRENDERBUFFERSTORAGEEXTPROC) - get_proc_address("glRenderbufferStorageEXT"); - if (!pOpenGLVTable->gl_renderbuffer_storage) - return 0; - pOpenGLVTable->gl_framebuffer_renderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) - get_proc_address("glFramebufferRenderbufferEXT"); - if (!pOpenGLVTable->gl_framebuffer_renderbuffer) - return 0; - pOpenGLVTable->gl_framebuffer_texture_2d = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) - get_proc_address("glFramebufferTexture2DEXT"); - if (!pOpenGLVTable->gl_framebuffer_texture_2d) - return 0; - pOpenGLVTable->gl_check_framebuffer_status = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) - get_proc_address("glCheckFramebufferStatusEXT"); - if (!pOpenGLVTable->gl_check_framebuffer_status) - return 0; - return 1; -} - - -/* ========================================================================= */ -/* === VA/GLX helpers === */ -/* ========================================================================= */ - -// OpenGL context state -typedef struct OpenGLContextState *OpenGLContextStateP; - -struct OpenGLContextState { - Display *display; - Window window; - GLXContext context; -}; - -static void -gl_destroy_context(OpenGLContextStateP cs) -{ - if (!cs) - return; - - if (cs->display && cs->context) { - if (glXGetCurrentContext() == cs->context) - glXMakeCurrent(cs->display, None, NULL); - glXDestroyContext(cs->display, cs->context); - cs->display = NULL; - cs->context = NULL; - } - free(cs); -} - -static OpenGLContextStateP -gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent) -{ - OpenGLContextStateP cs; - GLXFBConfig *fbconfigs = NULL; - int fbconfig_id, val, n, n_fbconfigs; - Status status; - - static GLint fbconfig_attrs[] = { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DOUBLEBUFFER, True, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - None - }; - - cs = malloc(sizeof(*cs)); - if (!cs) - goto error; - - if (parent) { - cs->display = parent->display; - cs->window = parent->window; - } - else { - cs->display = ctx->native_dpy; - cs->window = None; - } - cs->context = NULL; - - if (parent && parent->context) { - status = glXQueryContext( - parent->display, - parent->context, - GLX_FBCONFIG_ID, &fbconfig_id - ); - if (status != Success) - goto error; - - if (fbconfig_id == GLX_DONT_CARE) - goto choose_fbconfig; - - fbconfigs = glXGetFBConfigs( - parent->display, - DefaultScreen(parent->display), - &n_fbconfigs - ); - if (!fbconfigs) - goto error; - - /* Find out a GLXFBConfig compatible with the parent context */ - for (n = 0; n < n_fbconfigs; n++) { - status = glXGetFBConfigAttrib( - cs->display, - fbconfigs[n], - GLX_FBCONFIG_ID, &val - ); - if (status == Success && val == fbconfig_id) - break; - } - if (n == n_fbconfigs) - goto error; - } - else { - choose_fbconfig: - fbconfigs = glXChooseFBConfig( - ctx->native_dpy, - ctx->x11_screen, - fbconfig_attrs, &n_fbconfigs - ); - if (!fbconfigs) - goto error; - - /* Select the first one */ - n = 0; - } - - cs->context = glXCreateNewContext( - cs->display, - fbconfigs[n], - GLX_RGBA_TYPE, - parent ? parent->context : NULL, - True - ); - if (cs->context) - goto end; - -error: - gl_destroy_context(cs); - cs = NULL; -end: - if (fbconfigs) - XFree(fbconfigs); - return cs; -} - -static void gl_get_current_context(OpenGLContextStateP cs) -{ - cs->display = glXGetCurrentDisplay(); - cs->window = glXGetCurrentDrawable(); - cs->context = glXGetCurrentContext(); -} - -static int -gl_set_current_context(OpenGLContextStateP new_cs, OpenGLContextStateP old_cs) -{ - /* If display is NULL, this could be that new_cs was retrieved from - gl_get_current_context() with none set previously. If that case, - the other fields are also NULL and we don't return an error */ - if (!new_cs->display) - return !new_cs->window && !new_cs->context; - - if (old_cs) { - if (old_cs == new_cs) - return 1; - gl_get_current_context(old_cs); - if (old_cs->display == new_cs->display && - old_cs->window == new_cs->window && - old_cs->context == new_cs->context) - return 1; - } - return glXMakeCurrent(new_cs->display, new_cs->window, new_cs->context); -} - -/** Unique VASurfaceGLX identifier */ -#define VA_SURFACE_GLX_MAGIC VA_FOURCC('V','A','G','L') - -struct VASurfaceGLX { - uint32_t magic; ///< Magic number identifying a VASurfaceGLX - GLenum target; ///< GL target to which the texture is bound - GLuint texture; ///< GL texture - VASurfaceID surface; ///< Associated VA surface - unsigned int width; - unsigned int height; - OpenGLContextStateP gl_context; - int is_bound; - Pixmap pixmap; - GLuint pix_texture; - GLXPixmap glx_pixmap; - GLuint fbo; -}; - -// Create Pixmaps for GLX texture-from-pixmap extension -static int create_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP const pOpenGLVTable = gl_get_vtable(ctx); - const unsigned int width = pSurfaceGLX->width; - const unsigned int height = pSurfaceGLX->height; - Pixmap pixmap = None; - GLXFBConfig *fbconfig = NULL; - GLXPixmap glx_pixmap = None; - Window root_window; - XWindowAttributes wattr; - int *attrib; - int n_fbconfig_attrs; - - root_window = RootWindow(ctx->native_dpy, ctx->x11_screen); - XGetWindowAttributes(ctx->native_dpy, root_window, &wattr); - if (wattr.depth != 24 && wattr.depth != 32) - return 0; - pixmap = XCreatePixmap( - ctx->native_dpy, - root_window, - width, - height, - wattr.depth - ); - if (!pixmap) - return 0; - pSurfaceGLX->pixmap = pixmap; - - int fbconfig_attrs[32] = { - GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, - GLX_DOUBLEBUFFER, GL_TRUE, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_RENDERABLE, GL_TRUE, - GLX_Y_INVERTED_EXT, GL_TRUE, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - /* - * depth test isn't enabled in the implementaion of VA GLX, - * so depth buffer is unnecessary. However to workaround a - * bug in older verson of xorg-server, always require a depth - * buffer. - * - * See https://bugs.freedesktop.org/show_bug.cgi?id=76755 - */ - GLX_DEPTH_SIZE, 1, - GL_NONE, - }; - for (attrib = fbconfig_attrs; *attrib != GL_NONE; attrib += 2) - ; - if (wattr.depth == 32) { - *attrib++ = GLX_ALPHA_SIZE; *attrib++ = 8; - *attrib++ = GLX_BIND_TO_TEXTURE_RGBA_EXT; *attrib++ = GL_TRUE; - } - else { - *attrib++ = GLX_BIND_TO_TEXTURE_RGB_EXT; *attrib++ = GL_TRUE; - } - *attrib++ = GL_NONE; - - fbconfig = glXChooseFBConfig( - ctx->native_dpy, - ctx->x11_screen, - fbconfig_attrs, - &n_fbconfig_attrs - ); - if (!fbconfig) - return 0; - - int pixmap_attrs[10] = { - GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, - GLX_MIPMAP_TEXTURE_EXT, GL_FALSE, - GL_NONE, - }; - for (attrib = pixmap_attrs; *attrib != GL_NONE; attrib += 2) - ; - *attrib++ = GLX_TEXTURE_FORMAT_EXT; - if (wattr.depth == 32) - *attrib++ = GLX_TEXTURE_FORMAT_RGBA_EXT; - else - *attrib++ = GLX_TEXTURE_FORMAT_RGB_EXT; - *attrib++ = GL_NONE; - - x11_trap_errors(); - glx_pixmap = pOpenGLVTable->glx_create_pixmap( - ctx->native_dpy, - fbconfig[0], - pixmap, - pixmap_attrs - ); - free(fbconfig); - if (x11_untrap_errors() != 0) - return 0; - pSurfaceGLX->glx_pixmap = glx_pixmap; - - glGenTextures(1, &pSurfaceGLX->pix_texture); - glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->pix_texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - return 1; -} - -// Destroy Pixmaps used for TFP -static void destroy_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP const pOpenGLVTable = gl_get_vtable(ctx); - - if (pSurfaceGLX->pix_texture) { - glDeleteTextures(1, &pSurfaceGLX->pix_texture); - pSurfaceGLX->pix_texture = 0; - } - - if (pSurfaceGLX->glx_pixmap) { - pOpenGLVTable->glx_destroy_pixmap(ctx->native_dpy, pSurfaceGLX->glx_pixmap); - pSurfaceGLX->glx_pixmap = None; - } - - if (pSurfaceGLX->pixmap) { - XFreePixmap(ctx->native_dpy, pSurfaceGLX->pixmap); - pSurfaceGLX->pixmap = None; - } -} - -// Bind GLX Pixmap to texture -static int bind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (pSurfaceGLX->is_bound) - return 1; - - glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->pix_texture); - - x11_trap_errors(); - pOpenGLVTable->glx_bind_tex_image( - ctx->native_dpy, - pSurfaceGLX->glx_pixmap, - GLX_FRONT_LEFT_EXT, - NULL - ); - XSync(ctx->native_dpy, False); - if (x11_untrap_errors() != 0) { - va_glx_error_message("failed to bind pixmap\n"); - return 0; - } - - pSurfaceGLX->is_bound = 1; - return 1; -} - -// Release GLX Pixmap from texture -static int unbind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (!pSurfaceGLX->is_bound) - return 1; - - x11_trap_errors(); - pOpenGLVTable->glx_release_tex_image( - ctx->native_dpy, - pSurfaceGLX->glx_pixmap, - GLX_FRONT_LEFT_EXT - ); - XSync(ctx->native_dpy, False); - if (x11_untrap_errors() != 0) { - va_glx_error_message("failed to release pixmap\n"); - return 0; - } - - glBindTexture(GL_TEXTURE_2D, 0); - - pSurfaceGLX->is_bound = 0; - return 1; -} - -// Render GLX Pixmap to texture -static void render_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - const unsigned int w = pSurfaceGLX->width; - const unsigned int h = pSurfaceGLX->height; - - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - { - glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); - glTexCoord2f(0.0f, 1.0f); glVertex2i(0, h); - glTexCoord2f(1.0f, 1.0f); glVertex2i(w, h); - glTexCoord2f(1.0f, 0.0f); glVertex2i(w, 0); - } - glEnd(); -} - -// Create offscreen surface -static int create_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - GLuint fbo; - GLenum status; - - pOpenGLVTable->gl_gen_framebuffers(1, &fbo); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, fbo); - pOpenGLVTable->gl_framebuffer_texture_2d( - GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, - pSurfaceGLX->texture, - 0 - ); - - status = pOpenGLVTable->gl_check_framebuffer_status(GL_DRAW_FRAMEBUFFER_EXT); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); - if (status != GL_FRAMEBUFFER_COMPLETE_EXT) - return 0; - - pSurfaceGLX->fbo = fbo; - return 1; -} - -// Destroy offscreen surface -static void destroy_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (pSurfaceGLX->fbo) { - pOpenGLVTable->gl_delete_framebuffers(1, &pSurfaceGLX->fbo); - pSurfaceGLX->fbo = 0; - } -} - -// Setup matrices to match the FBO texture dimensions -static void fbo_enter(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - const unsigned int width = pSurfaceGLX->width; - const unsigned int height = pSurfaceGLX->height; - - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, pSurfaceGLX->fbo); - glPushAttrib(GL_VIEWPORT_BIT); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glViewport(0, 0, width, height); - glTranslatef(-1.0f, -1.0f, 0.0f); - glScalef(2.0f / width, 2.0f / height, 1.0f); -} - -// Restore original OpenGL matrices -static void fbo_leave(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - glPopAttrib(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); -} - -// Check internal texture format is supported -static int is_supported_internal_format(GLenum format) -{ - /* XXX: we don't support other textures than RGBA */ - switch (format) { - case 4: - case GL_RGBA: - case GL_RGBA8: - return 1; - } - return 0; -} - -// Destroy VA/GLX surface -static void -destroy_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - unbind_pixmap(ctx, pSurfaceGLX); - destroy_fbo_surface(ctx, pSurfaceGLX); - destroy_tfp_surface(ctx, pSurfaceGLX); - free(pSurfaceGLX); -} - -// Create VA/GLX surface -static VASurfaceGLXP -create_surface(VADriverContextP ctx, GLenum target, GLuint texture) -{ - VASurfaceGLXP pSurfaceGLX = NULL; - unsigned int internal_format, border_width, width, height; - int is_error = 1; - - pSurfaceGLX = malloc(sizeof(*pSurfaceGLX)); - if (!pSurfaceGLX) - goto end; - - pSurfaceGLX->magic = VA_SURFACE_GLX_MAGIC; - pSurfaceGLX->target = target; - pSurfaceGLX->texture = texture; - pSurfaceGLX->surface = VA_INVALID_SURFACE; - pSurfaceGLX->gl_context = NULL; - pSurfaceGLX->is_bound = 0; - pSurfaceGLX->pixmap = None; - pSurfaceGLX->pix_texture = 0; - pSurfaceGLX->glx_pixmap = None; - pSurfaceGLX->fbo = 0; - - glEnable(target); - glBindTexture(target, texture); - if (!gl_get_texture_param(GL_TEXTURE_INTERNAL_FORMAT, &internal_format)) - goto end; - if (!is_supported_internal_format(internal_format)) - goto end; - - /* Check texture dimensions */ - if (!gl_get_texture_param(GL_TEXTURE_BORDER, &border_width)) - goto end; - if (!gl_get_texture_param(GL_TEXTURE_WIDTH, &width)) - goto end; - if (!gl_get_texture_param(GL_TEXTURE_HEIGHT, &height)) - goto end; - - width -= 2 * border_width; - height -= 2 * border_width; - if (width == 0 || height == 0) - goto end; - - pSurfaceGLX->width = width; - pSurfaceGLX->height = height; - - /* Create TFP objects */ - if (!create_tfp_surface(ctx, pSurfaceGLX)) - goto end; - - /* Create FBO objects */ - if (!create_fbo_surface(ctx, pSurfaceGLX)) - goto end; - - is_error = 0; -end: - if (is_error && pSurfaceGLX) { - destroy_surface(ctx, pSurfaceGLX); - pSurfaceGLX = NULL; - } - return pSurfaceGLX; -} - - -/* ========================================================================= */ -/* === VA/GLX implementation from the driver (fordward calls) === */ -/* ========================================================================= */ - -#define INVOKE(ctx, func, args) do { \ - VADriverVTableGLXP vtable = (ctx)->vtable_glx; \ - if (!vtable->va##func##GLX) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - \ - VAStatus status = vtable->va##func##GLX args; \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - -static VAStatus -vaCreateSurfaceGLX_impl_driver( - VADriverContextP ctx, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDestroySurfaceGLX_impl_driver(VADriverContextP ctx, void *gl_surface) -{ - INVOKE(ctx, DestroySurface, (ctx, gl_surface)); - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaCopySurfaceGLX_impl_driver( - VADriverContextP ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - INVOKE(ctx, CopySurface, (ctx, gl_surface, surface, flags)); - return VA_STATUS_SUCCESS; -} - -#undef INVOKE - - -/* ========================================================================= */ -/* === VA/GLX implementation from libVA (generic and suboptimal path) === */ -/* ========================================================================= */ - -#define INIT_SURFACE(surface, surface_arg) do { \ - surface = (VASurfaceGLXP)(surface_arg); \ - if (!check_surface(surface)) \ - return VA_STATUS_ERROR_INVALID_SURFACE; \ - } while (0) - -// Check VASurfaceGLX is valid -static inline int check_surface(VASurfaceGLXP pSurfaceGLX) -{ - return pSurfaceGLX && pSurfaceGLX->magic == VA_SURFACE_GLX_MAGIC; -} - -static VAStatus -vaCreateSurfaceGLX_impl_libva( - VADriverContextP ctx, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - VASurfaceGLXP pSurfaceGLX; - struct OpenGLContextState old_cs, *new_cs; - - gl_get_current_context(&old_cs); - new_cs = gl_create_context(ctx, &old_cs); - if (!new_cs) - goto error; - if (!gl_set_current_context(new_cs, NULL)) - goto error; - - pSurfaceGLX = create_surface(ctx, target, texture); - if (!pSurfaceGLX) - goto error; - - pSurfaceGLX->gl_context = new_cs; - *gl_surface = pSurfaceGLX; - - gl_set_current_context(&old_cs, NULL); - return VA_STATUS_SUCCESS; - -error: - if (new_cs) - gl_destroy_context(new_cs); - - return VA_STATUS_ERROR_ALLOCATION_FAILED; -} - -static VAStatus -vaDestroySurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VASurfaceGLXP pSurfaceGLX; - struct OpenGLContextState old_cs, *new_cs; - - INIT_SURFACE(pSurfaceGLX, gl_surface); - - new_cs = pSurfaceGLX->gl_context; - if (!gl_set_current_context(new_cs, &old_cs)) - return VA_STATUS_ERROR_OPERATION_FAILED; - - destroy_surface(ctx, pSurfaceGLX); - - gl_destroy_context(new_cs); - gl_set_current_context(&old_cs, NULL); - return VA_STATUS_SUCCESS; -} - -static inline VAStatus -deassociate_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - if (!unbind_pixmap(ctx, pSurfaceGLX)) - return VA_STATUS_ERROR_OPERATION_FAILED; - - pSurfaceGLX->surface = VA_INVALID_SURFACE; - return VA_STATUS_SUCCESS; -} - -static VAStatus -associate_surface( - VADriverContextP ctx, - VASurfaceGLXP pSurfaceGLX, - VASurfaceID surface, - unsigned int flags -) -{ - VAStatus status; - - /* XXX: optimise case where we are associating the same VA surface - as before an no changed occurred to it */ - status = deassociate_surface(ctx, pSurfaceGLX); - if (status != VA_STATUS_SUCCESS) - return status; - - x11_trap_errors(); - status = ctx->vtable->vaPutSurface( - ctx, - surface, - (void *)pSurfaceGLX->pixmap, - 0, 0, pSurfaceGLX->width, pSurfaceGLX->height, - 0, 0, pSurfaceGLX->width, pSurfaceGLX->height, - NULL, 0, - flags - ); - XSync(ctx->native_dpy, False); - if (x11_untrap_errors() != 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (status != VA_STATUS_SUCCESS) - return status; - - pSurfaceGLX->surface = surface; - return VA_STATUS_SUCCESS; -} - -static inline VAStatus -sync_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - if (pSurfaceGLX->surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - - return ctx->vtable->vaSyncSurface(ctx, pSurfaceGLX->surface); -} - -static inline VAStatus -begin_render_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAStatus status; - - status = sync_surface(ctx, pSurfaceGLX); - if (status != VA_STATUS_SUCCESS) - return status; - - if (!bind_pixmap(ctx, pSurfaceGLX)) - return VA_STATUS_ERROR_OPERATION_FAILED; - - return VA_STATUS_SUCCESS; -} - -static inline VAStatus -end_render_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - if (!unbind_pixmap(ctx, pSurfaceGLX)) - return VA_STATUS_ERROR_OPERATION_FAILED; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -copy_surface( - VADriverContextP ctx, - VASurfaceGLXP pSurfaceGLX, - VASurfaceID surface, - unsigned int flags -) -{ - VAStatus status; - - /* Associate VA surface */ - status = associate_surface(ctx, pSurfaceGLX, surface, flags); - if (status != VA_STATUS_SUCCESS) - return status; - - /* Render to FBO */ - fbo_enter(ctx, pSurfaceGLX); - status = begin_render_surface(ctx, pSurfaceGLX); - if (status == VA_STATUS_SUCCESS) { - render_pixmap(ctx, pSurfaceGLX); - status = end_render_surface(ctx, pSurfaceGLX); - } - fbo_leave(ctx); - if (status != VA_STATUS_SUCCESS) - return status; - - return deassociate_surface(ctx, pSurfaceGLX); -} - -static VAStatus -vaCopySurfaceGLX_impl_libva( - VADriverContextP ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VASurfaceGLXP pSurfaceGLX; - VAStatus status; - struct OpenGLContextState old_cs; - - INIT_SURFACE(pSurfaceGLX, gl_surface); - - if (!gl_set_current_context(pSurfaceGLX->gl_context, &old_cs)) - return VA_STATUS_ERROR_OPERATION_FAILED; - - status = copy_surface(ctx, pSurfaceGLX, surface, flags); - - gl_set_current_context(&old_cs, NULL); - return status; -} - -#undef INIT_SURFACE - - -/* ========================================================================= */ -/* === Private VA/GLX vtable initialization === */ -/* ========================================================================= */ - -// Initialize GLX driver context -VAStatus va_glx_init_context(VADriverContextP ctx) -{ - VADriverContextGLXP glx_ctx = VA_DRIVER_CONTEXT_GLX(ctx); - VADriverVTableGLXP vtable = &glx_ctx->vtable; - int glx_major, glx_minor; - - if (glx_ctx->is_initialized) - return VA_STATUS_SUCCESS; - - if (ctx->vtable_glx && ctx->vtable_glx->vaCopySurfaceGLX) { - vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_driver; - vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_driver; - vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_driver; - } - else { - vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_libva; - vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_libva; - vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_libva; - - if (!glXQueryVersion(ctx->native_dpy, &glx_major, &glx_minor)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (!check_tfp_extensions(ctx) || !load_tfp_extensions(ctx)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (!check_fbo_extensions(ctx) || !load_fbo_extensions(ctx)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - } - - glx_ctx->is_initialized = 1; - return VA_STATUS_SUCCESS; -} diff --git a/va/glx/va_glx_impl.h b/va/glx/va_glx_impl.h deleted file mode 100644 index c47f54a..0000000 --- a/va/glx/va_glx_impl.h +++ /dev/null @@ -1,37 +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_GLX_IMPL_H -#define VA_GLX_IMPL_H - -/** - * Initialize GLX driver context - * - * @param[in] ctx the VA driver context - * @return VA_STATUS_SUCCESS if successful - */ -DLL_HIDDEN -VAStatus va_glx_init_context(VADriverContextP ctx); - -#endif /* VA_GLX_IMPL_H */ diff --git a/va/glx/va_glx_private.h b/va/glx/va_glx_private.h deleted file mode 100644 index e86efb6..0000000 --- a/va/glx/va_glx_private.h +++ /dev/null @@ -1,86 +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_GLX_PRIVATE_H -#define VA_GLX_PRIVATE_H - -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_x11.h" -#include "va_glx.h" -#include "va_backend_glx.h" -#include - -#if GLX_GLXEXT_VERSION < 18 -typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *); -typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int); -#endif - -#if GLX_GLXEXT_VERSION < 27 -/* XXX: this is not exactly that version but this is the only means to - make sure we have the correct with those signatures */ -typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC)(Display *, GLXFBConfig, Pixmap, const int *); -typedef void (*PFNGLXDESTROYPIXMAPPROC)(Display *, GLXPixmap); -#endif - -typedef struct VAOpenGLVTable *VAOpenGLVTableP; - -struct VAOpenGLVTable { - PFNGLXCREATEPIXMAPPROC glx_create_pixmap; - PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap; - PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image; - PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image; - PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers; - PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers; - PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer; - PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers; - PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers; - PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer; - PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage; - PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer; - PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d; - PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status; -}; - -typedef struct VADisplayContextGLX *VADisplayContextGLXP; -typedef struct VADriverContextGLX *VADriverContextGLXP; -typedef struct VASurfaceGLX *VASurfaceGLXP; -typedef struct VADriverVTableGLX *VADriverVTableGLXP; - -typedef void (*vaDestroyFunc)(VADisplayContextP); - -struct VADisplayContextGLX { - vaDestroyFunc vaDestroy; -}; - -#define VA_DRIVER_CONTEXT_GLX(ctx) ((VADriverContextGLXP)((ctx)->glx)) - -struct VADriverContextGLX { - struct VADriverVTableGLX vtable; - struct VAOpenGLVTable gl_vtable; - unsigned int is_initialized : 1; -}; - -#endif /* VA_GLX_PRIVATE_H */ diff --git a/va/libva.syms b/va/libva.syms deleted file mode 100644 index b15d546..0000000 --- a/va/libva.syms +++ /dev/null @@ -1,11 +0,0 @@ -VA_API_0.32.0 { - local: - vaCreateSurfaces_0_32_0; -}; - -VA_API_0.33.0 { - global: - vaCreateSurfaces; - local: - vaCreateSurfaces_0_33_0; -} VA_API_0.32.0; diff --git a/va/sysdeps.h b/va/sysdeps.h deleted file mode 100644 index 164a274..0000000 --- a/va/sysdeps.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2007-2009 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 INTEL 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 SYSDEPS_H -#define SYSDEPS_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef ANDROID -# define Bool int -# define True 1 -# define False 0 - -/* Macros generated from configure */ -# define LIBVA_VERSION_S "1.1.0" - -/* Android logging utilities */ -# include -#endif - -#if defined __GNUC__ && defined HAVE_GNUC_VISIBILITY_ATTRIBUTE -# define DLL_HIDDEN __attribute__((visibility("hidden"))) -# define DLL_EXPORT __attribute__((visibility("default"))) -#else -# define DLL_HIDDEN -# define DLL_EXPORT -#endif - -#endif /* SYSDEPS_H */ diff --git a/va/va.c b/va/va.c deleted file mode 100644 index 5040dc1..0000000 --- a/va/va.c +++ /dev/null @@ -1,1877 +0,0 @@ -/* - * 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_backend_vpp.h" -#include "va_trace.h" -#include "va_fool.h" - -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_EXTENSION "_drv_video.so" - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } - -#define ASSERT assert -#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable->va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; -#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; - -/* - * read a config "env" for libva.conf or from environment setting - * liva.conf has higher priority - * return 0: the "env" is set, and the value is copied into env_value - * 1: the env is not set - */ -int va_parseConfig(char *env, char *env_value) -{ - char *token, *value, *saveptr; - char oneline[1024]; - FILE *fp=NULL; - - if (env == NULL) - return 1; - - fp = fopen("/etc/libva.conf", "r"); - while (fp && (fgets(oneline, 1024, fp) != NULL)) { - if (strlen(oneline) == 1) - continue; - token = strtok_r(oneline, "=\n", &saveptr); - value = strtok_r(NULL, "=\n", &saveptr); - - if (NULL == token || NULL == value) - continue; - - if (strcmp(token, env) == 0) { - if (env_value) { - strncpy(env_value,value, 1024); - env_value[1023] = '\0'; - } - - fclose(fp); - - return 0; - } - } - if (fp) - fclose(fp); - - /* no setting in config file, use env setting */ - value = getenv(env); - if (value) { - if (env_value) { - strncpy(env_value, value, 1024); - env_value[1023] = '\0'; - } - return 0; - } - - return 1; -} - -int vaDisplayIsValid(VADisplay dpy) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext); -} - -static void default_log_error(const char *buffer) -{ -# ifdef ANDROID_ALOG - ALOGE("%s", buffer); -# elif ANDROID_LOG - LOGE("%s", buffer); -# else - fprintf(stderr, "libva error: %s", buffer); -# endif -} - -static void default_log_info(const char *buffer) -{ -# ifdef ANDROID_ALOG - ALOGI("%s", buffer); -# elif ANDROID_LOG - LOGI("%s", buffer); -# else - fprintf(stderr, "libva info: %s", buffer); -# endif -} - -static vaMessageCallback va_log_error = default_log_error; -static vaMessageCallback va_log_info = default_log_info; - -/** - * Set the callback for error messages, or NULL for no logging. - * Returns the previous one, or NULL if it was disabled. - */ -vaMessageCallback vaSetErrorCallback(vaMessageCallback callback) -{ - vaMessageCallback old_callback = va_log_error; - va_log_error = callback; - return old_callback; -} - -/** - * Set the callback for info messages, or NULL for no logging. - * Returns the previous one, or NULL if it was disabled. - */ -vaMessageCallback vaSetInfoCallback(vaMessageCallback callback) -{ - vaMessageCallback old_callback = va_log_info; - va_log_info = callback; - return old_callback; -} - -void va_errorMessage(const char *msg, ...) -{ - char buf[512], *dynbuf; - va_list args; - int n, len; - - if (va_log_error == NULL) - return; - - va_start(args, msg); - len = vsnprintf(buf, sizeof(buf), msg, args); - va_end(args); - - if (len >= (int)sizeof(buf)) { - dynbuf = malloc(len + 1); - if (!dynbuf) - return; - va_start(args, msg); - n = vsnprintf(dynbuf, len + 1, msg, args); - va_end(args); - if (n == len) - va_log_error(dynbuf); - free(dynbuf); - } - else if (len > 0) - va_log_error(buf); -} - -void va_infoMessage(const char *msg, ...) -{ - char buf[512], *dynbuf; - va_list args; - int n, len; - - if (va_log_info == NULL) - return; - - va_start(args, msg); - len = vsnprintf(buf, sizeof(buf), msg, args); - va_end(args); - - if (len >= (int)sizeof(buf)) { - dynbuf = malloc(len + 1); - if (!dynbuf) - return; - va_start(args, msg); - n = vsnprintf(dynbuf, len + 1, msg, args); - va_end(args); - if (n == len) - va_log_info(dynbuf); - free(dynbuf); - } - else if (len > 0) - va_log_info(buf); -} - -static bool va_checkVtable(void *ptr, char *function) -{ - if (!ptr) { - va_errorMessage("No valid vtable entry for va%s\n", function); - return false; - } - return true; -} - -static bool va_checkMaximum(int value, char *variable) -{ - if (!value) { - va_errorMessage("Failed to define max_%s in init\n", variable); - return false; - } - return true; -} - -static bool va_checkString(const char* value, char *variable) -{ - 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; - - return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name); -} - -static VAStatus va_openDriver(VADisplay dpy, char *driver_name) -{ - VADriverContextP ctx = CTX(dpy); - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; - char *search_path = NULL; - char *saveptr; - 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(search_path, ":", &saveptr); - while (driver_dir) { - void *handle = NULL; - char *driver_path = (char *) malloc( strlen(driver_dir) + - strlen(driver_name) + - strlen(DRIVER_EXTENSION) + 2 ); - if (!driver_path) { - va_errorMessage("%s L%d Out of memory!n", - __FUNCTION__, __LINE__); - free(search_path); - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - strncpy( driver_path, driver_dir, strlen(driver_dir) + 1); - strncat( driver_path, "/", strlen("/") ); - strncat( driver_path, driver_name, strlen(driver_name) ); - strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) ); - - va_infoMessage("Trying to open %s\n", driver_path); -#ifndef ANDROID - handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE ); -#else - handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL); -#endif - 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 = NULL; - char init_func_s[256]; - int i; - - static const struct { - int major; - int minor; - } compatible_versions[] = { - { VA_MAJOR_VERSION, VA_MINOR_VERSION }, - { 0, 39 }, - { 0, 38 }, - { 0, 37 }, - { 0, 36 }, - { 0, 35 }, - { 0, 34 }, - { 0, 33 }, - { 0, 32 }, - { -1, } - }; - - for (i = 0; compatible_versions[i].major >= 0; i++) { - if (va_getDriverInitName(init_func_s, sizeof(init_func_s), - compatible_versions[i].major, - compatible_versions[i].minor)) { - init_func = (VADriverInit)dlsym(handle, init_func_s); - if (init_func) { - va_infoMessage("Found init function %s\n", init_func_s); - break; - } - } - } - - if (compatible_versions[i].major < 0) { - va_errorMessage("%s has no function %s\n", - driver_path, init_func_s); - dlclose(handle); - } else { - struct VADriverVTable *vtable = ctx->vtable; - struct VADriverVTableVPP *vtable_vpp = ctx->vtable_vpp; - - vaStatus = VA_STATUS_SUCCESS; - if (!vtable) { - vtable = calloc(1, sizeof(*vtable)); - if (!vtable) - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - ctx->vtable = vtable; - - if (!vtable_vpp) { - vtable_vpp = calloc(1, sizeof(*vtable_vpp)); - if (vtable_vpp) - vtable_vpp->version = VA_DRIVER_VTABLE_VPP_VERSION; - else - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - ctx->vtable_vpp = vtable_vpp; - - if (init_func && VA_STATUS_SUCCESS == vaStatus) - vaStatus = (*init_func)(ctx); - - if (VA_STATUS_SUCCESS == vaStatus) { - CHECK_MAXIMUM(vaStatus, ctx, profiles); - CHECK_MAXIMUM(vaStatus, ctx, entrypoints); - CHECK_MAXIMUM(vaStatus, ctx, attributes); - CHECK_MAXIMUM(vaStatus, ctx, image_formats); - CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); - CHECK_MAXIMUM(vaStatus, ctx, display_attributes); - CHECK_STRING(vaStatus, ctx, vendor); - CHECK_VTABLE(vaStatus, ctx, Terminate); - CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); - CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); - CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes); - CHECK_VTABLE(vaStatus, ctx, CreateConfig); - CHECK_VTABLE(vaStatus, ctx, DestroyConfig); - CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes); - CHECK_VTABLE(vaStatus, ctx, CreateSurfaces); - CHECK_VTABLE(vaStatus, ctx, DestroySurfaces); - CHECK_VTABLE(vaStatus, ctx, CreateContext); - CHECK_VTABLE(vaStatus, ctx, DestroyContext); - CHECK_VTABLE(vaStatus, ctx, CreateBuffer); - CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements); - CHECK_VTABLE(vaStatus, ctx, MapBuffer); - CHECK_VTABLE(vaStatus, ctx, UnmapBuffer); - CHECK_VTABLE(vaStatus, ctx, DestroyBuffer); - CHECK_VTABLE(vaStatus, ctx, BeginPicture); - CHECK_VTABLE(vaStatus, ctx, RenderPicture); - CHECK_VTABLE(vaStatus, ctx, EndPicture); - CHECK_VTABLE(vaStatus, ctx, SyncSurface); - CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus); - CHECK_VTABLE(vaStatus, ctx, PutSurface); - CHECK_VTABLE(vaStatus, ctx, QueryImageFormats); - CHECK_VTABLE(vaStatus, ctx, CreateImage); - CHECK_VTABLE(vaStatus, ctx, DeriveImage); - CHECK_VTABLE(vaStatus, ctx, DestroyImage); - CHECK_VTABLE(vaStatus, ctx, SetImagePalette); - CHECK_VTABLE(vaStatus, ctx, GetImage); - CHECK_VTABLE(vaStatus, ctx, PutImage); - CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats); - CHECK_VTABLE(vaStatus, ctx, CreateSubpicture); - CHECK_VTABLE(vaStatus, ctx, DestroySubpicture); - CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage); - CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey); - CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha); - CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture); - CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture); - CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes); - CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes); - CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); - } - 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; - } - } - free(driver_path); - - driver_dir = strtok_r(NULL, ":", &saveptr); - } - - free(search_path); - - return vaStatus; -} - -VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func) -{ - VADriverContextP ctx; - if (!vaDisplayIsValid(dpy)) - return NULL; - ctx = CTX(dpy); - - if (NULL == ctx->handle) - return NULL; - - return (VAPrivFunc) dlsym(ctx->handle, func); -} - - -/* - * Returns a short english description of error_status - */ -const char *vaErrorStr(VAStatus error_status) -{ - switch(error_status) { - case VA_STATUS_SUCCESS: - return "success (no error)"; - case VA_STATUS_ERROR_OPERATION_FAILED: - return "operation failed"; - case VA_STATUS_ERROR_ALLOCATION_FAILED: - return "resource allocation failed"; - case VA_STATUS_ERROR_INVALID_DISPLAY: - return "invalid VADisplay"; - case VA_STATUS_ERROR_INVALID_CONFIG: - return "invalid VAConfigID"; - case VA_STATUS_ERROR_INVALID_CONTEXT: - return "invalid VAContextID"; - case VA_STATUS_ERROR_INVALID_SURFACE: - return "invalid VASurfaceID"; - case VA_STATUS_ERROR_INVALID_BUFFER: - return "invalid VABufferID"; - case VA_STATUS_ERROR_INVALID_IMAGE: - return "invalid VAImageID"; - case VA_STATUS_ERROR_INVALID_SUBPICTURE: - return "invalid VASubpictureID"; - case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED: - return "attribute not supported"; - case VA_STATUS_ERROR_MAX_NUM_EXCEEDED: - return "list argument exceeds maximum number"; - case VA_STATUS_ERROR_UNSUPPORTED_PROFILE: - return "the requested VAProfile is not supported"; - case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT: - return "the requested VAEntryPoint is not supported"; - case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT: - return "the requested RT Format is not supported"; - case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: - return "the requested VABufferType is not supported"; - case VA_STATUS_ERROR_SURFACE_BUSY: - return "surface is in use"; - case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED: - return "flag not supported"; - case VA_STATUS_ERROR_INVALID_PARAMETER: - return "invalid parameter"; - case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED: - return "resolution not supported"; - case VA_STATUS_ERROR_UNIMPLEMENTED: - return "the requested function is not implemented"; - case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING: - return "surface is in displaying (may by overlay)" ; - case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT: - return "invalid VAImageFormat"; - case VA_STATUS_ERROR_INVALID_VALUE: - return "an invalid/unsupported value was supplied"; - case VA_STATUS_ERROR_UNSUPPORTED_FILTER: - return "the requested filter is not supported"; - case VA_STATUS_ERROR_INVALID_FILTER_CHAIN: - return "an invalid filter chain was supplied"; - case VA_STATUS_ERROR_UNKNOWN: - return "unknown libva error"; - } - return "unknown libva error / description missing"; -} - -const static char *prefer_driver_list[4] = { - "i965", - "hybrid", - "pvr", - "iHD", -}; - -VAStatus vaSetDriverName( - VADisplay dpy, - char *driver_name -) -{ - VADriverContextP ctx; - VAStatus vaStatus = VA_STATUS_SUCCESS; - char *override_driver_name = NULL; - int i, found; - ctx = CTX(dpy); - - if (geteuid() != getuid()) { - vaStatus = VA_STATUS_ERROR_OPERATION_FAILED; - va_errorMessage("no permission to vaSetDriverName\n"); - return vaStatus; - } - - if (strlen(driver_name) == 0 || strlen(driver_name) >=256) { - vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; - va_errorMessage("vaSetDriverName returns %s\n", - vaErrorStr(vaStatus)); - return vaStatus; - } - - found = 0; - for (i = 0; i < sizeof(prefer_driver_list) / sizeof(char *); i++) { - if (strlen(prefer_driver_list[i]) != strlen(driver_name)) - continue; - if (!strncmp(prefer_driver_list[i], driver_name, strlen(driver_name))) { - found = 1; - break; - } - } - - if (!found) { - vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; - va_errorMessage("vaSetDriverName returns %s. Incorrect parameter\n", - vaErrorStr(vaStatus)); - return vaStatus; - } - - override_driver_name = strdup(driver_name); - - if (!override_driver_name) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - va_errorMessage("vaSetDriverName returns %s. Out of Memory\n", - vaErrorStr(vaStatus)); - return vaStatus; - } - - ctx->override_driver_name = override_driver_name; - return VA_STATUS_SUCCESS; -} - -VAStatus vaInitialize ( - VADisplay dpy, - int *major_version, /* out */ - int *minor_version /* out */ -) -{ - const char *driver_name_env = NULL; - char *driver_name = NULL; - VAStatus vaStatus; - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - - ctx = CTX(dpy); - - va_TraceInit(dpy); - - va_FoolInit(dpy); - - va_infoMessage("VA-API version %s\n", VA_VERSION_S); - - vaStatus = va_getDriverName(dpy, &driver_name); - - if (!ctx->override_driver_name) { - va_infoMessage("va_getDriverName() returns %d\n", vaStatus); - - driver_name_env = getenv("LIBVA_DRIVER_NAME"); - } else if (vaStatus == VA_STATUS_SUCCESS) { - if (driver_name) - free(driver_name); - - driver_name = strdup(ctx->override_driver_name); - if (!driver_name) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - va_errorMessage("vaInitialize() failed with %s, out of memory\n", - vaErrorStr(vaStatus)); - return vaStatus; - } - va_infoMessage("User requested driver '%s'\n", driver_name); - } - - if (driver_name_env && (geteuid() == getuid())) { - /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ - if (driver_name) /* memory is allocated in va_getDriverName */ - free(driver_name); - - driver_name = strdup(driver_name_env); - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("User requested driver '%s'\n", driver_name); - } - - if ((VA_STATUS_SUCCESS == vaStatus) && (driver_name != NULL)) { - vaStatus = va_openDriver(dpy, driver_name); - va_infoMessage("va_openDriver() returns %d\n", vaStatus); - - *major_version = VA_MAJOR_VERSION; - *minor_version = VA_MINOR_VERSION; - } else - va_errorMessage("va_getDriverName() failed with %s,driver_name=%s\n", - vaErrorStr(vaStatus), driver_name); - - if (driver_name) - free(driver_name); - - VA_TRACE_LOG(va_TraceInitialize, dpy, major_version, minor_version); - - return vaStatus; -} - - -/* - * After this call, all library internal resources will be cleaned up - */ -VAStatus vaTerminate ( - VADisplay dpy -) -{ - VAStatus vaStatus = VA_STATUS_SUCCESS; - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - VADriverContextP old_ctx; - - CHECK_DISPLAY(dpy); - old_ctx = CTX(dpy); - - if (old_ctx->handle) { - vaStatus = old_ctx->vtable->vaTerminate(old_ctx); - dlclose(old_ctx->handle); - old_ctx->handle = NULL; - } - free(old_ctx->vtable); - old_ctx->vtable = NULL; - free(old_ctx->vtable_vpp); - old_ctx->vtable_vpp = NULL; - - if (old_ctx->override_driver_name) { - free(old_ctx->override_driver_name); - old_ctx->override_driver_name = NULL; - } - - VA_TRACE_LOG(va_TraceTerminate, dpy); - - va_TraceEnd(dpy); - - va_FoolEnd(dpy); - - if (VA_STATUS_SUCCESS == vaStatus) - pDisplayContext->vaDestroy(pDisplayContext); - - return vaStatus; -} - -/* - * vaQueryVendorString returns a pointer to a zero-terminated string - * describing some aspects of the VA implemenation on a specific - * hardware accelerator. The format of the returned string is: - * --- - * e.g. for the Intel GMA500 implementation, an example would be: - * "IntelGMA500-1.0-0.2-patch3 - */ -const char *vaQueryVendorString ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return NULL; - - return CTX(dpy)->str_vendor; -} - - -/* Get maximum number of profiles supported by the implementation */ -int vaMaxNumProfiles ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return 0; - - return CTX(dpy)->max_profiles; -} - -/* Get maximum number of entrypoints supported by the implementation */ -int vaMaxNumEntrypoints ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return 0; - - return CTX(dpy)->max_entrypoints; -} - - -/* Get maximum number of attributs supported by the implementation */ -int vaMaxNumConfigAttributes ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return 0; - - return CTX(dpy)->max_attributes; -} - -VAStatus vaQueryConfigEntrypoints ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint *entrypoints, /* out */ - int *num_entrypoints /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints); -} - -VAStatus vaGetConfigAttributes ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs ); -} - -VAStatus vaQueryConfigProfiles ( - VADisplay dpy, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaQueryConfigProfiles ( ctx, profile_list, num_profiles ); -} - -VAStatus vaCreateConfig ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ -) -{ - VADriverContextP ctx; - VAStatus vaStatus = VA_STATUS_SUCCESS; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id ); - - /* record the current entrypoint for further trace/fool determination */ - VA_TRACE_ALL(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; -} - -VAStatus vaDestroyConfig ( - VADisplay dpy, - VAConfigID config_id -) -{ - VADriverContextP ctx; - VAStatus vaStatus = VA_STATUS_SUCCESS; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - vaStatus = ctx->vtable->vaDestroyConfig ( ctx, config_id ); - - VA_TRACE_ALL(va_TraceDestroyConfig, dpy, config_id); - - return vaStatus; -} - -VAStatus vaQueryConfigAttributes ( - VADisplay dpy, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list,/* out */ - int *num_attribs /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs); -} - -/* XXX: this is a slow implementation that will be removed */ -static VAStatus -va_impl_query_surface_attributes( - VADriverContextP ctx, - VAConfigID config, - VASurfaceAttrib *out_attribs, - unsigned int *out_num_attribs_ptr -) -{ - VASurfaceAttrib *attribs = NULL; - unsigned int num_attribs, n; - VASurfaceAttrib *out_attrib; - unsigned int out_num_attribs; - VAImageFormat *image_formats = NULL; - int num_image_formats, i; - VAStatus va_status; - - /* List of surface attributes to query */ - struct va_surface_attrib_map { - VASurfaceAttribType type; - VAGenericValueType value_type; - }; - static const struct va_surface_attrib_map attribs_map[] = { - { VASurfaceAttribMinWidth, VAGenericValueTypeInteger }, - { VASurfaceAttribMaxWidth, VAGenericValueTypeInteger }, - { VASurfaceAttribMinHeight, VAGenericValueTypeInteger }, - { VASurfaceAttribMaxHeight, VAGenericValueTypeInteger }, - { VASurfaceAttribMemoryType, VAGenericValueTypeInteger }, - { VASurfaceAttribNone, } - }; - - if (!out_attribs || !out_num_attribs_ptr) - return VA_STATUS_ERROR_INVALID_PARAMETER; - if (!ctx->vtable->vaGetSurfaceAttributes) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - num_image_formats = ctx->max_image_formats; - image_formats = malloc(num_image_formats * sizeof(*image_formats)); - if (!image_formats) { - va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; - goto end; - } - - va_status = ctx->vtable->vaQueryImageFormats( - ctx, image_formats, &num_image_formats); - if (va_status != VA_STATUS_SUCCESS) - goto end; - - num_attribs = VASurfaceAttribCount + num_image_formats; - attribs = malloc(num_attribs * sizeof(*attribs)); - if (!attribs) { - va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; - goto end; - } - - /* Initialize with base surface attributes, except pixel-formats */ - for (n = 0; attribs_map[n].type != VASurfaceAttribNone; n++) { - VASurfaceAttrib * const attrib = &attribs[n]; - attrib->type = attribs_map[n].type; - attrib->flags = VA_SURFACE_ATTRIB_GETTABLE; - attrib->value.type = attribs_map[n].value_type; - } - - /* Append image formats */ - for (i = 0; i < num_image_formats; i++) { - VASurfaceAttrib * const attrib = &attribs[n]; - attrib->type = VASurfaceAttribPixelFormat; - attrib->flags = VA_SURFACE_ATTRIB_GETTABLE|VA_SURFACE_ATTRIB_SETTABLE; - attrib->value.type = VAGenericValueTypeInteger; - attrib->value.value.i = image_formats[i].fourcc; - if (++n == num_attribs) { - va_status = VA_STATUS_ERROR_ALLOCATION_FAILED; - goto end; - } - } - num_attribs = n; - - va_status = ctx->vtable->vaGetSurfaceAttributes( - ctx, config, attribs, num_attribs); - if (va_status != VA_STATUS_SUCCESS) - goto end; - - /* Remove invalid entries */ - out_num_attribs = 0; - for (n = 0; n < num_attribs; n++) { - VASurfaceAttrib * const attrib = &attribs[n]; - - if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED) - continue; - - // Accept all surface attributes that are not pixel-formats - if (attrib->type != VASurfaceAttribPixelFormat) { - out_num_attribs++; - continue; - } - - // Drop invalid pixel-format attribute - if (!attrib->value.value.i) { - attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED; - continue; - } - - // Check for duplicates - int is_duplicate = 0; - for (i = n - 1; i >= 0 && !is_duplicate; i--) { - const VASurfaceAttrib * const prev_attrib = &attribs[i]; - if (prev_attrib->type != VASurfaceAttribPixelFormat) - break; - is_duplicate = prev_attrib->value.value.i == attrib->value.value.i; - } - if (is_duplicate) - attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED; - else - out_num_attribs++; - } - - if (*out_num_attribs_ptr < out_num_attribs) { - *out_num_attribs_ptr = out_num_attribs; - va_status = VA_STATUS_ERROR_MAX_NUM_EXCEEDED; - goto end; - } - - out_attrib = out_attribs; - for (n = 0; n < num_attribs; n++) { - const VASurfaceAttrib * const attrib = &attribs[n]; - if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED) - continue; - *out_attrib++ = *attrib; - } - -end: - free(attribs); - free(image_formats); - return va_status; -} - -VAStatus -vaQuerySurfaceAttributes( - VADisplay dpy, - VAConfigID config, - VASurfaceAttrib *attrib_list, - unsigned int *num_attribs -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - if (!ctx) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - if (!ctx->vtable->vaQuerySurfaceAttributes) - vaStatus = va_impl_query_surface_attributes(ctx, config, - attrib_list, num_attribs); - else - vaStatus = ctx->vtable->vaQuerySurfaceAttributes(ctx, config, - attrib_list, num_attribs); - - VA_TRACE_LOG(va_TraceQuerySurfaceAttributes, dpy, config, attrib_list, num_attribs); - - return vaStatus; -} - -VAStatus -vaCreateSurfaces( - VADisplay dpy, - unsigned int format, - unsigned int width, - unsigned int height, - VASurfaceID *surfaces, - unsigned int num_surfaces, - VASurfaceAttrib *attrib_list, - unsigned int num_attribs -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - if (!ctx) - return VA_STATUS_ERROR_INVALID_DISPLAY; - - if (ctx->vtable->vaCreateSurfaces2) - vaStatus = ctx->vtable->vaCreateSurfaces2(ctx, format, width, height, - surfaces, num_surfaces, - attrib_list, num_attribs); - else if (attrib_list && num_attribs > 0) - vaStatus = VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; - else - vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format, - num_surfaces, surfaces); - VA_TRACE_LOG(va_TraceCreateSurfaces, - dpy, width, height, format, num_surfaces, surfaces, - attrib_list, num_attribs); - - return vaStatus; -} - - -VAStatus vaDestroySurfaces ( - VADisplay dpy, - VASurfaceID *surface_list, - int num_surfaces -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_TRACE_LOG(va_TraceDestroySurfaces, - dpy, surface_list, num_surfaces); - - vaStatus = ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces ); - - return vaStatus; -} - -VAStatus vaCreateContext ( - VADisplay dpy, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - VAContextID *context /* out */ -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - vaStatus = ctx->vtable->vaCreateContext( ctx, config_id, picture_width, picture_height, - flag, render_targets, num_render_targets, context ); - - /* keep current encode/decode resoluton */ - VA_TRACE_ALL(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context); - - return vaStatus; -} - -VAStatus vaDestroyContext ( - VADisplay dpy, - VAContextID context -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - vaStatus = ctx->vtable->vaDestroyContext( ctx, context ); - - VA_TRACE_ALL(va_TraceDestroyContext, dpy, context); - - return vaStatus; -} - -VAStatus vaCreateBuffer ( - VADisplay dpy, - VAContextID context, /* in */ - VABufferType type, /* in */ - unsigned int size, /* in */ - unsigned int num_elements, /* in */ - void *data, /* in */ - VABufferID *buf_id /* out */ -) -{ - VADriverContextP ctx; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id); - - vaStatus = ctx->vtable->vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id); - - VA_TRACE_LOG(va_TraceCreateBuffer, - dpy, context, type, size, num_elements, data, buf_id); - - return vaStatus; -} - -VAStatus vaBufferSetNumElements ( - VADisplay dpy, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements ); -} - - -VAStatus vaMapBuffer ( - VADisplay dpy, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -) -{ - VADriverContextP ctx; - VAStatus va_status; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf); - - va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf ); - - VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf); - - return va_status; -} - -VAStatus vaUnmapBuffer ( - VADisplay dpy, - VABufferID buf_id /* in */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - return ctx->vtable->vaUnmapBuffer( ctx, buf_id ); -} - -VAStatus vaDestroyBuffer ( - VADisplay dpy, - VABufferID buffer_id -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - VA_TRACE_LOG(va_TraceDestroyBuffer, - dpy, buffer_id); - - return ctx->vtable->vaDestroyBuffer( ctx, buffer_id ); -} - -VAStatus vaBufferInfo ( - VADisplay dpy, - VAContextID context, /* in */ - VABufferID buf_id, /* in */ - VABufferType *type, /* out */ - unsigned int *size, /* out */ - unsigned int *num_elements /* out */ -) -{ - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements); - - return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements ); -} - -/* Locks buffer for external API usage */ -VAStatus -vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info) -{ - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - if (!ctx->vtable->vaAcquireBufferHandle) - return VA_STATUS_ERROR_UNIMPLEMENTED; - return ctx->vtable->vaAcquireBufferHandle(ctx, buf_id, buf_info); -} - -/* Unlocks buffer after usage from external API */ -VAStatus -vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id) -{ - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - if (!ctx->vtable->vaReleaseBufferHandle) - return VA_STATUS_ERROR_UNIMPLEMENTED; - return ctx->vtable->vaReleaseBufferHandle(ctx, buf_id); -} - -VAStatus vaBeginPicture ( - VADisplay dpy, - VAContextID context, - VASurfaceID render_target -) -{ - VADriverContextP ctx; - VAStatus va_status; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_TRACE_ALL(va_TraceBeginPicture, dpy, context, render_target); - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target ); - - return va_status; -} - -VAStatus vaRenderPicture ( - VADisplay dpy, - VAContextID context, - VABufferID *buffers, - int num_buffers -) -{ - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers); - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers ); -} - -VAStatus vaEndPicture ( - VADisplay dpy, - VAContextID context -) -{ - VAStatus va_status = VA_STATUS_SUCCESS; - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_FOOL_FUNC(va_FoolCheckContinuity, dpy); - - va_status = ctx->vtable->vaEndPicture( ctx, context ); - - /* dump surface content */ - VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 1); - - return va_status; -} - -VAStatus vaSyncSurface ( - VADisplay dpy, - VASurfaceID render_target -) -{ - VAStatus va_status; - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_status = ctx->vtable->vaSyncSurface( ctx, render_target ); - VA_TRACE_LOG(va_TraceSyncSurface, dpy, render_target); - - return va_status; -} - -VAStatus vaQuerySurfaceStatus ( - VADisplay dpy, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ -) -{ - VAStatus va_status; - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_status = ctx->vtable->vaQuerySurfaceStatus( ctx, render_target, status ); - - VA_TRACE_LOG(va_TraceQuerySurfaceStatus, dpy, render_target, status); - - return va_status; -} - -VAStatus vaQuerySurfaceError ( - VADisplay dpy, - VASurfaceID surface, - VAStatus error_status, - void **error_info /*out*/ -) -{ - VAStatus va_status; - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_status = ctx->vtable->vaQuerySurfaceError( ctx, surface, error_status, error_info ); - - VA_TRACE_LOG(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info); - - return va_status; -} - -/* Get maximum number of image formats supported by the implementation */ -int vaMaxNumImageFormats ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return 0; - - return CTX(dpy)->max_image_formats; -} - -VAStatus vaQueryImageFormats ( - VADisplay dpy, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaQueryImageFormats ( ctx, format_list, num_formats); -} - -/* - * The width and height fields returned in the VAImage structure may get - * enlarged for some YUV formats. The size of the data buffer that needs - * to be allocated will be given in the "data_size" field in VAImage. - * Image data is not allocated by this function. The client should - * allocate the memory and fill in the VAImage structure's data field - * after looking at "data_size" returned from the library. - */ -VAStatus vaCreateImage ( - VADisplay dpy, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaCreateImage ( ctx, format, width, height, image); -} - -/* - * Should call DestroyImage before destroying the surface it is bound to - */ -VAStatus vaDestroyImage ( - VADisplay dpy, - VAImageID image -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaDestroyImage ( ctx, image); -} - -VAStatus vaSetImagePalette ( - VADisplay dpy, - VAImageID image, - unsigned char *palette -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaSetImagePalette ( ctx, image, palette); -} - -/* - * Retrieve surface data into a VAImage - * Image must be in a format supported by the implementation - */ -VAStatus vaGetImage ( - VADisplay dpy, - VASurfaceID surface, - int x, /* coordinates of the upper left source pixel */ - int y, - unsigned int width, /* width and height of the region */ - unsigned int height, - VAImageID image -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaGetImage ( ctx, surface, x, y, width, height, image); -} - -/* - * Copy data from a VAImage to a surface - * Image must be in a format supported by the implementation - */ -VAStatus vaPutImage ( - VADisplay dpy, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int src_width, - unsigned int src_height, - int dest_x, - int dest_y, - unsigned int dest_width, - unsigned int dest_height -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height ); -} - -/* - * Derive an VAImage from an existing surface. - * This interface will derive a VAImage and corresponding image buffer from - * an existing VA Surface. The image buffer can then be mapped/unmapped for - * direct CPU access. This operation is only possible on implementations with - * direct rendering capabilities and internal surface formats that can be - * represented with a VAImage. When the operation is not possible this interface - * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back - * to using vaCreateImage + vaPutImage to accomplish the same task in an - * indirect manner. - * - * Implementations should only return success when the resulting image buffer - * would be useable with vaMap/Unmap. - * - * When directly accessing a surface special care must be taken to insure - * proper synchronization with the graphics hardware. Clients should call - * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent - * rendering or currently being displayed by an overlay. - * - * Additionally nothing about the contents of a surface should be assumed - * following a vaPutSurface. Implementations are free to modify the surface for - * scaling or subpicture blending within a call to vaPutImage. - * - * Calls to vaPutImage or vaGetImage using the same surface from which the image - * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or - * vaGetImage with other surfaces is supported. - * - * An image created with vaDeriveImage should be freed with vaDestroyImage. The - * image and image buffer structures will be destroyed; however, the underlying - * surface will remain unchanged until freed with vaDestroySurfaces. - */ -VAStatus vaDeriveImage ( - VADisplay dpy, - VASurfaceID surface, - VAImage *image /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaDeriveImage ( ctx, surface, image ); -} - - -/* Get maximum number of subpicture formats supported by the implementation */ -int vaMaxNumSubpictureFormats ( - VADisplay dpy -) -{ - if (!vaDisplayIsValid(dpy)) - return 0; - - return CTX(dpy)->max_subpic_formats; -} - -/* - * Query supported subpicture formats - * The caller must provide a "format_list" array that can hold at - * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag - * for each format to indicate additional capabilities for that format. The actual - * number of formats returned in "format_list" is returned in "num_formats". - */ -VAStatus vaQuerySubpictureFormats ( - VADisplay dpy, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ -) -{ - VADriverContextP ctx; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats); -} - -/* - * Subpictures are created with an image associated. - */ -VAStatus vaCreateSubpicture ( - VADisplay dpy, - VAImageID image, - VASubpictureID *subpicture /* out */ -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaCreateSubpicture ( ctx, image, subpicture ); -} - -/* - * Destroy the subpicture before destroying the image it is assocated to - */ -VAStatus vaDestroySubpicture ( - VADisplay dpy, - VASubpictureID subpicture -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaDestroySubpicture ( ctx, subpicture); -} - -VAStatus vaSetSubpictureImage ( - VADisplay dpy, - VASubpictureID subpicture, - VAImageID image -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaSetSubpictureImage ( ctx, subpicture, image); -} - - -/* - * If chromakey is enabled, then the area where the source value falls within - * the chromakey [min, max] range is transparent - */ -VAStatus vaSetSubpictureChromakey ( - VADisplay dpy, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask ); -} - - -/* - * Global alpha value is between 0 and 1. A value of 1 means fully opaque and - * a value of 0 means fully transparent. If per-pixel alpha is also specified then - * the overall alpha is per-pixel alpha multiplied by the global alpha - */ -VAStatus vaSetSubpictureGlobalAlpha ( - VADisplay dpy, - VASubpictureID subpicture, - float global_alpha -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha ); -} - -/* - vaAssociateSubpicture associates the subpicture with the target_surface. - It defines the region mapping between the subpicture and the target - surface through source and destination rectangles (with the same width and height). - Both will be displayed at the next call to vaPutSurface. Additional - associations before the call to vaPutSurface simply overrides the association. -*/ -VAStatus vaAssociateSubpicture ( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - unsigned short src_width, - unsigned short src_height, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short dest_width, - unsigned short dest_height, - /* - * whether to enable chroma-keying or global-alpha - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags ); -} - -/* - * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces. - */ -VAStatus vaDeassociateSubpicture ( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces ); -} - - -/* Get maximum number of display attributes supported by the implementation */ -int vaMaxNumDisplayAttributes ( - VADisplay dpy -) -{ - int tmp; - - if (!vaDisplayIsValid(dpy)) - return 0; - - tmp = CTX(dpy)->max_display_attributes; - - VA_TRACE_LOG(va_TraceMaxNumDisplayAttributes, dpy, tmp); - - return tmp; -} - -/* - * Query display attributes - * The caller must provide a "attr_list" array that can hold at - * least vaMaxNumDisplayAttributes() entries. The actual number of attributes - * returned in "attr_list" is returned in "num_attributes". - */ -VAStatus vaQueryDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ -) -{ - VADriverContextP ctx; - VAStatus va_status; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - va_status = ctx->vtable->vaQueryDisplayAttributes ( ctx, attr_list, num_attributes ); - - VA_TRACE_LOG(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes); - - return va_status; - -} - -/* - * Get display attributes - * This function returns the current attribute values in "attr_list". - * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can have their values retrieved. - */ -VAStatus vaGetDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes -) -{ - VADriverContextP ctx; - VAStatus va_status; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - va_status = ctx->vtable->vaGetDisplayAttributes ( ctx, attr_list, num_attributes ); - - VA_TRACE_LOG(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes); - - return va_status; -} - -/* - * Set display attributes - * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or - * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED - */ -VAStatus vaSetDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, - int num_attributes -) -{ - VADriverContextP ctx; - VAStatus va_status; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - va_status = ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attributes ); - VA_TRACE_LOG(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes); - - return va_status; -} - -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 -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaLockSurface( ctx, surface, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, buffer_name, buffer); -} - - -VAStatus vaUnlockSurface(VADisplay dpy, - VASurfaceID surface -) -{ - VADriverContextP ctx; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - return ctx->vtable->vaUnlockSurface( ctx, surface ); -} - -/* Video Processing */ -#define VA_VPP_INIT_CONTEXT(ctx, dpy) do { \ - CHECK_DISPLAY(dpy); \ - ctx = CTX(dpy); \ - if (!ctx) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - } while (0) - -#define VA_VPP_INVOKE(dpy, func, args) do { \ - if (!ctx->vtable_vpp->va##func) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - status = ctx->vtable_vpp->va##func args; \ - } while (0) - -VAStatus -vaQueryVideoProcFilters( - VADisplay dpy, - VAContextID context, - VAProcFilterType *filters, - unsigned int *num_filters -) -{ - VADriverContextP ctx; - VAStatus status; - - VA_VPP_INIT_CONTEXT(ctx, dpy); - VA_VPP_INVOKE( - ctx, - QueryVideoProcFilters, - (ctx, context, filters, num_filters) - ); - return status; -} - -VAStatus -vaQueryVideoProcFilterCaps( - VADisplay dpy, - VAContextID context, - VAProcFilterType type, - void *filter_caps, - unsigned int *num_filter_caps -) -{ - VADriverContextP ctx; - VAStatus status; - - VA_VPP_INIT_CONTEXT(ctx, dpy); - VA_VPP_INVOKE( - ctx, - QueryVideoProcFilterCaps, - (ctx, context, type, filter_caps, num_filter_caps) - ); - return status; -} - -VAStatus -vaQueryVideoProcPipelineCaps( - VADisplay dpy, - VAContextID context, - VABufferID *filters, - unsigned int num_filters, - VAProcPipelineCaps *pipeline_caps -) -{ - VADriverContextP ctx; - VAStatus status; - - VA_VPP_INIT_CONTEXT(ctx, dpy); - VA_VPP_INVOKE( - ctx, - QueryVideoProcPipelineCaps, - (ctx, context, filters, num_filters, pipeline_caps) - ); - return status; -} diff --git a/va/va.h b/va/va.h deleted file mode 100644 index e1382d8..0000000 --- a/va/va.h +++ /dev/null @@ -1,3132 +0,0 @@ -/* - * Copyright (c) 2007-2009 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 INTEL 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. - */ -/* - * Video Acceleration (VA) API Specification - * - * Rev. 0.30 - * - * - * Revision History: - * rev 0.10 (12/10/2006 Jonathan Bian) - Initial draft - * rev 0.11 (12/15/2006 Jonathan Bian) - Fixed some errors - * rev 0.12 (02/05/2007 Jonathan Bian) - Added VC-1 data structures for slice level decode - * rev 0.13 (02/28/2007 Jonathan Bian) - Added GetDisplay() - * rev 0.14 (04/13/2007 Jonathan Bian) - Fixed MPEG-2 PictureParameter structure, cleaned up a few funcs. - * rev 0.15 (04/20/2007 Jonathan Bian) - Overhauled buffer management - * rev 0.16 (05/02/2007 Jonathan Bian) - Added error codes and fixed some issues with configuration - * rev 0.17 (05/07/2007 Jonathan Bian) - Added H.264/AVC data structures for slice level decode. - * rev 0.18 (05/14/2007 Jonathan Bian) - Added data structures for MPEG-4 slice level decode - * and MPEG-2 motion compensation. - * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data. - * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure. - * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support. - * rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha. - * rev 0.23 (09/11/2007 Jonathan Bian) - Fixed some issues with images and subpictures. - * rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes. - * rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types. - * rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics - * rev 0.27 (11/19/2007 Matt Sottek) - Added DeriveImage - * rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture - * to enable scaling - * rev 0.29 (02/07/2008 Jonathan Bian) - VC1 parameter fixes, - * added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED - * rev 0.30 (03/01/2009 Jonathan Bian) - Added encoding support for H.264 BP and MPEG-4 SP and fixes - * for ISO C conformance. - * rev 0.31 (09/02/2009 Gwenole Beauchesne) - VC-1/H264 fields change for VDPAU and XvBA backend - * Application needs to relink with the new library. - * - * rev 0.31.1 (03/29/2009) - Data structure for JPEG encode - * rev 0.31.2 (01/13/2011 Anthony Pabon)- Added a flag to indicate Subpicture coordinates are screen - * screen relative rather than source video relative. - * rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1 - * update VAAPI to 0.32.0 - * - * Acknowledgements: - * Some concepts borrowed from XvMC and XvImage. - * Waldo Bastian (Intel), Matt Sottek (Intel), Austin Yuan (Intel), and Gwenole Beauchesne (SDS) - * contributed to various aspects of the API. - */ - -/** - * \file va.h - * \brief The Core API - * - * This file contains the \ref api_core "Core API". - */ - -#ifndef _VA_H_ -#define _VA_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \mainpage Video Acceleration (VA) API - * - * \section intro Introduction - * - * The main motivation for VA-API (Video Acceleration API) is to - * enable hardware accelerated video decode and encode at various - * entry-points (VLD, IDCT, Motion Compensation etc.) for the - * prevailing coding standards today (MPEG-2, MPEG-4 ASP/H.263, MPEG-4 - * AVC/H.264, VC-1/VMW3, and JPEG). - * - * VA-API is split into several modules: - * - \ref api_core - * - \ref api_enc_h264 - * - \ref api_vpp - */ - -/** - * \defgroup api_core Core API - * - * @{ - */ - -/** -Overview - -The VA API is intended to provide an interface between a video decode/encode/display -application (client) and a hardware accelerator (server), to off-load -video decode/encode/display operations from the host to the hardware accelerator at various -entry-points. - -The basic operation steps are: - -- Negotiate a mutually acceptable configuration with the server to lock - down profile, entrypoints, and other attributes that will not change on - a frame-by-frame basis. -- Create a decode context which represents a "virtualized" hardware decode - device -- Get and fill decode buffers with picture level, slice level and macroblock - level data (depending on entrypoints) -- Pass the decode buffers to the server to decode the current frame - -Initialization & Configuration Management - -- Find out supported profiles -- Find out entrypoints for a given profile -- Find out configuration attributes for a given profile/entrypoint pair -- Create a configuration for use by the decoder - -*/ - -typedef void* VADisplay; /* window system dependent */ - -typedef int VAStatus; /** Return status type from functions */ -/** Values for the return status */ -#define VA_STATUS_SUCCESS 0x00000000 -#define VA_STATUS_ERROR_OPERATION_FAILED 0x00000001 -#define VA_STATUS_ERROR_ALLOCATION_FAILED 0x00000002 -#define VA_STATUS_ERROR_INVALID_DISPLAY 0x00000003 -#define VA_STATUS_ERROR_INVALID_CONFIG 0x00000004 -#define VA_STATUS_ERROR_INVALID_CONTEXT 0x00000005 -#define VA_STATUS_ERROR_INVALID_SURFACE 0x00000006 -#define VA_STATUS_ERROR_INVALID_BUFFER 0x00000007 -#define VA_STATUS_ERROR_INVALID_IMAGE 0x00000008 -#define VA_STATUS_ERROR_INVALID_SUBPICTURE 0x00000009 -#define VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 0x0000000a -#define VA_STATUS_ERROR_MAX_NUM_EXCEEDED 0x0000000b -#define VA_STATUS_ERROR_UNSUPPORTED_PROFILE 0x0000000c -#define VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT 0x0000000d -#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e -#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f -#define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010 -#define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED 0x00000011 -#define VA_STATUS_ERROR_INVALID_PARAMETER 0x00000012 -#define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013 -#define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014 -#define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING 0x00000015 -#define VA_STATUS_ERROR_INVALID_IMAGE_FORMAT 0x00000016 -#define VA_STATUS_ERROR_DECODING_ERROR 0x00000017 -#define VA_STATUS_ERROR_ENCODING_ERROR 0x00000018 -/** - * \brief An invalid/unsupported value was supplied. - * - * This is a catch-all error code for invalid or unsupported values. - * e.g. value exceeding the valid range, invalid type in the context - * of generic attribute values. - */ -#define VA_STATUS_ERROR_INVALID_VALUE 0x00000019 -/** \brief An unsupported filter was supplied. */ -#define VA_STATUS_ERROR_UNSUPPORTED_FILTER 0x00000020 -/** \brief An invalid filter chain was supplied. */ -#define VA_STATUS_ERROR_INVALID_FILTER_CHAIN 0x00000021 -/** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */ -#define VA_STATUS_ERROR_HW_BUSY 0x00000022 -/** \brief An unsupported memory type was supplied. */ -#define VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE 0x00000024 -#define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF - -/** De-interlacing flags for vaPutSurface() */ -#define VA_FRAME_PICTURE 0x00000000 -#define VA_TOP_FIELD 0x00000001 -#define VA_BOTTOM_FIELD 0x00000002 - -/** - * Enabled the positioning/cropping/blending feature: - * 1, specify the video playback position in the isurface - * 2, specify the cropping info for video playback - * 3, encoded video will blend with background color - */ -#define VA_ENABLE_BLEND 0x00000004 /* video area blend with the constant color */ - -/** - * Clears the drawable with background color. - * for hardware overlay based implementation this flag - * can be used to turn off the overlay - */ -#define VA_CLEAR_DRAWABLE 0x00000008 - -/** Color space conversion flags for vaPutSurface() */ -#define VA_SRC_COLOR_MASK 0x000000f0 -#define VA_SRC_BT601 0x00000010 -#define VA_SRC_BT709 0x00000020 -#define VA_SRC_SMPTE_240 0x00000040 - -/** Scaling flags for vaPutSurface() */ -#define VA_FILTER_SCALING_DEFAULT 0x00000000 -#define VA_FILTER_SCALING_FAST 0x00000100 -#define VA_FILTER_SCALING_HQ 0x00000200 -#define VA_FILTER_SCALING_NL_ANAMORPHIC 0x00000300 -#define VA_FILTER_SCALING_MASK 0x00000f00 - -/** - * Returns a short english description of error_status - */ -const char *vaErrorStr(VAStatus error_status); - -typedef struct _VARectangle -{ - short x; - short y; - unsigned short width; - unsigned short height; -} VARectangle; - -/** Type of a message callback, used for both error and info log. */ -typedef void (*vaMessageCallback)(const char *message); - -/** - * Set the callback for error messages, or NULL for no logging. - * Returns the previous one, or NULL if it was disabled. - */ -vaMessageCallback vaSetErrorCallback(vaMessageCallback); - -/** - * Set the callback for info messages, or NULL for no logging. - * Returns the previous one, or NULL if it was disabled. - */ -vaMessageCallback vaSetInfoCallback(vaMessageCallback); - -/** - * Initialization: - * A display must be obtained by calling vaGetDisplay() before calling - * vaInitialize() and other functions. This connects the API to the - * native window system. - * For X Windows, native_dpy would be from XOpenDisplay() - */ -typedef void* VANativeDisplay; /* window system dependent */ - -int vaDisplayIsValid(VADisplay dpy); - -/** - * Set the override driver name instead of queried driver driver. - */ -VAStatus vaSetDriverName(VADisplay dpy, - char *driver_name -); - -/** - * Initialize the library - */ -VAStatus vaInitialize ( - VADisplay dpy, - int *major_version, /* out */ - int *minor_version /* out */ -); - -/** - * After this call, all library internal resources will be cleaned up - */ -VAStatus vaTerminate ( - VADisplay dpy -); - -/** - * vaQueryVendorString returns a pointer to a zero-terminated string - * describing some aspects of the VA implemenation on a specific - * hardware accelerator. The format of the returned string is vendor - * specific and at the discretion of the implementer. - * e.g. for the Intel GMA500 implementation, an example would be: - * "Intel GMA500 - 2.0.0.32L.0005" - */ -const char *vaQueryVendorString ( - VADisplay dpy -); - -typedef int (*VAPrivFunc)(void); - -/** - * Return a function pointer given a function name in the library. - * This allows private interfaces into the library - */ -VAPrivFunc vaGetLibFunc ( - VADisplay dpy, - const char *func -); - -/** Currently defined profiles */ -typedef enum -{ - /** \brief Profile ID used for video processing. */ - VAProfileNone = -1, - VAProfileMPEG2Simple = 0, - VAProfileMPEG2Main = 1, - VAProfileMPEG4Simple = 2, - VAProfileMPEG4AdvancedSimple = 3, - VAProfileMPEG4Main = 4, - VAProfileH264Baseline = 5, - VAProfileH264Main = 6, - VAProfileH264High = 7, - VAProfileVC1Simple = 8, - VAProfileVC1Main = 9, - VAProfileVC1Advanced = 10, - VAProfileH263Baseline = 11, - VAProfileJPEGBaseline = 12, - VAProfileH264ConstrainedBaseline = 13, - VAProfileVP8Version0_3 = 14, - VAProfileH264MultiviewHigh = 15, - VAProfileH264StereoHigh = 16, - VAProfileHEVCMain = 17, - VAProfileHEVCMain10 = 18, - VAProfileVP9Profile0 = 19, - VAProfileVP9Profile1 = 20, - VAProfileVP9Profile2 = 21, - VAProfileVP9Profile3 = 22 -} VAProfile; - -/** - * Currently defined entrypoints - */ -typedef enum -{ - VAEntrypointVLD = 1, - VAEntrypointIZZ = 2, - VAEntrypointIDCT = 3, - VAEntrypointMoComp = 4, - VAEntrypointDeblocking = 5, - VAEntrypointEncSlice = 6, /* slice level encode */ - VAEntrypointEncPicture = 7, /* pictuer encode, JPEG, etc */ - /* - * For an implementation that supports a low power/high performance variant - * for slice level encode, it can choose to expose the - * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be - * available with this entrypoint (e.g. interlace, MBAFF) and the - * application can query the encoding configuration attributes to find - * out more details if this entrypoint is supported. - */ - VAEntrypointEncSliceLP = 8, - VAEntrypointVideoProc = 10, /**< Video pre/post-processing. */ -} VAEntrypoint; - -/** Currently defined configuration attribute types */ -typedef enum -{ - VAConfigAttribRTFormat = 0, - VAConfigAttribSpatialResidual = 1, - VAConfigAttribSpatialClipping = 2, - VAConfigAttribIntraResidual = 3, - VAConfigAttribEncryption = 4, - VAConfigAttribRateControl = 5, - - /** @name Attributes for decoding */ - /**@{*/ - /** - * \brief Slice Decoding mode. Read/write. - * - * This attribute determines what mode the driver supports for slice - * decoding, through vaGetConfigAttributes(); and what mode the user - * will be providing to the driver, through vaCreateConfig(), if the - * driver supports those. If this attribute is not set by the user then - * it is assumed that VA_DEC_SLICE_MODE_NORMAL mode is used. - * - * See \c VA_DEC_SLICE_MODE_xxx for the list of slice decoding modes. - */ - VAConfigAttribDecSliceMode = 6, - - /** @name Attributes for encoding */ - /**@{*/ - /** - * \brief Packed headers mode. Read/write. - * - * This attribute determines what packed headers the driver supports, - * through vaGetConfigAttributes(); and what packed headers the user - * will be providing to the driver, through vaCreateConfig(), if the - * driver supports those. - * - * See \c VA_ENC_PACKED_HEADER_xxx for the list of packed headers. - */ - VAConfigAttribEncPackedHeaders = 10, - /** - * \brief Interlaced mode. Read/write. - * - * This attribute determines what kind of interlaced encoding mode - * the driver supports. - * - * See \c VA_ENC_INTERLACED_xxx for the list of interlaced modes. - */ - VAConfigAttribEncInterlaced = 11, - /** - * \brief Maximum number of reference frames. Read-only. - * - * This attribute determines the maximum number of reference - * frames supported for encoding. - * - * Note: for H.264 encoding, the value represents the maximum number - * of reference frames for both the reference picture list 0 (bottom - * 16 bits) and the reference picture list 1 (top 16 bits). - */ - VAConfigAttribEncMaxRefFrames = 13, - /** - * \brief Maximum number of slices per frame. Read-only. - * - * This attribute determines the maximum number of slices the - * driver can support to encode a single frame. - */ - VAConfigAttribEncMaxSlices = 14, - /** - * \brief Slice structure. Read-only. - * - * This attribute determines slice structures supported by the - * driver for encoding. This attribute is a hint to the user so - * that he can choose a suitable surface size and how to arrange - * the encoding process of multiple slices per frame. - * - * More specifically, for H.264 encoding, this attribute - * determines the range of accepted values to - * VAEncSliceParameterBufferH264::macroblock_address and - * VAEncSliceParameterBufferH264::num_macroblocks. - * - * See \c VA_ENC_SLICE_STRUCTURE_xxx for the supported slice - * structure types. - */ - VAConfigAttribEncSliceStructure = 15, - /** - * \brief Macroblock information. Read-only. - * - * This attribute determines whether the driver supports extra - * encoding information per-macroblock. e.g. QP. - * - * More specifically, for H.264 encoding, if the driver returns a non-zero - * value for this attribute, this means the application can create - * additional #VAEncMacroblockParameterBufferH264 buffers referenced - * through VAEncSliceParameterBufferH264::macroblock_info. - */ - VAConfigAttribEncMacroblockInfo = 16, - /** - * \brief JPEG encoding attribute. Read-only. - * - * This attribute exposes a number of capabilities of the underlying - * JPEG implementation. The attribute value is partitioned into fields as defined in the - * VAConfigAttribValEncJPEG union. - */ - VAConfigAttribEncJPEG = 20, - /** - * \brief Encoding quality range attribute. Read-only. - * - * This attribute conveys whether the driver supports different quality level settings - * for encoding. A value less than or equal to 1 means that the encoder only has a single - * quality setting, and a value greater than 1 represents the number of quality levels - * that can be configured. e.g. a value of 2 means there are two distinct quality levels. - */ - VAConfigAttribEncQualityRange = 21, - /** - * \brief Encoding skip frame attribute. Read-only. - * - * This attribute conveys whether the driver supports sending skip frame parameters - * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has - * externally skipped frames. - */ - VAConfigAttribEncSkipFrame = 24, - /** - * \brief Encoding region-of-interest (ROI) attribute. Read-only. - * - * This attribute conveys whether the driver supports region-of-interest (ROI) encoding, - * based on user provided ROI rectangles. The attribute value is partitioned into fields - * as defined in the VAConfigAttribValEncROI union. - * - * If ROI encoding is supported, the ROI information is passed to the driver using - * VAEncMiscParameterTypeROI. - */ - VAConfigAttribEncROI = 25, - /** - * \brief Encoding extended rate control attribute. Read-only. - * - * This attribute conveys whether the driver supports any extended rate control features - * The attribute value is partitioned into fields as defined in the - * VAConfigAttribValEncRateControlExt union. - */ - VAConfigAttribEncRateControlExt = 26, - - /**@}*/ - VAConfigAttribTypeMax -} VAConfigAttribType; - -/** - * Configuration attributes - * If there is more than one value for an attribute, a default - * value will be assigned to the attribute if the client does not - * specify the attribute when creating a configuration - */ -typedef struct _VAConfigAttrib { - VAConfigAttribType type; - unsigned int value; /* OR'd flags (bits) for this attribute */ -} VAConfigAttrib; - -/** attribute value for VAConfigAttribRTFormat */ -#define VA_RT_FORMAT_YUV420 0x00000001 -#define VA_RT_FORMAT_YUV422 0x00000002 -#define VA_RT_FORMAT_YUV444 0x00000004 -#define VA_RT_FORMAT_YUV411 0x00000008 -#define VA_RT_FORMAT_YUV400 0x00000010 -/** YUV formats with more than 8 bpp */ -#define VA_RT_FORMAT_YUV420_10BPP 0x00000100 -/** RGB formats */ -#define VA_RT_FORMAT_RGB16 0x00010000 -#define VA_RT_FORMAT_RGB32 0x00020000 -/* RGBP covers RGBP and BGRP fourcc */ -#define VA_RT_FORMAT_RGBP 0x00100000 -#define VA_RT_FORMAT_PROTECTED 0x80000000 - -/** @name Attribute values for VAConfigAttribRateControl */ -/**@{*/ -/** \brief Driver does not support any form of rate control. */ -#define VA_RC_NONE 0x00000001 -/** \brief Constant bitrate. */ -#define VA_RC_CBR 0x00000002 -/** \brief Variable bitrate. */ -#define VA_RC_VBR 0x00000004 -/** \brief Video conference mode. */ -#define VA_RC_VCM 0x00000008 -/** \brief Constant QP. */ -#define VA_RC_CQP 0x00000010 -/** \brief Variable bitrate with peak rate higher than average bitrate. */ -#define VA_RC_VBR_CONSTRAINED 0x00000020 -/** \brief Macroblock based rate control. Per MB control is decided - * internally in the encoder. It may be combined with other RC modes, except CQP. */ -#define VA_RC_MB 0x00000080 - -/**@}*/ - -/** @name Attribute values for VAConfigAttribDecSliceMode */ -/**@{*/ -/** \brief Driver supports normal mode for slice decoding */ -#define VA_DEC_SLICE_MODE_NORMAL 0x00000001 -/** \brief Driver supports base mode for slice decoding */ -#define VA_DEC_SLICE_MODE_BASE 0x00000002 -/**@}*/ - -/** @name Attribute values for VAConfigAttribEncPackedHeaders */ -/**@{*/ -/** \brief Driver does not support any packed headers mode. */ -#define VA_ENC_PACKED_HEADER_NONE 0x00000000 -/** \brief Driver supports packed sequence headers. e.g. SPS for H.264. */ -#define VA_ENC_PACKED_HEADER_SEQUENCE 0x00000001 -/** \brief Driver supports packed picture headers. e.g. PPS for H.264. */ -#define VA_ENC_PACKED_HEADER_PICTURE 0x00000002 -/** \brief Driver supports packed slice headers. e.g. \c slice_header() for H.264. */ -#define VA_ENC_PACKED_HEADER_SLICE 0x00000004 -/** \brief Driver supports misc packed headers. e.g. SEI for H.264. */ -#define VA_ENC_PACKED_HEADER_MISC 0x00000008 -/** \brief Driver supports raw packed header, see VAEncPackedHeaderRawData */ -#define VA_ENC_PACKED_HEADER_RAW_DATA 0x00000010 -/**@}*/ - -/** @name Attribute values for VAConfigAttribEncInterlaced */ -/**@{*/ -/** \brief Driver does not support interlaced coding. */ -#define VA_ENC_INTERLACED_NONE 0x00000000 -/** \brief Driver supports interlaced frame coding. */ -#define VA_ENC_INTERLACED_FRAME 0x00000001 -/** \brief Driver supports interlaced field coding. */ -#define VA_ENC_INTERLACED_FIELD 0x00000002 -/** \brief Driver supports macroblock adaptive frame field coding. */ -#define VA_ENC_INTERLACED_MBAFF 0x00000004 -/** \brief Driver supports picture adaptive frame field coding. */ -#define VA_ENC_INTERLACED_PAFF 0x00000008 -/**@}*/ - -/** @name Attribute values for VAConfigAttribEncSliceStructure */ -/**@{*/ -/** \brief Driver supports an arbitrary number of rows per slice. */ -#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000000 -/** \brief Driver supports a power-of-two number of rows per slice. */ -#define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001 -/** \brief Driver supports an arbitrary number of rows per slice. */ -#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002 -/**@}*/ - -/** \brief Attribute value for VAConfigAttribEncJPEG */ -typedef union _VAConfigAttribValEncJPEG { - struct { - /** \brief set to 1 for arithmatic coding. */ - unsigned int arithmatic_coding_mode : 1; - /** \brief set to 1 for progressive dct. */ - unsigned int progressive_dct_mode : 1; - /** \brief set to 1 for non-interleaved. */ - unsigned int non_interleaved_mode : 1; - /** \brief set to 1 for differential. */ - unsigned int differential_mode : 1; - unsigned int max_num_components : 3; - unsigned int max_num_scans : 4; - unsigned int max_num_huffman_tables : 3; - unsigned int max_num_quantization_tables : 3; - } bits; - unsigned int value; -} VAConfigAttribValEncJPEG; - -/** \brief Attribute value for VAConfigAttribEncROI */ -typedef union _VAConfigAttribValEncROI { - struct { - /** \brief The number of ROI regions supported, 0 if ROI is not supported. */ - unsigned int num_roi_regions : 8; - /** - * \brief A flag indicates whether ROI priority is supported - * - * \ref roi_rc_priority_support equal to 1 specifies the underlying driver supports - * ROI priority when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value - * in #VAEncROI to set ROI priority. \ref roi_rc_priority_support equal to 0 specifies - * the underlying driver doesn't support ROI priority. - * - * User should ignore \ref roi_rc_priority_support when VAConfigAttribRateControl == VA_RC_CQP - * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP. - */ - unsigned int roi_rc_priority_support : 1; - /** - * \brief A flag indicates whether ROI delta QP is supported - * - * \ref roi_rc_qp_delat_support equal to 1 specifies the underlying driver supports - * ROI delta QP when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value - * in #VAEncROI to set ROI delta QP. \ref roi_rc_qp_delat_support equal to 0 specifies - * the underlying driver doesn't support ROI delta QP. - * - * User should ignore \ref roi_rc_qp_delat_support when VAConfigAttribRateControl == VA_RC_CQP - * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP. - */ - unsigned int roi_rc_qp_delat_support : 1; - unsigned int reserved : 22; - } bits; - unsigned int value; -} VAConfigAttribValEncROI; - -/** \brief Attribute value for VAConfigAttribEncRateControlExt */ -typedef union _VAConfigAttribValEncRateControlExt { - struct { - /** - * \brief The maximum number of temporal layers minus 1 - * - * \ref max_num_temporal_layers_minus1 plus 1 specifies the maximum number of temporal - * layers that supported by the underlying driver. \ref max_num_temporal_layers_minus1 - * equal to 0 implies the underlying driver doesn't support encoding with temporal layer. - */ - unsigned int max_num_temporal_layers_minus1 : 8; - - /** - * /brief support temporal layer bit-rate control flag - * - * \ref temporal_layer_bitrate_control_flag equal to 1 specifies the underlying driver - * can support bit-rate control per temporal layer when (#VAConfigAttribRateControl == #VA_RC_CBR || - * #VAConfigAttribRateControl == #VA_RC_VBR). - * - * The underlying driver must set \ref temporal_layer_bitrate_control_flag to 0 when - * \c max_num_temporal_layers_minus1 is equal to 0 - * - * To use bit-rate control per temporal layer, an application must send the right layer - * structure via #VAEncMiscParameterTemporalLayerStructure at the beginning of a coded sequence - * and then followed by #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate structures - * for each layer, using the \c temporal_id field as the layer identifier. Otherwise - * the driver doesn't use bitrate control per temporal layer if an application doesn't send the - * layer structure via #VAEncMiscParameterTemporalLayerStructure to the driver. The driver returns - * VA_STATUS_ERROR_INVALID_PARAMETER if an application sends a wrong layer structure or doesn't send - * #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate for each layer. - * - * The driver will ignore #VAEncMiscParameterTemporalLayerStructure and the \c temporal_id field - * in #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate if - * \ref temporal_layer_bitrate_control_flag is equal to 0 or #VAConfigAttribRateControl == #VA_RC_CQP - */ - unsigned int temporal_layer_bitrate_control_flag : 1; - unsigned int reserved : 23; - } bits; - unsigned int value; -} VAConfigAttribValEncRateControlExt; - -/** - * if an attribute is not applicable for a given - * profile/entrypoint pair, then set the value to the following - */ -#define VA_ATTRIB_NOT_SUPPORTED 0x80000000 - -/** Get maximum number of profiles supported by the implementation */ -int vaMaxNumProfiles ( - VADisplay dpy -); - -/** Get maximum number of entrypoints supported by the implementation */ -int vaMaxNumEntrypoints ( - VADisplay dpy -); - -/** Get maximum number of attributs supported by the implementation */ -int vaMaxNumConfigAttributes ( - VADisplay dpy -); - -/** - * Query supported profiles - * The caller must provide a "profile_list" array that can hold at - * least vaMaxNumProfile() entries. The actual number of profiles - * returned in "profile_list" is returned in "num_profile". - */ -VAStatus vaQueryConfigProfiles ( - VADisplay dpy, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ -); - -/** - * Query supported entrypoints for a given profile - * The caller must provide an "entrypoint_list" array that can hold at - * least vaMaxNumEntrypoints() entries. The actual number of entrypoints - * returned in "entrypoint_list" is returned in "num_entrypoints". - */ -VAStatus vaQueryConfigEntrypoints ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint *entrypoint_list, /* out */ - int *num_entrypoints /* out */ -); - -/** - * Get attributes for a given profile/entrypoint pair - * The caller must provide an "attrib_list" with all attributes to be - * retrieved. Upon return, the attributes in "attrib_list" have been - * updated with their value. Unknown attributes or attributes that are - * not supported for the given profile/entrypoint pair will have their - * value set to VA_ATTRIB_NOT_SUPPORTED - */ -VAStatus vaGetConfigAttributes ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs -); - -/** Generic ID type, can be re-typed for specific implementation */ -typedef unsigned int VAGenericID; - -typedef VAGenericID VAConfigID; - -/** - * Create a configuration for the decode pipeline - * it passes in the attribute list that specifies the attributes it cares - * about, with the rest taking default values. - */ -VAStatus vaCreateConfig ( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ -); - -/** - * Free resources associdated with a given config - */ -VAStatus vaDestroyConfig ( - VADisplay dpy, - VAConfigID config_id -); - -/** - * Query all attributes for a given configuration - * The profile of the configuration is returned in "profile" - * The entrypoint of the configuration is returned in "entrypoint" - * The caller must provide an "attrib_list" array that can hold at least - * vaMaxNumConfigAttributes() entries. The actual number of attributes - * returned in "attrib_list" is returned in "num_attribs" - */ -VAStatus vaQueryConfigAttributes ( - VADisplay dpy, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list,/* out */ - int *num_attribs /* out */ -); - - -/** - * Contexts and Surfaces - * - * Context represents a "virtual" video decode pipeline. Surfaces are render - * targets for a given context. The data in the surfaces are not accessible - * to the client and the internal data format of the surface is implementatin - * specific. - * - * Surfaces will be bound to a context when the context is created. Once - * a surface is bound to a given context, it can not be used to create - * another context. The association is removed when the context is destroyed - * - * Both contexts and surfaces are identified by unique IDs and its - * implementation specific internals are kept opaque to the clients - */ - -typedef VAGenericID VAContextID; - -typedef VAGenericID VASurfaceID; - -#define VA_INVALID_ID 0xffffffff -#define VA_INVALID_SURFACE VA_INVALID_ID - -/** \brief Generic value types. */ -typedef enum { - VAGenericValueTypeInteger = 1, /**< 32-bit signed integer. */ - VAGenericValueTypeFloat, /**< 32-bit floating-point value. */ - VAGenericValueTypePointer, /**< Generic pointer type */ - VAGenericValueTypeFunc /**< Pointer to function */ -} VAGenericValueType; - -/** \brief Generic function type. */ -typedef void (*VAGenericFunc)(void); - -/** \brief Generic value. */ -typedef struct _VAGenericValue { - /** \brief Value type. See #VAGenericValueType. */ - VAGenericValueType type; - /** \brief Value holder. */ - union { - /** \brief 32-bit signed integer. */ - int i; - /** \brief 32-bit float. */ - float f; - /** \brief Generic pointer. */ - void *p; - /** \brief Pointer to function. */ - VAGenericFunc fn; - } value; -} VAGenericValue; - -/** @name Surface attribute flags */ -/**@{*/ -/** \brief Surface attribute is not supported. */ -#define VA_SURFACE_ATTRIB_NOT_SUPPORTED 0x00000000 -/** \brief Surface attribute can be got through vaQuerySurfaceAttributes(). */ -#define VA_SURFACE_ATTRIB_GETTABLE 0x00000001 -/** \brief Surface attribute can be set through vaCreateSurfaces(). */ -#define VA_SURFACE_ATTRIB_SETTABLE 0x00000002 -/**@}*/ - -/** \brief Surface attribute types. */ -typedef enum { - VASurfaceAttribNone = 0, - /** - * \brief Pixel format (fourcc). - * - * The value is meaningful as input to vaQuerySurfaceAttributes(). - * If zero, the driver returns the optimal pixel format for the - * specified config. Otherwise, if non-zero, the value represents - * a pixel format (FOURCC) that is kept as is on output, if the - * driver supports it. Otherwise, the driver sets the value to - * zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag. - */ - VASurfaceAttribPixelFormat, - /** \brief Minimal width in pixels (int, read-only). */ - VASurfaceAttribMinWidth, - /** \brief Maximal width in pixels (int, read-only). */ - VASurfaceAttribMaxWidth, - /** \brief Minimal height in pixels (int, read-only). */ - VASurfaceAttribMinHeight, - /** \brief Maximal height in pixels (int, read-only). */ - VASurfaceAttribMaxHeight, - /** \brief Surface memory type expressed in bit fields (int, read/write). */ - VASurfaceAttribMemoryType, - /** \brief External buffer descriptor (pointer, write). */ - VASurfaceAttribExternalBufferDescriptor, - /** \brief Surface usage hint, gives the driver a hint of intended usage - * to optimize allocation (e.g. tiling) (int, read/write). */ - VASurfaceAttribUsageHint, - /** \brief Number of surface attributes. */ - VASurfaceAttribCount -} VASurfaceAttribType; - -/** \brief Surface attribute. */ -typedef struct _VASurfaceAttrib { - /** \brief Type. */ - VASurfaceAttribType type; - /** \brief Flags. See "Surface attribute flags". */ - unsigned int flags; - /** \brief Value. See "Surface attribute types" for the expected types. */ - VAGenericValue value; -} VASurfaceAttrib; - -/** - * @name VASurfaceAttribMemoryType values in bit fields. - * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for - * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific - * types are defined in DRM and Android header files. - */ -/**@{*/ -/** \brief VA memory type (default) is supported. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_VA 0x00000001 -/** \brief V4L2 buffer memory type is supported. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2 0x00000002 -/** \brief User pointer memory type is supported. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR 0x00000004 -/**@}*/ - -/** - * \brief VASurfaceAttribExternalBuffers structure for - * the VASurfaceAttribExternalBufferDescriptor attribute. - */ -typedef struct _VASurfaceAttribExternalBuffers { - /** \brief pixel format in fourcc. */ - unsigned int pixel_format; - /** \brief width in pixels. */ - unsigned int width; - /** \brief height in pixels. */ - unsigned int height; - /** \brief total size of the buffer in bytes. */ - unsigned int data_size; - /** \brief number of planes for planar layout */ - unsigned int num_planes; - /** \brief pitch for each plane in bytes */ - unsigned int pitches[4]; - /** \brief offset for each plane in bytes */ - unsigned int offsets[4]; - /** \brief buffer handles or user pointers */ - unsigned long *buffers; - /** \brief number of elements in the "buffers" array */ - unsigned int num_buffers; - /** \brief flags. See "Surface external buffer descriptor flags". */ - unsigned int flags; - /** \brief reserved for passing private data */ - void *private_data; -} VASurfaceAttribExternalBuffers; - -/** @name VASurfaceAttribExternalBuffers flags */ -/**@{*/ -/** \brief Enable memory tiling */ -#define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING 0x00000001 -/** \brief Memory is cacheable */ -#define VA_SURFACE_EXTBUF_DESC_CACHED 0x00000002 -/** \brief Memory is non-cacheable */ -#define VA_SURFACE_EXTBUF_DESC_UNCACHED 0x00000004 -/** \brief Memory is write-combined */ -#define VA_SURFACE_EXTBUF_DESC_WC 0x00000008 -/** \brief Memory is protected */ -#define VA_SURFACE_EXTBUF_DESC_PROTECTED 0x80000000 - -/** @name VASurfaceAttribUsageHint attribute usage hint flags */ -/**@{*/ -/** \brief Surface usage not indicated. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC 0x00000000 -/** \brief Surface used by video decoder. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_DECODER 0x00000001 -/** \brief Surface used by video encoder. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_ENCODER 0x00000002 -/** \brief Surface read by video post-processing. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_READ 0x00000004 -/** \brief Surface written by video post-processing. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE 0x00000008 -/** \brief Surface used for display. */ -#define VA_SURFACE_ATTRIB_USAGE_HINT_DISPLAY 0x00000010 - -/**@}*/ - -/** - * \brief Queries surface attributes for the supplied config. - * - * Unlike vaGetSurfaceAttributes(), this function queries for all - * supported attributes for the supplied VA @config. In particular, if - * the underlying hardware supports the creation of VA surfaces in - * various formats, then this function will enumerate all pixel - * formats that are supported. - * - * The \c attrib_list array is allocated by the user and \c - * num_attribs shall be initialized to the number of allocated - * elements in that array. Upon successful return, the actual number - * of attributes will be overwritten into \c num_attribs. Otherwise, - * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_attribs - * is adjusted to the number of elements that would be returned if - * enough space was available. - * - * Note: it is perfectly valid to pass NULL to the \c attrib_list - * argument when vaQuerySurfaceAttributes() is used to determine the - * actual number of elements that need to be allocated. - * - * @param[in] dpy the VA display - * @param[in] config the config identifying a codec or a video - * processing pipeline - * @param[out] attrib_list the output array of #VASurfaceAttrib elements - * @param[in,out] num_attribs the number of elements allocated on - * input, the number of elements actually filled in output - */ -VAStatus -vaQuerySurfaceAttributes( - VADisplay dpy, - VAConfigID config, - VASurfaceAttrib *attrib_list, - unsigned int *num_attribs -); - -/** - * \brief Creates an array of surfaces - * - * Creates an array of surfaces. The optional list of attributes shall - * be constructed and validated through vaGetSurfaceAttributes() or - * constructed based based on what the underlying hardware could - * expose through vaQuerySurfaceAttributes(). - * - * @param[in] dpy the VA display - * @param[in] format the desired surface format. See \c VA_RT_FORMAT_* - * @param[in] width the surface width - * @param[in] height the surface height - * @param[out] surfaces the array of newly created surfaces - * @param[in] num_surfaces the number of surfaces to create - * @param[in] attrib_list the list of (optional) attributes, or \c NULL - * @param[in] num_attribs the number of attributes supplied in - * \c attrib_list, or zero - */ -VAStatus -vaCreateSurfaces( - VADisplay dpy, - unsigned int format, - unsigned int width, - unsigned int height, - VASurfaceID *surfaces, - unsigned int num_surfaces, - VASurfaceAttrib *attrib_list, - unsigned int num_attribs -); - -/** - * vaDestroySurfaces - Destroy resources associated with surfaces. - * Surfaces can only be destroyed after the context associated has been - * destroyed. - * dpy: display - * surfaces: array of surfaces to destroy - * num_surfaces: number of surfaces in the array to be destroyed. - */ -VAStatus vaDestroySurfaces ( - VADisplay dpy, - VASurfaceID *surfaces, - int num_surfaces -); - -#define VA_PROGRESSIVE 0x1 -/** - * vaCreateContext - Create a context - * dpy: display - * config_id: configuration for the context - * picture_width: coded picture width - * picture_height: coded picture height - * flag: any combination of the following: - * VA_PROGRESSIVE (only progressive frame pictures in the sequence when set) - * render_targets: render targets (surfaces) tied to the context - * num_render_targets: number of render targets in the above array - * context: created context id upon return - */ -VAStatus vaCreateContext ( - VADisplay dpy, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - VAContextID *context /* out */ -); - -/** - * vaDestroyContext - Destroy a context - * dpy: display - * context: context to be destroyed - */ -VAStatus vaDestroyContext ( - VADisplay dpy, - VAContextID context -); - -/** - * Buffers - * Buffers are used to pass various types of data from the - * client to the server. The server maintains a data store - * for each buffer created, and the client idenfies a buffer - * through a unique buffer id assigned by the server. - */ - -typedef VAGenericID VABufferID; - -typedef enum -{ - VAPictureParameterBufferType = 0, - VAIQMatrixBufferType = 1, - VABitPlaneBufferType = 2, - VASliceGroupMapBufferType = 3, - VASliceParameterBufferType = 4, - VASliceDataBufferType = 5, - VAMacroblockParameterBufferType = 6, - VAResidualDataBufferType = 7, - VADeblockingParameterBufferType = 8, - VAImageBufferType = 9, - VAProtectedSliceDataBufferType = 10, - VAQMatrixBufferType = 11, - VAHuffmanTableBufferType = 12, - VAProbabilityBufferType = 13, - -/* Following are encode buffer types */ - VAEncCodedBufferType = 21, - VAEncSequenceParameterBufferType = 22, - VAEncPictureParameterBufferType = 23, - VAEncSliceParameterBufferType = 24, - VAEncPackedHeaderParameterBufferType = 25, - VAEncPackedHeaderDataBufferType = 26, - VAEncMiscParameterBufferType = 27, - VAEncMacroblockParameterBufferType = 28, - VAEncMacroblockMapBufferType = 29, -/* Following are video processing buffer types */ - /** - * \brief Video processing pipeline parameter buffer. - * - * This buffer describes the video processing pipeline. See - * #VAProcPipelineParameterBuffer for details. - */ - VAProcPipelineParameterBufferType = 41, - /** - * \brief Video filter parameter buffer. - * - * This buffer describes the video filter parameters. All buffers - * inherit from #VAProcFilterParameterBufferBase, thus including - * a unique filter buffer type. - * - * The default buffer used by most filters is #VAProcFilterParameterBuffer. - * Filters requiring advanced parameters include, but are not limited to, - * deinterlacing (#VAProcFilterParameterBufferDeinterlacing), - * color balance (#VAProcFilterParameterBufferColorBalance), etc. - */ - VAProcFilterParameterBufferType = 42, - VABufferTypeMax -} VABufferType; - -typedef enum -{ - VAEncMiscParameterTypeFrameRate = 0, - VAEncMiscParameterTypeRateControl = 1, - VAEncMiscParameterTypeMaxSliceSize = 2, - VAEncMiscParameterTypeAIR = 3, - /** \brief Buffer type used to express a maximum frame size (in bits). */ - VAEncMiscParameterTypeMaxFrameSize = 4, - /** \brief Buffer type used for HRD parameters. */ - VAEncMiscParameterTypeHRD = 5, - VAEncMiscParameterTypeQualityLevel = 6, - /** \brief Buffer type used for sending skip frame parameters to the encoder's - * rate control, when the user has externally skipped frames. */ - VAEncMiscParameterTypeSkipFrame = 9, - /** \brief Buffer type used for region-of-interest (ROI) parameters. */ - VAEncMiscParameterTypeROI = 10, - /** \brief Buffer type used for temporal layer structure */ - VAEncMiscParameterTypeTemporalLayerStructure = 12, -} VAEncMiscParameterType; - -/** \brief Packed header type. */ -typedef enum { - /** \brief Packed sequence header. */ - VAEncPackedHeaderSequence = 1, - /** \brief Packed picture header. */ - VAEncPackedHeaderPicture = 2, - /** \brief Packed slice header. */ - VAEncPackedHeaderSlice = 3, - /** - * \brief Packed raw header. - * - * Packed raw data header can be used by the client to insert a header - * into the bitstream data buffer at the point it is passed, the driver - * will handle the raw packed header based on "has_emulation_bytes" field - * in the packed header parameter structure. - */ - VAEncPackedHeaderRawData = 4, - /** \brief Misc packed header. See codec-specific definitions. */ - VAEncPackedHeaderMiscMask = 0x80000000, -} VAEncPackedHeaderType; - -/** \brief Packed header parameter. */ -typedef struct _VAEncPackedHeaderParameterBuffer { - /** Type of the packed header buffer. See #VAEncPackedHeaderType. */ - unsigned int type; - /** \brief Size of the #VAEncPackedHeaderDataBuffer in bits. */ - unsigned int bit_length; - /** \brief Flag: buffer contains start code emulation prevention bytes? */ - unsigned char has_emulation_bytes; -} VAEncPackedHeaderParameterBuffer; - -/** - * For application, e.g. set a new bitrate - * VABufferID buf_id; - * VAEncMiscParameterBuffer *misc_param; - * VAEncMiscParameterRateControl *misc_rate_ctrl; - * - * vaCreateBuffer(dpy, context, VAEncMiscParameterBufferType, - * sizeof(VAEncMiscParameterBuffer) + sizeof(VAEncMiscParameterRateControl), - * 1, NULL, &buf_id); - * - * vaMapBuffer(dpy,buf_id,(void **)&misc_param); - * misc_param->type = VAEncMiscParameterTypeRateControl; - * misc_rate_ctrl= (VAEncMiscParameterRateControl *)misc_param->data; - * misc_rate_ctrl->bits_per_second = 6400000; - * vaUnmapBuffer(dpy, buf_id); - * vaRenderPicture(dpy, context, &buf_id, 1); - */ -typedef struct _VAEncMiscParameterBuffer -{ - VAEncMiscParameterType type; - unsigned int data[0]; -} VAEncMiscParameterBuffer; - -/** \brief Temporal layer Structure*/ -typedef struct _VAEncMiscParameterTemporalLayerStructure -{ - /** \brief The number of temporal layers */ - unsigned int number_of_layers; - /** \brief The length of the array defining frame layer membership. Should be 1-32 */ - unsigned int periodicity; - /** - * \brief The array indicating the layer id for each frame - * - * The layer id for the first frame in a coded sequence is always 0, so layer_id[] specifies the layer - * ids for frames starting from the 2nd frame. - */ - unsigned int layer_id[32]; -} VAEncMiscParameterTemporalLayerStructure; - - -/** \brief Rate control parameters */ -typedef struct _VAEncMiscParameterRateControl -{ - /* this is the maximum bit-rate to be constrained by the rate control implementation */ - unsigned int bits_per_second; - /* this is the bit-rate the rate control is targeting, as a percentage of the maximum - * bit-rate for example if target_percentage is 95 then the rate control will target - * a bit-rate that is 95% of the maximum bit-rate - */ - unsigned int target_percentage; - /* windows size in milliseconds. For example if this is set to 500, - * then the rate control will guarantee the target bit-rate over a 500 ms window - */ - unsigned int window_size; - /* initial QP at I frames */ - unsigned int initial_qp; - unsigned int min_qp; - unsigned int basic_unit_size; - union - { - struct - { - unsigned int reset : 1; - unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */ - unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */ - unsigned int mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/ - /* - * The temporal layer that the rate control parameters are specified for. - */ - unsigned int temporal_id : 8; - unsigned int reserved : 17; - } bits; - unsigned int value; - } rc_flags; -} VAEncMiscParameterRateControl; - -typedef struct _VAEncMiscParameterFrameRate -{ - /* - * The framerate is specified as a number of frames per second, as a - * fraction. The denominator of the fraction is given in the top half - * (the high two bytes) of the framerate field, and the numerator is - * given in the bottom half (the low two bytes). - * - * That is: - * denominator = framerate >> 16 & 0xffff; - * numerator = framerate & 0xffff; - * fps = numerator / denominator; - * - * For example, if framerate is set to (100 << 16 | 750), this is - * 750 / 100, hence 7.5fps. - * - * If the denominator is zero (the high two bytes are both zero) then - * it takes the value one instead, so the framerate is just the integer - * in the low 2 bytes. - */ - unsigned int framerate; - union - { - struct - { - /* - * The temporal id the framerate parameters are specified for. - */ - unsigned int temporal_id : 8; - unsigned int reserved : 24; - } bits; - unsigned int value; - } framerate_flags; -} VAEncMiscParameterFrameRate; - -/** - * Allow a maximum slice size to be specified (in bits). - * The encoder will attempt to make sure that individual slices do not exceed this size - * Or to signal applicate if the slice size exceed this size, see "status" of VACodedBufferSegment - */ -typedef struct _VAEncMiscParameterMaxSliceSize -{ - unsigned int max_slice_size; -} VAEncMiscParameterMaxSliceSize; - -typedef struct _VAEncMiscParameterAIR -{ - unsigned int air_num_mbs; - unsigned int air_threshold; - unsigned int air_auto; /* if set to 1 then hardware auto-tune the AIR threshold */ -} VAEncMiscParameterAIR; - -typedef struct _VAEncMiscParameterHRD -{ - unsigned int initial_buffer_fullness; /* in bits */ - unsigned int buffer_size; /* in bits */ -} VAEncMiscParameterHRD; - -/** - * \brief Defines a maximum frame size (in bits). - * - * This misc parameter buffer defines the maximum size of a frame (in - * bits). The encoder will try to make sure that each frame does not - * exceed this size. Otherwise, if the frame size exceeds this size, - * the \c status flag of #VACodedBufferSegment will contain - * #VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW. - */ -typedef struct _VAEncMiscParameterBufferMaxFrameSize { - /** \brief Type. Shall be set to #VAEncMiscParameterTypeMaxFrameSize. */ - VAEncMiscParameterType type; - /** \brief Maximum size of a frame (in bits). */ - unsigned int max_frame_size; -} VAEncMiscParameterBufferMaxFrameSize; - -/** - * \brief Encoding quality level. - * - * The encoding quality could be set through this structure, if the implementation - * supports multiple quality levels. The quality level set through this structure is - * persistent over the entire coded sequence, or until a new structure is being sent. - * The quality level range can be queried through the VAConfigAttribEncQualityRange - * attribute. A lower value means higher quality, and a value of 1 represents the highest - * quality. The quality level setting is used as a trade-off between quality and speed/power - * consumption, with higher quality corresponds to lower speed and higher power consumption. - */ -typedef struct _VAEncMiscParameterBufferQualityLevel { - /** \brief Encoding quality level setting. When set to 0, default quality - * level is used. - */ - unsigned int quality_level; -} VAEncMiscParameterBufferQualityLevel; - -/** - * \brief Encoding skip frame. - * - * The application may choose to skip frames externally to the encoder (e.g. drop completely or - * code as all skip's). For rate control purposes the encoder will need to know the size and number - * of skipped frames. Skip frame(s) indicated through this structure is applicable only to the - * current frame. It is allowed for the application to still send in packed headers for the driver to - * pack, although no frame will be encoded (e.g. for HW to encrypt the frame). - */ -typedef struct _VAEncMiscParameterSkipFrame { - /** \brief Indicates skip frames as below. - * 0: Encode as normal, no skip. - * 1: One or more frames were skipped prior to the current frame, encode the current frame as normal. - * 2: The current frame is to be skipped, do not encode it but pack/encrypt the packed header contents - * (all except VAEncPackedHeaderSlice) which could contain actual frame contents (e.g. pack the frame - * in VAEncPackedHeaderPicture). */ - unsigned char skip_frame_flag; - /** \brief The number of frames skipped prior to the current frame. Valid when skip_frame_flag = 1. */ - unsigned char num_skip_frames; - /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits. When skip_frame_flag = 2, - * the size of the current skipped frame that is to be packed/encrypted in bits. */ - unsigned int size_skip_frames; -} VAEncMiscParameterSkipFrame; - -/** - * \brief Encoding region-of-interest (ROI). - * - * The encoding ROI can be set through VAEncMiscParameterBufferROI, if the implementation - * supports ROI input. The ROI set through this structure is applicable only to the - * current frame or field, so must be sent every frame or field to be applied. The number of - * supported ROIs can be queried through the VAConfigAttribEncROI. The encoder will use the - * ROI information to adjust the QP values of the MB's that fall within the ROIs. - */ -typedef struct _VAEncROI -{ - /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate - * codec coding units. It is relative to frame coordinates for the frame case and - * to field coordinates for the field case. */ - VARectangle roi_rectangle; - /** - * \brief ROI value - * - * \ref roi_value specifies ROI delta QP or ROI priority. - * -- ROI delta QP is the value that will be added on top of the frame level QP. - * -- ROI priority specifies the priority of a region, it can be positive (more important) - * or negative (less important) values and is compared with non-ROI region (taken as value 0), - * E.g. ROI region with \ref roi_value -3 is less important than the non-ROI region (\ref roi_value - * implied to be 0) which is less important than ROI region with roi_value +2. For overlapping - * regions, the roi_value that is first in the ROI array will have priority. - * - * \ref roi_value always specifes ROI delta QP when VAConfigAttribRateControl == VA_RC_CQP, no matter - * the value of \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI. - * - * \ref roi_value depends on \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI when - * VAConfigAttribRateControl != VA_RC_CQP. \ref roi_value specifies ROI_delta QP if \c roi_value_is_qp_delta - * in VAEncMiscParameterBufferROI is 1, otherwise \ref roi_value specifies ROI priority. - */ - char roi_value; -} VAEncROI; - -typedef struct _VAEncMiscParameterBufferROI { - /** \brief Number of ROIs being sent.*/ - unsigned int num_roi; - - /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's - * rate control will determine actual delta QPs. Specifies the max/min allowed delta - * QPs. */ - char max_delta_qp; - char min_delta_qp; - - /** \brief Pointer to a VAEncROI array with num_roi elements. It is relative to frame - * coordinates for the frame case and to field coordinates for the field case.*/ - VAEncROI *roi; - union { - struct { - /** - * \brief An indication for roi value. - * - * \ref roi_value_is_qp_delta equal to 1 indicates \c roi_value in #VAEncROI should - * be used as ROI delta QP. \ref roi_value_is_qp_delta equal to 0 indicates \c roi_value - * in #VAEncROI should be used as ROI priority. - * - * \ref roi_value_is_qp_delta is only available when VAConfigAttribRateControl != VA_RC_CQP, - * the setting must comply with \c roi_rc_priority_support and \c roi_rc_qp_delat_support in - * #VAConfigAttribValEncROI. The underlying driver should ignore this field - * when VAConfigAttribRateControl == VA_RC_CQP. - */ - uint32_t roi_value_is_qp_delta : 1; - uint32_t reserved : 31; - } bits; - uint32_t value; - } roi_flags; -} VAEncMiscParameterBufferROI; - -/** - * There will be cases where the bitstream buffer will not have enough room to hold - * the data for the entire slice, and the following flags will be used in the slice - * parameter to signal to the server for the possible cases. - * If a slice parameter buffer and slice data buffer pair is sent to the server with - * the slice data partially in the slice data buffer (BEGIN and MIDDLE cases below), - * then a slice parameter and data buffer needs to be sent again to complete this slice. - */ -#define VA_SLICE_DATA_FLAG_ALL 0x00 /* whole slice is in the buffer */ -#define VA_SLICE_DATA_FLAG_BEGIN 0x01 /* The beginning of the slice is in the buffer but the end if not */ -#define VA_SLICE_DATA_FLAG_MIDDLE 0x02 /* Neither beginning nor end of the slice is in the buffer */ -#define VA_SLICE_DATA_FLAG_END 0x04 /* end of the slice is in the buffer */ - -/* Codec-independent Slice Parameter Buffer base */ -typedef struct _VASliceParameterBufferBase -{ - unsigned int slice_data_size; /* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset; /* the offset to the first byte of slice data */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */ -} VASliceParameterBufferBase; - -/********************************** - * JPEG common data structures - **********************************/ -/** - * \brief Huffman table for JPEG decoding. - * - * This structure holds the complete Huffman tables. This is an - * aggregation of all Huffman table (DHT) segments maintained by the - * application. i.e. up to 2 Huffman tables are stored in there for - * baseline profile. - * - * The #load_huffman_table array can be used as a hint to notify the - * VA driver implementation about which table(s) actually changed - * since the last submission of this buffer. - */ -typedef struct _VAHuffmanTableBufferJPEGBaseline { - /** \brief Specifies which #huffman_table is valid. */ - unsigned char load_huffman_table[2]; - /** \brief Huffman tables indexed by table identifier (Th). */ - struct { - /** @name DC table (up to 12 categories) */ - /**@{*/ - /** \brief Number of Huffman codes of length i + 1 (Li). */ - unsigned char num_dc_codes[16]; - /** \brief Value associated with each Huffman code (Vij). */ - unsigned char dc_values[12]; - /**@}*/ - /** @name AC table (2 special codes + up to 16 * 10 codes) */ - /**@{*/ - /** \brief Number of Huffman codes of length i + 1 (Li). */ - unsigned char num_ac_codes[16]; - /** \brief Value associated with each Huffman code (Vij). */ - unsigned char ac_values[162]; - /** \brief Padding to 4-byte boundaries. Must be set to zero. */ - unsigned char pad[2]; - /**@}*/ - } huffman_table[2]; -} VAHuffmanTableBufferJPEGBaseline; - -/**************************** - * MPEG-2 data structures - ****************************/ - -/* MPEG-2 Picture Parameter Buffer */ -/* - * For each frame or field, and before any slice data, a single - * picture parameter buffer must be send. - */ -typedef struct _VAPictureParameterBufferMPEG2 -{ - unsigned short horizontal_size; - unsigned short vertical_size; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* meanings of the following fields are the same as in the standard */ - int picture_coding_type; - int f_code; /* pack all four fcode into this */ - union { - struct { - unsigned int intra_dc_precision : 2; - unsigned int picture_structure : 2; - unsigned int top_field_first : 1; - unsigned int frame_pred_frame_dct : 1; - unsigned int concealment_motion_vectors : 1; - unsigned int q_scale_type : 1; - unsigned int intra_vlc_format : 1; - unsigned int alternate_scan : 1; - unsigned int repeat_first_field : 1; - unsigned int progressive_frame : 1; - unsigned int is_first_field : 1; /* indicate whether the current field - * is the first field for field picture - */ - } bits; - unsigned int value; - } picture_coding_extension; -} VAPictureParameterBufferMPEG2; - -/** MPEG-2 Inverse Quantization Matrix Buffer */ -typedef struct _VAIQMatrixBufferMPEG2 -{ - /** \brief Same as the MPEG-2 bitstream syntax element. */ - int load_intra_quantiser_matrix; - /** \brief Same as the MPEG-2 bitstream syntax element. */ - int load_non_intra_quantiser_matrix; - /** \brief Same as the MPEG-2 bitstream syntax element. */ - int load_chroma_intra_quantiser_matrix; - /** \brief Same as the MPEG-2 bitstream syntax element. */ - int load_chroma_non_intra_quantiser_matrix; - /** \brief Luminance intra matrix, in zig-zag scan order. */ - unsigned char intra_quantiser_matrix[64]; - /** \brief Luminance non-intra matrix, in zig-zag scan order. */ - unsigned char non_intra_quantiser_matrix[64]; - /** \brief Chroma intra matrix, in zig-zag scan order. */ - unsigned char chroma_intra_quantiser_matrix[64]; - /** \brief Chroma non-intra matrix, in zig-zag scan order. */ - unsigned char chroma_non_intra_quantiser_matrix[64]; -} VAIQMatrixBufferMPEG2; - -/** MPEG-2 Slice Parameter Buffer */ -typedef struct _VASliceParameterBufferMPEG2 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the first byte of slice data */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ - unsigned int slice_horizontal_position; - unsigned int slice_vertical_position; - int quantiser_scale_code; - int intra_slice_flag; -} VASliceParameterBufferMPEG2; - -/** MPEG-2 Macroblock Parameter Buffer */ -typedef struct _VAMacroblockParameterBufferMPEG2 -{ - unsigned short macroblock_address; - /* - * macroblock_address (in raster scan order) - * top-left: 0 - * bottom-right: picture-height-in-mb*picture-width-in-mb - 1 - */ - unsigned char macroblock_type; /* see definition below */ - union { - struct { - unsigned int frame_motion_type : 2; - unsigned int field_motion_type : 2; - unsigned int dct_type : 1; - } bits; - unsigned int value; - } macroblock_modes; - unsigned char motion_vertical_field_select; - /* - * motion_vertical_field_select: - * see section 6.3.17.2 in the spec - * only the lower 4 bits are used - * bit 0: first vector forward - * bit 1: first vector backward - * bit 2: second vector forward - * bit 3: second vector backward - */ - short PMV[2][2][2]; /* see Table 7-7 in the spec */ - unsigned short coded_block_pattern; - /* - * The bitplanes for coded_block_pattern are described - * in Figure 6.10-12 in the spec - */ - - /* Number of skipped macroblocks after this macroblock */ - unsigned short num_skipped_macroblocks; -} VAMacroblockParameterBufferMPEG2; - -/* - * OR'd flags for macroblock_type (section 6.3.17.1 in the spec) - */ -#define VA_MB_TYPE_MOTION_FORWARD 0x02 -#define VA_MB_TYPE_MOTION_BACKWARD 0x04 -#define VA_MB_TYPE_MOTION_PATTERN 0x08 -#define VA_MB_TYPE_MOTION_INTRA 0x10 - -/** - * MPEG-2 Residual Data Buffer - * For each macroblock, there wil be 64 shorts (16-bit) in the - * residual data buffer - */ - -/**************************** - * MPEG-4 Part 2 data structures - ****************************/ - -/* MPEG-4 Picture Parameter Buffer */ -/* - * For each frame or field, and before any slice data, a single - * picture parameter buffer must be send. - */ -typedef struct _VAPictureParameterBufferMPEG4 -{ - unsigned short vop_width; - unsigned short vop_height; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - union { - struct { - unsigned int short_video_header : 1; - unsigned int chroma_format : 2; - unsigned int interlaced : 1; - unsigned int obmc_disable : 1; - unsigned int sprite_enable : 2; - unsigned int sprite_warping_accuracy : 2; - unsigned int quant_type : 1; - unsigned int quarter_sample : 1; - unsigned int data_partitioned : 1; - unsigned int reversible_vlc : 1; - unsigned int resync_marker_disable : 1; - } bits; - unsigned int value; - } vol_fields; - unsigned char no_of_sprite_warping_points; - short sprite_trajectory_du[3]; - short sprite_trajectory_dv[3]; - unsigned char quant_precision; - union { - struct { - unsigned int vop_coding_type : 2; - unsigned int backward_reference_vop_coding_type : 2; - unsigned int vop_rounding_type : 1; - unsigned int intra_dc_vlc_thr : 3; - unsigned int top_field_first : 1; - unsigned int alternate_vertical_scan_flag : 1; - } bits; - unsigned int value; - } vop_fields; - unsigned char vop_fcode_forward; - unsigned char vop_fcode_backward; - unsigned short vop_time_increment_resolution; - /* short header related */ - unsigned char num_gobs_in_vop; - unsigned char num_macroblocks_in_gob; - /* for direct mode prediction */ - short TRB; - short TRD; -} VAPictureParameterBufferMPEG4; - -/** MPEG-4 Inverse Quantization Matrix Buffer */ -typedef struct _VAIQMatrixBufferMPEG4 -{ - /** Same as the MPEG-4:2 bitstream syntax element. */ - int load_intra_quant_mat; - /** Same as the MPEG-4:2 bitstream syntax element. */ - int load_non_intra_quant_mat; - /** The matrix for intra blocks, in zig-zag scan order. */ - unsigned char intra_quant_mat[64]; - /** The matrix for non-intra blocks, in zig-zag scan order. */ - unsigned char non_intra_quant_mat[64]; -} VAIQMatrixBufferMPEG4; - -/** MPEG-4 Slice Parameter Buffer */ -typedef struct _VASliceParameterBufferMPEG4 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the first byte of slice data */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ - unsigned int macroblock_number; - int quant_scale; -} VASliceParameterBufferMPEG4; - -/** - VC-1 data structures -*/ - -typedef enum /* see 7.1.1.32 */ -{ - VAMvMode1Mv = 0, - VAMvMode1MvHalfPel = 1, - VAMvMode1MvHalfPelBilinear = 2, - VAMvModeMixedMv = 3, - VAMvModeIntensityCompensation = 4 -} VAMvModeVC1; - -/** VC-1 Picture Parameter Buffer */ -/* - * For each picture, and before any slice data, a picture parameter - * buffer must be send. Multiple picture parameter buffers may be - * sent for a single picture. In that case picture parameters will - * apply to all slice data that follow it until a new picture - * parameter buffer is sent. - * - * Notes: - * pic_quantizer_type should be set to the applicable quantizer - * type as defined by QUANTIZER (J.1.19) and either - * PQUANTIZER (7.1.1.8) or PQINDEX (7.1.1.6) - */ -typedef struct _VAPictureParameterBufferVC1 -{ - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* if out-of-loop post-processing is done on the render - target, then we need to keep the in-loop decoded - picture as a reference picture */ - VASurfaceID inloop_decoded_picture; - - /* sequence layer for AP or meta data for SP and MP */ - union { - struct { - unsigned int pulldown : 1; /* SEQUENCE_LAYER::PULLDOWN */ - unsigned int interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ - unsigned int tfcntrflag : 1; /* SEQUENCE_LAYER::TFCNTRFLAG */ - unsigned int finterpflag : 1; /* SEQUENCE_LAYER::FINTERPFLAG */ - unsigned int psf : 1; /* SEQUENCE_LAYER::PSF */ - unsigned int multires : 1; /* METADATA::MULTIRES */ - unsigned int overlap : 1; /* METADATA::OVERLAP */ - unsigned int syncmarker : 1; /* METADATA::SYNCMARKER */ - unsigned int rangered : 1; /* METADATA::RANGERED */ - unsigned int max_b_frames : 3; /* METADATA::MAXBFRAMES */ - unsigned int profile : 2; /* SEQUENCE_LAYER::PROFILE or The MSB of METADATA::PROFILE */ - } bits; - unsigned int value; - } sequence_fields; - - unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ - unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ - union { - struct { - unsigned int broken_link : 1; /* ENTRY_POINT_LAYER::BROKEN_LINK */ - unsigned int closed_entry : 1; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ - unsigned int panscan_flag : 1; /* ENTRY_POINT_LAYER::PANSCAN_FLAG */ - unsigned int loopfilter : 1; /* ENTRY_POINT_LAYER::LOOPFILTER */ - } bits; - unsigned int value; - } entrypoint_fields; - unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ - unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ - union { - struct { - unsigned int luma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */ - unsigned int luma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */ - unsigned int chroma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */ - unsigned int chroma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */ - } bits; - unsigned int value; - } range_mapping_fields; - - unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ - unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ - unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ - unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ - unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ - unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ - unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ - unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ - unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */ - union { - struct { - unsigned int picture_type : 3; /* PICTURE_LAYER::PTYPE */ - unsigned int frame_coding_mode : 3; /* PICTURE_LAYER::FCM */ - unsigned int top_field_first : 1; /* PICTURE_LAYER::TFF */ - unsigned int is_first_field : 1; /* set to 1 if it is the first field */ - unsigned int intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */ - } bits; - unsigned int value; - } picture_fields; - union { - struct { - unsigned int mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned int direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned int skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned int field_tx : 1; /* PICTURE::FIELDTX */ - unsigned int forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned int ac_pred : 1; /* PICTURE::ACPRED */ - unsigned int overflags : 1; /* PICTURE::OVERFLAGS */ - } flags; - unsigned int value; - } raw_coding; - union { - struct { - unsigned int bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned int bp_direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned int bp_skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned int bp_field_tx : 1; /* PICTURE::FIELDTX */ - unsigned int bp_forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned int bp_ac_pred : 1; /* PICTURE::ACPRED */ - unsigned int bp_overflags : 1; /* PICTURE::OVERFLAGS */ - } flags; - unsigned int value; - } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */ - union { - struct { - unsigned int reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ - unsigned int reference_distance : 5;/* PICTURE_LAYER::REFDIST */ - unsigned int num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ - unsigned int reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */ - } bits; - unsigned int value; - } reference_fields; - union { - struct { - unsigned int mv_mode : 3; /* PICTURE_LAYER::MVMODE */ - unsigned int mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ - unsigned int mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ - unsigned int two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ - unsigned int four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ - unsigned int four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ - unsigned int extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ - unsigned int extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ - unsigned int extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */ - unsigned int extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ - } bits; - unsigned int value; - } mv_fields; - union { - struct { - unsigned int dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ - unsigned int quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ - unsigned int half_qp : 1; /* PICTURE_LAYER::HALFQP */ - unsigned int pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ - unsigned int pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ - unsigned int dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ - unsigned int dq_profile : 2; /* VOPDQUANT::DQPROFILE */ - unsigned int dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ - unsigned int dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ - unsigned int dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ - unsigned int alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ - } bits; - unsigned int value; - } pic_quantizer_fields; - union { - struct { - unsigned int variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ - unsigned int mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ - unsigned int frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ - unsigned int transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */ - unsigned int transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */ - unsigned int intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */ - } bits; - unsigned int value; - } transform_fields; -} VAPictureParameterBufferVC1; - -/** VC-1 Bitplane Buffer -There will be at most three bitplanes coded in any picture header. To send -the bitplane data more efficiently, each byte is divided in two nibbles, with -each nibble carrying three bitplanes for one macroblock. The following table -shows the bitplane data arrangement within each nibble based on the picture -type. - -Picture Type Bit3 Bit2 Bit1 Bit0 -I or BI OVERFLAGS ACPRED FIELDTX -P MYTYPEMB SKIPMB DIRECTMB -B FORWARDMB SKIPMB DIRECTMB - -Within each byte, the lower nibble is for the first MB and the upper nibble is -for the second MB. E.g. the lower nibble of the first byte in the bitplane -buffer is for Macroblock #1 and the upper nibble of the first byte is for -Macroblock #2 in the first row. -*/ - -/* VC-1 Slice Parameter Buffer */ -typedef struct _VASliceParameterBufferVC1 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the first byte of slice data */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ - unsigned int slice_vertical_position; -} VASliceParameterBufferVC1; - -/* VC-1 Slice Data Buffer */ -/* -This is simplely a buffer containing raw bit-stream bytes -*/ - -/**************************** - * H.264/AVC data structures - ****************************/ - -typedef struct _VAPictureH264 -{ - VASurfaceID picture_id; - unsigned int frame_idx; - unsigned int flags; - signed int TopFieldOrderCnt; - signed int BottomFieldOrderCnt; -} VAPictureH264; -/* flags in VAPictureH264 could be OR of the following */ -#define VA_PICTURE_H264_INVALID 0x00000001 -#define VA_PICTURE_H264_TOP_FIELD 0x00000002 -#define VA_PICTURE_H264_BOTTOM_FIELD 0x00000004 -#define VA_PICTURE_H264_SHORT_TERM_REFERENCE 0x00000008 -#define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010 - -/** H.264 Picture Parameter Buffer */ -/* - * For each picture, and before any slice data, a single - * picture parameter buffer must be send. - */ -typedef struct _VAPictureParameterBufferH264 -{ - VAPictureH264 CurrPic; - VAPictureH264 ReferenceFrames[16]; /* in DPB */ - unsigned short picture_width_in_mbs_minus1; - unsigned short picture_height_in_mbs_minus1; - unsigned char bit_depth_luma_minus8; - unsigned char bit_depth_chroma_minus8; - unsigned char num_ref_frames; - union { - struct { - unsigned int chroma_format_idc : 2; - unsigned int residual_colour_transform_flag : 1; - unsigned int gaps_in_frame_num_value_allowed_flag : 1; - unsigned int frame_mbs_only_flag : 1; - unsigned int mb_adaptive_frame_field_flag : 1; - unsigned int direct_8x8_inference_flag : 1; - unsigned int MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ - unsigned int log2_max_frame_num_minus4 : 4; - unsigned int pic_order_cnt_type : 2; - unsigned int log2_max_pic_order_cnt_lsb_minus4 : 4; - unsigned int delta_pic_order_always_zero_flag : 1; - } bits; - unsigned int value; - } seq_fields; - unsigned char num_slice_groups_minus1; - unsigned char slice_group_map_type; - unsigned short slice_group_change_rate_minus1; - signed char pic_init_qp_minus26; - signed char pic_init_qs_minus26; - signed char chroma_qp_index_offset; - signed char second_chroma_qp_index_offset; - union { - struct { - unsigned int entropy_coding_mode_flag : 1; - unsigned int weighted_pred_flag : 1; - unsigned int weighted_bipred_idc : 2; - unsigned int transform_8x8_mode_flag : 1; - unsigned int field_pic_flag : 1; - unsigned int constrained_intra_pred_flag : 1; - unsigned int pic_order_present_flag : 1; - unsigned int deblocking_filter_control_present_flag : 1; - unsigned int redundant_pic_cnt_present_flag : 1; - unsigned int reference_pic_flag : 1; /* nal_ref_idc != 0 */ - } bits; - unsigned int value; - } pic_fields; - unsigned short frame_num; -} VAPictureParameterBufferH264; - -/** H.264 Inverse Quantization Matrix Buffer */ -typedef struct _VAIQMatrixBufferH264 -{ - /** \brief 4x4 scaling list, in raster scan order. */ - unsigned char ScalingList4x4[6][16]; - /** \brief 8x8 scaling list, in raster scan order. */ - unsigned char ScalingList8x8[2][64]; -} VAIQMatrixBufferH264; - -/** - * H.264 Slice Group Map Buffer - * When VAPictureParameterBufferH264::num_slice_group_minus1 is not equal to 0, - * A slice group map buffer should be sent for each picture if required. The buffer - * is sent only when there is a change in the mapping values. - * The slice group map buffer map "map units" to slice groups as specified in - * section 8.2.2 of the H.264 spec. The buffer will contain one byte for each macroblock - * in raster scan order - */ - -/** H.264 Slice Parameter Buffer */ -typedef struct _VASliceParameterBufferH264 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - /** \brief Byte offset to the NAL Header Unit for this slice. */ - unsigned int slice_data_offset; - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - /** - * \brief Bit offset from NAL Header Unit to the begining of slice_data(). - * - * This bit offset is relative to and includes the NAL unit byte - * and represents the number of bits parsed in the slice_header() - * after the removal of any emulation prevention bytes in - * there. However, the slice data buffer passed to the hardware is - * the original bitstream, thus including any emulation prevention - * bytes. - */ - unsigned short slice_data_bit_offset; - unsigned short first_mb_in_slice; - unsigned char slice_type; - unsigned char direct_spatial_mv_pred_flag; - unsigned char num_ref_idx_l0_active_minus1; - unsigned char num_ref_idx_l1_active_minus1; - unsigned char cabac_init_idc; - char slice_qp_delta; - unsigned char disable_deblocking_filter_idc; - char slice_alpha_c0_offset_div2; - char slice_beta_offset_div2; - VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */ - VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */ - unsigned char luma_log2_weight_denom; - unsigned char chroma_log2_weight_denom; - unsigned char luma_weight_l0_flag; - short luma_weight_l0[32]; - short luma_offset_l0[32]; - unsigned char chroma_weight_l0_flag; - short chroma_weight_l0[32][2]; - short chroma_offset_l0[32][2]; - unsigned char luma_weight_l1_flag; - short luma_weight_l1[32]; - short luma_offset_l1[32]; - unsigned char chroma_weight_l1_flag; - short chroma_weight_l1[32][2]; - short chroma_offset_l1[32][2]; -} VASliceParameterBufferH264; - -/**************************** - * Common encode data structures - ****************************/ -typedef enum -{ - VAEncPictureTypeIntra = 0, - VAEncPictureTypePredictive = 1, - VAEncPictureTypeBidirectional = 2, -} VAEncPictureType; - -/* Encode Slice Parameter Buffer */ -typedef struct _VAEncSliceParameterBuffer -{ - unsigned int start_row_number; /* starting MB row number for this slice */ - unsigned int slice_height; /* slice height measured in MB */ - union { - struct { - unsigned int is_intra : 1; - unsigned int disable_deblocking_filter_idc : 2; - unsigned int uses_long_term_ref :1; - unsigned int is_long_term_ref :1; - } bits; - unsigned int value; - } slice_flags; -} VAEncSliceParameterBuffer; - - -/**************************** - * H.263 specific encode data structures - ****************************/ - -typedef struct _VAEncSequenceParameterBufferH263 -{ - unsigned int intra_period; - unsigned int bits_per_second; - unsigned int frame_rate; - unsigned int initial_qp; - unsigned int min_qp; -} VAEncSequenceParameterBufferH263; - -typedef struct _VAEncPictureParameterBufferH263 -{ - VASurfaceID reference_picture; - VASurfaceID reconstructed_picture; - VABufferID coded_buf; - unsigned short picture_width; - unsigned short picture_height; - VAEncPictureType picture_type; -} VAEncPictureParameterBufferH263; - -/**************************** - * MPEG-4 specific encode data structures - ****************************/ - -typedef struct _VAEncSequenceParameterBufferMPEG4 -{ - unsigned char profile_and_level_indication; - unsigned int intra_period; - unsigned int video_object_layer_width; - unsigned int video_object_layer_height; - unsigned int vop_time_increment_resolution; - unsigned int fixed_vop_rate; - unsigned int fixed_vop_time_increment; - unsigned int bits_per_second; - unsigned int frame_rate; - unsigned int initial_qp; - unsigned int min_qp; -} VAEncSequenceParameterBufferMPEG4; - -typedef struct _VAEncPictureParameterBufferMPEG4 -{ - VASurfaceID reference_picture; - VASurfaceID reconstructed_picture; - VABufferID coded_buf; - unsigned short picture_width; - unsigned short picture_height; - unsigned int modulo_time_base; /* number of 1s */ - unsigned int vop_time_increment; - VAEncPictureType picture_type; -} VAEncPictureParameterBufferMPEG4; - - - -/** Buffer functions */ - -/** - * Creates a buffer for "num_elements" elements of "size" bytes and - * initalize with "data". - * if "data" is null, then the contents of the buffer data store - * are undefined. - * Basically there are two ways to get buffer data to the server side. One is - * to call vaCreateBuffer() with a non-null "data", which results the data being - * copied to the data store on the server side. A different method that - * eliminates this copy is to pass null as "data" when calling vaCreateBuffer(), - * and then use vaMapBuffer() to map the data store from the server side to the - * client address space for access. - * The user must call vaDestroyBuffer() to destroy a buffer. - * Note: image buffers are created by the library, not the client. Please see - * vaCreateImage on how image buffers are managed. - */ -VAStatus vaCreateBuffer ( - VADisplay dpy, - VAContextID context, - VABufferType type, /* in */ - unsigned int size, /* in */ - unsigned int num_elements, /* in */ - void *data, /* in */ - VABufferID *buf_id /* out */ -); - -/** - * Convey to the server how many valid elements are in the buffer. - * e.g. if multiple slice parameters are being held in a single buffer, - * this will communicate to the server the number of slice parameters - * that are valid in the buffer. - */ -VAStatus vaBufferSetNumElements ( - VADisplay dpy, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ -); - - -/** - * device independent data structure for codedbuffer - */ - -/* - * FICTURE_AVE_QP(bit7-0): The average Qp value used during this frame - * LARGE_SLICE(bit8):At least one slice in the current frame was large - * enough for the encoder to attempt to limit its size. - * SLICE_OVERFLOW(bit9): At least one slice in the current frame has - * exceeded the maximum slice size specified. - * BITRATE_OVERFLOW(bit10): The peak bitrate was exceeded for this frame. - * BITRATE_HIGH(bit11): The frame size got within the safety margin of the maximum size (VCM only) - * AIR_MB_OVER_THRESHOLD: the number of MBs adapted to Intra MB - */ -#define VA_CODED_BUF_STATUS_PICTURE_AVE_QP_MASK 0xff -#define VA_CODED_BUF_STATUS_LARGE_SLICE_MASK 0x100 -#define VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK 0x200 -#define VA_CODED_BUF_STATUS_BITRATE_OVERFLOW 0x400 -#define VA_CODED_BUF_STATUS_BITRATE_HIGH 0x800 -/** - * \brief The frame has exceeded the maximum requested size. - * - * This flag indicates that the encoded frame size exceeds the value - * specified through a misc parameter buffer of type - * #VAEncMiscParameterTypeMaxFrameSize. - */ -#define VA_CODED_BUF_STATUS_FRAME_SIZE_OVERFLOW 0x1000 -#define VA_CODED_BUF_STATUS_AIR_MB_OVER_THRESHOLD 0xff0000 - -/** - * \brief The coded buffer segment contains a single NAL unit. - * - * This flag indicates that the coded buffer segment contains a - * single NAL unit. This flag might be useful to the user for - * processing the coded buffer. - */ -#define VA_CODED_BUF_STATUS_SINGLE_NALU 0x10000000 - -/** - * \brief Coded buffer segment. - * - * #VACodedBufferSegment is an element of a linked list describing - * some information on the coded buffer. The coded buffer segment - * could contain either a single NAL unit, or more than one NAL unit. - * It is recommended (but not required) to return a single NAL unit - * in a coded buffer segment, and the implementation should set the - * VA_CODED_BUF_STATUS_SINGLE_NALU status flag if that is the case. - */ -typedef struct _VACodedBufferSegment { - /** - * \brief Size of the data buffer in this segment (in bytes). - */ - unsigned int size; - /** \brief Bit offset into the data buffer where the video data starts. */ - unsigned int bit_offset; - /** \brief Status set by the driver. See \c VA_CODED_BUF_STATUS_*. */ - unsigned int status; - /** \brief Reserved for future use. */ - unsigned int reserved; - /** \brief Pointer to the start of the data buffer. */ - void *buf; - /** - * \brief Pointer to the next #VACodedBufferSegment element, - * or \c NULL if there is none. - */ - void *next; -} VACodedBufferSegment; - -/** - * Map data store of the buffer into the client's address space - * vaCreateBuffer() needs to be called with "data" set to NULL before - * calling vaMapBuffer() - * - * if buffer type is VAEncCodedBufferType, pbuf points to link-list of - * VACodedBufferSegment, and the list is terminated if "next" is NULL - */ -VAStatus vaMapBuffer ( - VADisplay dpy, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -); - -/** - * After client making changes to a mapped data store, it needs to - * "Unmap" it to let the server know that the data is ready to be - * consumed by the server - */ -VAStatus vaUnmapBuffer ( - VADisplay dpy, - VABufferID buf_id /* in */ -); - -/** - * After this call, the buffer is deleted and this buffer_id is no longer valid - * - * A buffer can be re-used and sent to the server by another Begin/Render/End - * sequence if vaDestroyBuffer() is not called with this buffer. - * - * Note re-using a shared buffer (e.g. a slice data buffer) between the host and the - * hardware accelerator can result in performance dropping. - */ -VAStatus vaDestroyBuffer ( - VADisplay dpy, - VABufferID buffer_id -); - -/** \brief VA buffer information */ -typedef struct { - /** \brief Buffer handle */ - uintptr_t handle; - /** \brief Buffer type (See \ref VABufferType). */ - uint32_t type; - /** - * \brief Buffer memory type (See \ref VASurfaceAttribMemoryType). - * - * On input to vaAcquireBufferHandle(), this field can serve as a hint - * to specify the set of memory types the caller is interested in. - * On successful return from vaAcquireBufferHandle(), the field is - * updated with the best matching memory type. - */ - uint32_t mem_type; - /** \brief Size of the underlying buffer. */ - size_t mem_size; -} VABufferInfo; - -/** - * \brief Acquires buffer handle for external API usage - * - * Locks the VA buffer object \ref buf_id for external API usage like - * EGL or OpenCL (OCL). This function is a synchronization point. This - * means that any pending operation is guaranteed to be completed - * prior to returning from the function. - * - * If the referenced VA buffer object is the backing store of a VA - * surface, then this function acts as if vaSyncSurface() on the - * parent surface was called first. - * - * The \ref VABufferInfo argument shall be zero'ed on input. On - * successful output, the data structure is filled in with all the - * necessary buffer level implementation details like handle, type, - * memory type and memory size. - * - * Note: the external API implementation, or the application, can - * express the memory types it is interested in by filling in the \ref - * mem_type field accordingly. On successful output, the memory type - * that fits best the request and that was used is updated in the \ref - * VABufferInfo data structure. If none of the supplied memory types - * is supported, then a \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE - * error is returned. - * - * The \ref VABufferInfo data is valid until vaReleaseBufferHandle() - * is called. Besides, no additional operation is allowed on any of - * the buffer parent object until vaReleaseBufferHandle() is called. - * e.g. decoding into a VA surface backed with the supplied VA buffer - * object \ref buf_id would fail with a \ref VA_STATUS_ERROR_SURFACE_BUSY - * error. - * - * Possible errors: - * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation - * does not support this interface - * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied - * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied - * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation - * does not support exporting buffers of the specified type - * - \ref VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE: none of the requested - * memory types in \ref VABufferInfo.mem_type was supported - * - * @param[in] dpy the VA display - * @param[in] buf_id the VA buffer - * @param[in,out] buf_info the associated VA buffer information - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus -vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info); - -/** - * \brief Releases buffer after usage from external API - * - * Unlocks the VA buffer object \ref buf_id from external API usage like - * EGL or OpenCL (OCL). This function is a synchronization point. This - * means that any pending operation is guaranteed to be completed - * prior to returning from the function. - * - * The \ref VABufferInfo argument shall point to the original data - * structure that was obtained from vaAcquireBufferHandle(), unaltered. - * This is necessary so that the VA driver implementation could - * deallocate any resources that were needed. - * - * In any case, returning from this function invalidates any contents - * in \ref VABufferInfo. i.e. the underlyng buffer handle is no longer - * valid. Therefore, VA driver implementations are free to reset this - * data structure to safe defaults. - * - * Possible errors: - * - \ref VA_STATUS_ERROR_UNIMPLEMENTED: the VA driver implementation - * does not support this interface - * - \ref VA_STATUS_ERROR_INVALID_DISPLAY: an invalid display was supplied - * - \ref VA_STATUS_ERROR_INVALID_BUFFER: an invalid buffer was supplied - * - \ref VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: the implementation - * does not support exporting buffers of the specified type - * - * @param[in] dpy the VA display - * @param[in] buf_id the VA buffer - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus -vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id); - -/* -Render (Decode) Pictures - -A picture represents either a frame or a field. - -The Begin/Render/End sequence sends the decode buffers to the server -*/ - -/** - * Get ready to decode a picture to a target surface - */ -VAStatus vaBeginPicture ( - VADisplay dpy, - VAContextID context, - VASurfaceID render_target -); - -/** - * Send decode buffers to the server. - */ -VAStatus vaRenderPicture ( - VADisplay dpy, - VAContextID context, - VABufferID *buffers, - int num_buffers -); - -/** - * Make the end of rendering for a picture. - * The server should start processing all pending operations for this - * surface. This call is non-blocking. The client can start another - * Begin/Render/End sequence on a different render target. - */ -VAStatus vaEndPicture ( - VADisplay dpy, - VAContextID context -); - -/* - -Synchronization - -*/ - -/** - * This function blocks until all pending operations on the render target - * have been completed. Upon return it is safe to use the render target for a - * different picture. - */ -VAStatus vaSyncSurface ( - VADisplay dpy, - VASurfaceID render_target -); - -typedef enum -{ - VASurfaceRendering = 1, /* Rendering in progress */ - VASurfaceDisplaying = 2, /* Displaying in progress (not safe to render into it) */ - /* this status is useful if surface is used as the source */ - /* of an overlay */ - VASurfaceReady = 4, /* not being rendered or displayed */ - VASurfaceSkipped = 8 /* Indicate a skipped frame during encode */ -} VASurfaceStatus; - -/** - * Find out any pending ops on the render target - */ -VAStatus vaQuerySurfaceStatus ( - VADisplay dpy, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ -); - -typedef enum -{ - VADecodeSliceMissing = 0, - VADecodeMBError = 1, -} VADecodeErrorType; - -/** - * Client calls vaQuerySurfaceError with VA_STATUS_ERROR_DECODING_ERROR, server side returns - * an array of structure VASurfaceDecodeMBErrors, and the array is terminated by setting status=-1 -*/ -typedef struct _VASurfaceDecodeMBErrors -{ - int status; /* 1 if hardware has returned detailed info below, -1 means this record is invalid */ - unsigned int start_mb; /* start mb address with errors */ - unsigned int end_mb; /* end mb address with errors */ - VADecodeErrorType decode_error_type; -} VASurfaceDecodeMBErrors; - -/** - * After the application gets VA_STATUS_ERROR_DECODING_ERROR after calling vaSyncSurface(), - * it can call vaQuerySurfaceError to find out further details on the particular error. - * VA_STATUS_ERROR_DECODING_ERROR should be passed in as "error_status", - * upon the return, error_info will point to an array of _VASurfaceDecodeMBErrors structure, - * which is allocated and filled by libVA with detailed information on the missing or error macroblocks. - * The array is terminated if "status==-1" is detected. - */ -VAStatus vaQuerySurfaceError( - VADisplay dpy, - VASurfaceID surface, - VAStatus error_status, - void **error_info -); - -/** - * Images and Subpictures - * VAImage is used to either get the surface data to client memory, or - * to copy image data in client memory to a surface. - * Both images, subpictures and surfaces follow the same 2D coordinate system where origin - * is at the upper left corner with positive X to the right and positive Y down - */ -#define VA_FOURCC(ch0, ch1, ch2, ch3) \ - ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \ - ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 )) - -/* - * Pre-defined fourcc codes - */ -#define VA_FOURCC_NV12 0x3231564E -#define VA_FOURCC_AI44 0x34344149 -#define VA_FOURCC_RGBA 0x41424752 -#define VA_FOURCC_RGBX 0x58424752 -#define VA_FOURCC_BGRA 0x41524742 -#define VA_FOURCC_BGRX 0x58524742 -#define VA_FOURCC_ARGB 0x42475241 -#define VA_FOURCC_XRGB 0x42475258 -#define VA_FOURCC_ABGR 0x52474241 -#define VA_FOURCC_XBGR 0x52474258 -#define VA_FOURCC_UYVY 0x59565955 -#define VA_FOURCC_YUY2 0x32595559 -#define VA_FOURCC_AYUV 0x56555941 -#define VA_FOURCC_NV11 0x3131564e -#define VA_FOURCC_YV12 0x32315659 -#define VA_FOURCC_P208 0x38303250 -#define VA_FOURCC_IYUV 0x56555949 -#define VA_FOURCC_YV24 0x34325659 -#define VA_FOURCC_YV32 0x32335659 -#define VA_FOURCC_Y800 0x30303859 -#define VA_FOURCC_IMC3 0x33434D49 -#define VA_FOURCC_411P 0x50313134 -#define VA_FOURCC_422H 0x48323234 -#define VA_FOURCC_422V 0x56323234 -#define VA_FOURCC_444P 0x50343434 -#define VA_FOURCC_RGBP 0x50424752 -#define VA_FOURCC_BGRP 0x50524742 -#define VA_FOURCC_411R 0x52313134 /* rotated 411P */ -/** - * Planar YUV 4:2:2. - * 8-bit Y plane, followed by 8-bit 2x1 subsampled V and U planes - */ -#define VA_FOURCC_YV16 0x36315659 -/** - * 10-bit and 16-bit Planar YUV 4:2:0. - */ -#define VA_FOURCC_P010 0x30313050 -#define VA_FOURCC_P016 0x36313050 - -/** - * 10-bit Planar YUV 420 and occupy the lower 10-bit. - */ -#define VA_FOURCC_I010 0x30313049 - -/* byte order */ -#define VA_LSB_FIRST 1 -#define VA_MSB_FIRST 2 - -typedef struct _VAImageFormat -{ - unsigned int fourcc; - unsigned int byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */ - unsigned int bits_per_pixel; - /* for RGB formats */ - unsigned int depth; /* significant bits per pixel */ - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - unsigned int alpha_mask; -} VAImageFormat; - -typedef VAGenericID VAImageID; - -typedef struct _VAImage -{ - VAImageID image_id; /* uniquely identify this image */ - VAImageFormat format; - VABufferID buf; /* image data buffer */ - /* - * Image data will be stored in a buffer of type VAImageBufferType to facilitate - * data store on the server side for optimal performance. The buffer will be - * created by the CreateImage function, and proper storage allocated based on the image - * size and format. This buffer is managed by the library implementation, and - * accessed by the client through the buffer Map/Unmap functions. - */ - unsigned short width; - unsigned short height; - unsigned int data_size; - unsigned int num_planes; /* can not be greater than 3 */ - /* - * An array indicating the scanline pitch in bytes for each plane. - * Each plane may have a different pitch. Maximum 3 planes for planar formats - */ - unsigned int pitches[3]; - /* - * An array indicating the byte offset from the beginning of the image data - * to the start of each plane. - */ - unsigned int offsets[3]; - - /* The following fields are only needed for paletted formats */ - int num_palette_entries; /* set to zero for non-palette images */ - /* - * Each component is one byte and entry_bytes indicates the number of components in - * each entry (eg. 3 for YUV palette entries). set to zero for non-palette images - */ - int entry_bytes; - /* - * An array of ascii characters describing the order of the components within the bytes. - * Only entry_bytes characters of the string are used. - */ - char component_order[4]; -} VAImage; - -/** Get maximum number of image formats supported by the implementation */ -int vaMaxNumImageFormats ( - VADisplay dpy -); - -/** - * Query supported image formats - * The caller must provide a "format_list" array that can hold at - * least vaMaxNumImageFormats() entries. The actual number of formats - * returned in "format_list" is returned in "num_formats". - */ -VAStatus vaQueryImageFormats ( - VADisplay dpy, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ -); - -/** - * Create a VAImage structure - * The width and height fields returned in the VAImage structure may get - * enlarged for some YUV formats. Upon return from this function, - * image->buf has been created and proper storage allocated by the library. - * The client can access the image through the Map/Unmap calls. - */ -VAStatus vaCreateImage ( - VADisplay dpy, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ -); - -/** - * Should call DestroyImage before destroying the surface it is bound to - */ -VAStatus vaDestroyImage ( - VADisplay dpy, - VAImageID image -); - -VAStatus vaSetImagePalette ( - VADisplay dpy, - VAImageID image, - /* - * pointer to an array holding the palette data. The size of the array is - * num_palette_entries * entry_bytes in size. The order of the components - * in the palette is described by the component_order in VAImage struct - */ - unsigned char *palette -); - -/** - * Retrive surface data into a VAImage - * Image must be in a format supported by the implementation - */ -VAStatus vaGetImage ( - VADisplay dpy, - VASurfaceID surface, - int x, /* coordinates of the upper left source pixel */ - int y, - unsigned int width, /* width and height of the region */ - unsigned int height, - VAImageID image -); - -/** - * Copy data from a VAImage to a surface - * Image must be in a format supported by the implementation - * Returns a VA_STATUS_ERROR_SURFACE_BUSY if the surface - * shouldn't be rendered into when this is called - */ -VAStatus vaPutImage ( - VADisplay dpy, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int src_width, - unsigned int src_height, - int dest_x, - int dest_y, - unsigned int dest_width, - unsigned int dest_height -); - -/** - * Derive an VAImage from an existing surface. - * This interface will derive a VAImage and corresponding image buffer from - * an existing VA Surface. The image buffer can then be mapped/unmapped for - * direct CPU access. This operation is only possible on implementations with - * direct rendering capabilities and internal surface formats that can be - * represented with a VAImage. When the operation is not possible this interface - * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back - * to using vaCreateImage + vaPutImage to accomplish the same task in an - * indirect manner. - * - * Implementations should only return success when the resulting image buffer - * would be useable with vaMap/Unmap. - * - * When directly accessing a surface special care must be taken to insure - * proper synchronization with the graphics hardware. Clients should call - * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent - * rendering or currently being displayed by an overlay. - * - * Additionally nothing about the contents of a surface should be assumed - * following a vaPutSurface. Implementations are free to modify the surface for - * scaling or subpicture blending within a call to vaPutImage. - * - * Calls to vaPutImage or vaGetImage using the same surface from which the image - * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or - * vaGetImage with other surfaces is supported. - * - * An image created with vaDeriveImage should be freed with vaDestroyImage. The - * image and image buffer structures will be destroyed; however, the underlying - * surface will remain unchanged until freed with vaDestroySurfaces. - */ -VAStatus vaDeriveImage ( - VADisplay dpy, - VASurfaceID surface, - VAImage *image /* out */ -); - -/** - * Subpictures - * Subpicture is a special type of image that can be blended - * with a surface during vaPutSurface(). Subpicture can be used to render - * DVD sub-titles or closed captioning text etc. - */ - -typedef VAGenericID VASubpictureID; - -/** Get maximum number of subpicture formats supported by the implementation */ -int vaMaxNumSubpictureFormats ( - VADisplay dpy -); - -/** flags for subpictures */ -#define VA_SUBPICTURE_CHROMA_KEYING 0x0001 -#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002 -#define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD 0x0004 -/** - * Query supported subpicture formats - * The caller must provide a "format_list" array that can hold at - * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag - * for each format to indicate additional capabilities for that format. The actual - * number of formats returned in "format_list" is returned in "num_formats". - * flags: returned value to indicate addtional capabilities - * VA_SUBPICTURE_CHROMA_KEYING - supports chroma-keying - * VA_SUBPICTURE_GLOBAL_ALPHA - supports global alpha - * VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD - supports unscaled screen relative subpictures for On Screen Display - */ - -VAStatus vaQuerySubpictureFormats ( - VADisplay dpy, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ -); - -/** - * Subpictures are created with an image associated. - */ -VAStatus vaCreateSubpicture ( - VADisplay dpy, - VAImageID image, - VASubpictureID *subpicture /* out */ -); - -/** - * Destroy the subpicture before destroying the image it is assocated to - */ -VAStatus vaDestroySubpicture ( - VADisplay dpy, - VASubpictureID subpicture -); - -/** - * Bind an image to the subpicture. This image will now be associated with - * the subpicture instead of the one at creation. - */ -VAStatus vaSetSubpictureImage ( - VADisplay dpy, - VASubpictureID subpicture, - VAImageID image -); - -/** - * If chromakey is enabled, then the area where the source value falls within - * the chromakey [min, max] range is transparent - * The chromakey component format is the following: - * For RGB: [0:7] Red [8:15] Blue [16:23] Green - * For YUV: [0:7] V [8:15] U [16:23] Y - * The chromakey mask can be used to mask out certain components for chromakey - * comparision - */ -VAStatus vaSetSubpictureChromakey ( - VADisplay dpy, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask -); - -/** - * Global alpha value is between 0 and 1. A value of 1 means fully opaque and - * a value of 0 means fully transparent. If per-pixel alpha is also specified then - * the overall alpha is per-pixel alpha multiplied by the global alpha - */ -VAStatus vaSetSubpictureGlobalAlpha ( - VADisplay dpy, - VASubpictureID subpicture, - float global_alpha -); - -/** - * vaAssociateSubpicture associates the subpicture with target_surfaces. - * It defines the region mapping between the subpicture and the target - * surfaces through source and destination rectangles (with the same width and height). - * Both will be displayed at the next call to vaPutSurface. Additional - * associations before the call to vaPutSurface simply overrides the association. - */ -VAStatus vaAssociateSubpicture ( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - unsigned short src_width, - unsigned short src_height, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short dest_width, - unsigned short dest_height, - /* - * whether to enable chroma-keying, global-alpha, or screen relative mode - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags -); - -/** - * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces. - */ -VAStatus vaDeassociateSubpicture ( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces -); - -/** - * Display attributes - * Display attributes are used to control things such as contrast, hue, saturation, - * brightness etc. in the rendering process. The application can query what - * attributes are supported by the driver, and then set the appropriate attributes - * before calling vaPutSurface() - */ -/* PowerVR IEP Lite attributes */ -typedef enum -{ - VADISPLAYATTRIB_BLE_OFF = 0x00, - VADISPLAYATTRIB_BLE_LOW, - VADISPLAYATTRIB_BLE_MEDIUM, - VADISPLAYATTRIB_BLE_HIGH, - VADISPLAYATTRIB_BLE_NONE, -} VADisplayAttribBLEMode; - -/** attribute value for VADisplayAttribRotation */ -#define VA_ROTATION_NONE 0x00000000 -#define VA_ROTATION_90 0x00000001 -#define VA_ROTATION_180 0x00000002 -#define VA_ROTATION_270 0x00000003 - -/** attribute value for VADisplayAttribOutOfLoopDeblock */ -#define VA_OOL_DEBLOCKING_FALSE 0x00000000 -#define VA_OOL_DEBLOCKING_TRUE 0x00000001 - -/** Render mode */ -#define VA_RENDER_MODE_UNDEFINED 0 -#define VA_RENDER_MODE_LOCAL_OVERLAY 1 -#define VA_RENDER_MODE_LOCAL_GPU 2 -#define VA_RENDER_MODE_EXTERNAL_OVERLAY 4 -#define VA_RENDER_MODE_EXTERNAL_GPU 8 - -/** Render device */ -#define VA_RENDER_DEVICE_UNDEFINED 0 -#define VA_RENDER_DEVICE_LOCAL 1 -#define VA_RENDER_DEVICE_EXTERNAL 2 - -/** Currently defined display attribute types */ -typedef enum -{ - VADisplayAttribBrightness = 0, - VADisplayAttribContrast = 1, - VADisplayAttribHue = 2, - VADisplayAttribSaturation = 3, - /* client can specifiy a background color for the target window - * the new feature of video conference, - * the uncovered area of the surface is filled by this color - * also it will blend with the decoded video color - */ - VADisplayAttribBackgroundColor = 4, - /* - * this is a gettable only attribute. For some implementations that use the - * hardware overlay, after PutSurface is called, the surface can not be - * re-used until after the subsequent PutSurface call. If this is the case - * then the value for this attribute will be set to 1 so that the client - * will not attempt to re-use the surface right after returning from a call - * to PutSurface. - * - * Don't use it, use flag VASurfaceDisplaying of vaQuerySurfaceStatus since - * driver may use overlay or GPU alternatively - */ - VADisplayAttribDirectSurface = 5, - VADisplayAttribRotation = 6, - VADisplayAttribOutofLoopDeblock = 7, - - /* PowerVR IEP Lite specific attributes */ - VADisplayAttribBLEBlackMode = 8, - VADisplayAttribBLEWhiteMode = 9, - VADisplayAttribBlueStretch = 10, - VADisplayAttribSkinColorCorrection = 11, - /* - * For type VADisplayAttribCSCMatrix, "value" field is a pointer to the color - * conversion matrix. Each element in the matrix is float-point - */ - VADisplayAttribCSCMatrix = 12, - /* specify the constant color used to blend with video surface - * Cd = Cv*Cc*Ac + Cb *(1 - Ac) C means the constant RGB - * d: the final color to overwrite into the frame buffer - * v: decoded video after color conversion, - * c: video color specified by VADisplayAttribBlendColor - * b: background color of the drawable - */ - VADisplayAttribBlendColor = 13, - /* - * Indicate driver to skip painting color key or not. - * only applicable if the render is overlay - */ - VADisplayAttribOverlayAutoPaintColorKey = 14, - /* - * customized overlay color key, the format is RGB888 - * [23:16] = Red, [15:08] = Green, [07:00] = Blue. - */ - VADisplayAttribOverlayColorKey = 15, - /* - * The hint for the implementation of vaPutSurface - * normally, the driver could use an overlay or GPU to render the surface on the screen - * this flag provides APP the flexibity to switch the render dynamically - */ - VADisplayAttribRenderMode = 16, - /* - * specify if vaPutSurface needs to render into specified monitors - * one example is that one external monitor (e.g. HDMI) is enabled, - * but the window manager is not aware of it, and there is no associated drawable - */ - VADisplayAttribRenderDevice = 17, - /* - * specify vaPutSurface render area if there is no drawable on the monitor - */ - VADisplayAttribRenderRect = 18, -} VADisplayAttribType; - -/* flags for VADisplayAttribute */ -#define VA_DISPLAY_ATTRIB_NOT_SUPPORTED 0x0000 -#define VA_DISPLAY_ATTRIB_GETTABLE 0x0001 -#define VA_DISPLAY_ATTRIB_SETTABLE 0x0002 - -typedef struct _VADisplayAttribute -{ - VADisplayAttribType type; - int min_value; - int max_value; - int value; /* used by the set/get attribute functions */ -/* flags can be VA_DISPLAY_ATTRIB_GETTABLE or VA_DISPLAY_ATTRIB_SETTABLE or OR'd together */ - unsigned int flags; -} VADisplayAttribute; - -/** Get maximum number of display attributs supported by the implementation */ -int vaMaxNumDisplayAttributes ( - VADisplay dpy -); - -/** - * Query display attributes - * The caller must provide a "attr_list" array that can hold at - * least vaMaxNumDisplayAttributes() entries. The actual number of attributes - * returned in "attr_list" is returned in "num_attributes". - */ -VAStatus vaQueryDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ -); - -/** - * Get display attributes - * This function returns the current attribute values in "attr_list". - * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can have their values retrieved. - */ -VAStatus vaGetDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes -); - -/** - * Set display attributes - * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field - * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or - * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED - */ -VAStatus vaSetDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, - int num_attributes -); - -/**************************** - * HEVC data structures - ****************************/ -/** - * \brief Description of picture properties of those in DPB surfaces. - * - * If only progressive scan is supported, each surface contains one whole - * frame picture. - * Otherwise, each surface contains two fields of whole picture. - * In this case, two entries of ReferenceFrames[] may share same picture_id - * value. - */ -typedef struct _VAPictureHEVC -{ - /** \brief reconstructed picture buffer surface index - * invalid when taking value VA_INVALID_SURFACE. - */ - VASurfaceID picture_id; - /** \brief picture order count. - * in HEVC, POCs for top and bottom fields of same picture should - * take different values. - */ - int32_t pic_order_cnt; - /* described below */ - uint32_t flags; -} VAPictureHEVC; - -/* flags in VAPictureHEVC could be OR of the following */ -#define VA_PICTURE_HEVC_INVALID 0x00000001 -/** \brief indication of interlace scan picture. - * should take same value for all the pictures in sequence. - */ -#define VA_PICTURE_HEVC_FIELD_PIC 0x00000002 -/** \brief polarity of the field picture. - * top field takes even lines of buffer surface. - * bottom field takes odd lines of buffer surface. - */ -#define VA_PICTURE_HEVC_BOTTOM_FIELD 0x00000004 -/** \brief Long term reference picture */ -#define VA_PICTURE_HEVC_LONG_TERM_REFERENCE 0x00000008 -/** - * VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE, VA_PICTURE_HEVC_RPS_ST_CURR_AFTER - * and VA_PICTURE_HEVC_RPS_LT_CURR of any picture in ReferenceFrames[] should - * be exclusive. No more than one of them can be set for any picture. - * Sum of NumPocStCurrBefore, NumPocStCurrAfter and NumPocLtCurr - * equals NumPocTotalCurr, which should be equal to or smaller than 8. - * Application should provide valid values for both short format and long format. - * The pictures in DPB with any of these three flags turned on are referred by - * the current picture. - */ -/** \brief RefPicSetStCurrBefore of HEVC spec variable - * Number of ReferenceFrames[] entries with this bit set equals - * NumPocStCurrBefore. - */ -#define VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE 0x00000010 -/** \brief RefPicSetStCurrAfter of HEVC spec variable - * Number of ReferenceFrames[] entries with this bit set equals - * NumPocStCurrAfter. - */ -#define VA_PICTURE_HEVC_RPS_ST_CURR_AFTER 0x00000020 -/** \brief RefPicSetLtCurr of HEVC spec variable - * Number of ReferenceFrames[] entries with this bit set equals - * NumPocLtCurr. - */ -#define VA_PICTURE_HEVC_RPS_LT_CURR 0x00000040 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _VA_H_ */ diff --git a/va/va_android.h b/va/va_android.h deleted file mode 100644 index 796ab63..0000000 --- a/va/va_android.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -#ifndef _VA_ANDROID_H_ -#define _VA_ANDROID_H_ - -#include - -/** \brief Android Gralloc buffer memory type. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC 0x00100000 -/** \brief Android ION buffer memory type. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_ION 0x00200000 - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Returns a suitable VADisplay for VA API - */ -VADisplay vaGetDisplay ( - void *android_dpy -); - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -#ifdef ANDROID -#include -using namespace android; - -/* - * Output rendering - * Following is the rendering interface for Android system, - * to get the decode output surface to an ISurface object. - * It basically performs a de-interlacing (if needed), - * color space conversion and scaling to the destination - * rectangle - */ -VAStatus vaPutSurface ( - VADisplay dpy, - VASurfaceID surface, - sp draw, /* Android Window/Surface */ - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth, - VARectangle *cliprects, /* client supplied destination clip list */ - unsigned int number_cliprects, /* number of clip rects in the clip list */ - unsigned int flags /* PutSurface flags */ -); - -#endif /* ANDROID */ -#endif /* __cplusplus */ - -#endif /* _VA_ANDROID_H_ */ diff --git a/va/va_backend.h b/va/va_backend.h deleted file mode 100644 index 7ab52d2..0000000 --- a/va/va_backend.h +++ /dev/null @@ -1,562 +0,0 @@ -/* - * 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. - */ - -/* - * Video Decode Acceleration -Backend API - */ - -#ifndef _VA_BACKEND_H_ -#define _VA_BACKEND_H_ - -#include -#include - -typedef struct VADriverContext *VADriverContextP; -typedef struct VADisplayContext *VADisplayContextP; - -/** \brief VA display types. */ -enum { - /** \brief Mask to major identifier for VA display type. */ - VA_DISPLAY_MAJOR_MASK = 0xf0, - - /** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */ - VA_DISPLAY_X11 = 0x10, - /** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */ - VA_DISPLAY_GLX = (VA_DISPLAY_X11 | (1 << 0)), - /** \brief VA/Android API is used, through vaGetDisplay() entry-point. */ - VA_DISPLAY_ANDROID = 0x20, - /** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */ - VA_DISPLAY_DRM = 0x30, - /** \brief VA/DRM API is used, with a render-node device path */ - VA_DISPLAY_DRM_RENDERNODES = (VA_DISPLAY_DRM | (1 << 0)), - /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */ - VA_DISPLAY_WAYLAND = 0x40, -}; - -struct VADriverVTable -{ - VAStatus (*vaTerminate) ( VADriverContextP ctx ); - - VAStatus (*vaQueryConfigProfiles) ( - VADriverContextP ctx, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ - ); - - VAStatus (*vaQueryConfigEntrypoints) ( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint *entrypoint_list, /* out */ - int *num_entrypoints /* out */ - ); - - VAStatus (*vaGetConfigAttributes) ( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs - ); - - VAStatus (*vaCreateConfig) ( - VADriverContextP ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ - ); - - VAStatus (*vaDestroyConfig) ( - VADriverContextP ctx, - VAConfigID config_id - ); - - VAStatus (*vaQueryConfigAttributes) ( - VADriverContextP ctx, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list, /* out */ - int *num_attribs /* out */ - ); - - VAStatus (*vaCreateSurfaces) ( - VADriverContextP ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces /* out */ - ); - - VAStatus (*vaDestroySurfaces) ( - VADriverContextP ctx, - VASurfaceID *surface_list, - int num_surfaces - ); - - VAStatus (*vaCreateContext) ( - VADriverContextP ctx, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - VAContextID *context /* out */ - ); - - VAStatus (*vaDestroyContext) ( - VADriverContextP ctx, - VAContextID context - ); - - VAStatus (*vaCreateBuffer) ( - VADriverContextP ctx, - VAContextID context, /* in */ - VABufferType type, /* in */ - unsigned int size, /* in */ - unsigned int num_elements, /* in */ - void *data, /* in */ - VABufferID *buf_id /* out */ - ); - - VAStatus (*vaBufferSetNumElements) ( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ - ); - - VAStatus (*vaMapBuffer) ( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - void **pbuf /* out */ - ); - - VAStatus (*vaUnmapBuffer) ( - VADriverContextP ctx, - VABufferID buf_id /* in */ - ); - - VAStatus (*vaDestroyBuffer) ( - VADriverContextP ctx, - VABufferID buffer_id - ); - - VAStatus (*vaBeginPicture) ( - VADriverContextP ctx, - VAContextID context, - VASurfaceID render_target - ); - - VAStatus (*vaRenderPicture) ( - VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers - ); - - VAStatus (*vaEndPicture) ( - VADriverContextP ctx, - VAContextID context - ); - - VAStatus (*vaSyncSurface) ( - VADriverContextP ctx, - VASurfaceID render_target - ); - - VAStatus (*vaQuerySurfaceStatus) ( - VADriverContextP ctx, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ - ); - - VAStatus (*vaQuerySurfaceError) ( - VADriverContextP ctx, - VASurfaceID render_target, - VAStatus error_status, - void **error_info /*out*/ - ); - - VAStatus (*vaPutSurface) ( - VADriverContextP ctx, - VASurfaceID surface, - void* draw, /* Drawable of window system */ - 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 (*vaQueryImageFormats) ( - VADriverContextP ctx, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ - ); - - VAStatus (*vaCreateImage) ( - VADriverContextP ctx, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ - ); - - VAStatus (*vaDeriveImage) ( - VADriverContextP ctx, - VASurfaceID surface, - VAImage *image /* out */ - ); - - VAStatus (*vaDestroyImage) ( - VADriverContextP ctx, - VAImageID image - ); - - VAStatus (*vaSetImagePalette) ( - VADriverContextP ctx, - VAImageID image, - /* - * pointer to an array holding the palette data. The size of the array is - * num_palette_entries * entry_bytes in size. The order of the components - * in the palette is described by the component_order in VAImage struct - */ - unsigned char *palette - ); - - VAStatus (*vaGetImage) ( - VADriverContextP ctx, - VASurfaceID surface, - int x, /* coordinates of the upper left source pixel */ - int y, - unsigned int width, /* width and height of the region */ - unsigned int height, - VAImageID image - ); - - VAStatus (*vaPutImage) ( - VADriverContextP ctx, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int src_width, - unsigned int src_height, - int dest_x, - int dest_y, - unsigned int dest_width, - unsigned int dest_height - ); - - VAStatus (*vaQuerySubpictureFormats) ( - VADriverContextP ctx, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ - ); - - VAStatus (*vaCreateSubpicture) ( - VADriverContextP ctx, - VAImageID image, - VASubpictureID *subpicture /* out */ - ); - - VAStatus (*vaDestroySubpicture) ( - VADriverContextP ctx, - VASubpictureID subpicture - ); - - VAStatus (*vaSetSubpictureImage) ( - VADriverContextP ctx, - VASubpictureID subpicture, - VAImageID image - ); - - VAStatus (*vaSetSubpictureChromakey) ( - VADriverContextP ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask - ); - - VAStatus (*vaSetSubpictureGlobalAlpha) ( - VADriverContextP ctx, - VASubpictureID subpicture, - float global_alpha - ); - - VAStatus (*vaAssociateSubpicture) ( - VADriverContextP ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - unsigned short src_width, - unsigned short src_height, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short dest_width, - unsigned short dest_height, - /* - * whether to enable chroma-keying or global-alpha - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags - ); - - VAStatus (*vaDeassociateSubpicture) ( - VADriverContextP ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces - ); - - VAStatus (*vaQueryDisplayAttributes) ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ - ); - - VAStatus (*vaGetDisplayAttributes) ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes - ); - - VAStatus (*vaSetDisplayAttributes) ( - VADriverContextP ctx, - VADisplayAttribute *attr_list, - int num_attributes - ); - - /* used by va trace */ - VAStatus (*vaBufferInfo) ( - VADriverContextP ctx, /* in */ - VABufferID buf_id, /* in */ - VABufferType *type, /* out */ - unsigned int *size, /* out */ - unsigned int *num_elements /* out */ - ); - - /* lock/unlock surface for external access */ - VAStatus (*vaLockSurface) ( - VADriverContextP ctx, - VASurfaceID surface, - unsigned int *fourcc, /* out for follow 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, /* if it is not NULL, assign the low lever - * surface buffer name - */ - void **buffer /* if it is not NULL, map the surface buffer for - * CPU access - */ - ); - - VAStatus (*vaUnlockSurface) ( - VADriverContextP ctx, - VASurfaceID surface - ); - - /* DEPRECATED */ - VAStatus - (*vaGetSurfaceAttributes)( - VADriverContextP dpy, - VAConfigID config, - VASurfaceAttrib *attrib_list, - unsigned int num_attribs - ); - - VAStatus - (*vaCreateSurfaces2)( - VADriverContextP ctx, - unsigned int format, - unsigned int width, - unsigned int height, - VASurfaceID *surfaces, - unsigned int num_surfaces, - VASurfaceAttrib *attrib_list, - unsigned int num_attribs - ); - - VAStatus - (*vaQuerySurfaceAttributes)( - VADriverContextP dpy, - VAConfigID config, - VASurfaceAttrib *attrib_list, - unsigned int *num_attribs - ); - - VAStatus - (*vaAcquireBufferHandle)( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - VABufferInfo * buf_info /* in/out */ - ); - - VAStatus - (*vaReleaseBufferHandle)( - VADriverContextP ctx, - VABufferID buf_id /* in */ - ); -}; - -struct VADriverContext -{ - void *pDriverData; - - /** - * The core VA implementation hooks. - * - * This structure is allocated from libva with calloc(). - */ - struct VADriverVTable *vtable; - - /** - * The VA/GLX implementation hooks. - * - * This structure is intended for drivers that implement the - * VA/GLX API. The driver implementation is responsible for the - * allocation and deallocation of this structure. - */ - struct VADriverVTableGLX *vtable_glx; - - /** - * The VA/EGL implementation hooks. - * - * This structure is intended for drivers that implement the - * VA/EGL API. The driver implementation is responsible for the - * allocation and deallocation of this structure. - */ - struct VADriverVTableEGL *vtable_egl; - - /** - * The third-party/private implementation hooks. - * - * This structure is intended for drivers that implement the - * private API. The driver implementation is responsible for the - * allocation and deallocation of this structure. - */ - void *vtable_tpi; - - void *native_dpy; - int x11_screen; - int version_major; - int version_minor; - int max_profiles; - int max_entrypoints; - int max_attributes; - int max_image_formats; - int max_subpic_formats; - int max_display_attributes; - const char *str_vendor; - - void *handle; /* dlopen handle */ - - /** - * \brief DRM state. - * - * This field holds driver specific data for DRM-based - * drivers. This structure is allocated from libva with - * calloc(). Do not deallocate from within VA driver - * implementations. - * - * All structures shall be derived from struct drm_state. So, for - * instance, this field holds a dri_state structure for VA/X11 - * drivers that use the DRM protocol. - */ - void *drm_state; - - void *glx; /* opaque for GLX code */ - - /** \brief VA display type. */ - unsigned long display_type; - - /** - * The VA/Wayland implementation hooks. - * - * This structure is intended for drivers that implement the - * VA/Wayland API. libVA allocates this structure with calloc() - * and owns the resulting memory. - */ - struct VADriverVTableWayland *vtable_wayland; - - /** - * \brief The VA/VPP implementation hooks. - * - * This structure is allocated from libva with calloc(). - */ - struct VADriverVTableVPP *vtable_vpp; - - char *override_driver_name; - - unsigned long reserved[41]; /* reserve for future add-ins, decrease the subscript accordingly */ -}; - -#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ -struct VADisplayContext -{ - int vadpy_magic; - - VADisplayContextP pNext; - VADriverContextP pDriverContext; - - int (*vaIsValid) ( - VADisplayContextP ctx - ); - - void (*vaDestroy) ( - VADisplayContextP ctx - ); - - VAStatus (*vaGetDriverName) ( - VADisplayContextP ctx, - char **driver_name - ); - - void *opaque; /* opaque for display extensions (e.g. GLX) */ - void *vatrace; /* opaque for VA trace context */ - void *vafool; /* opaque for VA fool context */ -}; - -typedef VAStatus (*VADriverInit) ( - VADriverContextP driver_context -); - -#endif /* _VA_BACKEND_H_ */ diff --git a/va/va_backend_tpi.h b/va/va_backend_tpi.h deleted file mode 100644 index 141eb75..0000000 --- a/va/va_backend_tpi.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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. - */ - -/* - * Video Decode Acceleration -Backend API - */ - -#ifndef _VA_BACKEND_TPI_H_ -#define _VA_BACKEND_TPI_H_ - -#include -#include -#include - -struct VADriverVTableTPI -{ - VAStatus (*vaCreateSurfacesWithAttribute) ( - VADisplay dpy, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces, /* out */ - VASurfaceAttributeTPI *attribute_tpi - ); - - - 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 */ - ); -}; - - -#endif /* _VA_BACKEND_TPI_H_ */ diff --git a/va/va_backend_vpp.h b/va/va_backend_vpp.h deleted file mode 100644 index b776ef6..0000000 --- a/va/va_backend_vpp.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2007-2011 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 INTEL 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_BACKEND_VPP_H -#define VA_BACKEND_VPP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** \brief VTable version for VA/VPP hooks. */ -#define VA_DRIVER_VTABLE_VPP_VERSION 1 - -struct VADriverVTableVPP { - unsigned int version; - - VAStatus - (*vaQueryVideoProcFilters)( - VADriverContextP ctx, - VAContextID context, - VAProcFilterType *filters, - unsigned int *num_filters - ); - - VAStatus - (*vaQueryVideoProcFilterCaps)( - VADriverContextP ctx, - VAContextID context, - VAProcFilterType type, - void *filter_caps, - unsigned int *num_filter_caps - ); - - VAStatus - (*vaQueryVideoProcPipelineCaps)( - VADriverContextP ctx, - VAContextID context, - VABufferID *filters, - unsigned int num_filters, - VAProcPipelineCaps *pipeline_caps - ); -}; - -#ifdef __cplusplus -} -#endif - -#endif /* VA_BACKEND_VPP_H */ diff --git a/va/va_compat.c b/va/va_compat.c deleted file mode 100644 index 113591f..0000000 --- a/va/va_compat.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2007-2011 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 INTEL 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. - */ - -#define VA_COMPAT_DISABLED 1 -#include "sysdeps.h" -#include "va.h" -#include "va_compat.h" - -VAStatus -vaCreateSurfaces_0_32_0( - VADisplay dpy, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces -) -{ - return vaCreateSurfaces(dpy, format, width, height, surfaces, num_surfaces, - NULL, 0); -} -VA_CPP_HELPER_ALIAS(vaCreateSurfaces, 0,32,0); diff --git a/va/va_compat.h b/va/va_compat.h deleted file mode 100644 index 41a3f73..0000000 --- a/va/va_compat.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2007-2011 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 INTEL 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. - */ - -/** - * \file va_compat.h - * \brief The Compatibility API - * - * This file contains the \ref api_compat "Compatibility API". - */ - -#ifndef VA_COMPAT_H -#define VA_COMPAT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_compat Compatibility API - * - * The Compatibility API allows older programs that are not ported to - * the current API to still build and run correctly. In particular, - * this exposes older API to allow for backwards source compatibility. - * - * @{ - */ - -/** - * Makes a string literal out of the macro argument - */ -#define VA_CPP_HELPER_STRINGIFY(x) \ - VA_CPP_HELPER_STRINGIFY_(x) -#define VA_CPP_HELPER_STRINGIFY_(x) \ - #x - -/** - * Concatenates two macro arguments at preprocessing time. - */ -#define VA_CPP_HELPER_CONCAT(a, b) \ - VA_CPP_HELPER_CONCAT_(a, b) -#define VA_CPP_HELPER_CONCAT_(a, b) \ - a ## b - -/** - * Generates the number of macro arguments at preprocessing time. - * - * - * Note: this doesn't work for macros with no arguments - */ -#define VA_CPP_HELPER_N_ARGS(...) \ - VA_CPP_HELPER_N_ARGS_(__VA_ARGS__, VA_CPP_HELPER_N_ARGS_LIST_REV()) -#define VA_CPP_HELPER_N_ARGS_(...) \ - VA_CPP_HELPER_N_ARGS_LIST(__VA_ARGS__) -#define VA_CPP_HELPER_N_ARGS_LIST(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a12, a13, a14, a15, a16, N, ...) N -#define VA_CPP_HELPER_N_ARGS_LIST_REV() \ - 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 - -/** - * Generates a versioned function alias. - * - * VA_CPP_HELPER_ALIAS(vaSomeFunction, 0,32,0) will generate - * .symber vaSomeFunction_0_32_0, vaSomeFunction@VA_API_0.32.0 - */ -#define VA_CPP_HELPER_ALIAS(func, major, minor, micro) \ - VA_CPP_HELPER_ALIAS_(func, major, minor, micro, "@") -#define VA_CPP_HELPER_ALIAS_DEFAULT(func, major, minor, micro) \ - VA_CPP_HELPER_ALIAS_(func, major, minor, micro, "@@") -#define VA_CPP_HELPER_ALIAS_(func, major, minor, micro, binding) \ - asm(".symver " #func "_" #major "_" #minor "_" #micro ", " \ - #func binding "VA_API_" #major "." #minor "." #micro) - -/* vaCreateSurfaces() */ - -#ifndef VA_COMPAT_DISABLED -#define vaCreateSurfaces(dpy, ...) \ - VA_CPP_HELPER_CONCAT(vaCreateSurfaces, \ - VA_CPP_HELPER_N_ARGS(dpy, __VA_ARGS__)) \ - (dpy, __VA_ARGS__) -#endif - -#define vaCreateSurfaces6(dpy, width, height, format, num_surfaces, surfaces) \ - (vaCreateSurfaces)(dpy, format, width, height, surfaces, num_surfaces, \ - NULL, 0) - -#define vaCreateSurfaces8(dpy, format, width, height, surfaces, num_surfaces, attribs, num_attribs) \ - (vaCreateSurfaces)(dpy, format, width, height, surfaces, num_surfaces, \ - attribs, num_attribs) - -/*@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_COMPAT_H */ diff --git a/va/va_dec_hevc.h b/va/va_dec_hevc.h deleted file mode 100644 index d61a283..0000000 --- a/va/va_dec_hevc.h +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (c) 2014 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 INTEL 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. - */ - -/** - * \file va_dec_hevc.h - * \brief The HEVC decoding API - * - * This file contains the \ref api_dec_hevc "HEVC decoding API". - */ - -#ifndef VA_DEC_HEVC_H -#define VA_DEC_HEVC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_dec_hevc HEVC decoding API - * - * This HEVC decoding API supports Main and Main Still Picture profiles. - * And it supports both short slice format and long slice format. - * - * @{ - */ - -/** - * \brief HEVC Decoding Picture Parameter Buffer Structure - * - * This structure conveys picture level parameters and should be sent once - * per frame. - * - */ -typedef struct _VAPictureParameterBufferHEVC -{ - /** \brief buffer description of decoded current picture - * only VA_PICTURE_HEVC_FIELD_PIC and VA_PICTURE_HEVC_BOTTOM_FIELD - * of "flags" fields are meaningful. - */ - VAPictureHEVC CurrPic; - /** \brief buffer description of reference frames in DPB */ - VAPictureHEVC ReferenceFrames[15]; - /** \brief picture width, shall be integer multiple of minimum CB size. */ - uint16_t pic_width_in_luma_samples; - /** \brief picture height, shall be integer multiple of minimum CB size. */ - uint16_t pic_height_in_luma_samples; - - - union - { - struct - { - /** following flags have same syntax and semantic as those in HEVC spec */ - uint32_t chroma_format_idc : 2; - uint32_t separate_colour_plane_flag : 1; - uint32_t pcm_enabled_flag : 1; - uint32_t scaling_list_enabled_flag : 1; - uint32_t transform_skip_enabled_flag : 1; - uint32_t amp_enabled_flag : 1; - uint32_t strong_intra_smoothing_enabled_flag : 1; - uint32_t sign_data_hiding_enabled_flag : 1; - uint32_t constrained_intra_pred_flag : 1; - uint32_t cu_qp_delta_enabled_flag : 1; - uint32_t weighted_pred_flag : 1; - uint32_t weighted_bipred_flag : 1; - uint32_t transquant_bypass_enabled_flag : 1; - uint32_t tiles_enabled_flag : 1; - uint32_t entropy_coding_sync_enabled_flag : 1; - uint32_t pps_loop_filter_across_slices_enabled_flag : 1; - uint32_t loop_filter_across_tiles_enabled_flag : 1; - uint32_t pcm_loop_filter_disabled_flag : 1; - /** set based on sps_max_num_reorder_pics of current temporal layer. */ - uint32_t NoPicReorderingFlag : 1; - /** picture has no B slices */ - uint32_t NoBiPredFlag : 1; - - uint32_t ReservedBits : 11; - } bits; - uint32_t value; - } pic_fields; - - /** following parameters have same syntax with those in HEVC spec */ - /** \brief DPB size for current temporal layer */ - uint8_t sps_max_dec_pic_buffering_minus1; - uint8_t bit_depth_luma_minus8; - uint8_t bit_depth_chroma_minus8; - uint8_t pcm_sample_bit_depth_luma_minus1; - uint8_t pcm_sample_bit_depth_chroma_minus1; - uint8_t log2_min_luma_coding_block_size_minus3; - uint8_t log2_diff_max_min_luma_coding_block_size; - uint8_t log2_min_transform_block_size_minus2; - uint8_t log2_diff_max_min_transform_block_size; - uint8_t log2_min_pcm_luma_coding_block_size_minus3; - uint8_t log2_diff_max_min_pcm_luma_coding_block_size; - uint8_t max_transform_hierarchy_depth_intra; - uint8_t max_transform_hierarchy_depth_inter; - int8_t init_qp_minus26; - uint8_t diff_cu_qp_delta_depth; - int8_t pps_cb_qp_offset; - int8_t pps_cr_qp_offset; - uint8_t log2_parallel_merge_level_minus2; - uint8_t num_tile_columns_minus1; - uint8_t num_tile_rows_minus1; - /** - * when uniform_spacing_flag equals 1, application should populate - * column_width_minus[], and row_height_minus1[] with approperiate values. - */ - uint16_t column_width_minus1[19]; - uint16_t row_height_minus1[21]; - - /** - * The Following Parameters are needed for Short Slice Format Only. - * Only format decoding can ignore them. - */ - - /** - * \brief Parameters needed for parsing slice segment headers - */ - union - { - struct - { - /** following parameters have same syntax with those in HEVC spec */ - uint32_t lists_modification_present_flag : 1; - uint32_t long_term_ref_pics_present_flag : 1; - uint32_t sps_temporal_mvp_enabled_flag : 1; - uint32_t cabac_init_present_flag : 1; - uint32_t output_flag_present_flag : 1; - uint32_t dependent_slice_segments_enabled_flag : 1; - uint32_t pps_slice_chroma_qp_offsets_present_flag : 1; - uint32_t sample_adaptive_offset_enabled_flag : 1; - uint32_t deblocking_filter_override_enabled_flag : 1; - uint32_t pps_disable_deblocking_filter_flag : 1; - uint32_t slice_segment_header_extension_present_flag : 1; - - /** current picture with NUT between 16 and 21 inclusive */ - uint32_t RapPicFlag : 1; - /** current picture with NUT between 19 and 20 inclusive */ - uint32_t IdrPicFlag : 1; - /** current picture has only intra slices */ - uint32_t IntraPicFlag : 1; - - uint32_t ReservedBits : 18; - } bits; - uint32_t value; - } slice_parsing_fields; - - /** following parameters have same syntax with those in HEVC spec */ - uint8_t log2_max_pic_order_cnt_lsb_minus4; - uint8_t num_short_term_ref_pic_sets; - uint8_t num_long_term_ref_pic_sps; - uint8_t num_ref_idx_l0_default_active_minus1; - uint8_t num_ref_idx_l1_default_active_minus1; - int8_t pps_beta_offset_div2; - int8_t pps_tc_offset_div2; - uint8_t num_extra_slice_header_bits; - - /** - * \brief number of bits that structure - * short_term_ref_pic_set( num_short_term_ref_pic_sets ) takes in slice - * segment header when short_term_ref_pic_set_sps_flag equals 0. - * if short_term_ref_pic_set_sps_flag equals 1, the value should be 0. - * the bit count is calculated after emulation prevention bytes are removed - * from bit streams. - * This variable is used for accelorater to skip parsing the - * short_term_ref_pic_set( num_short_term_ref_pic_sets ) structure. - */ - uint32_t st_rps_bits; - -} VAPictureParameterBufferHEVC; - - - -/** - * \brief HEVC Slice Parameter Buffer Structure For Short Format - * - * VASliceParameterBufferBaseHEVC structure should be accompanied by a - * slice data buffer, which holds the whole raw slice NAL unit bit streams - * including start code prefix and emulation prevention bytes not removed. - * - * This structure conveys parameters related to slice segment header and should - * be sent once per slice. - * - * For long format, this data structure is not sent by application. - * - */ -typedef struct _VASliceParameterBufferBaseHEVC -{ - /** @name Codec-independent Slice Parameter Buffer base. */ - - /**@{*/ - - /** \brief Number of bytes in the slice data buffer for this slice - * counting from and including NAL unit header. - */ - uint32_t slice_data_size; - /** \brief The offset to the NAL unit header for this slice */ - uint32_t slice_data_offset; - /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_XXX. */ - uint16_t slice_data_flag; - /**@}*/ - -} VASliceParameterBufferBaseHEVC; - - - - -/** - * \brief HEVC Slice Parameter Buffer Structure For Long Format - * - * VASliceParameterBufferHEVC structure should be accompanied by a - * slice data buffer, which holds the whole raw slice NAL unit bit streams - * including start code prefix and emulation prevention bytes not removed. - * - * This structure conveys parameters related to slice segment header and should - * be sent once per slice. - * - * For short format, this data structure is not sent by application. - * - */ -typedef struct _VASliceParameterBufferHEVC -{ - /** @name Codec-independent Slice Parameter Buffer base. */ - - /**@{*/ - - /** \brief Number of bytes in the slice data buffer for this slice - * counting from and including NAL unit header. - */ - uint32_t slice_data_size; - /** \brief The offset to the NAL unit header for this slice */ - uint32_t slice_data_offset; - /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_XXX. */ - uint16_t slice_data_flag; - /** - * \brief Byte offset from NAL unit header to the begining of slice_data(). - * - * This byte offset is relative to and includes the NAL unit header - * and represents the number of bytes parsed in the slice_header() - * after the removal of any emulation prevention bytes in - * there. However, the slice data buffer passed to the hardware is - * the original bitstream, thus including any emulation prevention - * bytes. - */ - uint32_t slice_data_byte_offset; - /** HEVC syntax element. */ - uint32_t slice_segment_address; - /** \brief index into ReferenceFrames[] - * RefPicList[0][] corresponds to RefPicList0[] of HEVC variable. - * RefPicList[1][] corresponds to RefPicList1[] of HEVC variable. - * value range [0..14, 0xFF], where 0xFF indicates invalid entry. - */ - uint8_t RefPicList[2][15]; - union - { - uint32_t value; - struct - { - /** current slice is last slice of picture. */ - uint32_t LastSliceOfPic : 1; - /** HEVC syntax element. */ - uint32_t dependent_slice_segment_flag : 1; - /** HEVC syntax element. */ - uint32_t slice_type : 2; - /** HEVC syntax element. */ - uint32_t color_plane_id : 2; - /** HEVC syntax element. */ - uint32_t slice_sao_luma_flag : 1; - /** HEVC syntax element. */ - uint32_t slice_sao_chroma_flag : 1; - /** HEVC syntax element. */ - uint32_t mvd_l1_zero_flag : 1; - /** HEVC syntax element. */ - uint32_t cabac_init_flag : 1; - /** HEVC syntax element. */ - uint32_t slice_temporal_mvp_enabled_flag : 1; - /** HEVC syntax element. */ - uint32_t slice_deblocking_filter_disabled_flag : 1; - /** HEVC syntax element. */ - uint32_t collocated_from_l0_flag : 1; - /** HEVC syntax element. */ - uint32_t slice_loop_filter_across_slices_enabled_flag : 1; - uint32_t reserved : 18; - } fields; - } LongSliceFlags; - - /** HEVC syntax element. Collocated Reference Picture Index. - * index to RefPicList[0][] or RefPicList[1][]. - * when slice_temporal_mvp_enabled_flag equals 0, it should take value 0xFF. - * value range [0..14, 0xFF]. - */ - uint8_t collocated_ref_idx; - /** HEVC syntax element. - * if num_ref_idx_active_override_flag equals 0, host decoder should - * set its value to num_ref_idx_l0_default_minus1. - */ - uint8_t num_ref_idx_l0_active_minus1; - /** HEVC syntax element. - * if num_ref_idx_active_override_flag equals 0, host decoder should - * set its value to num_ref_idx_l1_default_minus1. - */ - uint8_t num_ref_idx_l1_active_minus1; - /** HEVC syntax element. */ - int8_t slice_qp_delta; - /** HEVC syntax element. */ - int8_t slice_cb_qp_offset; - /** HEVC syntax element. */ - int8_t slice_cr_qp_offset; - /** HEVC syntax element. */ - int8_t slice_beta_offset_div2; - /** HEVC syntax element. */ - int8_t slice_tc_offset_div2; - /** HEVC syntax element. */ - uint8_t luma_log2_weight_denom; - /** HEVC syntax element. */ - int8_t delta_chroma_log2_weight_denom; - /** HEVC syntax element. */ - int8_t delta_luma_weight_l0[15]; - /** HEVC syntax element. */ - int8_t luma_offset_l0[15]; - /** HEVC syntax element. */ - int8_t delta_chroma_weight_l0[15][2]; - /** corresponds to HEVC spec variable of the same name. */ - int8_t ChromaOffsetL0[15][2]; - /** HEVC syntax element. */ - int8_t delta_luma_weight_l1[15]; - /** HEVC syntax element. */ - int8_t luma_offset_l1[15]; - /** HEVC syntax element. */ - int8_t delta_chroma_weight_l1[15][2]; - /** corresponds to HEVC spec variable of the same name. */ - int8_t ChromaOffsetL1[15][2]; - /** HEVC syntax element. */ - uint8_t five_minus_max_num_merge_cand; - /**@}*/ - -} VASliceParameterBufferHEVC; - - - -/** - * \brief HEVC Inverse Quantization Matrix Buffer Structure - * - * This structure is sent once per frame, - * and only when scaling_list_enabled_flag = 1. - * When sps_scaling_list_data_present_flag = 0, app still - * needs to send in this structure with default matrix values. - * - * Matrix entries are in raster scan order which follows HEVC spec. - */ -typedef struct _VAIQMatrixBufferHEVC -{ - /** - * \brief scaling lists, - * corresponds to same HEVC spec syntax element - * ScalingList[ i ][ MatrixID ][ j ]. - * - * \brief 4x4 scaling, - * correspongs i = 0, MatrixID is in the range of 0 to 5, - * inclusive. And j is in the range of 0 to 15, inclusive. - */ - uint8_t ScalingList4x4[6][16]; - /** - * \brief 8x8 scaling, - * correspongs i = 1, MatrixID is in the range of 0 to 5, - * inclusive. And j is in the range of 0 to 63, inclusive. - */ - uint8_t ScalingList8x8[6][64]; - /** - * \brief 16x16 scaling, - * correspongs i = 2, MatrixID is in the range of 0 to 5, - * inclusive. And j is in the range of 0 to 63, inclusive. - */ - uint8_t ScalingList16x16[6][64]; - /** - * \brief 32x32 scaling, - * correspongs i = 3, MatrixID is in the range of 0 to 1, - * inclusive. And j is in the range of 0 to 63, inclusive. - */ - uint8_t ScalingList32x32[2][64]; - /** - * \brief DC values of the 16x16 scaling lists, - * corresponds to HEVC spec syntax - * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 - * with sizeID = 2 and matrixID in the range of 0 to 5, inclusive. - */ - uint8_t ScalingListDC16x16[6]; - /** - * \brief DC values of the 32x32 scaling lists, - * corresponds to HEVC spec syntax - * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 - * with sizeID = 3 and matrixID in the range of 0 to 1, inclusive. - */ - uint8_t ScalingListDC32x32[2]; -} VAIQMatrixBufferHEVC; - - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DEC_HEVC_H */ diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h deleted file mode 100644 index 644ce3b..0000000 --- a/va/va_dec_jpeg.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2007-2012 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 INTEL 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. - */ - -/** - * \file va_dec_jpeg.h - * \brief The JPEG decoding API - * - * This file contains the \ref api_dec_jpeg "JPEG decoding API". - */ - -#ifndef VA_DEC_JPEG_H -#define VA_DEC_JPEG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * \defgroup api_dec_jpeg JPEG decoding API - * - * This JPEG decoding API supports Baseline profile only. - * - * @{ - */ - -/** - * \brief Picture parameter for JPEG decoding. - * - * This structure holds information from the frame header, along with - * definitions from additional segments. - */ -typedef struct _VAPictureParameterBufferJPEGBaseline { - /** \brief Picture width in pixels. */ - unsigned short picture_width; - /** \brief Picture height in pixels. */ - unsigned short picture_height; - - struct { - /** \brief Component identifier (Ci). */ - unsigned char component_id; - /** \brief Horizontal sampling factor (Hi). */ - unsigned char h_sampling_factor; - /** \brief Vertical sampling factor (Vi). */ - unsigned char v_sampling_factor; - /* \brief Quantization table selector (Tqi). */ - unsigned char quantiser_table_selector; - } components[255]; - /** \brief Number of components in frame (Nf). */ - unsigned char num_components; -} VAPictureParameterBufferJPEGBaseline; - -/** - * \brief Quantization table for JPEG decoding. - * - * This structure holds the complete quantization tables. This is an - * aggregation of all quantization table (DQT) segments maintained by - * the application. i.e. up to 4 quantization tables are stored in - * there for baseline profile. - * - * The #load_quantization_table array can be used as a hint to notify - * the VA driver implementation about which table(s) actually changed - * since the last submission of this buffer. - * - * The #quantiser_table values are specified in zig-zag scan order. - */ -typedef struct _VAIQMatrixBufferJPEGBaseline { - /** \brief Specifies which #quantiser_table is valid. */ - unsigned char load_quantiser_table[4]; - /** \brief Quanziation tables indexed by table identifier (Tqi). */ - unsigned char quantiser_table[4][64]; -} VAIQMatrixBufferJPEGBaseline; - -/** - * \brief Slice parameter for JPEG decoding. - * - * This structure holds information from the scan header, along with - * definitions from additional segments. The associated slice data - * buffer holds all entropy coded segments (ECS) in the scan. - */ -typedef struct _VASliceParameterBufferJPEGBaseline { - /** @name Codec-independent Slice Parameter Buffer base. */ - /**@{*/ - /** \brief Number of bytes in the slice data buffer for this slice. */ - unsigned int slice_data_size; - /** \brief The offset to the first byte of the first MCU. */ - unsigned int slice_data_offset; - /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_xxx. */ - unsigned int slice_data_flag; - /**@}*/ - - /** \brief Scan horizontal position. */ - unsigned int slice_horizontal_position; - /** \brief Scan vertical position. */ - unsigned int slice_vertical_position; - - struct { - /** \brief Scan component selector (Csj). */ - unsigned char component_selector; - /** \brief DC entropy coding table selector (Tdj). */ - unsigned char dc_table_selector; - /** \brief AC entropy coding table selector (Taj). */ - unsigned char ac_table_selector; - } components[4]; - /** \brief Number of components in scan (Ns). */ - unsigned char num_components; - - /** \brief Restart interval definition (Ri). */ - unsigned short restart_interval; - /** \brief Number of MCUs in a scan. */ - unsigned int num_mcus; -} VASliceParameterBufferJPEGBaseline; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DEC_JPEG_H */ diff --git a/va/va_dec_vp8.h b/va/va_dec_vp8.h deleted file mode 100644 index 32830cb..0000000 --- a/va/va_dec_vp8.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2007-2012 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 INTEL 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. - */ - -/** - * \file va_dec_vp.h - * \brief VP8 decoding API - * - * This file contains the \ref api_dec_vp8 "VP8 decoding API". - */ - -#ifndef VA_DEC_VP8_H -#define VA_DEC_VP8_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_dec_vp8 VP8 decoding API - * - * @{ - */ - -/** - * \brief VPX Bool Coder Context structure - * - * This common structure is defined for potential sharing by other VP formats - * - */ -typedef struct _VABoolCoderContextVPX -{ - /* partition 0 "range" */ - unsigned char range; - /* partition 0 "value" */ - unsigned char value; - /* - * 'partition 0 number of shifts before an output byte is available' - * it is the number of remaining bits in 'value' for decoding, range [0, 7]. - */ - - unsigned char count; -} VABoolCoderContextVPX; - -/** - * \brief VP8 Decoding Picture Parameter Buffer Structure - * - * This structure conveys frame level parameters and should be sent once - * per frame. - * - */ -typedef struct _VAPictureParameterBufferVP8 -{ - /* frame width in pixels */ - unsigned int frame_width; - /* frame height in pixels */ - unsigned int frame_height; - - /* specifies the "last" reference frame */ - VASurfaceID last_ref_frame; - /* specifies the "golden" reference frame */ - VASurfaceID golden_ref_frame; - /* specifies the "alternate" referrence frame */ - VASurfaceID alt_ref_frame; - /* specifies the out-of-loop deblocked frame, not used currently */ - VASurfaceID out_of_loop_frame; - - union { - struct { - /* same as key_frame in bitstream syntax, 0 means a key frame */ - unsigned int key_frame : 1; - /* same as version in bitstream syntax */ - unsigned int version : 3; - /* same as segmentation_enabled in bitstream syntax */ - unsigned int segmentation_enabled : 1; - /* same as update_mb_segmentation_map in bitstream syntax */ - unsigned int update_mb_segmentation_map : 1; - /* same as update_segment_feature_data in bitstream syntax */ - unsigned int update_segment_feature_data : 1; - /* same as filter_type in bitstream syntax */ - unsigned int filter_type : 1; - /* same as sharpness_level in bitstream syntax */ - unsigned int sharpness_level : 3; - /* same as loop_filter_adj_enable in bitstream syntax */ - unsigned int loop_filter_adj_enable : 1; - /* same as mode_ref_lf_delta_update in bitstream syntax */ - unsigned int mode_ref_lf_delta_update : 1; - /* same as sign_bias_golden in bitstream syntax */ - unsigned int sign_bias_golden : 1; - /* same as sign_bias_alternate in bitstream syntax */ - unsigned int sign_bias_alternate : 1; - /* same as mb_no_coeff_skip in bitstream syntax */ - unsigned int mb_no_coeff_skip : 1; - /* flag to indicate that loop filter should be disabled */ - unsigned int loop_filter_disable : 1; - } bits; - unsigned int value; - } pic_fields; - - /* - * probabilities of the segment_id decoding tree and same as - * mb_segment_tree_probs in the spec. - */ - unsigned char mb_segment_tree_probs[3]; - - /* Post-adjustment loop filter levels for the 4 segments */ - unsigned char loop_filter_level[4]; - /* loop filter deltas for reference frame based MB level adjustment */ - char loop_filter_deltas_ref_frame[4]; - /* loop filter deltas for coding mode based MB level adjustment */ - char loop_filter_deltas_mode[4]; - - /* same as prob_skip_false in bitstream syntax */ - unsigned char prob_skip_false; - /* same as prob_intra in bitstream syntax */ - unsigned char prob_intra; - /* same as prob_last in bitstream syntax */ - unsigned char prob_last; - /* same as prob_gf in bitstream syntax */ - unsigned char prob_gf; - - /* - * list of 4 probabilities of the luma intra prediction mode decoding - * tree and same as y_mode_probs in frame header - */ - unsigned char y_mode_probs[4]; - /* - * list of 3 probabilities of the chroma intra prediction mode decoding - * tree and same as uv_mode_probs in frame header - */ - unsigned char uv_mode_probs[3]; - /* - * updated mv decoding probabilities and same as mv_probs in - * frame header - */ - unsigned char mv_probs[2][19]; - - VABoolCoderContextVPX bool_coder_ctx; - -} VAPictureParameterBufferVP8; - -/** - * \brief VP8 Slice Parameter Buffer Structure - * - * This structure conveys parameters related to data partitions and should be - * sent once per frame. Slice data buffer of VASliceDataBufferType is used - * to send the partition data. - * - */ -typedef struct _VASliceParameterBufferVP8 -{ - /* - * number of bytes in the slice data buffer for the partitions - */ - unsigned int slice_data_size; - /* - * offset to the first byte of partition data (control partition) - */ - unsigned int slice_data_offset; - /* - * see VA_SLICE_DATA_FLAG_XXX definitions - */ - unsigned int slice_data_flag; - /* - * offset to the first bit of MB from the first byte of partition data(slice_data_offset) - */ - unsigned int macroblock_offset; - - /* - * Partitions - * (1<lvl[seg][ref][mode] in VP9 code, - * where m is [ref], and n is [mode] in FilterLevel[m][n]. - */ - uint8_t filter_level[4][2]; - /** \brief Specifies per segment Luma AC quantization scale. - * Corresponding to y_dequant[qindex][1] in vp9_mb_init_quantizer() - * function of VP9 code. - */ - int16_t luma_ac_quant_scale; - /** \brief Specifies per segment Luma DC quantization scale. - * Corresponding to y_dequant[qindex][0] in vp9_mb_init_quantizer() - * function of VP9 code. - */ - int16_t luma_dc_quant_scale; - /** \brief Specifies per segment Chroma AC quantization scale. - * Corresponding to uv_dequant[qindex][1] in vp9_mb_init_quantizer() - * function of VP9 code. - */ - int16_t chroma_ac_quant_scale; - /** \brief Specifies per segment Chroma DC quantization scale. - * Corresponding to uv_dequant[qindex][0] in vp9_mb_init_quantizer() - * function of VP9 code. - */ - int16_t chroma_dc_quant_scale; - - /**@}*/ - -} VASegmentParameterVP9; - - - -/** - * \brief VP9 Slice Parameter Buffer Structure - * - * This structure conveys parameters related to segmentation data and should be - * sent once per frame. - * - * When segmentation is disabled, only SegParam[0] has valid values, - * all other entries should be populated with 0. - * Otherwise, all eight entries should be valid. - * - * Slice data buffer of VASliceDataBufferType is used - * to send the bitstream which should include whole or part of partition 0 - * (at least compressed header) to the end of frame. - * - */ -typedef struct _VASliceParameterBufferVP9 -{ - /**@{*/ - /** \brief The byte count of current frame in the bitstream buffer, - * starting from first byte of the buffer. - * It uses the name slice_data_size to be consitent with other codec, - * but actually means frame_data_size. - */ - uint32_t slice_data_size; - /** - * offset to the first byte of partition data (control partition) - */ - uint32_t slice_data_offset; - /** - * see VA_SLICE_DATA_FLAG_XXX definitions - */ - uint32_t slice_data_flag; - - /** - * \brief per segment information - */ - VASegmentParameterVP9 seg_param[8]; - - /**@}*/ - -} VASliceParameterBufferVP9; - - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_DEC_VP9_H */ diff --git a/va/va_drmcommon.h b/va/va_drmcommon.h deleted file mode 100644 index 76820a3..0000000 --- a/va/va_drmcommon.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * va_drmcommon.h - Common utilities for DRM-based drivers - * - * Copyright (c) 2012 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 INTEL 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_DRM_COMMON_H -#define VA_DRM_COMMON_H - -/** \brief DRM authentication type. */ -enum { - /** \brief Disconnected. */ - VA_DRM_AUTH_NONE = 0, - /** - * \brief Connected. Authenticated with DRI1 protocol. - * - * @deprecated - * This is a deprecated authentication type. All DRI-based drivers have - * been migrated to use the DRI2 protocol. Newly written drivers shall - * use DRI2 protocol only, or a custom authentication means. e.g. opt - * for authenticating on the VA driver side, instead of libva side. - */ - VA_DRM_AUTH_DRI1 = 1, - /** - * \brief Connected. Authenticated with DRI2 protocol. - * - * This is only useful to VA/X11 drivers. The libva-x11 library provides - * a helper function VA_DRI2Authenticate() for authenticating the - * connection. However, DRI2 conformant drivers don't need to call that - * function since authentication happens on the libva side, implicitly. - */ - VA_DRM_AUTH_DRI2 = 2, - /** - * \brief Connected. Authenticated with some alternate raw protocol. - * - * This authentication mode is mainly used in non-VA/X11 drivers. - * Authentication happens through some alternative method, at the - * discretion of the VA driver implementation. - */ - VA_DRM_AUTH_CUSTOM = 3 -}; - -/** \brief Base DRM state. */ -struct drm_state { - /** \brief DRM connection descriptor. */ - int fd; - /** \brief DRM authentication type. */ - int auth_type; -}; - -/** \brief Kernel DRM buffer memory type. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM 0x10000000 -/** \brief DRM PRIME memory type. */ -#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000 - -#endif /* VA_DRM_COMMON_H */ diff --git a/va/va_enc_h264.h b/va/va_enc_h264.h deleted file mode 100644 index 2e7eb8d..0000000 --- a/va/va_enc_h264.h +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (c) 2007-2011 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 INTEL 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. - */ - -/** - * \file va_enc_h264.h - * \brief The H.264 encoding API - * - * This file contains the \ref api_enc_h264 "H.264 encoding API". - */ - -#ifndef VA_ENC_H264_H -#define VA_ENC_H264_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_enc_h264 H.264 encoding API - * - * @{ - */ - -/** - * @name Picture flags - * - * Those flags flags are meant to signal when a picture marks the end - * of a sequence, a stream, or even both at once. - * - * @{ - */ -/** - * \brief Marks the last picture in the sequence. - * - * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame. - */ -#define H264_LAST_PICTURE_EOSEQ 0x01 -/** - * \brief Marks the last picture in the stream. - * - * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame. - */ -#define H264_LAST_PICTURE_EOSTREAM 0x02 -/**@}*/ - -/** - * \brief Packed header types specific to H.264 encoding. - * - * Types of packed headers generally used for H.264 encoding. Each - * associated packed header data buffer shall contain the start code - * prefix 0x000001 followed by the complete NAL unit, thus also - * including the \c nal_unit_type. - * - * Note: the start code prefix can contain an arbitrary number of leading - * zeros. The driver will skip them for emulation prevention bytes insertion, - * if necessary. - */ -typedef enum { - /** - * \brief Packed Sequence Parameter Set (SPS). - * - * The corresponding packed header data buffer shall contain the - * complete seq_parameter_set_rbsp() syntax element. - * - * Note: packed \c nal_unit_type shall be equal to 7. - */ - VAEncPackedHeaderH264_SPS = VAEncPackedHeaderSequence, - /** - * \brief Packed Picture Parameter Set (PPS). - * - * The corresponding packed header data buffer shall contain the - * complete pic_parameter_set_rbsp() syntax element. - * - * Note: packed \c nal_unit_type shall be equal to 8. - */ - VAEncPackedHeaderH264_PPS = VAEncPackedHeaderPicture, - /** - * \brief Packed slice header. - * - * The corresponding packed header data buffer shall contain the - * \c slice_header() syntax element only, along with any start - * code prefix and NAL unit type preceeding it. i.e. this means - * that the buffer does not contain any of the \c slice_data() or - * the \c rbsp_slice_trailing_bits(). - * - * Note: packed \c nal_unit_type shall be equal to 1 (non-IDR - * picture), or 5 (IDR picture). - */ - VAEncPackedHeaderH264_Slice = VAEncPackedHeaderSlice, - /** - * \brief Packed Supplemental Enhancement Information (SEI). - * - * The corresponding packed header data buffer shall contain the - * complete sei_rbsp() syntax element, thus including several - * sei_message() elements if necessary. - * - * Note: packed \c nal_unit_type shall be equal to 6. - */ - VAEncPackedHeaderH264_SEI = (VAEncPackedHeaderMiscMask | 1), -} VAEncPackedHeaderTypeH264; - -/** - * \brief Sequence parameter for H.264 encoding in baseline, main & high - * profiles. - * - * This structure holds information for \c seq_parameter_set_data() as - * defined by the H.264 specification. - * - * If packed sequence headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderSequence ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - * If \c seq_scaling_matrix_present_flag is set to \c 1, then a - * #VAIQMatrixBufferH264 buffer shall also be provided within the same - * \c vaRenderPicture() call as this sequence parameter buffer. - */ -typedef struct _VAEncSequenceParameterBufferH264 { - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char seq_parameter_set_id; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char level_idc; - /** \brief Period between I frames. */ - unsigned int intra_period; - /** \brief Period between IDR frames. */ - unsigned int intra_idr_period; - /** \brief Period between I/P frames. */ - unsigned int ip_period; - /** - * \brief Initial bitrate set for this sequence in CBR or VBR modes. - * - * This field represents the initial bitrate value for this - * sequence if CBR or VBR mode is used, i.e. if the encoder - * pipeline was created with a #VAConfigAttribRateControl - * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. - * - * The bitrate can be modified later on through - * #VAEncMiscParameterRateControl buffers. - */ - unsigned int bits_per_second; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int max_num_ref_frames; - /** \brief Picture width in macroblocks. */ - unsigned short picture_width_in_mbs; - /** \brief Picture height in macroblocks. */ - unsigned short picture_height_in_mbs; - - union { - struct { - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int chroma_format_idc : 2; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int frame_mbs_only_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int mb_adaptive_frame_field_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int seq_scaling_matrix_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int direct_8x8_inference_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int log2_max_frame_num_minus4 : 4; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int pic_order_cnt_type : 2; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int log2_max_pic_order_cnt_lsb_minus4 : 4; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int delta_pic_order_always_zero_flag : 1; - } bits; - unsigned int value; - } seq_fields; - - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char bit_depth_luma_minus8; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char bit_depth_chroma_minus8; - - /** if pic_order_cnt_type == 1 */ - /**@{*/ - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char num_ref_frames_in_pic_order_cnt_cycle; - /** \brief Same as the H.264 bitstream syntax element. */ - int offset_for_non_ref_pic; - /** \brief Same as the H.264 bitstream syntax element. */ - int offset_for_top_to_bottom_field; - /** \brief Same as the H.264 bitstream syntax element. */ - int offset_for_ref_frame[256]; - /**@}*/ - - /** @name Cropping (optional) */ - /**@{*/ - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char frame_cropping_flag; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int frame_crop_left_offset; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int frame_crop_right_offset; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int frame_crop_top_offset; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int frame_crop_bottom_offset; - /**@}*/ - - /** @name VUI parameters (optional) */ - /**@{*/ - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char vui_parameters_present_flag; - union { - struct { - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int aspect_ratio_info_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int timing_info_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int bitstream_restriction_flag : 1; - /** \brief Range: 0 to 16, inclusive. */ - unsigned int log2_max_mv_length_horizontal : 5; - /** \brief Range: 0 to 16, inclusive. */ - unsigned int log2_max_mv_length_vertical : 5; - } bits; - unsigned int value; - } vui_fields; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char aspect_ratio_idc; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int sar_width; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int sar_height; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int num_units_in_tick; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int time_scale; - /**@}*/ -} VAEncSequenceParameterBufferH264; - -/** - * \brief Picture parameter for H.264 encoding in baseline, main & high - * profiles. - * - * This structure holds information for \c pic_parameter_set_rbsp() as - * defined by the H.264 specification. - * - * If packed picture headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderPicture ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - * If \c pic_scaling_matrix_present_flag is set to \c 1, then a - * #VAIQMatrixBufferH264 buffer shall also be provided within the same - * \c vaRenderPicture() call as this picture parameter buffer. - */ -typedef struct _VAEncPictureParameterBufferH264 { - /** - * \brief Information about the picture to be encoded. - * - * See #VAPictureH264 for further description of each field. - * Note that CurrPic.picture_id represents the reconstructed - * (decoded) picture. User provides a scratch VA surface ID here. - */ - VAPictureH264 CurrPic; - /** - * \brief Decoded Picture Buffer (DPB). - * - * This array represents the list of reconstructed (decoded) - * frames used as reference. It is important to keep track of - * reconstructed frames so that they can be used later on as - * reference for P or B-frames encoding. - */ - VAPictureH264 ReferenceFrames[16]; - /** - * \brief Output encoded bitstream. - * - * \ref coded_buf has type #VAEncCodedBufferType. It should be - * large enough to hold the compressed NAL slice and possibly SPS - * and PPS NAL units. - */ - VABufferID coded_buf; - - /** \brief The picture parameter set referred to in the slice header. */ - unsigned char pic_parameter_set_id; - /** \brief The active sequence parameter set. Range: 0 to 31, inclusive. */ - unsigned char seq_parameter_set_id; - - /** - * \brief OR'd flags describing whether the picture is the last one or not. - * - * This fields holds 0 if the picture to be encoded is not the last - * one in the stream or sequence. Otherwise, it is a combination of - * \ref H264_LAST_PICTURE_EOSEQ or \ref H264_LAST_PICTURE_EOSTREAM. - */ - unsigned char last_picture; - - /** \brief The picture identifier. - * Range: 0 to \f$2^{log2\_max\_frame\_num\_minus4 + 4} - 1\f$, inclusive. - */ - unsigned short frame_num; - - /** \brief \c pic_init_qp_minus26 + 26. */ - unsigned char pic_init_qp; - /** \brief Maximum reference index for reference picture list 0. - * Range: 0 to 31, inclusive. - */ - unsigned char num_ref_idx_l0_active_minus1; - /** \brief Maximum reference index for reference picture list 1. - * Range: 0 to 31, inclusive. - */ - unsigned char num_ref_idx_l1_active_minus1; - - /** \brief Range: -12 to 12, inclusive. */ - signed char chroma_qp_index_offset; - /** \brief Range: -12 to 12, inclusive. */ - signed char second_chroma_qp_index_offset; - - union { - struct { - /** \brief Is picture an IDR picture? */ - unsigned int idr_pic_flag : 1; - /** \brief Is picture a reference picture? */ - unsigned int reference_pic_flag : 2; - /** \brief Selects CAVLC (0) or CABAC (1) entropy coding mode. */ - unsigned int entropy_coding_mode_flag : 1; - /** \brief Is weighted prediction applied to P slices? */ - unsigned int weighted_pred_flag : 1; - /** \brief Range: 0 to 2, inclusive. */ - unsigned int weighted_bipred_idc : 2; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int constrained_intra_pred_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int transform_8x8_mode_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int deblocking_filter_control_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int redundant_pic_cnt_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int pic_order_present_flag : 1; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned int pic_scaling_matrix_present_flag : 1; - } bits; - unsigned int value; - } pic_fields; -} VAEncPictureParameterBufferH264; - -/** - * \brief Slice parameter for H.264 encoding in baseline, main & high profiles. - * - * This structure holds information for \c - * slice_layer_without_partitioning_rbsp() as defined by the H.264 - * specification. - * - * If packed slice headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderSlice ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - * If per-macroblock encoder configuration is needed, \c macroblock_info - * references a buffer of type #VAEncMacroblockParameterBufferH264. This - * buffer is not passed to vaRenderPicture() and it can be re-used - * without re-allocating the whole buffer. - */ -typedef struct _VAEncSliceParameterBufferH264 { - /** \brief Starting MB address for this slice. */ - unsigned int macroblock_address; - /** \brief Number of macroblocks in this slice. */ - unsigned int num_macroblocks; - /** - * \brief Per-MB encoder configuration buffer, or \c VA_INVALID_ID. - * - * If per-MB encoder configuration is needed, then \ref macroblock_info - * references a buffer of type #VAEncMacroblockParameterBufferH264 - * (\c VAEncMacroblockParameterBufferType). Otherwise, buffer id - * is set to \c VA_INVALID_ID and per-MB configuration is derived - * from this slice parameter. - * - * The \c macroblock_info buffer must hold \ref num_macroblocks - * elements. - */ - VABufferID macroblock_info; - /** \brief Slice type. - * Range: 0..2, 5..7, i.e. no switching slices. - */ - unsigned char slice_type; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char pic_parameter_set_id; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned short idr_pic_id; - - /** @name If pic_order_cnt_type == 0 */ - /**@{*/ - /** \brief The picture order count modulo MaxPicOrderCntLsb. */ - unsigned short pic_order_cnt_lsb; - /** \brief Valid if \c pic_order_present_flag and this is a bottom field. */ - int delta_pic_order_cnt_bottom; - /**@}*/ - /** @name If pic_order_cnt_type == 1 && !delta_pic_order_always_zero_flag */ - /**@{*/ - /** \brief [0]: top, [1]: bottom. */ - int delta_pic_order_cnt[2]; - /**@}*/ - - /** @name If slice_type == B */ - /**@{*/ - unsigned char direct_spatial_mv_pred_flag; - /**@}*/ - - /** @name If slice_type == P */ - /**@{*/ - /** \brief Specifies if - * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l0_active_minus1 or - * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l1_active_minus1 are - * overriden by the values for this slice. - */ - unsigned char num_ref_idx_active_override_flag; - /** \brief Maximum reference index for reference picture list 0. - * Range: 0 to 31, inclusive. - */ - unsigned char num_ref_idx_l0_active_minus1; - /** \brief Maximum reference index for reference picture list 1. - * Range: 0 to 31, inclusive. - */ - unsigned char num_ref_idx_l1_active_minus1; - /** \brief Reference picture list 0 (for P slices). */ - VAPictureH264 RefPicList0[32]; - /** \brief Reference picture list 1 (for B slices). */ - VAPictureH264 RefPicList1[32]; - /**@}*/ - - /** @name pred_weight_table() */ - /**@{*/ - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char luma_log2_weight_denom; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char chroma_log2_weight_denom; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char luma_weight_l0_flag; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short luma_weight_l0[32]; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short luma_offset_l0[32]; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char chroma_weight_l0_flag; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short chroma_weight_l0[32][2]; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short chroma_offset_l0[32][2]; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char luma_weight_l1_flag; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short luma_weight_l1[32]; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short luma_offset_l1[32]; - /** \brief Same as the H.264 bitstream syntax element. */ - unsigned char chroma_weight_l1_flag; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short chroma_weight_l1[32][2]; - /** \brief Same as the H.264 bitstream syntax element. */ - signed short chroma_offset_l1[32][2]; - /**@}*/ - - /** \brief Range: 0 to 2, inclusive. */ - unsigned char cabac_init_idc; - /** \brief Same as the H.264 bitstream syntax element. */ - signed char slice_qp_delta; - /** @name If deblocking_filter_control_present_flag */ - /**@{*/ - /** \brief Range: 0 to 2, inclusive. */ - unsigned char disable_deblocking_filter_idc; - /** \brief Same as the H.264 bitstream syntax element. */ - signed char slice_alpha_c0_offset_div2; - /** \brief Same as the H.264 bitstream syntax element. */ - signed char slice_beta_offset_div2; - /**@}*/ -} VAEncSliceParameterBufferH264; - -/** - * @name Macroblock neighbour availability bits - * - * \anchor api_enc_h264_mb_pred_avail_bits - * Definitions for macroblock neighbour availability bits used in - * intra prediction mode (non MBAFF only). - * - * @{ - */ -/** \brief References macroblock in the top-left corner. */ -#define VA_MB_PRED_AVAIL_TOP_LEFT (1 << 2) -/** \brief References macroblock above the current macroblock. */ -#define VA_MB_PRED_AVAIL_TOP (1 << 4) -/** \brief References macroblock in the top-right corner. */ -#define VA_MB_PRED_AVAIL_TOP_RIGHT (1 << 3) -/** \brief References macroblock on the left of the current macroblock. */ -#define VA_MB_PRED_AVAIL_LEFT (1 << 6) -/**@}*/ - -/** - * \brief Macroblock parameter for H.264 encoding in baseline, main & high - * profiles. - * - * This structure holds per-macroblock information. The buffer must be - * allocated with as many elements (macroblocks) as necessary to fit - * the slice to be encoded. Besides, the per-macroblock records must - * be written in a strict raster order and with no gap. i.e. every - * macroblock, regardless of its type, shall have an entry. - */ -typedef struct _VAEncMacroblockParameterBufferH264 { - /** - * \brief Quantization parameter. - * - * Requested quantization parameter. Range: 0 to 51, inclusive. - * If \ref qp is set to 0xff, then the actual value is derived - * from the slice-level value: \c pic_init_qp + \c slice_qp_delta. - */ - unsigned char qp; - - union { - /** @name Data for intra macroblock */ - /**@{*/ - struct { - union { - /** - * \brief Flag specified to override MB neighbour - * availability bits from VME stage. - * - * This flag specifies that macroblock neighbour - * availability bits from the VME stage are overriden - * by the \ref pred_avail_flags hereunder. - */ - unsigned int pred_avail_override_flag : 1; - /** - * \brief Bitwise representation of which macroblocks - * are available for intra prediction. - * - * If the slice is intra-coded, this field represents - * the macroblocks available for intra prediction. - * See \ref api_enc_h264_mb_pred_avail_bits - * "macroblock neighbour availability" bit definitions. - */ - unsigned int pred_avail_flags : 8; - } bits; - unsigned int value; - } intra_fields; - /**@}*/ - - /** @name Data for inter macroblock */ - /**@{*/ - struct { - union { - } bits; - unsigned int value; - } inter_fields; - /**@}*/ - } info; -} VAEncMacroblockParameterBufferH264; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_ENC_H264_H */ diff --git a/va/va_enc_hevc.h b/va/va_enc_hevc.h deleted file mode 100644 index 5cd614b..0000000 --- a/va/va_enc_hevc.h +++ /dev/null @@ -1,701 +0,0 @@ -/* - * Copyright (c) 2007-2014 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 INTEL 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. - */ - -/** - * \file va_enc_hevc.h - * \brief The HEVC encoding API - * - * This file contains the \ref api_enc_hevc "HEVC encoding API". - * - */ - -#ifndef VA_ENC_HEVC_H -#define VA_ENC_HEVC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * \defgroup api_enc_hevc HEVC encoding API - * - * @{ - */ - -/** - * @name Picture flags - * - * Those flags flags are meant to signal when a picture marks the end - * of a sequence, a stream, or even both at once. - * - * @{ - */ -/** - * \brief Marks the last picture in the sequence. - * - * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame. - */ -#define HEVC_LAST_PICTURE_EOSEQ 0x01 -/** - * \brief Marks the last picture in the stream. - * - * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame. - */ -#define HEVC_LAST_PICTURE_EOSTREAM 0x02 -/**@}*/ - -/** - * \brief Packed header types specific to HEVC encoding. - * - * Types of packed headers generally used for HEVC encoding. Each - * associated packed header data buffer shall contain the start code - * prefix 0x000001 followed by the complete NAL unit, thus also - * including the \c nal_unit_type. - * - * Note: the start code prefix can contain an arbitrary number of leading - * zeros. The driver will skip them for emulation prevention bytes insertion, - * if necessary. - */ -typedef enum { - /** - * \brief Packed Video Parameter Set (VPS). - * - * The corresponding packed header data buffer shall contain the - * complete video_parameter_set_rbsp() syntax element. - * - * Note: packed \c nal_unit_type shall be equal to 32. - */ - VAEncPackedHeaderHEVC_VPS = VAEncPackedHeaderSequence, - /** - * \brief Packed Sequence Parameter Set (SPS). - * - * The corresponding packed header data buffer shall contain the - * complete seq_parameter_set_rbsp() syntax element. - * - * Note: packed \c nal_unit_type shall be equal to 33. - */ - VAEncPackedHeaderHEVC_SPS = VAEncPackedHeaderSequence, - /** - * \brief Packed Picture Parameter Set (PPS). - * - * The corresponding packed header data buffer shall contain the - * complete pic_parameter_set_rbsp() syntax element. - * - * Note: packed \c nal_unit_type shall be equal to 34. - */ - VAEncPackedHeaderHEVC_PPS = VAEncPackedHeaderPicture, - /** - * \brief Packed slice header. - * - * The corresponding packed header data buffer shall contain the - * \c slice_header() syntax element only, along with any start - * code prefix and NAL unit type preceeding it. i.e. this means - * that the buffer does not contain any of the \c slice_data() or - * the \c rbsp_slice_trailing_bits(). - * - * Note: packed \c nal_unit_type shall be equal to 0 to 9 (non-IRAP - * picture), or 16 to 21 (IRAP picture). - */ - VAEncPackedHeaderHEVC_Slice = VAEncPackedHeaderSlice, - /** - * \brief Packed Supplemental Enhancement Information (SEI). - * - * The corresponding packed header data buffer shall contain the - * complete sei_rbsp() syntax element, thus including several - * sei_message() elements if necessary. - * - * Note: packed \c nal_unit_type shall be equal to 39 or 40. - */ - VAEncPackedHeaderHEVC_SEI = (VAEncPackedHeaderMiscMask | 1), -} VAEncPackedHeaderTypeHEVC; - -/** - * \brief Sequence parameter for HEVC encoding in main & main 10 - * profiles. - * - * This structure holds information for \c seq_parameter_set_data() as - * defined by the HEVC specification. - * - * If packed sequence headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderSequence ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - * If \c seq_scaling_matrix_present_flag is set to \c 1, then a - * #VAQMatrixBufferHEVC buffer shall also be provided within the same - * \c vaRenderPicture() call as this sequence parameter buffer. - */ -typedef struct _VAEncSequenceParameterBufferHEVC { - /** \brief Same as the HEVC bitstream syntax element. - * value range [1..2]. - */ - uint8_t general_profile_idc; - /** \brief Same as the HEVC bitstream syntax element. - * general_level_idc shall be set equal to a value of 30 times the level - * numbers allowed [1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2] - */ - uint8_t general_level_idc; - /** \brief Same as the HEVC bitstream syntax element. - * Only value 0 is allowed for level value below 4, exclusive. - */ - uint8_t general_tier_flag; - /** \brief Period between I frames. */ - uint32_t intra_period; - /** \brief Period between IDR frames. */ - uint32_t intra_idr_period; - /** \brief Period between I/P frames. */ - uint32_t ip_period; - /** - * \brief Initial bitrate set for this sequence in CBR or VBR modes. - * - * This field represents the initial bitrate value for this - * sequence if CBR or VBR mode is used, i.e. if the encoder - * pipeline was created with a #VAConfigAttribRateControl - * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. - * - * The bitrate can be modified later on through - * #VAEncMiscParameterRateControl buffers. - */ - uint32_t bits_per_second; - /** \brief Picture width in pixel samples. - * Its value must be multiple of min CU size. - */ - uint16_t pic_width_in_luma_samples; - /** \brief Picture height in pixel samples. - * Its value must be multiple of min CU size. - */ - uint16_t pic_height_in_luma_samples; - - union { - struct { - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t chroma_format_idc : 2; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t separate_colour_plane_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t bit_depth_luma_minus8 : 3; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t bit_depth_chroma_minus8 : 3; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t scaling_list_enabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t strong_intra_smoothing_enabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t amp_enabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t sample_adaptive_offset_enabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t pcm_enabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t pcm_loop_filter_disabled_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t sps_temporal_mvp_enabled_flag : 1; - - uint32_t reserved_bits : 16; - } bits; - uint32_t value; - } seq_fields; - - /** \brief Same as the HEVC bitstream syntax element. - * value range [0..3] - */ - uint8_t log2_min_luma_coding_block_size_minus3; - - /** \brief Same as the HEVC bitstream syntax element. - */ - uint8_t log2_diff_max_min_luma_coding_block_size; - - /** \brief Same as the HEVC bitstream syntax element. - * value range [0..3] - */ - uint8_t log2_min_transform_block_size_minus2; - - /** \brief Same as the HEVC bitstream syntax element. - */ - uint8_t log2_diff_max_min_transform_block_size; - - /** \brief Same as the HEVC bitstream syntax element. - * value range [2] - */ - uint8_t max_transform_hierarchy_depth_inter; - - /** \brief Same as the HEVC bitstream syntax element. - * value range [2] - */ - uint8_t max_transform_hierarchy_depth_intra; - - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t pcm_sample_bit_depth_luma_minus1; - - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t pcm_sample_bit_depth_chroma_minus1; - - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t log2_min_pcm_luma_coding_block_size_minus3; - - /** \brief Derived from the HEVC bitstream syntax element. - * log2_min_pcm_luma_coding_block_size_minus3 + - * log2_diff_max_min_pcm_luma_coding_block_size - */ - uint32_t log2_max_pcm_luma_coding_block_size_minus3; - - /** @name VUI parameters (optional) */ - /**@{*/ - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t vui_parameters_present_flag; - union { - struct { - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t aspect_ratio_info_present_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t neutral_chroma_indication_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t field_seq_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t vui_timing_info_present_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t bitstream_restriction_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t tiles_fixed_structure_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t motion_vectors_over_pic_boundaries_flag : 1; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t restricted_ref_pic_lists_flag : 1; - /** \brief Range: 0 to 16, inclusive. */ - uint32_t log2_max_mv_length_horizontal : 5; - /** \brief Range: 0 to 16, inclusive. */ - uint32_t log2_max_mv_length_vertical : 5; - } bits; - uint32_t value; - } vui_fields; - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t aspect_ratio_idc; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t sar_width; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t sar_height; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t vui_num_units_in_tick; - /** \brief Same as the HEVC bitstream syntax element. */ - uint32_t vui_time_scale; - /** \brief Same as the HEVC bitstream syntax element. */ - uint16_t min_spatial_segmentation_idc; - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t max_bytes_per_pic_denom; - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t max_bits_per_min_cu_denom; - /**@}*/ -} VAEncSequenceParameterBufferHEVC; - -/**************************** - * HEVC data structures - ****************************/ -/** - * \brief Picture parameter for HEVC encoding in main & main 10 - * profiles. - * - * This structure holds information for \c pic_parameter_set_rbsp() as - * defined by the HEVC specification. - * - * If packed picture headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderPicture ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - * If \c pic_scaling_matrix_present_flag is set to \c 1, then a - * #VAQMatrixBufferHEVC buffer shall also be provided within the same - * \c vaRenderPicture() call as this picture parameter buffer. - */ -typedef struct _VAEncPictureParameterBufferHEVC { - /** - * \brief Information about the picture to be encoded. - * - * See #VAPictureHEVC for further description of each field. - * Note that decoded_curr_pic.picture_id represents the reconstructed - * (decoded) picture. User provides a scratch VA surface ID here. - * Long term reference and RPS related fields should be set to 0 - * and ignored. - */ - VAPictureHEVC decoded_curr_pic; - /** - * \brief Decoded Picture Buffer (DPB). - * - * This array represents the list of reconstructed (decoded) - * frames used as reference. It is important to keep track of - * reconstructed frames so that they can be used later on as - * reference for P or B-frames encoding. - */ - VAPictureHEVC reference_frames[15]; - /** - * \brief Output encoded bitstream. - * - * \ref coded_buf has type #VAEncCodedBufferType. It should be - * large enough to hold the compressed NAL slice and possibly VPS, SPS - * and PPS NAL units, and other NAL units such as SEI. - */ - VABufferID coded_buf; - - /** \brief collocated reference picture buffer index of ReferenceFrames[]. - * Please note it is different from HEVC syntac element collocated_ref_idx. - * When the HEVC syntax element slice_temporal_mvp_enable_flag takes value 0, - * collocated_ref_pic_index should take value 0xFF. . - * Range: [0..14, 0xFF] - */ - uint8_t collocated_ref_pic_index; - - /** - * \brief OR'd flags describing whether the picture is the last one or not. - * - * This fields holds 0 if the picture to be encoded is not the last - * one in the stream or sequence. Otherwise, it is a combination of - * \ref HEVC_LAST_PICTURE_EOSEQ or \ref HEVC_LAST_PICTURE_EOSTREAM. - */ - uint8_t last_picture; - - /** \brief \c init_qp_minus26 + 26. */ - uint8_t pic_init_qp; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t diff_cu_qp_delta_depth; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - int8_t pps_cb_qp_offset; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - int8_t pps_cr_qp_offset; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t num_tile_columns_minus1; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t num_tile_rows_minus1; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t column_width_minus1[19]; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t row_height_minus1[21]; - - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint8_t log2_parallel_merge_level_minus2; - - /** \brief Application may set the CTU bit size limit based on - * spec requirement (A.3.2), or other value for special purpose. - * If the value is set 0, no bit size limit is checked. - */ - uint8_t ctu_max_bitsize_allowed; - - /** \brief Maximum reference index for reference picture list 0. - * value range: [0..14]. - */ - uint8_t num_ref_idx_l0_default_active_minus1; - - /** \brief Maximum reference index for reference picture list 1. - * value range: [0..14]. - */ - uint8_t num_ref_idx_l1_default_active_minus1; - - /** \brief PPS header - * Used by GPU to generate new slice headers in slice size control. - * value range: [0..63]. - */ - uint8_t slice_pic_parameter_set_id; - - /** \brief NAL unit type - * Used by GPU to generate new slice headers in slice size control. - * value range: [0..63]. - */ - uint8_t nal_unit_type; - - union { - struct { - /** \brief Is picture an IDR picture? */ - uint32_t idr_pic_flag : 1; - /** \brief Picture type. - * I - 1; - * P - 2; - * B - 3; - * B1 - 4; - * B2 - 5; - * B1 and B2 are frame types for hierachical B, explanation - * can refer to num_b_in_gop[]. - */ - uint32_t coding_type : 3; - /** \brief Is picture a reference picture? */ - uint32_t reference_pic_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t dependent_slice_segments_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t sign_data_hiding_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t constrained_intra_pred_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t transform_skip_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t cu_qp_delta_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t weighted_pred_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t weighted_bipred_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t transquant_bypass_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t tiles_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t entropy_coding_sync_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t loop_filter_across_tiles_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t pps_loop_filter_across_slices_enabled_flag : 1; - /** \brief A combination of HEVC syntax element of - * sps_scaling_list_data_present_flag and - * pps_scaling_list_data_present_flag - * when scaling_list_enable_flag is 0, it must be 0. - */ - uint32_t scaling_list_data_present_flag : 1; - /** \brief indicate the current picture contains significant - * screen contents (text, characters, etc.) or animated image. - * GPU may want to treat them differently from normal video. - * For example, encoder may choose a small transform unit size - * and may use transform skip mode. - */ - uint32_t screen_content_flag : 1; - /** - * When either weighted_pred_flag or weighted_bipred_flag is - * turned on, the flag enable_gpu_weighted_prediction requests - * GPU to determine weighted prediction factors. In this case, - * the following parameters in slice control data structure - * shall be ignored: - * luma_log2_weight_denom, delta_chroma_log2_weight_denom, - * luma_offset_l0[15], luma_offset_l1[15], - * delta_luma_weight_l0[15], delta_luma_weight_l1[15], - * chroma_offset_l0[15][2], chroma_offset_l1[15][2], - * and delta_chroma_weight_l0[15][2], delta_chroma_weight_l1[15][2]. - */ - uint32_t enable_gpu_weighted_prediction : 1; - /** \brief HEVC syntax element in slice segment header - * GPU uses it to generate new slice headers in slice size control. - */ - uint32_t no_output_of_prior_pics_flag : 1; - uint32_t reserved : 11; - } bits; - uint32_t value; - } pic_fields; -} VAEncPictureParameterBufferHEVC; - -/** - * \brief Slice parameter for HEVC encoding in main & main 10 profiles. - * - * This structure holds information for \c - * slice_segment_layer_rbsp() as defined by the HEVC - * specification. - * - * If packed slice headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderSlice ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - */ -typedef struct _VAEncSliceParameterBufferHEVC { - /** \brief Starting CTU address for this slice. */ - uint32_t slice_segment_address; - /** \brief Number of CTUs in this slice. */ - uint32_t num_ctu_in_slice; - - /** \brief Slice type. - * Corresponds to HEVC syntax element of the same name. - */ - uint8_t slice_type; - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t slice_pic_parameter_set_id; - - /** \brief Maximum reference index for reference picture list 0. - * Range: 0 to 14, inclusive. - */ - uint8_t num_ref_idx_l0_active_minus1; - /** \brief Maximum reference index for reference picture list 1. - * Range: 0 to 14, inclusive. - */ - uint8_t num_ref_idx_l1_active_minus1; - /** \brief Reference picture list 0 (for P slices). */ - VAPictureHEVC ref_pic_list0[15]; - /** \brief Reference picture list 1 (for B slices). */ - VAPictureHEVC ref_pic_list1[15]; - /**@}*/ - - /** @name pred_weight_table() */ - /**@{*/ - /** \brief Same as the HEVC bitstream syntax element. */ - uint8_t luma_log2_weight_denom; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t delta_chroma_log2_weight_denom; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t delta_luma_weight_l0[15]; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t luma_offset_l0[15]; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t delta_chroma_weight_l0[15][2]; - /** \brief Same as the HEVC spec variable ChromaOffsetL0[]. */ - int8_t chroma_offset_l0[15][2]; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t delta_luma_weight_l1[15]; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t luma_offset_l1[15]; - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t delta_chroma_weight_l1[15][2]; - /** \brief Same as the HEVC spec variable ChromaOffsetL1[]. */ - int8_t chroma_offset_l1[15][2]; - /**@}*/ - - /** \brief Corresponds to HEVC spec variable MaxNumMergeCand. - * Range: [1..5]. - */ - uint8_t max_num_merge_cand; - - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t slice_qp_delta; - - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t slice_cb_qp_offset; - - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t slice_cr_qp_offset; - - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t slice_beta_offset_div2; - - /** \brief Same as the HEVC bitstream syntax element. */ - int8_t slice_tc_offset_div2; - - union { - struct { - /** \brief Indicates if current slice is the last one in picture */ - uint32_t last_slice_of_pic_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name */ - uint32_t dependent_slice_segment_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name */ - uint32_t colour_plane_id : 2; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t slice_temporal_mvp_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t slice_sao_luma_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t slice_sao_chroma_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. - * if this flag is set to 0, num_ref_idx_l0_active_minus1 should be - * equal to num_ref_idx_l0_default_active_minus1 - * as well as for that for l1. - */ - uint32_t num_ref_idx_active_override_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t mvd_l1_zero_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t cabac_init_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t slice_deblocking_filter_disabled_flag : 2; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t slice_loop_filter_across_slices_enabled_flag : 1; - /** \brief Corresponds to HEVC syntax element of the same name. */ - uint32_t collocated_from_l0_flag : 1; - } bits; - uint32_t value; - } slice_fields; - /**@}*/ -} VAEncSliceParameterBufferHEVC; - -/** - * \brief HEVC Quantization Matrix Buffer Structure - * - * This structure is sent once per frame, - * and only when scaling_list_enabled_flag = 1 and scaling_list_data_present_flag = 1. - * Only when scaling_list_data_present_flag = 1, app still - * needs to send in this structure. When scaling_list_enabled_flag = 1 and - * scaling_list_data_present_flag = 0, driver is responsible to generate - * the default scaling list values. - * - * Matrix entries are in raster scan order which follows HEVC spec. - */ -typedef struct _VAQMatrixBufferHEVC -{ - /** - * \brief scaling lists, - * corresponds to same HEVC spec syntax element - * ScalingList[ i ][ MatrixID ][ j ]. - * - * \brief 4x4 scaling, - */ - uint8_t scaling_lists_4x4[3][2][16]; - /** - * \brief 8x8 scaling, - */ - uint8_t scaling_lists_8x8[3][2][64]; - /** - * \brief 16x16 scaling, - * correspongs i = 2, MatrixID is in the range of 0 to 5, - * inclusive. And j is in the range of 0 to 63, inclusive. - */ - uint8_t scaling_lists_16x16[3][2][64]; - /** - * \brief 32x32 scaling, - * correspongs i = 3, MatrixID is in the range of 0 to 1, - * inclusive. And j is in the range of 0 to 63, inclusive. - */ - uint8_t scaling_lists_32x32[2][64]; - /** - * \brief DC values of the 16x16 scaling lists, - * corresponds to HEVC spec syntax - * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 - * with sizeID = 2 and matrixID in the range of 0 to 5, inclusive. - */ - uint8_t scaling_list_dc_16x16[3][2]; - /** - * \brief DC values of the 32x32 scaling lists, - * corresponds to HEVC spec syntax - * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8 - * with sizeID = 3 and matrixID in the range of 0 to 1, inclusive. - */ - uint8_t scaling_list_dc_32x32[2]; -} VAQMatrixBufferHEVC; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_ENC_HEVC_H */ diff --git a/va/va_enc_jpeg.h b/va/va_enc_jpeg.h deleted file mode 100644 index 3aba7ad..0000000 --- a/va/va_enc_jpeg.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2007-2013 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 INTEL 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. - */ - -/** - * \file va_enc_jpeg.h - * \brief JPEG encoding API - * - * This file contains the \ref api_enc_jpeg "JPEG encoding API". - */ - -#ifndef VA_ENC_JPEG_H -#define VA_ENC_JPEG_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_enc_jpeg JPEG encoding API - * - * @{ - */ - -/** - * \brief JPEG Encoding Picture Parameter Buffer Structure - * - * This structure conveys picture level parameters. - * - */ -typedef struct _VAEncPictureParameterBufferJPEG -{ - /** \brief holds reconstructed picture. */ - VASurfaceID reconstructed_picture; - /** \brief picture width. */ - unsigned short picture_width; - /** \brief picture height. */ - unsigned short picture_height; - /** \brief holds coded data. */ - VABufferID coded_buf; - - /** - * \brief pic_flags - * - */ - union { - struct { - /** - * \brief profile: - * 0 - Baseline, 1 - Extended, 2 - Lossless, 3 - Hierarchical - */ - unsigned int profile : 2; - /** - * \brief progressive: - * 0 - sequential, 1 - extended, 2 - progressive - */ - unsigned int progressive : 1; - /** - * \brief huffman: - * 0 - arithmetic, 1 - huffman - */ - unsigned int huffman : 1; - /** - * \brief interleaved: - * 0 - non interleaved, 1 - interleaved - */ - unsigned int interleaved : 1; - /** - * \brief differential: - * 0 - non differential, 1 - differential - */ - unsigned int differential : 1; - } bits; - unsigned int value; - } pic_flags; - - /** \brief number of bits per sample. */ - unsigned char sample_bit_depth; - /** \brief total number of scans in image. */ - unsigned char num_scan; - /** \brief number of image components in frame. */ - unsigned short num_components; - /** \brief Component identifier (Ci). */ - unsigned char component_id[4]; - /** \brief Quantization table selector (Tqi). */ - unsigned char quantiser_table_selector[4]; - /** \brief number from 1 to 100 that specifies quality of image. */ - unsigned char quality; - -} VAEncPictureParameterBufferJPEG; - - -/** - * \brief Slice parameter for JPEG encoding. - * - * This structure conveys slice (scan) level parameters. - * - */ -typedef struct _VAEncSliceParameterBufferJPEG { - /** \brief Restart interval definition (Ri). */ - unsigned short restart_interval; - /** \brief number of image components in a scan. */ - unsigned short num_components; - struct { - /** \brief Scan component selector (Csj). */ - unsigned char component_selector; - /** \brief DC entropy coding table selector (Tdj). */ - unsigned char dc_table_selector; - /** \brief AC entropy coding table selector (Taj). */ - unsigned char ac_table_selector; - } components[4]; -} VAEncSliceParameterBufferJPEG; - -/** - * \brief Quantization table for JPEG encoding. - * - */ -typedef struct _VAQMatrixBufferJPEG -{ - /** \brief load luma quantization table. */ - int load_lum_quantiser_matrix; - /** \brief load chroma quantization table. */ - int load_chroma_quantiser_matrix; - /** \brief luma quantization table. */ - unsigned char lum_quantiser_matrix[64]; - /** \brief chroma quantization table. */ - unsigned char chroma_quantiser_matrix[64]; -} VAQMatrixBufferJPEG; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_ENC_JPEG_H */ diff --git a/va/va_enc_mpeg2.h b/va/va_enc_mpeg2.h deleted file mode 100644 index c12c8de..0000000 --- a/va/va_enc_mpeg2.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2012 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 INTEL 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. - */ - -/** - * \file va_enc_mpeg2.h - * \brief The MPEG-2 encoding API - * - * This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API". - */ - -#ifndef _VA_ENC_MPEG2_H_ -#define _VA_ENC_MPEG2_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_enc_mpeg2 MPEG-2 encoding API - * - * @{ - */ - -/** - * \brief MPEG-2 Quantization Matrix Buffer - * - */ -typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2; - -/** - * \brief Packed header types specific to MPEG-2 encoding. - * - * Types of packed headers generally used for MPEG-2 encoding. - */ -typedef enum { - /** - * \brief Packed Sequence Parameter Set (SPS). - * - */ - VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence, - /** - * \brief Packed Picture Parameter Set (PPS). - * - */ - VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture, - /** - * \brief Packed slice header. - * - */ - VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice, -} VAEncPackedHeaderTypeMPEG2; - -/** - * \brief Sequence parameter for MPEG-2 encoding - * - * This structure holds information for \c sequence_header() and - * sequence_extension(). - * - * If packed sequence headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderSequence ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - */ -typedef struct _VAEncSequenceParameterBufferMPEG2 { - /** \brief Period between I frames. */ - unsigned int intra_period; - /** \brief Period between I/P frames. */ - unsigned int ip_period; - /** \brief Picture width. - * - * A 14bits unsigned inter, the lower 12bits - * is horizontal_size_value, and the upper - * 2bits is \c horizontal_size_extension - * - */ - unsigned short picture_width; - /** \brief Picture height. - * - * A 14bits unsigned inter, the lower 12bits - * is vertical_size_value, and the upper 2bits is - * vertical_size_size_extension - * - */ - unsigned short picture_height; - /** - * \brief Initial bitrate set for this sequence in CBR or VBR modes. - * - * This field represents the initial bitrate value for this - * sequence if CBR or VBR mode is used, i.e. if the encoder - * pipeline was created with a #VAConfigAttribRateControl - * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. - * - * bits_per_second may be derived from bit_rate. - * - */ - unsigned int bits_per_second; - /** - * \brief Frame rate - * - * Derived from frame_rate_value, frame_rate_extension_n and - * frame_rate_extension_d - * - */ - float frame_rate; - /** \brief Same as the element in sequence_header() */ - unsigned short aspect_ratio_information; - /** \brief Define the size of VBV */ - unsigned int vbv_buffer_size; - - union { - struct { - /** \brief Same as the element in Sequence extension() */ - unsigned int profile_and_level_indication : 8; - /** \brief Same as the element in Sequence extension() */ - unsigned int progressive_sequence : 1; - /** \brief Same as the element in Sequence extension() */ - unsigned int chroma_format : 2; - /** \brief Same as the element in Sequence extension() */ - unsigned int low_delay : 1; - /** \brief Same as the element in Sequence extension() */ - unsigned int frame_rate_extension_n : 2; - /** \brief Same as the element in Sequence extension() */ - unsigned int frame_rate_extension_d : 5; - } bits; - unsigned int value; - } sequence_extension; - - /** \brief Flag to indicate the following GOP header are being updated */ - unsigned int new_gop_header; - - union { - struct { - /** \brief Time code */ - unsigned int time_code : 25; - /** \brief Same as the element in GOP header */ - unsigned int closed_gop : 1; - /** \brief SAme as the element in GOP header */ - unsigned int broken_link : 1; - } bits; - unsigned int value; - } gop_header; -} VAEncSequenceParameterBufferMPEG2; - -/** - * \brief Picture parameter for MPEG-2 encoding - * - * This structure holds information for picture_header() and - * picture_coding_extension() - * - * If packed picture headers mode is used, i.e. if the encoding - * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE - * flag, then the driver expects two more buffers to be provided to - * the same \c vaRenderPicture() as this buffer: - * - a #VAEncPackedHeaderParameterBuffer with type set to - * VAEncPackedHeaderType::VAEncPackedHeaderPicture ; - * - a #VAEncPackedHeaderDataBuffer which holds the actual packed - * header data. - * - */ -typedef struct _VAEncPictureParameterBufferMPEG2 { - /** \brief Forward reference picture */ - VASurfaceID forward_reference_picture; - /** \brief Backward reference picture */ - VASurfaceID backward_reference_picture; - /** \brief Reconstructed(decoded) picture */ - VASurfaceID reconstructed_picture; - /** - * \brief Output encoded bitstream. - * - * \ref coded_buf has type #VAEncCodedBufferType. It should be - * large enough to hold the compressed NAL slice and possibly SPS - * and PPS NAL units. - */ - VABufferID coded_buf; - /** - * \brief Flag to indicate the picture is the last one or not. - * - * This fields holds 0 if the picture to be encoded is not - * the last one in the stream. Otherwise, it - * is \ref MPEG2_LAST_PICTURE_EOSTREAM. - */ - unsigned char last_picture; - /** \brief Picture type */ - VAEncPictureType picture_type; - /** \brief Same as the element in picture_header() */ - unsigned int temporal_reference; - /** \brief Same as the element in picture_header() */ - unsigned int vbv_delay; - /** \brief Same as the element in Picture coding extension */ - unsigned char f_code[2][2]; - union { - struct { - /** \brief Same as the element in Picture coding extension */ - unsigned int intra_dc_precision : 2; - /** \brief Same as the element in Picture coding extension */ - unsigned int picture_structure : 2; - /** \brief Same as the element in Picture coding extension */ - unsigned int top_field_first : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int frame_pred_frame_dct : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int concealment_motion_vectors : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int q_scale_type : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int intra_vlc_format : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int alternate_scan : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int repeat_first_field : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int progressive_frame : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int composite_display_flag : 1; - } bits; - unsigned int value; - } picture_coding_extension; - - /* \brief Parameters for composite display - * - * Valid only when omposite_display_flag is 1 - */ - union { - struct { - /** \brief Same as the element in Picture coding extension */ - unsigned int v_axis : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int field_sequence : 3; - /** \brief Same as the element in Picture coding extension */ - unsigned int sub_carrier : 1; - /** \brief Same as the element in Picture coding extension */ - unsigned int burst_amplitude : 7; - /** \brief Same as the element in Picture coding extension */ - unsigned int sub_carrier_phase : 8; - } bits; - unsigned int value; - } composite_display; -} VAEncPictureParameterBufferMPEG2; - -/** - * \brief Slice parameter for MPEG-2 encoding - * - */ -typedef struct _VAEncSliceParameterBufferMPEG2 { - /** \brief Starting MB address for this slice. */ - unsigned int macroblock_address; - /** \brief Number of macroblocks in this slice. */ - unsigned int num_macroblocks; - /** \brief Same as the element in slice() */ - int quantiser_scale_code; - /** \brief Flag to indicate intra slice */ - int is_intra_slice; -} VAEncSliceParameterBufferMPEG2; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _VA_ENC_MPEG2_H_ */ diff --git a/va/va_enc_vp8.h b/va/va_enc_vp8.h deleted file mode 100644 index d294042..0000000 --- a/va/va_enc_vp8.h +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2007-2012 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 INTEL 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. - */ - -/** - * \file va_enc_vp8.h - * \brief VP8 encoding API - * - * This file contains the \ref api_enc_vp8 "VP8 encoding API". - */ - -#ifndef VA_ENC_VP8_H -#define VA_ENC_VP8_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_enc_vp8 VP8 encoding API - * - * @{ - */ - -/** - * \brief VP8 Encoding Sequence Parameter Buffer Structure - * - * This structure conveys sequence level parameters. - * - */ -typedef struct _VAEncSequenceParameterBufferVP8 -{ - /* frame width in pixels */ - unsigned int frame_width; - /* frame height in pixels */ - unsigned int frame_height; - /* horizontal scale */ - unsigned int frame_width_scale; - /* vertical scale */ - unsigned int frame_height_scale; - - /* whether to enable error resilience features */ - unsigned int error_resilient; - /* auto keyframe placement, non-zero means enable auto keyframe placement */ - unsigned int kf_auto; - /* keyframe minimum interval */ - unsigned int kf_min_dist; - /* keyframe maximum interval */ - unsigned int kf_max_dist; - - - /* RC related fields. RC modes are set with VAConfigAttribRateControl */ - /* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */ - - /** - * Initial bitrate set for this sequence in CBR or VBR modes. - * - * This field represents the initial bitrate value for this - * sequence if CBR or VBR mode is used, i.e. if the encoder - * pipeline was created with a #VAConfigAttribRateControl - * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. - * - * The bitrate can be modified later on through - * #VAEncMiscParameterRateControl buffers. - */ - unsigned int bits_per_second; - /* Period between I frames. */ - unsigned int intra_period; - - /* reference and reconstructed frame buffers - * Used for driver auto reference management when configured through - * VAConfigAttribEncAutoReference. - */ - VASurfaceID reference_frames[4]; - -} VAEncSequenceParameterBufferVP8; - - -/** - * \brief VP8 Encoding Picture Parameter Buffer Structure - * - * This structure conveys picture level parameters. - * - */ -typedef struct _VAEncPictureParameterBufferVP8 -{ - /* surface to store reconstructed frame */ - VASurfaceID reconstructed_frame; - - /* - * surfaces to store reference frames in non auto reference mode - * VA_INVALID_SURFACE can be used to denote an invalid reference frame. - */ - VASurfaceID ref_last_frame; - VASurfaceID ref_gf_frame; - VASurfaceID ref_arf_frame; - - /* buffer to store coded data */ - VABufferID coded_buf; - - union { - struct { - /* force this frame to be a keyframe */ - unsigned int force_kf : 1; - /* don't reference the last frame */ - unsigned int no_ref_last : 1; - /* don't reference the golden frame */ - unsigned int no_ref_gf : 1; - /* don't reference the alternate reference frame */ - unsigned int no_ref_arf : 1; - unsigned int reserved : 28; - } bits; - unsigned int value; - } ref_flags; - - union { - struct { - /* version */ - unsigned int frame_type : 1; - unsigned int version : 3; - /* show_frame */ - unsigned int show_frame : 1; - /* color_space */ - unsigned int color_space : 1; - /* 0: bicubic, 1: bilinear, other: none */ - unsigned int recon_filter_type : 2; - /* 0: no loop fitler, 1: simple loop filter */ - unsigned int loop_filter_type : 2; - /* 0: disabled, 1: normal, 2: simple */ - unsigned int auto_partitions : 1; - /* same as log2_nbr_of_dct_partitions in frame header syntax */ - unsigned int num_token_partitions : 2; - - /** - * The following fields correspond to the same VP8 syntax elements - * in the frame header. - */ - /** - * 0: clamping of reconstruction pixels is disabled, - * 1: clamping enabled. - */ - unsigned int clamping_type : 1; - /* indicate segmentation is enabled for the current frame. */ - unsigned int segmentation_enabled : 1; - /** - * Determines if the MB segmentation map is updated in the current - * frame. - */ - unsigned int update_mb_segmentation_map : 1; - /** - * Indicates if the segment feature data is updated in the current - * frame. - */ - unsigned int update_segment_feature_data : 1; - /** - * indicates if the MB level loop filter adjustment is enabled for - * the current frame (0 off, 1 on). - */ - unsigned int loop_filter_adj_enable : 1; - /** - * Determines whether updated token probabilities are used only for - * this frame or until further update. - * It may be used by application to enable error resilient mode. - * In this mode probability updates are allowed only at Key Frames. - */ - unsigned int refresh_entropy_probs : 1; - /** - * Determines if the current decoded frame refreshes the golden frame. - */ - unsigned int refresh_golden_frame : 1; - /** - * Determines if the current decoded frame refreshes the alternate - * reference frame. - */ - unsigned int refresh_alternate_frame : 1; - /** - * Determines if the current decoded frame refreshes the last frame - * reference buffer. - */ - unsigned int refresh_last : 1; - /** - * Determines if the golden reference is replaced by another reference. - */ - unsigned int copy_buffer_to_golden : 2; - /** - * Determines if the alternate reference is replaced by another reference. - */ - unsigned int copy_buffer_to_alternate : 2; - /** - * Controls the sign of motion vectors when the golden frame is referenced. - */ - unsigned int sign_bias_golden : 1; - /** - * Controls the sign of motion vectors when the alternate frame is - * referenced. - */ - unsigned int sign_bias_alternate : 1; - /** - * Enables or disables the skipping of macroblocks containing no - * non-zero coefficients. - */ - unsigned int mb_no_coeff_skip : 1; - /** - * Enforces unconditional per-MB loop filter delta update setting frame - * header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4], - * and all ref_frame_delta_update_flag[4] to 1. - * Since loop filter deltas are not automatically refreshed to default - * values at key frames, dropped frame with delta update may prevent - * correct decoding from the next key frame. - * Encoder application is advised to set this flag to 1 at key frames. - */ - unsigned int forced_lf_adjustment : 1; - unsigned int reserved : 2; - } bits; - unsigned int value; - } pic_flags; - - /** - * Contains a list of 4 loop filter level values (updated value if applicable) - * controlling the deblocking filter strength. Each entry represents a segment. - * When segmentation is disabled, use entry 0. - * When loop_filter_level is 0, loop filter shall be disabled. - */ - char loop_filter_level[4]; - - /** - * Contains a list of 4 delta values for reference frame based MB-level - * loop filter adjustment. - * If no update, then set to 0. - */ - char ref_lf_delta[4]; - - /** - * Contains a list of 4 delta values for coding mode based MB-level loop - * filter adjustment. - * If no update, then set to 0. - */ - char mode_lf_delta[4]; - - /** - * Controls the deblocking filter sensitivity. - * Corresponds to the same VP8 syntax element in frame header. - */ - unsigned char sharpness_level; - - /** - * Application supplied maximum clamp value for Qindex used in quantization. - * Qindex will not be allowed to exceed this value. - * It has a valid range [0..127] inclusive. - */ - unsigned char clamp_qindex_high; - - /** - * Application supplied minimum clamp value for Qindex used in quantization. - * Qindex will not be allowed to be lower than this value. - * It has a valid range [0..127] inclusive. - * Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed, - * otherwise they are ignored. - */ - unsigned char clamp_qindex_low; - -} VAEncPictureParameterBufferVP8; - - -/** - * \brief VP8 MB Segmentation ID Buffer - * - * application provides buffer containing the initial segmentation id for each - * MB, in raster scan order. Rate control may reassign it. - * For an 640x480 video, the buffer has 1200 entries. - * the value of each entry should be in the range [0..3], inclusive. - * If segmentation is not enabled, application does not need to provide it. - */ -typedef struct _VAEncMBMapBufferVP8 -{ - /** - * number of MBs in the frame. - * It is also the number of entries of mb_segment_id[]; - */ - unsigned int num_mbs; - /** - * per MB Segmentation ID Buffer - */ - unsigned char *mb_segment_id; -} VAEncMBMapBufferVP8; - - -/** - * \brief VP8 Quantization Matrix Buffer Structure - * - * Contains quantization index for yac(0-3) for each segment and quantization - * index deltas, ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied - * to all segments. When segmentation is disabled, only quantization_index[0] - * will be used. This structure is sent once per frame. - */ -typedef struct _VAQMatrixBufferVP8 -{ - unsigned short quantization_index[4]; - short quantization_index_delta[5]; -} VAQMatrixBufferVP8; - - - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_ENC_VP8_H */ diff --git a/va/va_enc_vp9.h b/va/va_enc_vp9.h deleted file mode 100755 index cd870e7..0000000 --- a/va/va_enc_vp9.h +++ /dev/null @@ -1,598 +0,0 @@ -/* - * Copyright (c) 2007-2015 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 INTEL 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. - */ - -/** - * \file va_enc_vp9.h - * \brief VP9 encoding API - * - * This file contains the \ref api_enc_vp9 "VP9 encoding API". - * - */ - -#ifndef VA_ENC_VP9_H -#define VA_ENC_VP9_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_enc_vp9 VP9 encoding API - * - * @{ - */ - -/** - * \brief VP9 Encoding Status Data Buffer Structure - * - * This structure is used to convey status data from encoder to application. - * Driver allocates VACodedBufferVP9Status as a private data buffer. - * Driver encapsulates the status buffer with a VACodedBufferSegment, - * and sets VACodedBufferSegment.status to be VA_CODED_BUF_STATUS_CODEC_SPECIFIC. - * And driver associates status data segment to the bit stream buffer segment - * by setting VACodedBufferSegment.next of coded_buf (bit stream) to the private - * buffer segment of status data. - * Application accesses it by calling VAMapBuffer() with VAEncCodedBufferType. - */ -typedef struct _VACodedBufferVP9Status -{ - /** Final quantization index used (yac), determined by BRC. - * Application is providing quantization index deltas - * ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied to all segments - * and segmentation qi deltas, they will not be changed by BRC. - */ - uint16_t base_qp_index; - - /** Final loopfilter levels for the frame, if segmentation is disabled only - * index 0 is used. - * If loop_filter_level is 0, it indicates loop filter is disabled. - */ - uint8_t loop_filter_level; - - /** - * Long term reference frame indication from BRC. BRC recommends the - * current frame that is being queried is a good candidate for a long - * term reference. - */ - uint8_t long_term_indication; - - /* suggested next frame width */ - uint16_t next_frame_width; - - /* suggested next frame height */ - uint16_t next_frame_height; - -} VACodedBufferVP9Status; - -/** - * \brief VP9 Encoding Sequence Parameter Buffer Structure - * - * This structure conveys sequence level parameters. - * - */ -typedef struct _VAEncSequenceParameterBufferVP9 -{ - /** \brief Frame size note: - * Picture resolution may change frame by frame. - * Application needs to allocate surfaces and frame buffers based on - * max frame resolution in case resolution changes for later frames. - * The source and recon surfaces allocated should be 64x64(SB) aligned - * on both horizontal and vertical directions. - * But buffers on the surfaces need to be aligned to CU boundaries. - */ - /* maximum frame width in pixels for the whole sequence */ - uint32_t max_frame_width; - - /* maximum frame height in pixels for the whole sequence */ - uint32_t max_frame_height; - - /* auto keyframe placement, non-zero means enable auto keyframe placement */ - uint32_t kf_auto; - - /* keyframe minimum interval */ - uint32_t kf_min_dist; - - /* keyframe maximum interval */ - uint32_t kf_max_dist; - - - /* RC related fields. RC modes are set with VAConfigAttribRateControl */ - /* For VP9, CBR implies HRD conformance and VBR implies no HRD conformance */ - - /** - * Initial bitrate set for this sequence in CBR or VBR modes. - * - * This field represents the initial bitrate value for this - * sequence if CBR or VBR mode is used, i.e. if the encoder - * pipeline was created with a #VAConfigAttribRateControl - * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. - * - * The bitrate can be modified later on through - * #VAEncMiscParameterRateControl buffers. - */ - uint32_t bits_per_second; - - /* Period between key frames */ - uint32_t intra_period; - -} VAEncSequenceParameterBufferVP9; - - -/** - * \brief VP9 Encoding Picture Parameter Buffer Structure - * - * This structure conveys picture level parameters. - * - */ -typedef struct _VAEncPictureParameterBufferVP9 -{ - /** VP9 encoder may support dynamic scaling function. - * If enabled (enable_dynamic_scaling is set), application may request - * GPU encodes picture with a different resolution from the raw source. - * GPU should handle the scaling process of source and - * all reference frames. - */ - /* raw source frame width in pixels */ - uint32_t frame_width_src; - /* raw source frame height in pixels */ - uint32_t frame_height_src; - - /* to be encoded frame width in pixels */ - uint32_t frame_width_dst; - /* to be encoded frame height in pixels */ - uint32_t frame_height_dst; - - /* surface to store reconstructed frame, not used for enc only case */ - VASurfaceID reconstructed_frame; - - /** \brief reference frame buffers - * Each entry of the array specifies the surface index of the picture - * that is referred by current picture or will be referred by any future - * picture. The valid entries take value from 0 to 127, inclusive. - * Non-valid entries, those do not point to pictures which are referred - * by current picture or future pictures, should take value 0xFF. - * Other values are not allowed. - * - * Application should update this array based on the refreshing - * information expected. - */ - VASurfaceID reference_frames[8]; - - /* buffer to store coded data */ - VABufferID coded_buf; - - union { - struct { - /* force this frame to be a keyframe */ - uint32_t force_kf : 1; - - /** \brief Indiates which frames to be used as reference. - * (Ref_frame_ctrl & 0x01) ? 1: last frame as reference frame, 0: not. - * (Ref_frame_ctrl & 0x02) ? 1: golden frame as reference frame, 0: not. - * (Ref_frame_ctrl & 0x04) ? 1: alt frame as reference frame, 0: not. - * L0 is for forward prediction. - * L1 is for backward prediction. - */ - uint32_t ref_frame_ctrl_l0 : 3; - uint32_t ref_frame_ctrl_l1 : 3; - - /** \brief Last Reference Frame index - * Specifies the index to RefFrameList[] which points to the LAST - * reference frame. It corresponds to active_ref_idx[0] in VP9 code. - */ - uint32_t ref_last_idx : 3; - - /** \brief Specifies the Sign Bias of the LAST reference frame. - * It corresponds to ref_frame_sign_bias[LAST_FRAME] in VP9 code. - */ - uint32_t ref_last_sign_bias : 1; - - /** \brief GOLDEN Reference Frame index - * Specifies the index to RefFrameList[] which points to the Golden - * reference frame. It corresponds to active_ref_idx[1] in VP9 code. - */ - uint32_t ref_gf_idx : 3; - - /** \brief Specifies the Sign Bias of the GOLDEN reference frame. - * It corresponds to ref_frame_sign_bias[GOLDEN_FRAME] in VP9 code. - */ - uint32_t ref_gf_sign_bias : 1; - - /** \brief Alternate Reference Frame index - * Specifies the index to RefFrameList[] which points to the Alternate - * reference frame. It corresponds to active_ref_idx[2] in VP9 code. - */ - uint32_t ref_arf_idx : 3; - - /** \brief Specifies the Sign Bias of the ALTERNATE reference frame. - * It corresponds to ref_frame_sign_bias[ALTREF_FRAME] in VP9 code. - */ - uint32_t ref_arf_sign_bias : 1; - - /* The temporal id the frame belongs to */ - uint32_t temporal_id : 8; - - uint32_t reserved : 5; - } bits; - uint32_t value; - } ref_flags; - - union { - struct { - /** - * Indicates if the current frame is a key frame or not. - * Corresponds to the same VP9 syntax element in frame tag. - */ - uint32_t frame_type : 1; - - /** \brief show_frame - * 0: current frame is not for display - * 1: current frame is for display - */ - uint32_t show_frame : 1; - - /** - * The following fields correspond to the same VP9 syntax elements - * in the frame header. - */ - uint32_t error_resilient_mode : 1; - - /** \brief Indicate intra-only for inter pictures. - * Must be 0 for key frames. - * 0: inter frame use both intra and inter blocks - * 1: inter frame use only intra blocks. - */ - uint32_t intra_only : 1; - - /** \brief Indicate high precision mode for Motion Vector prediction - * 0: normal mode - * 1: high precision mode - */ - uint32_t allow_high_precision_mv : 1; - - /** \brief Motion Compensation Filter type - * 0: eight-tap (only this mode is supported now.) - * 1: eight-tap-smooth - * 2: eight-tap-sharp - * 3: bilinear - * 4: switchable - */ - uint32_t mcomp_filter_type : 3; - uint32_t frame_parallel_decoding_mode : 1; - uint32_t reset_frame_context : 2; - uint32_t refresh_frame_context : 1; - uint32_t frame_context_idx : 2; - uint32_t segmentation_enabled : 1; - - /* corresponds to variable temporal_update in VP9 code. - * Indicates whether Segment ID is from bitstream or from previous - * frame. - * 0: Segment ID from bitstream - * 1: Segment ID from previous frame - */ - uint32_t segmentation_temporal_update : 1; - - /* corresponds to variable update_mb_segmentation_map in VP9 code. - * Indicates how hardware determines segmentation ID - * 0: intra block - segment id is 0; - * inter block - segment id from previous frame - * 1: intra block - segment id from bitstream (app or GPU decides) - * inter block - depends on segmentation_temporal_update - */ - uint32_t segmentation_update_map : 1; - - /** \brief Specifies if the picture is coded in lossless mode. - * - * lossless_mode = base_qindex == 0 && y_dc_delta_q == 0 \ - * && uv_dc_delta_q == 0 && uv_ac_delta_q == 0; - * Where base_qindex, y_dc_delta_q, uv_dc_delta_q and uv_ac_delta_q - * are all variables in VP9 code. - * - * When enabled, tx_mode needs to be set to 4x4 only and all - * tu_size in CU record set to 4x4 for entire frame. - * Software also has to program such that final_qindex=0 and - * final_filter_level=0 following the Quant Scale and - * Filter Level Table in Segmentation State section. - * Hardware forces Hadamard Tx when this bit is set. - * When lossless_mode is on, BRC has to be turned off. - * 0: normal mode - * 1: lossless mode - */ - uint32_t lossless_mode : 1; - - /** \brief MV prediction mode. Corresponds to VP9 variable with same name. - * comp_prediction_mode = 0: single prediction ony, - * comp_prediction_mode = 1: compound prediction, - * comp_prediction_mode = 2: hybrid prediction - * - * Not mandatory. App may suggest the setting based on power or - * performance. Kernal may use it as a guildline and decide the proper - * setting on its own. - */ - uint32_t comp_prediction_mode : 2; - - /** \brief Indicate how segmentation is specified - * 0 application specifies segmentation partitioning and - * relevant parameters. - * 1 GPU may decide on segmentation. If application already - * provides segmentation information, GPU may choose to - * honor it and further split into more levels if possible. - */ - uint32_t auto_segmentation : 1; - - /** \brief Indicate super frame syntax should be inserted - * 0 current frame is not encapsulated in super frame structure - * 1 current fame is to be encapsulated in super frame structure. - * super frame index syntax will be inserted by encoder at - * the end of current frame. - */ - uint32_t super_frame_flag : 1; - - uint32_t reserved : 10; - } bits; - uint32_t value; - } pic_flags; - - /** \brief indicate which frames in DPB should be refreshed. - * same syntax and semantic as in VP9 code. - */ - uint8_t refresh_frame_flags; - - /** \brief Base Q index in the VP9 term. - * Added with per segment delta Q index to get Q index of Luma AC. - */ - uint8_t luma_ac_qindex; - - /** - * Q index delta from base Q index in the VP9 term for Luma DC. - */ - int8_t luma_dc_qindex_delta; - - /** - * Q index delta from base Q index in the VP9 term for Chroma AC. - */ - int8_t chroma_ac_qindex_delta; - - /** - * Q index delta from base Q index in the VP9 term for Chroma DC. - */ - int8_t chroma_dc_qindex_delta; - - /** \brief filter level - * Corresponds to the same VP9 syntax element in frame header. - */ - uint8_t filter_level; - - /** - * Controls the deblocking filter sensitivity. - * Corresponds to the same VP9 syntax element in frame header. - */ - uint8_t sharpness_level; - - /** \brief Loop filter level reference delta values. - * Contains a list of 4 delta values for reference frame based block-level - * loop filter adjustment. - * If no update, set to 0. - * value range [-63..63] - */ - int8_t ref_lf_delta[4]; - - /** \brief Loop filter level mode delta values. - * Contains a list of 4 delta values for coding mode based MB-level loop - * filter adjustment. - * If no update, set to 0. - * value range [-63..63] - */ - int8_t mode_lf_delta[2]; - - /** - * Offset from starting position of output bitstream in bits where - * ref_lf_delta[] should be inserted. This offset should cover any metadata - * ahead of uncompressed header in inserted bit stream buffer (the offset - * should be same as that for final output bitstream buffer). - * - * In BRC mode, always insert ref_lf_delta[] (This implies uncompressed - * header should have mode_ref_delta_enabled=1 and mode_ref_delta_update=1). - */ - uint16_t bit_offset_ref_lf_delta; - - /** - * Offset from starting position of output bitstream in bits where - * mode_lf_delta[] should be inserted. - * - * In BRC mode, always insert mode_lf_delta[] (This implies uncompressed - * header should have mode_ref_delta_enabled=1 and mode_ref_delta_update=1). - */ - uint16_t bit_offset_mode_lf_delta; - - /** - * Offset from starting position of output bitstream in bits where (loop) - * filter_level should be inserted. - */ - uint16_t bit_offset_lf_level; - - /** - * Offset from starting position of output bitstream in bits where - * Base Qindex should be inserted. - */ - uint16_t bit_offset_qindex; - - /** - * Offset from starting position of output bitstream in bits where - * First Partition Size should be inserted. - */ - uint16_t bit_offset_first_partition_size; - - /** - * Offset from starting position of output bitstream in bits where - * segmentation_enabled is located in bitstream. When auto_segmentation - * is enabled, GPU uses this offset to locate and update the - * segmentation related information. - */ - uint16_t bit_offset_segmentation; - - /** \brief length in bit of segmentation portion from the location - * in bit stream where segmentation_enabled syntax is coded. - * When auto_segmentation is enabled, GPU uses this bit size to locate - * and update the information after segmentation. - */ - uint16_t bit_size_segmentation; - - - /** \brief log2 of number of tile rows - * Corresponds to the same VP9 syntax element in frame header. - * value range [0..2] - */ - uint8_t log2_tile_rows; - - /** \brief log2 of number of tile columns - * Corresponds to the same VP9 syntax element in frame header. - * value range [0..5] - */ - uint8_t log2_tile_columns; - - /** \brief indicate frame-skip happens - * Application may choose to drop/skip one or mulitple encoded frames or - * to-be-encoded frame due to various reasons such as insufficient - * bandwidth. - * Application uses the following three flags to inform GPU about frame-skip. - * - * value range of skip_frame_flag: [0..2] - * 0 - encode as normal, no skip; - * 1 - one or more frames were skipped by application prior to the - * current frame. Encode the current frame as normal. The driver - * will pass the number_skip_frames and skip_frames_size - * to bit rate control for adjustment. - * 2 - the current frame is to be skipped. Do not encode it but encrypt - * the packed header contents. This is for the secure encoding case - * where application generates a frame of all skipped blocks. - * The packed header will contain the skipped frame. - */ - uint8_t skip_frame_flag; - - /** \brief The number of frames skipped prior to the current frame. - * It includes only the skipped frames that were not counted before, - * and does not include the frame with skip_frame_flag == 2. - * Valid when skip_frame_flag = 1. - */ - uint8_t number_skip_frames; - - /** \brief When skip_frame_flag = 1, the size of the skipped frames in bits. - * It includes only the skipped frames that were not counted before, - * and does not include the frame size with skip_frame_flag = 2. - * When skip_frame_flag = 2, it is the size of the current skipped frame - * that is to be encrypted. - */ - uint32_t skip_frames_size; - -} VAEncPictureParameterBufferVP9; - - -/** - * \brief Per segment parameters - */ -typedef struct _VAEncSegParamVP9 -{ - union { - struct { - /** \brief Indicates if per segment reference frame indicator is enabled. - * Corresponding to variable feature_enabled when - * j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code. - */ - uint8_t segment_reference_enabled : 1; - - /** \brief Specifies per segment reference indication. - * 0: reserved - * 1: Last ref - * 2: golden - * 3: altref - * Value can be derived from variable data when - * j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code. - * value range: [0..3] - */ - uint8_t segment_reference : 2; - - /** \brief Indicates if per segment skip mode is enabled. - * Corresponding to variable feature_enabled when - * j == SEG_LVL_SKIP in function setup_segmentation() VP9 code. - */ - uint8_t segment_reference_skipped : 1; - - uint8_t reserved : 4; - - } bits; - uint8_t value; - } seg_flags; - - /** \brief Specifies per segment Loop Filter Delta. - * Must be 0 when segmentation_enabled == 0. - * value range: [-63..63] - */ - int8_t segment_lf_level_delta; - - /** \brief Specifies per segment QIndex Delta. - * Must be 0 when segmentation_enabled == 0. - * value range: [-255..255] - */ - int16_t segment_qindex_delta; - -} VAEncSegParamVP9; - -/** - * Structure to convey all segment related information. - * If segmentation is disabled, this data structure is still required. - * In this case, only seg_data[0] contains valid data. - * This buffer is sent once per frame. - * - * The buffer is created with VABufferType VAQMatrixBufferType. - * - */ -typedef struct _VAEncMiscParameterTypeVP9PerSegmantParam -{ - /** - * Parameters for 8 segments. - */ - VAEncSegParamVP9 seg_data[8]; - -} VAEncMiscParameterTypeVP9PerSegmantParam; - - -/** - * \brief VP9 Block Segmentation ID Buffer - * - * The application provides a buffer of VAEncMacroblockMapBufferType containing - * the initial segmentation id for each 8x8 block, one byte each, in raster scan order. - * Rate control may reassign it. For example, a 640x480 video, the buffer has 4800 entries. - * The value of each entry should be in the range [0..7], inclusive. - * If segmentation is not enabled, the application does not need to provide it. - */ - - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_ENC_VP9_H */ diff --git a/va/va_fool.c b/va/va_fool.c deleted file mode 100644 index 8dbe8dd..0000000 --- a/va/va_fool.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2009 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_trace.h" -#include "va_fool.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Do dummy decode/encode, ignore the input data - * In order to debug memory leak or low performance issues, we need to isolate driver problems - * We export env "VA_FOOL", with which, we can do fake decode/encode: - * - * LIBVA_FOOL_DECODE: - * . if set, decode does nothing - * LIBVA_FOOL_ENCODE=: - * . if set, encode does nothing, but fill in the coded buffer from the content of files with - * name framename.0,framename.1,..., framename.N, framename.0,..., framename.N,...repeatly - * Use file name to determine h264 or vp8 - * LIBVA_FOOL_JPEG=:fill the content of filename to codedbuf for jpeg encoding - * LIBVA_FOOL_POSTP: - * . if set, do nothing for vaPutSurface - */ - - -/* global settings */ -int fool_codec = 0; -int fool_postp = 0; - -#define FOOL_BUFID_MAGIC 0x12345600 -#define FOOL_BUFID_MASK 0xffffff00 - -struct fool_context { - int enabled; /* fool_codec is global, and it is for concurent encode/decode */ - 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; - - 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] - * the size is ignored here - */ - 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; -}; - -#define FOOL_CTX(dpy) ((struct fool_context *)((VADisplayContextP)dpy)->vafool) - -#define DPY2FOOLCTX(dpy) \ - struct fool_context *fool_ctx = FOOL_CTX(dpy); \ - if (fool_ctx == NULL) \ - return 0; /* no fool for the context */ \ - -#define DPY2FOOLCTX_CHK(dpy) \ - struct fool_context *fool_ctx = FOOL_CTX(dpy); \ - if ((fool_ctx == NULL) || (fool_ctx->enabled == 0)) \ - return 0; /* no fool for the context */ \ - -/* 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); - -void va_FoolInit(VADisplay dpy) -{ - char env_value[1024]; - - struct fool_context *fool_ctx = calloc(sizeof(struct fool_context), 1); - - if (fool_ctx == NULL) - return; - - 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_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_codec |= VA_FOOL_FLAG_ENCODE; - fool_ctx->fn_enc = strdup(env_value); - va_infoMessage("LIBVA_FOOL_ENCODE is on, load encode data from file with patten %s\n", - fool_ctx->fn_enc); - } - if (va_parseConfig("LIBVA_FOOL_JPEG", &env_value[0]) == 0) { - fool_codec |= VA_FOOL_FLAG_JPEG; - fool_ctx->fn_jpg = strdup(env_value); - va_infoMessage("LIBVA_FOOL_JPEG is on, load encode data from file with patten %s\n", - fool_ctx->fn_jpg); - } - - ((VADisplayContextP)dpy)->vafool = fool_ctx; -} - - -int va_FoolEnd(VADisplay dpy) -{ - int i; - DPY2FOOLCTX(dpy); - - for (i = 0; i < VABufferTypeMax; i++) {/* free memory */ - if (fool_ctx->fool_buf[i]) - free(fool_ctx->fool_buf[i]); - } - if (fool_ctx->segbuf_enc) - free(fool_ctx->segbuf_enc); - if (fool_ctx->segbuf_jpg) - free(fool_ctx->segbuf_jpg); - if (fool_ctx->fn_enc) - free(fool_ctx->fn_enc); - if (fool_ctx->fn_jpg) - free(fool_ctx->fn_jpg); - - free(fool_ctx); - ((VADisplayContextP)dpy)->vafool = NULL; - - return 0; -} - -int va_FoolCreateConfig( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ -) -{ - DPY2FOOLCTX(dpy); - - fool_ctx->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_JPEG) && (entrypoint == VAEntrypointEncPicture))) - fool_ctx->enabled = 1; - else if ((fool_codec & VA_FOOL_FLAG_ENCODE) && (entrypoint == VAEntrypointEncSlice)) { - /* H264 is desired */ - if (((profile == VAProfileH264Baseline || - profile == VAProfileH264Main || - profile == VAProfileH264High || - profile == VAProfileH264ConstrainedBaseline)) && - strstr(fool_ctx->fn_enc, "h264")) - fool_ctx->enabled = 1; - - /* vp8 is desired */ - if ((profile == VAProfileVP8Version0_3) && - strstr(fool_ctx->fn_enc, "vp8")) - fool_ctx->enabled = 1; - } - if (fool_ctx->enabled) - va_infoMessage("FOOL is enabled for this context\n"); - else - va_infoMessage("FOOL is not enabled for this context\n"); - - - return 0; /* continue */ -} - - -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 */ -) -{ - unsigned int new_size = size * num_elements; - unsigned int old_size; - DPY2FOOLCTX_CHK(dpy); - - old_size = fool_ctx->fool_buf_size[type] * fool_ctx->fool_buf_element[type]; - - if (old_size < new_size) - fool_ctx->fool_buf[type] = realloc(fool_ctx->fool_buf[type], new_size); - - fool_ctx->fool_buf_size[type] = size; - fool_ctx->fool_buf_element[type] = num_elements; - fool_ctx->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_FoolBufferInfo( - VADisplay dpy, - VABufferID buf_id, /* in */ - VABufferType *type, /* out */ - unsigned int *size, /* out */ - unsigned int *num_elements /* out */ -) -{ - unsigned int magic; - - DPY2FOOLCTX_CHK(dpy); - - magic = buf_id & FOOL_BUFID_MASK; - if (magic != FOOL_BUFID_MAGIC) - return 0; /* could be VAImageBufferType from vaDeriveImage */ - - *type = buf_id & 0xff; - *size = fool_ctx->fool_buf_size[*type]; - *num_elements = fool_ctx->fool_buf_element[*type];; - - return 1; /* fool is valid */ -} - -static int va_FoolFillCodedBufEnc(struct fool_context *fool_ctx) -{ - char file_name[1024]; - struct stat file_stat = {0}; - VACodedBufferSegment *codedbuf; - int i, fd = -1; - - /* try file_name.file_count, if fail, try file_name.file_count-- */ - for (i=0; i<=1; i++) { - snprintf(file_name, 1024, "%s.%d", - fool_ctx->fn_enc, - fool_ctx->file_count); - - if ((fd = open(file_name, O_RDONLY)) != -1) { - fstat(fd, &file_stat); - fool_ctx->file_count++; /* open next file */ - break; - } else /* fall back to the first file file */ - fool_ctx->file_count = 0; - } - if (fd != -1) { - fool_ctx->segbuf_enc = realloc(fool_ctx->segbuf_enc, file_stat.st_size); - read(fd, fool_ctx->segbuf_enc, file_stat.st_size); - close(fd); - } else - va_errorMessage("Open file %s failed:%s\n", file_name, strerror(errno)); - - codedbuf = (VACodedBufferSegment *)fool_ctx->fool_buf[VAEncCodedBufferType]; - codedbuf->size = file_stat.st_size; - codedbuf->bit_offset = 0; - codedbuf->status = 0; - codedbuf->reserved = 0; - codedbuf->buf = fool_ctx->segbuf_enc; - codedbuf->next = NULL; - - return 0; -} - -static int va_FoolFillCodedBufJPG(struct fool_context *fool_ctx) -{ - struct stat file_stat = {0}; - VACodedBufferSegment *codedbuf; - int fd = -1; - - if ((fd = open(fool_ctx->fn_jpg, O_RDONLY)) != -1) { - fstat(fd, &file_stat); - fool_ctx->segbuf_jpg = realloc(fool_ctx->segbuf_jpg, file_stat.st_size); - read(fd, fool_ctx->segbuf_jpg, file_stat.st_size); - close(fd); - } else - va_errorMessage("Open file %s failed:%s\n", fool_ctx->fn_jpg, strerror(errno)); - - codedbuf = (VACodedBufferSegment *)fool_ctx->fool_buf[VAEncCodedBufferType]; - codedbuf->size = file_stat.st_size; - codedbuf->bit_offset = 0; - codedbuf->status = 0; - codedbuf->reserved = 0; - codedbuf->buf = fool_ctx->segbuf_jpg; - codedbuf->next = NULL; - - return 0; -} - - -static int va_FoolFillCodedBuf(struct fool_context *fool_ctx) -{ - if (fool_ctx->entrypoint == VAEntrypointEncSlice) - va_FoolFillCodedBufEnc(fool_ctx); - else if (fool_ctx->entrypoint == VAEntrypointEncPicture) - va_FoolFillCodedBufJPG(fool_ctx); - - return 0; -} - - -VAStatus va_FoolMapBuffer( - VADisplay dpy, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -) -{ - unsigned int magic, buftype; - DPY2FOOLCTX_CHK(dpy); - - magic = buf_id & FOOL_BUFID_MASK; - if (magic != FOOL_BUFID_MAGIC) - return 0; /* could be VAImageBufferType from vaDeriveImage */ - - buftype = buf_id & 0xff; - *pbuf = fool_ctx->fool_buf[buftype]; - - /* it is coded buffer, fill coded segment from file */ - if (*pbuf && (buftype == VAEncCodedBufferType)) - va_FoolFillCodedBuf(fool_ctx); - - return 1; /* fool is valid */ -} - -VAStatus va_FoolCheckContinuity(VADisplay dpy) -{ - DPY2FOOLCTX_CHK(dpy); - - return 1; /* fool is valid */ -} - diff --git a/va/va_fool.h b/va/va_fool.h deleted file mode 100644 index 6f4f917..0000000 --- a/va/va_fool.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2009 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. - */ - - -#ifndef VA_FOOL_H -#define VA_FOOL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern int fool_codec; -extern int fool_postp; - -#define VA_FOOL_FLAG_DECODE 0x1 -#define VA_FOOL_FLAG_ENCODE 0x2 -#define VA_FOOL_FLAG_JPEG 0x4 - -#define VA_FOOL_FUNC(fool_func,...) \ - if (fool_codec) { \ - if (fool_func(__VA_ARGS__)) \ - 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 */ -); - - -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_FoolMapBuffer ( - VADisplay dpy, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -); - -VAStatus va_FoolBufferInfo ( - VADisplay dpy, - VABufferID buf_id, /* in */ - VABufferType *type, /* out */ - unsigned int *size, /* out */ - unsigned int *num_elements /* out */ -); - -VAStatus va_FoolCheckContinuity(VADisplay dpy); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/va/va_tpi.c b/va/va_tpi.c deleted file mode 100644 index 21d547d..0000000 --- a/va/va_tpi.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_backend_tpi.h" - -#include -#include -#include -#include -#include -#include -#include - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } - - -/* - * Create surfaces with special inputs/requirements - */ -VAStatus vaCreateSurfacesWithAttribute ( - VADisplay dpy, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces, /* out */ - VASurfaceAttributeTPI *attribute_tpi -) -{ - VADriverContextP ctx; - struct VADriverVTableTPI *tpi; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - tpi = (struct VADriverVTableTPI *)ctx->vtable_tpi; - if (tpi && tpi->vaCreateSurfacesWithAttribute) { - return tpi->vaCreateSurfacesWithAttribute( ctx, width, height, format, num_surfaces, surfaces, attribute_tpi); - } else - return VA_STATUS_ERROR_UNIMPLEMENTED; -} - - -VAStatus vaPutSurfaceBuf ( - VADisplay dpy, - 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 */ -) -{ - VADriverContextP ctx; - struct VADriverVTableTPI *tpi; - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - tpi = ( struct VADriverVTableTPI *)ctx->vtable_tpi; - if (tpi && tpi->vaPutSurfaceBuf) { - return tpi->vaPutSurfaceBuf( ctx, surface, data, data_len, srcx, srcy, srcw, srch, - destx, desty, destw, desth, cliprects, number_cliprects, flags ); - } else - return VA_STATUS_ERROR_UNIMPLEMENTED; -} diff --git a/va/va_tpi.h b/va/va_tpi.h deleted file mode 100644 index d4a9d06..0000000 --- a/va/va_tpi.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2007-2009 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 INTEL 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_TPI_H_ -#define _VA_TPI_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef enum { - VAExternalMemoryNULL, /* it is not external buffer, but requires the implementation allocates - * the surface with the input attribute - */ - VAExternalMemoryV4L2Buffer, - VAExternalMemoryCIFrame, /* the memory is from camera frames and buffers points the frame ID list */ - VAExternalMemoryUserPointer, /* the memory is malloc-ed and buffers points to the buffers */ - VAExternalMemoryKernelDRMBufffer, /* the memory is from kernel DRM buffers and buffers points the - * DRM buffer handle list - */ - VAExternalMemoryAndroidGrallocBuffer, /* the memory is from Android Gralloc memory, and buffers points - * the gralloc native_handle_t list - */ -} VASurfaceMemoryType; - -typedef struct _VASurfaceAttributeTPI { - VASurfaceMemoryType type; - unsigned int width; - unsigned int height; - unsigned int size; - unsigned int pixel_format; /* buffer format */ - unsigned int tiling; /* the memory is tiling or not */ - 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; /* U offset from the beginning of the memory */ - unsigned int chroma_v_offset; /* V offset from the beginning of the memory */ - unsigned int count; /* buffer count for surface creation */ - unsigned int *buffers; /* buffer handles or user pointers */ - unsigned int reserved[4]; /* used to pass additional information, like - * Android native window pointer - */ -} VASurfaceAttributeTPI; - - -VAStatus vaPutSurfaceBuf ( - VADisplay dpy, - 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 vaCreateSurfacesWithAttribute ( - VADisplay dpy, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces, /* out */ - VASurfaceAttributeTPI *attribute_tpi -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/va/va_trace.c b/va/va_trace.c deleted file mode 100644 index ff7aa5d..0000000 --- a/va/va_trace.c +++ /dev/null @@ -1,5119 +0,0 @@ - -/* - * Copyright (c) 2009-2011 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_enc_h264.h" -#include "va_backend.h" -#include "va_trace.h" -#include "va_enc_h264.h" -#include "va_enc_jpeg.h" -#include "va_enc_vp8.h" -#include "va_dec_jpeg.h" -#include "va_dec_vp8.h" -#include "va_dec_vp9.h" -#include "va_dec_hevc.h" -#include "va_vpp.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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 all VA data buffer into log_file - * .LIBVA_TRACE_CODEDBUF=coded_clip_file: save the coded clip into file coded_clip_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_SURFACE_GEOMETRY=WIDTHxHEIGHT+XOFF+YOFF: only save part of surface context into file - * due to storage bandwidth limitation - */ - -/* global settings */ - -/* LIBVA_TRACE */ -int trace_flag = 0; - -#define MAX_TRACE_CTX_NUM 64 -#define TRACE_CTX_ID_MASK (MAX_TRACE_CTX_NUM - 1) - -#define MAX_TRACE_THREAD_NUM 64 - -#define MAX_TRACE_BUF_INFO_HASH_SIZE 1024 // 1<<10 -#define MAX_TRACE_BUF_INFO_HASH_LEVEL 3 -#define TRACE_BUF_INFO_HASH_ID_MASK (MAX_TRACE_BUF_INFO_HASH_SIZE - 1) - -struct trace_buf_info { - int valid; - - VABufferID buf_id; - VAContextID ctx_id; -}; - -struct trace_buf_manager { - struct trace_buf_info *pbuf_info[MAX_TRACE_BUF_INFO_HASH_LEVEL]; -}; - -struct trace_log_file { - pid_t thread_id; - int used; - - char *fn_log; - FILE *fp_log; -}; - -struct trace_log_files_manager { - int num; - - struct trace_log_file log_file[MAX_TRACE_THREAD_NUM]; -}; - -/* per context settings */ -struct trace_context { - struct trace_log_file *plog_file; - struct trace_log_file *plog_file_list[MAX_TRACE_THREAD_NUM]; - - /* LIBVA_TRACE_CODEDBUF */ - FILE *trace_fp_codedbuf; /* save the encode result into a file */ - char *trace_codedbuf_fn; /* file name */ - - /* LIBVA_TRACE_SURFACE */ - FILE *trace_fp_surface; /* save the surface YUV into a file */ - char *trace_surface_fn; /* file name */ - - VAContextID trace_context; /* current context */ - - VASurfaceID trace_rendertarget; /* current render target */ - VAProfile trace_profile; /* current profile for buffers */ - VAEntrypoint trace_entrypoint; /* current entrypoint */ - - unsigned int trace_frame_no; /* current frame NO */ - unsigned int trace_slice_no; /* current slice NO */ - unsigned int trace_slice_size; /* current slice buffer size */ - - unsigned int trace_surface_width; /* surface dumping geometry */ - unsigned int trace_surface_height; - unsigned int trace_surface_xoff; - unsigned int trace_surface_yoff; - - unsigned int trace_frame_width; /* current frame width */ - unsigned int trace_frame_height; /* current frame height */ - - unsigned int pts; /* IVF header information */ - - pid_t created_thd_id; -}; - -struct trace_config_info { - int valid; - VAConfigID config_id; - - VAProfile trace_profile; - VAEntrypoint trace_entrypoint; - - pid_t created_thd_id; -}; - -struct va_trace { - struct trace_context *ptra_ctx[MAX_TRACE_CTX_NUM + 1]; - int context_num; - struct trace_buf_manager buf_manager; - struct trace_log_files_manager log_files_manager; - struct trace_config_info config_info[MAX_TRACE_CTX_NUM]; - - char *fn_log_env; - char *fn_codedbuf_env; - char *fn_surface_env; - - pthread_mutex_t resource_mutex; - pthread_mutex_t context_mutex; -}; - -#define LOCK_RESOURCE(pva_trace) \ - if(pva_trace) \ - pthread_mutex_lock(&pva_trace->resource_mutex) - -#define UNLOCK_RESOURCE(pva_trace) \ - if(pva_trace) \ - pthread_mutex_unlock(&pva_trace->resource_mutex) - -#define LOCK_CONTEXT(pva_trace) \ - if(pva_trace) \ - pthread_mutex_lock(&pva_trace->context_mutex) - -#define UNLOCK_CONTEXT(pva_trace) \ - if(pva_trace) \ - pthread_mutex_unlock(&pva_trace->context_mutex) - -#define DPY2TRACECTX(dpy, context, buf_id) \ - struct va_trace *pva_trace = NULL; \ - struct trace_context *trace_ctx = NULL; \ - int ctx_id = context; \ - \ - pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \ - if(!pva_trace) \ - return; \ - \ - if(ctx_id == VA_INVALID_ID) { \ - if(buf_id != VA_INVALID_ID) \ - ctx_id = get_ctx_by_buf(pva_trace, buf_id); \ - else \ - return; \ - } \ - \ - if (ctx_id != VA_INVALID_ID) { \ - int temp_idx = get_valid_ctx_idx(pva_trace, ctx_id); \ - if(temp_idx < MAX_TRACE_CTX_NUM) \ - trace_ctx = pva_trace->ptra_ctx[temp_idx]; \ - } \ - \ - if(!trace_ctx \ - || trace_ctx->trace_context != context) { \ - return; \ - } \ - refresh_log_file(pva_trace, trace_ctx) - -#define DPY2TRACE_VIRCTX(dpy) \ - struct va_trace *pva_trace = NULL; \ - struct trace_context *trace_ctx = NULL; \ - \ - pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); \ - if(!pva_trace) \ - return; \ - \ - LOCK_CONTEXT(pva_trace); \ - trace_ctx = pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]; \ - if(!trace_ctx) { \ - UNLOCK_CONTEXT(pva_trace); \ - return; \ - } \ - refresh_log_file(pva_trace, trace_ctx) - -#define DPY2TRACE_VIRCTX_EXIT(pva_trace) \ - UNLOCK_CONTEXT(pva_trace) - -#define TRACE_FUNCNAME(idx) va_TraceMsg(trace_ctx, "==========%s\n", __func__); - -#define TRACE_NEWLINE() do { \ - va_TracePrint(trace_ctx, "\n"); \ - va_TraceMsg(trace_ctx, "") ; \ -} while (0) - -/* 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 - ); - -static int get_valid_config_idx( - struct va_trace *pva_trace, - VAConfigID config_id) -{ - struct trace_config_info *pconfig_info; - int idx = MAX_TRACE_CTX_NUM; - - LOCK_RESOURCE(pva_trace); - - pconfig_info = pva_trace->config_info; - idx = config_id & TRACE_CTX_ID_MASK; - if(!pconfig_info[idx].valid - || pconfig_info[idx].config_id != config_id) - idx = MAX_TRACE_CTX_NUM; - - UNLOCK_RESOURCE(pva_trace); - - return idx; -} - -static void add_trace_config_info( - struct va_trace *pva_trace, - VAConfigID config_id, - VAProfile profile, - VAEntrypoint entrypoint) -{ - struct trace_config_info *pconfig_info; - int idx = 0; - pid_t thd_id = syscall(__NR_gettid); - - LOCK_RESOURCE(pva_trace); - - idx = config_id & TRACE_CTX_ID_MASK; - pconfig_info = &pva_trace->config_info[idx]; - if(!pconfig_info->valid || - pconfig_info->config_id == config_id) { - pconfig_info->valid = 1; - pconfig_info->config_id = config_id; - pconfig_info->trace_profile = profile; - pconfig_info->trace_entrypoint = entrypoint; - pconfig_info->created_thd_id = thd_id; - } - - UNLOCK_RESOURCE(pva_trace); -} - -static void delete_trace_config_info( - struct va_trace *pva_trace, - VAConfigID config_id) -{ - struct trace_config_info *pconfig_info; - int idx = 0; - pid_t thd_id = syscall(__NR_gettid); - - LOCK_RESOURCE(pva_trace); - - idx = config_id & TRACE_CTX_ID_MASK; - pconfig_info = &pva_trace->config_info[idx]; - if(pconfig_info->valid && - pconfig_info->config_id == config_id && - pconfig_info->created_thd_id == thd_id) { - pconfig_info->valid = 0; - } - - UNLOCK_RESOURCE(pva_trace); -} - -static VAContextID get_ctx_by_buf( - struct va_trace *pva_trace, - VABufferID buf_id) -{ - struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; - struct trace_buf_info *pbuf_info = pbuf_mgr->pbuf_info[0]; - VAContextID context = VA_INVALID_ID; - int i = 0, idx = 0, valid = 0; - - LOCK_RESOURCE(pva_trace); - - idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; - for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { - pbuf_info = pbuf_mgr->pbuf_info[i]; - if(!pbuf_info) - break; - - if(pbuf_info[idx].valid - && pbuf_info[idx].buf_id == buf_id) { - context = pbuf_info[idx].ctx_id; - break; - } - } - - UNLOCK_RESOURCE(pva_trace); - - return context; -} - -static void add_trace_buf_info( - struct va_trace *pva_trace, - VAContextID context, - VABufferID buf_id) -{ - struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; - struct trace_buf_info *pbuf_info = NULL; - int i = 0, idx = 0; - - LOCK_RESOURCE(pva_trace); - - idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; - for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { - pbuf_info = pbuf_mgr->pbuf_info[i]; - if(!pbuf_info) { - pbuf_info = (struct trace_buf_info *)calloc( - sizeof(struct trace_buf_info) * MAX_TRACE_BUF_INFO_HASH_SIZE, - 1); - if(!pbuf_info) - break; - - pbuf_mgr->pbuf_info[i] = pbuf_info; - } - - if(pbuf_info[idx].valid - && pbuf_info[idx].buf_id != buf_id) - continue; - - pbuf_info[idx].buf_id = buf_id; - pbuf_info[idx].ctx_id = context; - pbuf_info[idx].valid = 1; - break; - } - - if(i >= MAX_TRACE_BUF_INFO_HASH_LEVEL) - va_errorMessage("Add buf info failed\n"); - - UNLOCK_RESOURCE(pva_trace); -} - -static void delete_trace_buf_info( - struct va_trace *pva_trace, - VABufferID buf_id) -{ - struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; - struct trace_buf_info *pbuf_info = NULL; - int i = 0, idx = 0; - - LOCK_RESOURCE(pva_trace); - - idx = buf_id & TRACE_BUF_INFO_HASH_ID_MASK; - for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { - pbuf_info = pbuf_mgr->pbuf_info[i]; - if(!pbuf_info) - break; - - if(pbuf_info[idx].valid - && pbuf_info[idx].buf_id == buf_id) { - pbuf_info[idx].valid = 0; - break; - } - } - - UNLOCK_RESOURCE(pva_trace); -} - -/* -static void delete_trace_all_context_buf( - struct va_trace *pva_trace, - VAContextID context) -{ - struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager; - struct trace_buf_info *pbuf_info = NULL; - int i = 0, j = 0; - - LOCK_RESOURCE(pva_trace); - - for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) { - pbuf_info = pbuf_mgr->pbuf_info[i]; - if(!pbuf_info) - break; - - for(j = 0;j < MAX_TRACE_BUF_INFO_HASH_SIZE;j++) - if(pbuf_info[j].valid - && pbuf_info[j].ctx_id == context) - pbuf_info[j].valid = 0; - } - - UNLOCK_RESOURCE(pva_trace); -} -*/ - -static int get_free_ctx_idx( - struct va_trace *pva_trace, - VAContextID context) -{ - int idx = MAX_TRACE_CTX_NUM; - int i = 0; - - LOCK_RESOURCE(pva_trace); - - i = context & TRACE_CTX_ID_MASK; - if(!pva_trace->ptra_ctx[i] - || pva_trace->ptra_ctx[i]->trace_context == context) - idx = i; - - UNLOCK_RESOURCE(pva_trace); - - return idx; -} - -static int get_valid_ctx_idx( - struct va_trace *pva_trace, - VAContextID context) -{ - int idx = MAX_TRACE_CTX_NUM; - int i = 0; - - LOCK_RESOURCE(pva_trace); - - i = context & TRACE_CTX_ID_MASK; - if(pva_trace->ptra_ctx[i] - && pva_trace->ptra_ctx[i]->trace_context == context) - idx = i; - - UNLOCK_RESOURCE(pva_trace); - - return idx; -} - -static void FILE_NAME_SUFFIX( - char *env_value, - int max_size, - char *suffix_str, - unsigned int suffix_handle) -{ - int tmp = strnlen(env_value, max_size); - int left = max_size - tmp; - struct timeval tv; - int size = 0; - - if (suffix_str) - strlen(suffix_str); - - if(left < (size + 8 + 10)) - return; - - if(gettimeofday(&tv, NULL) == 0) { - sprintf(env_value + tmp, - ".%02d%02d%02d.", - (unsigned int)(tv.tv_sec/3600)%24, - (unsigned int)(tv.tv_sec/60)%60, - (unsigned int)tv.tv_sec%60); - - tmp += 8; - left -= 8; - } - - if(suffix_str) { - strcat(env_value + tmp, - suffix_str); - - tmp += size; - left -= size; - } - - if(suffix_handle) { - sprintf(env_value + tmp, - "0x%08x", - suffix_handle); - } -} - -static int open_tracing_specil_file( - struct va_trace *pva_trace, - struct trace_context *ptra_ctx, - int type) // 0: codedbuf, 1: surface -{ - char *fn_env = type == 0 ? - pva_trace->fn_codedbuf_env : pva_trace->fn_surface_env; - char env_value[1024]; - FILE *fp = NULL; - - strncpy(env_value, fn_env, 1024); - env_value[1023] = '\0'; - FILE_NAME_SUFFIX(env_value, 1024, - "ctx-", (unsigned int)ptra_ctx->trace_context); - - fn_env = strdup(env_value); - if(!fn_env) - return -1; - - fp = fopen(fn_env, "w"); - if(!fp) { - free(fn_env); - - return -1; - } - - if(type == 0) { - ptra_ctx->trace_codedbuf_fn = fn_env; - ptra_ctx->trace_fp_codedbuf = fp; - va_infoMessage("LIBVA_TRACE_CODEDBUF is on, save codedbuf into %s\n", - fn_env); - } - else { - ptra_ctx->trace_surface_fn = fn_env; - ptra_ctx->trace_fp_surface = fp; - va_infoMessage("LIBVA_TRACE_SURFACE is on, save surface into %s\n", - fn_env); - } - - return 0; -} - -static int open_tracing_log_file( - struct va_trace *pva_trace, - struct trace_log_file *plog_file, - pid_t thd_id) -{ - FILE *pfp = NULL; - int new_fn_flag = 0; - - if(plog_file->used && plog_file->thread_id != thd_id) { - va_errorMessage("Try to open a busy log file occupied by other thread\n"); - - return -1; - } - - if(plog_file->thread_id != thd_id) { - char env_value[1024]; - - strncpy(env_value, pva_trace->fn_log_env, 1024); - env_value[1023] = '\0'; - FILE_NAME_SUFFIX(env_value, 1024, - "thd-", (unsigned int)thd_id); - - if(plog_file->fn_log) - free(plog_file->fn_log); - - plog_file->fn_log = strdup(env_value); - if(!plog_file->fn_log) - goto FAIL; - - new_fn_flag = 1; - } - - if(!plog_file->used) { - if(new_fn_flag) - pfp = fopen(plog_file->fn_log, "w"); - else - pfp = fopen(plog_file->fn_log, "a"); - - if(!pfp) - goto FAIL; - - va_infoMessage("%s %s for the thread 0x%08x\n", - new_fn_flag ? "Open new log file" : "Append to log file", - plog_file->fn_log, thd_id); - - plog_file->fp_log = pfp; - plog_file->thread_id = thd_id; - } - - plog_file->used++; - return 0; - -FAIL: - if(plog_file->fn_log) { - free(plog_file->fn_log); - plog_file->fn_log = NULL; - } - - return -1; -} - -static int get_log_file_idx_by_thd( - struct trace_log_files_manager *plog_files_mgr, - pid_t thd_id) -{ - struct trace_log_file *plog_file = plog_files_mgr->log_file; - int first_free_idx = MAX_TRACE_THREAD_NUM; - int i = 0; - - for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { - if(plog_file[i].thread_id == thd_id) - break; - else if(!plog_file[i].used && - first_free_idx >= MAX_TRACE_THREAD_NUM) - first_free_idx = i; - } - - if(i >= MAX_TRACE_THREAD_NUM) - i = first_free_idx; - - return i; -} - -static struct trace_log_file *start_tracing2log_file( - struct va_trace *pva_trace) -{ - struct trace_log_files_manager *plog_files_mgr = NULL; - struct trace_log_file *plog_file = NULL; - pid_t thd_id = syscall(__NR_gettid); - int i = 0; - - LOCK_RESOURCE(pva_trace); - - plog_files_mgr = &pva_trace->log_files_manager; - i = get_log_file_idx_by_thd(plog_files_mgr, thd_id); - if(i < MAX_TRACE_THREAD_NUM) { - plog_file = &plog_files_mgr->log_file[i]; - if(open_tracing_log_file(pva_trace, plog_file, thd_id) < 0) { - plog_file = NULL; - } - } - - UNLOCK_RESOURCE(pva_trace); - return plog_file; -} - -static void stop_tracing2log_file( - struct va_trace *pva_trace, - struct trace_log_file *plog_file) -{ - LOCK_RESOURCE(pva_trace); - - if(--plog_file->used <= 0) { - if(plog_file->fp_log) { - fclose(plog_file->fp_log); - plog_file->fp_log = NULL; - } - } - - UNLOCK_RESOURCE(pva_trace); -} - -static void refresh_log_file( - struct va_trace *pva_trace, - struct trace_context *ptra_ctx) -{ - struct trace_log_file *plog_file = NULL; - pid_t thd_id = syscall(__NR_gettid); - int i = 0; - - plog_file = ptra_ctx->plog_file; - if(plog_file && plog_file->thread_id != thd_id) { - plog_file = start_tracing2log_file(pva_trace); - if(plog_file) { - int first_free_idx = -1; - - ptra_ctx->plog_file = plog_file; - - for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { - if(!ptra_ctx->plog_file_list[i]){ - if(first_free_idx < 0) - first_free_idx = i; - } - else if(ptra_ctx->plog_file_list[i]->thread_id == thd_id) - break; - } - - if(i > MAX_TRACE_THREAD_NUM - && first_free_idx >= 0) - ptra_ctx->plog_file_list[first_free_idx] = plog_file; - } - } -} - -void va_TraceInit(VADisplay dpy) -{ - char env_value[1024]; - unsigned short suffix = 0xffff & ((unsigned int)time(NULL)); - FILE *tmp; - struct va_trace *pva_trace = calloc(sizeof(struct va_trace), 1); - struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1); - - if (pva_trace == NULL || trace_ctx == NULL) { - free(pva_trace); - free(trace_ctx); - - return; - } - - if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) { - pva_trace->fn_log_env = strdup(env_value); - trace_ctx->plog_file = start_tracing2log_file(pva_trace); - if(trace_ctx->plog_file) { - trace_ctx->plog_file_list[0] = trace_ctx->plog_file; - trace_flag = VA_TRACE_FLAG_LOG; - - va_infoMessage("LIBVA_TRACE is on, save log into %s\n", - trace_ctx->plog_file->fn_log); - } - else - va_errorMessage("Open file %s failed (%s)\n", env_value, strerror(errno)); - } - - /* may re-get the global settings for multiple context */ - 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) { - pva_trace->fn_codedbuf_env = strdup(env_value); - trace_flag |= VA_TRACE_FLAG_CODEDBUF; - } - - if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) { - pva_trace->fn_surface_env = strdup(env_value); - - /* 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; - - if (va_parseConfig("LIBVA_TRACE_SURFACE_GEOMETRY", &env_value[0]) == 0) { - char *p = env_value, *q; - - trace_ctx->trace_surface_width = strtod(p, &q); - p = q+1; /* skip "x" */ - trace_ctx->trace_surface_height = strtod(p, &q); - p = q+1; /* skip "+" */ - trace_ctx->trace_surface_xoff = strtod(p, &q); - p = q+1; /* skip "+" */ - trace_ctx->trace_surface_yoff = strtod(p, &q); - - va_infoMessage("LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n", - trace_ctx->trace_surface_width, - trace_ctx->trace_surface_height, - trace_ctx->trace_surface_xoff, - trace_ctx->trace_surface_yoff); - } - } - - pthread_mutex_init(&pva_trace->resource_mutex, NULL); - pthread_mutex_init(&pva_trace->context_mutex, NULL); - - trace_ctx->trace_context = VA_INVALID_ID; - pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM] = trace_ctx; - - ((VADisplayContextP)dpy)->vatrace = (void *)pva_trace; - - if(!trace_flag) - va_TraceEnd(dpy); -} - -void va_TraceEnd(VADisplay dpy) -{ - struct va_trace *pva_trace = NULL; - int i = 0, j = 0; - - pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); - if(!pva_trace) - return; - - if(pva_trace->fn_log_env) - free(pva_trace->fn_log_env); - - if(pva_trace->fn_codedbuf_env) - free(pva_trace->fn_codedbuf_env); - - if(pva_trace->fn_surface_env) - free(pva_trace->fn_surface_env); - - for(i = 0;i < MAX_TRACE_BUF_INFO_HASH_LEVEL;i++) - if(pva_trace->buf_manager.pbuf_info[i]) - free(pva_trace->buf_manager.pbuf_info[i]); - - for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) { - struct trace_log_file *plog_file = NULL; - - if(pva_trace->log_files_manager.num <= 0) - break; - - plog_file = &pva_trace->log_files_manager.log_file[i]; - if(plog_file) { - if(plog_file->fn_log) - free(plog_file->fn_log); - - if(plog_file->fp_log) - fclose(plog_file->fp_log); - - pva_trace->log_files_manager.num--; - } - } - - for(i = 0;i < MAX_TRACE_CTX_NUM;i++) { - struct trace_context *trace_ctx = NULL; - - if(pva_trace->context_num <= 0) - break; - - trace_ctx = pva_trace->ptra_ctx[i]; - if(trace_ctx) { - if(trace_ctx->trace_codedbuf_fn) - free(trace_ctx->trace_codedbuf_fn); - - if(trace_ctx->trace_fp_codedbuf) - fclose(trace_ctx->trace_fp_codedbuf); - - if(trace_ctx->trace_surface_fn) - free(trace_ctx->trace_surface_fn); - - if(trace_ctx->trace_fp_surface) - fclose(trace_ctx->trace_fp_surface); - - free(pva_trace->ptra_ctx[i]); - pva_trace->context_num--; - } - } - free(pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM]); - - free(pva_trace); - ((VADisplayContextP)dpy)->vatrace = NULL; -} - -static void va_TraceVPrint(struct trace_context *trace_ctx, const char *msg, va_list args) -{ - FILE *fp = NULL; - - if (!(trace_flag & VA_TRACE_FLAG_LOG) - || !trace_ctx->plog_file) - return; - - fp = trace_ctx->plog_file->fp_log; - if (msg) { - vfprintf(fp, msg, args); - } else - fflush(fp); -} - -static void va_TracePrint(struct trace_context *trace_ctx, const char *msg, ...) -{ - va_list args; - va_start(args, msg); - va_TraceVPrint(trace_ctx, msg, args); - va_end(args); -} - -static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...) -{ - va_list args; - struct timeval tv; - - if (!msg) { - va_TracePrint(trace_ctx, msg); - return; - } - - if (gettimeofday(&tv, NULL) == 0) - va_TracePrint(trace_ctx, "[%04d.%06d]", - (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec); - - if(trace_ctx->trace_context != VA_INVALID_ID) - va_TracePrint(trace_ctx, - "[ctx 0x%08x]", trace_ctx->trace_context); - else - va_TracePrint(trace_ctx, "[ctx none]"); - - va_start(args, msg); - va_TraceVPrint(trace_ctx, msg, args); - va_end(args); -} - -static void va_TraceSurface(VADisplay dpy, VAContextID context) -{ - unsigned 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, *UV_data, *tmp; - VAStatus va_status; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if (!trace_ctx->trace_fp_surface) - return; - - va_TraceMsg(trace_ctx, "==========dump surface data in file %s\n", trace_ctx->trace_surface_fn); - - va_TraceMsg(trace_ctx, NULL); - - va_status = vaLockSurface( - dpy, - trace_ctx->trace_rendertarget, - &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) { - va_TraceMsg(trace_ctx, "Error:vaLockSurface failed\n"); - return; - } - - va_TraceMsg(trace_ctx, "\tfourcc = 0x%08x\n", fourcc); - va_TraceMsg(trace_ctx, "\twidth = %d\n", trace_ctx->trace_frame_width); - va_TraceMsg(trace_ctx, "\theight = %d\n", trace_ctx->trace_frame_height); - va_TraceMsg(trace_ctx, "\tluma_stride = %d\n", luma_stride); - va_TraceMsg(trace_ctx, "\tchroma_u_stride = %d\n", chroma_u_stride); - va_TraceMsg(trace_ctx, "\tchroma_v_stride = %d\n", chroma_v_stride); - va_TraceMsg(trace_ctx, "\tluma_offset = %d\n", luma_offset); - va_TraceMsg(trace_ctx, "\tchroma_u_offset = %d\n", chroma_u_offset); - va_TraceMsg(trace_ctx, "\tchroma_v_offset = %d\n", chroma_v_offset); - - if (buffer == NULL) { - va_TraceMsg(trace_ctx, "Error:vaLockSurface return NULL buffer\n"); - va_TraceMsg(trace_ctx, NULL); - - vaUnlockSurface(dpy, trace_ctx->trace_rendertarget); - return; - } - va_TraceMsg(trace_ctx, "\tbuffer location = 0x%08x\n", buffer); - va_TraceMsg(trace_ctx, NULL); - - Y_data = (unsigned char*)buffer; - UV_data = (unsigned char*)buffer + chroma_u_offset; - - tmp = Y_data + luma_stride * trace_ctx->trace_surface_yoff; - for (i=0; itrace_surface_height; i++) { - fwrite(tmp + trace_ctx->trace_surface_xoff, - trace_ctx->trace_surface_width, - 1, trace_ctx->trace_fp_surface); - - tmp += luma_stride; - } - tmp = UV_data + chroma_u_stride * trace_ctx->trace_surface_yoff / 2; - if (fourcc == VA_FOURCC_NV12) { - for (i=0; itrace_surface_height/2; i++) { - fwrite(tmp + trace_ctx->trace_surface_xoff, - trace_ctx->trace_surface_width, - 1, trace_ctx->trace_fp_surface); - - tmp += chroma_u_stride; - } - } - - fflush(trace_ctx->trace_fp_surface); - - vaUnlockSurface(dpy, trace_ctx->trace_rendertarget); - - va_TraceMsg(trace_ctx, NULL); -} - - -void va_TraceInitialize ( - VADisplay dpy, - int *major_version, /* out */ - int *minor_version /* out */ -) -{ - DPY2TRACE_VIRCTX(dpy); - TRACE_FUNCNAME(idx); - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceTerminate ( - VADisplay dpy -) -{ - DPY2TRACE_VIRCTX(dpy); - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, NULL); - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - - -void va_TraceCreateConfig( - VADisplay dpy, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ -) -{ - int i; - - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\tprofile = %d\n", profile); - va_TraceMsg(trace_ctx, "\tentrypoint = %d\n", entrypoint); - va_TraceMsg(trace_ctx, "\tnum_attribs = %d\n", num_attribs); - if (attrib_list) { - for (i = 0; i < num_attribs; i++) { - va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].type = 0x%08x\n", i, attrib_list[i].type); - va_TraceMsg(trace_ctx, "\t\tattrib_list[%d].value = 0x%08x\n", i, attrib_list[i].value); - } - } - va_TraceMsg(trace_ctx, NULL); - - add_trace_config_info(pva_trace, *config_id, profile, entrypoint); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceDestroyConfig ( - VADisplay dpy, - VAConfigID config_id -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id); - va_TraceMsg(trace_ctx, NULL); - - delete_trace_config_info(pva_trace, config_id); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -static void va_TraceSurfaceAttributes( - struct trace_context *trace_ctx, - VASurfaceAttrib *attrib_list, - unsigned int *num_attribs -) -{ - int i, num; - VASurfaceAttrib *p; - - if (!attrib_list || !num_attribs) - return; - - p = attrib_list; - num = *num_attribs; - if (num > VASurfaceAttribCount) - num = VASurfaceAttribCount; - - for (i=0; ivalue.type; - - va_TraceMsg(trace_ctx, "\tattrib_list[%i] =\n", i); - - va_TraceMsg(trace_ctx, "\t\ttype = %d\n", p->type); - va_TraceMsg(trace_ctx, "\t\tflags = %d\n", p->flags); - va_TraceMsg(trace_ctx, "\t\tvalue.type = %d\n", type); - switch (type) { - case VAGenericValueTypeInteger: - va_TraceMsg(trace_ctx, "\t\tvalue.value.i = 0x%08x\n", p->value.value.i); - break; - case VAGenericValueTypeFloat: - va_TraceMsg(trace_ctx, "\t\tvalue.value.f = %f\n", p->value.value.f); - break; - case VAGenericValueTypePointer: - va_TraceMsg(trace_ctx, "\t\tvalue.value.p = %p\n", p->value.value.p); - if ((p->type == VASurfaceAttribExternalBufferDescriptor) && p->value.value.p) { - VASurfaceAttribExternalBuffers *tmp = (VASurfaceAttribExternalBuffers *) p->value.value.p; - int j; - - va_TraceMsg(trace_ctx, "\t\t--VASurfaceAttribExternalBufferDescriptor\n"); - va_TraceMsg(trace_ctx, "\t\t pixel_format=0x%08x\n", tmp->pixel_format); - va_TraceMsg(trace_ctx, "\t\t width=%d\n", tmp->width); - va_TraceMsg(trace_ctx, "\t\t height=%d\n", tmp->height); - va_TraceMsg(trace_ctx, "\t\t data_size=%d\n", tmp->data_size); - va_TraceMsg(trace_ctx, "\t\t num_planes=%d\n", tmp->num_planes); - va_TraceMsg(trace_ctx, "\t\t pitches[4]=%d %d %d %d\n", - tmp->pitches[0], tmp->pitches[1], tmp->pitches[2], tmp->pitches[3]); - va_TraceMsg(trace_ctx, "\t\t offsets[4]=%d %d %d %d\n", - tmp->offsets[0], tmp->offsets[1], tmp->offsets[2], tmp->offsets[3]); - va_TraceMsg(trace_ctx, "\t\t flags=0x%08x\n", tmp->flags); - va_TraceMsg(trace_ctx, "\t\t num_buffers=0x%08x\n", tmp->num_buffers); - va_TraceMsg(trace_ctx, "\t\t buffers=%p\n", tmp->buffers); - for (j = 0; j < tmp->num_buffers; j++) { - va_TraceMsg(trace_ctx, "\t\t\tbuffers[%d]=%p\n", j, tmp->buffers[j]); - } - } - break; - case VAGenericValueTypeFunc: - va_TraceMsg(trace_ctx, "\t\tvalue.value.fn = %p\n", p->value.value.fn); - break; - default: - break; - } - - p++; - } -} - -void va_TraceCreateSurfaces( - VADisplay dpy, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces, /* out */ - VASurfaceAttrib *attrib_list, - unsigned int num_attribs -) -{ - int i; - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\twidth = %d\n", width); - va_TraceMsg(trace_ctx, "\theight = %d\n", height); - va_TraceMsg(trace_ctx, "\tformat = %d\n", format); - va_TraceMsg(trace_ctx, "\tnum_surfaces = %d\n", num_surfaces); - - if (surfaces) { - for (i = 0; i < num_surfaces; i++) - va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surfaces[i]); - } - - va_TraceSurfaceAttributes(trace_ctx, attrib_list, &num_attribs); - - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceDestroySurfaces( - VADisplay dpy, - VASurfaceID *surface_list, - int num_surfaces -) -{ - int i; - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - if (surface_list) { - for (i = 0; i < num_surfaces; i++) - va_TraceMsg(trace_ctx, "\t\tsurfaces[%d] = 0x%08x\n", i, surface_list[i]); - } - - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - - -static void internal_TraceUpdateContext ( - struct va_trace *pva_trace, - int tra_ctx_idx, - struct trace_context *new_trace_ctx, - VAContextID context, - int destroy_flag -) -{ - struct trace_context *trace_ctx = NULL; - int i = 0, delete = 1; - pid_t thd_id = syscall(__NR_gettid); - - if(tra_ctx_idx >= MAX_TRACE_CTX_NUM) - return; - - LOCK_RESOURCE(pva_trace); - - trace_ctx = pva_trace->ptra_ctx[tra_ctx_idx]; - if(trace_ctx) { - if(!new_trace_ctx && - trace_ctx->created_thd_id != thd_id - && !destroy_flag) { - delete = 0; - } - else { - pva_trace->context_num--; - pva_trace->ptra_ctx[tra_ctx_idx] = NULL; - } - } - - if(new_trace_ctx) { - new_trace_ctx->created_thd_id = thd_id; - pva_trace->ptra_ctx[tra_ctx_idx] = new_trace_ctx; - pva_trace->context_num++; - } - - UNLOCK_RESOURCE(pva_trace); - - if(trace_ctx && delete) { - for(i = 0;i < MAX_TRACE_THREAD_NUM;i++) - if(trace_ctx->plog_file_list[i]) - stop_tracing2log_file(pva_trace, trace_ctx->plog_file_list[i]); - - if(trace_ctx->trace_codedbuf_fn) - free(trace_ctx->trace_codedbuf_fn); - - if(trace_ctx->trace_fp_codedbuf) - fclose(trace_ctx->trace_fp_codedbuf); - - if(trace_ctx->trace_surface_fn) - free(trace_ctx->trace_surface_fn); - - if(trace_ctx->trace_fp_surface) - fclose(trace_ctx->trace_fp_surface); - - //delete_trace_all_context_buf(pva_trace, context); - - free(trace_ctx); - } -} - -void va_TraceCreateContext( - VADisplay dpy, - VAConfigID config_id, - int picture_width, - int picture_height, - int flag, - VASurfaceID *render_targets, - int num_render_targets, - VAContextID *context /* out */ -) -{ - struct va_trace *pva_trace = NULL; - struct trace_context *trace_ctx = NULL; - int tra_ctx_id = 0; - int encode = 0, decode = 0, jpeg = 0; - int i; - - pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); - if(!context - || *context == VA_INVALID_ID - || !pva_trace) { - va_errorMessage("Invalid context id 0x%08x\n", - context == NULL ? 0 : (int)*context); - return; - } - - LOCK_CONTEXT(pva_trace); - - tra_ctx_id = get_free_ctx_idx(pva_trace, *context); - if(tra_ctx_id >= MAX_TRACE_CTX_NUM) { - va_errorMessage("Can't get trace context for ctx 0x%08x\n", - *context); - - goto FAIL; - } - - trace_ctx = calloc(sizeof(struct trace_context), 1); - if(trace_ctx == NULL) { - va_errorMessage("Allocate trace context failed for ctx 0x%08x\n", - *context); - - goto FAIL; - } - - i = get_valid_config_idx(pva_trace, config_id); - if(i >= MAX_TRACE_CTX_NUM) { - va_errorMessage("Can't get trace config id for ctx 0x%08x cfg %x\n", - *context, config_id); - - goto FAIL; - } - trace_ctx->trace_profile = pva_trace->config_info[i].trace_profile; - trace_ctx->trace_entrypoint = pva_trace->config_info[i].trace_entrypoint; - - if(trace_flag & VA_TRACE_FLAG_LOG) { - trace_ctx->plog_file = start_tracing2log_file(pva_trace); - if(!trace_ctx->plog_file) { - va_errorMessage("Can't get trace log file for ctx 0x%08x\n", - *context); - - goto FAIL; - } - else - va_infoMessage("Save context 0x%08x into log file %s\n", *context, - trace_ctx->plog_file->fn_log); - - trace_ctx->plog_file_list[0] = trace_ctx->plog_file; - } - - trace_ctx->trace_context = *context; - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tcontext = 0x%08x trace_flag 0x%x\n", *context, trace_flag); - va_TraceMsg(trace_ctx, "\tprofile = %d entrypoint = %d\n", trace_ctx->trace_profile, - trace_ctx->trace_entrypoint); - va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config_id); - va_TraceMsg(trace_ctx, "\twidth = %d\n", picture_width); - va_TraceMsg(trace_ctx, "\theight = %d\n", picture_height); - va_TraceMsg(trace_ctx, "\tflag = 0x%08x\n", flag); - va_TraceMsg(trace_ctx, "\tnum_render_targets = %d\n", num_render_targets); - if (render_targets) { - for (i=0; itrace_frame_no = 0; - trace_ctx->trace_slice_no = 0; - - trace_ctx->trace_frame_width = picture_width; - trace_ctx->trace_frame_height = picture_height; - - if (trace_ctx->trace_surface_width == 0) - trace_ctx->trace_surface_width = picture_width; - if (trace_ctx->trace_surface_height == 0) - trace_ctx->trace_surface_height = picture_height; - - /* avoid to create so many empty files */ - encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice); - decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD); - jpeg = (trace_ctx->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))) { - if(open_tracing_specil_file(pva_trace, trace_ctx, 1) < 0) { - va_errorMessage("Open surface fail failed for ctx 0x%08x\n", *context); - - trace_flag &= ~(VA_TRACE_FLAG_SURFACE); - } - } - - if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) { - if(open_tracing_specil_file(pva_trace, trace_ctx, 0) < 0) { - va_errorMessage("Open codedbuf fail failed for ctx 0x%08x\n", *context); - - trace_flag &= ~(VA_TRACE_FLAG_CODEDBUF); - } - } - - internal_TraceUpdateContext(pva_trace, tra_ctx_id, trace_ctx, *context, 0); - - UNLOCK_CONTEXT(pva_trace); - return; - -FAIL: - internal_TraceUpdateContext(pva_trace, tra_ctx_id, NULL, *context, 1); - - UNLOCK_CONTEXT(pva_trace); - - if(trace_ctx) - free(trace_ctx); -} - -void va_TraceDestroyContext ( - VADisplay dpy, - VAContextID context -) -{ - struct va_trace *pva_trace = NULL; - struct trace_context *trace_ctx = NULL; - int ctx_id = 0; - - pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace); - - if(!pva_trace) - return; - - LOCK_CONTEXT(pva_trace); - - ctx_id = get_valid_ctx_idx(pva_trace, context); - if(ctx_id < MAX_TRACE_CTX_NUM) { - trace_ctx = pva_trace->ptra_ctx[ctx_id]; - - if(trace_ctx) { - refresh_log_file(pva_trace, trace_ctx); - - internal_TraceUpdateContext(pva_trace, - get_valid_ctx_idx(pva_trace, context), - NULL, context, 0); - } - } - - UNLOCK_CONTEXT(pva_trace); -} - -static char * buffer_type_to_string(int type) -{ - switch (type) { - case VAPictureParameterBufferType: return "VAPictureParameterBufferType"; - case VAIQMatrixBufferType: return "VAIQMatrixBufferType"; - case VABitPlaneBufferType: return "VABitPlaneBufferType"; - case VASliceGroupMapBufferType: return "VASliceGroupMapBufferType"; - case VASliceParameterBufferType: return "VASliceParameterBufferType"; - case VASliceDataBufferType: return "VASliceDataBufferType"; - case VAProtectedSliceDataBufferType: return "VAProtectedSliceDataBufferType"; - case VAMacroblockParameterBufferType: return "VAMacroblockParameterBufferType"; - case VAResidualDataBufferType: return "VAResidualDataBufferType"; - case VADeblockingParameterBufferType: return "VADeblockingParameterBufferType"; - case VAImageBufferType: return "VAImageBufferType"; - case VAQMatrixBufferType: return "VAQMatrixBufferType"; - case VAHuffmanTableBufferType: return "VAHuffmanTableBufferType"; -/* Following are encode buffer types */ - case VAEncCodedBufferType: return "VAEncCodedBufferType"; - case VAEncSequenceParameterBufferType: return "VAEncSequenceParameterBufferType"; - case VAEncPictureParameterBufferType: return "VAEncPictureParameterBufferType"; - case VAEncSliceParameterBufferType: return "VAEncSliceParameterBufferType"; - case VAEncPackedHeaderParameterBufferType: return "VAEncPackedHeaderParameterBufferType"; - case VAEncPackedHeaderDataBufferType: return "VAEncPackedHeaderDataBufferType"; - case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType"; - case VAEncMacroblockParameterBufferType: return "VAEncMacroblockParameterBufferType"; - case VAProcPipelineParameterBufferType: return "VAProcPipelineParameterBufferType"; - case VAProcFilterParameterBufferType: return "VAProcFilterParameterBufferType"; - default: return "UnknowBuffer"; - } -} - -void va_TraceCreateBuffer ( - VADisplay dpy, - VAContextID context, /* in */ - VABufferType type, /* in */ - unsigned int size, /* in */ - unsigned int num_elements, /* in */ - void *data, /* in */ - VABufferID *buf_id /* out */ -) -{ - if (!buf_id || *buf_id == VA_INVALID_ID) - return; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - add_trace_buf_info(pva_trace, context, *buf_id); - - /* only trace CodedBuffer */ - if (type != VAEncCodedBufferType) - return; - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type)); - if (buf_id) - va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", *buf_id); - va_TraceMsg(trace_ctx, "\tsize=%u\n", size); - va_TraceMsg(trace_ctx, "\tnum_elements=%u\n", num_elements); - - va_TraceMsg(trace_ctx, NULL); -} - -void va_TraceDestroyBuffer ( - VADisplay dpy, - VABufferID buf_id /* in */ -) -{ - VABufferType type; - unsigned int size; - unsigned int num_elements; - - if (buf_id == VA_INVALID_ID) - return; - - DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id); - - vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements); - - delete_trace_buf_info(pva_trace, buf_id); - - /* only trace CodedBuffer */ - if (type != VAEncCodedBufferType) - return; - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type)); - va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id); - va_TraceMsg(trace_ctx, "\tsize=%u\n", size); - va_TraceMsg(trace_ctx, "\tnum_elements=%u\n", num_elements); - - va_TraceMsg(trace_ctx, NULL); -} - - -static void mem_put_le16(char *mem, unsigned int val) -{ - mem[0] = val; - mem[1] = val>>8; -} - -static void mem_put_le32(char *mem, unsigned int val) -{ - mem[0] = val; - mem[1] = val>>8; - mem[2] = val>>16; - mem[3] = val>>24; -} - -static void va_TraceCodedBufferIVFHeader(struct trace_context *trace_ctx, void **pbuf) -{ - VACodedBufferSegment *buf_list; - unsigned int frame_length = 0; - char header[32]; - - buf_list = (VACodedBufferSegment *)(*pbuf); - - if (ftell(trace_ctx->trace_fp_codedbuf) == 0) { /* write ivf header */ - header[0] = 'D'; - header[1] = 'K'; - header[2] = 'I'; - header[3] = 'F'; - mem_put_le16(header+4, 0); /* version */ - mem_put_le16(header+6, 32); /* headersize */ - mem_put_le32(header+8, 0x30385056); /* headersize */ - /* write width and height of the first rc_param to IVF file header */ - mem_put_le16(header+12, trace_ctx->trace_frame_width); /* width */ - mem_put_le16(header+14, trace_ctx->trace_frame_height); /* height */ - mem_put_le32(header+16, 30); /* rate */ - mem_put_le32(header+20, 1); /* scale */ - mem_put_le32(header+24, 0xffffffff); /* length */ - mem_put_le32(header+28, 0); /* unused */ - fwrite(header, 1, 32, trace_ctx->trace_fp_codedbuf); - } - - /* write frame header */ - while (buf_list != NULL) { - frame_length += buf_list->size; - buf_list = (VACodedBufferSegment *) buf_list->next; - } - mem_put_le32(header, frame_length); - mem_put_le32(header+4, trace_ctx->pts&0xFFFFFFFF); - mem_put_le32(header+8, 0); - fwrite(header, 1, 12, trace_ctx->trace_fp_codedbuf); - trace_ctx->pts++; - - fflush(trace_ctx->trace_fp_codedbuf); -} - -void va_TraceMapBuffer ( - VADisplay dpy, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -) -{ - VABufferType type; - unsigned int size; - unsigned int num_elements; - - VACodedBufferSegment *buf_list; - int i = 0; - - DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id); - - vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements); - - /* only trace CodedBuffer */ - if (type != VAEncCodedBufferType) - return; - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tbuf_id=0x%x\n", buf_id); - va_TraceMsg(trace_ctx, "\tbuf_type=%s\n", buffer_type_to_string(type)); - if ((pbuf == NULL) || (*pbuf == NULL)) - return; - - if (trace_ctx->trace_profile == VAProfileVP8Version0_3) { - va_TraceMsg(trace_ctx, "\tAdd IVF header information\n"); - va_TraceCodedBufferIVFHeader(trace_ctx, pbuf); - } - - buf_list = (VACodedBufferSegment *)(*pbuf); - while (buf_list != NULL) { - va_TraceMsg(trace_ctx, "\tCodedbuf[%d] =\n", i++); - - va_TraceMsg(trace_ctx, "\t size = %u\n", buf_list->size); - va_TraceMsg(trace_ctx, "\t bit_offset = %u\n", buf_list->bit_offset); - va_TraceMsg(trace_ctx, "\t status = 0x%08x\n", buf_list->status); - va_TraceMsg(trace_ctx, "\t reserved = 0x%08x\n", buf_list->reserved); - va_TraceMsg(trace_ctx, "\t buf = 0x%08x\n", buf_list->buf); - - if (trace_ctx->trace_fp_codedbuf) { - va_TraceMsg(trace_ctx, "\tDump the content to file\n"); - fwrite(buf_list->buf, buf_list->size, 1, trace_ctx->trace_fp_codedbuf); - - fflush(trace_ctx->trace_fp_codedbuf); - } - - buf_list = buf_list->next; - } - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVABuffers( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - unsigned int i; - unsigned char *p = pbuf; - FILE *fp = NULL; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TracePrint(trace_ctx, "--%s\n", buffer_type_to_string(type)); - - if(trace_ctx->plog_file) - fp = trace_ctx->plog_file->fp_log; - - if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && fp) { - for (i=0; ihorizontal_size); - va_TraceMsg(trace_ctx,"\tvertical size= %d\n", p->vertical_size); - va_TraceMsg(trace_ctx,"\tforward reference picture= %d\n", p->forward_reference_picture); - va_TraceMsg(trace_ctx,"\tbackward reference picture= %d\n", p->backward_reference_picture); - va_TraceMsg(trace_ctx,"\tpicture coding type= %d\n", p->picture_coding_type); - va_TraceMsg(trace_ctx,"\tf mode= %d\n", p->f_code); - - va_TraceMsg(trace_ctx,"\tpicture coding extension = %d\n", p->picture_coding_extension.value); - va_TraceMsg(trace_ctx,"\tintra_dc_precision= %d\n", p->picture_coding_extension.bits.intra_dc_precision); - va_TraceMsg(trace_ctx,"\tpicture_structure= %d\n", p->picture_coding_extension.bits.picture_structure); - va_TraceMsg(trace_ctx,"\ttop_field_first= %d\n", p->picture_coding_extension.bits.top_field_first); - va_TraceMsg(trace_ctx,"\tframe_pred_frame_dct= %d\n", p->picture_coding_extension.bits.frame_pred_frame_dct); - va_TraceMsg(trace_ctx,"\tconcealment_motion_vectors= %d\n", p->picture_coding_extension.bits.concealment_motion_vectors); - va_TraceMsg(trace_ctx,"\tq_scale_type= %d\n", p->picture_coding_extension.bits.q_scale_type); - va_TraceMsg(trace_ctx,"\tintra_vlc_format= %d\n", p->picture_coding_extension.bits.intra_vlc_format); - va_TraceMsg(trace_ctx,"\talternate_scan= %d\n", p->picture_coding_extension.bits.alternate_scan); - va_TraceMsg(trace_ctx,"\trepeat_first_field= %d\n", p->picture_coding_extension.bits.repeat_first_field); - va_TraceMsg(trace_ctx,"\tprogressive_frame= %d\n", p->picture_coding_extension.bits.progressive_frame); - va_TraceMsg(trace_ctx,"\tis_first_field= %d\n", p->picture_coding_extension.bits.is_first_field); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAIQMatrixBufferMPEG2( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAIQMatrixBufferMPEG2 *p=(VAIQMatrixBufferMPEG2 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG2\n"); - - va_TraceMsg(trace_ctx,"\tload_intra_quantiser_matrix = %d\n", p->load_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tload_non_intra_quantiser_matrix = %d\n", p->load_non_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tload_chroma_intra_quantiser_matrix = %d\n", p->load_chroma_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tload_chroma_non_intra_quantiser_matrix = %d\n", p->load_chroma_non_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tintra_quantiser_matrix = %d\n", p->intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tnon_intra_quantiser_matrix = %d\n", p->non_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tchroma_intra_quantiser_matrix = %d\n", p->chroma_intra_quantiser_matrix); - va_TraceMsg(trace_ctx,"\tchroma_non_intra_quantiser_matrix = %d\n", p->chroma_non_intra_quantiser_matrix); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVASliceParameterBufferMPEG2( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VASliceParameterBufferMPEG2 *p=(VASliceParameterBufferMPEG2 *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - trace_ctx->trace_slice_no++; - - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TraceMsg(trace_ctx,"VASliceParameterBufferMPEG2\n"); - - va_TraceMsg(trace_ctx,"\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx,"\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx,"\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx,"\tmacroblock_offset = %d\n", p->macroblock_offset); - va_TraceMsg(trace_ctx,"\tslice_horizontal_position = %d\n", p->slice_horizontal_position); - va_TraceMsg(trace_ctx,"\tslice_vertical_position = %d\n", p->slice_vertical_position); - va_TraceMsg(trace_ctx,"\tquantiser_scale_code = %d\n", p->quantiser_scale_code); - va_TraceMsg(trace_ctx,"\tintra_slice_flag = %d\n", p->intra_slice_flag); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAPictureParameterBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAPictureParameterBufferJPEGBaseline *p=(VAPictureParameterBufferJPEGBaseline *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx,"*VAPictureParameterBufferJPEG\n"); - va_TraceMsg(trace_ctx,"\tpicture_width = %u\n", p->picture_width); - va_TraceMsg(trace_ctx,"\tpicture_height = %u\n", p->picture_height); - va_TraceMsg(trace_ctx,"\tcomponents = \n"); - for (i = 0; i < p->num_components && i < 255; ++i) { - va_TraceMsg(trace_ctx,"\t\t[%d] component_id = %u\n", i, p->components[i].component_id); - va_TraceMsg(trace_ctx,"\t\t[%d] h_sampling_factor = %u\n", i, p->components[i].h_sampling_factor); - va_TraceMsg(trace_ctx,"\t\t[%d] v_sampling_factor = %u\n", i, p->components[i].v_sampling_factor); - va_TraceMsg(trace_ctx,"\t\t[%d] quantiser_table_selector = %u\n", i, p->components[i].quantiser_table_selector); - } -} - -static void va_TraceVAIQMatrixBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i, j; - static char tmp[1024]; - VAIQMatrixBufferJPEGBaseline *p=(VAIQMatrixBufferJPEGBaseline *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - va_TraceMsg(trace_ctx,"*VAIQMatrixParameterBufferJPEG\n"); - va_TraceMsg(trace_ctx,"\tload_quantiser_table =\n"); - for (i = 0; i < 4; ++i) { - va_TraceMsg(trace_ctx,"\t\t[%d] = %u\n", i, p->load_quantiser_table[i]); - } - va_TraceMsg(trace_ctx,"\tquantiser_table =\n"); - for (i = 0; i < 4; ++i) { - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 64; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->quantiser_table[i][j]); - } - va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp); - } -} - -static void va_TraceVASliceParameterBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VASliceParameterBufferJPEGBaseline *p=(VASliceParameterBufferJPEGBaseline *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - va_TraceMsg(trace_ctx,"*VASliceParameterBufferJPEG\n"); - va_TraceMsg(trace_ctx,"\tslice_data_size = %u\n", p->slice_data_size); - va_TraceMsg(trace_ctx,"\tslice_data_offset = %u\n", p->slice_data_offset); - va_TraceMsg(trace_ctx,"\tslice_data_flag = %u\n", p->slice_data_flag); - va_TraceMsg(trace_ctx,"\tslice_horizontal_position = %u\n", p->slice_horizontal_position); - va_TraceMsg(trace_ctx,"\tslice_vertical_position = %u\n", p->slice_vertical_position); - va_TraceMsg(trace_ctx,"\tcomponents = \n"); - for (i = 0; i < p->num_components && i < 4; ++i) { - va_TraceMsg(trace_ctx,"\t\t[%d] component_selector = %u\n", i, p->components[i].component_selector); - va_TraceMsg(trace_ctx,"\t\t[%d] dc_table_selector = %u\n", i, p->components[i].dc_table_selector); - va_TraceMsg(trace_ctx,"\t\t[%d] ac_table_selector = %u\n", i, p->components[i].ac_table_selector); - } - va_TraceMsg(trace_ctx,"\trestart_interval = %u\n", p->restart_interval); - va_TraceMsg(trace_ctx,"\tnum_mcus = %u\n", p->num_mcus); -} - -static void va_TraceVAHuffmanTableBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i, j; - static char tmp[1024]; - VAHuffmanTableBufferJPEGBaseline *p=(VAHuffmanTableBufferJPEGBaseline *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - va_TraceMsg(trace_ctx,"*VAHuffmanTableBufferJPEG\n"); - - for (i = 0; i < 2; ++i) { - va_TraceMsg(trace_ctx,"\tload_huffman_table[%d] =%u\n", i, p->load_huffman_table[i]); - va_TraceMsg(trace_ctx,"\thuffman_table[%d] =\n", i); - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 16; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_dc_codes[j]); - } - va_TraceMsg(trace_ctx,"\t\tnum_dc_codes =%s\n", tmp); - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 12; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].dc_values[j]); - } - va_TraceMsg(trace_ctx,"\t\tdc_values =%s\n", tmp); - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 16; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].num_ac_codes[j]); - } - va_TraceMsg(trace_ctx,"\t\tnum_ac_codes =%s\n", tmp); - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 162; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].ac_values[j]); - } - va_TraceMsg(trace_ctx,"\t\tac_values =%s\n", tmp); - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 2; ++j) { - sprintf(tmp + strlen(tmp), "%u ", p->huffman_table[i].pad[j]); - } - va_TraceMsg(trace_ctx,"\t\tpad =%s\n", tmp); - } -} - -static void va_TraceVAPictureParameterBufferMPEG4( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAPictureParameterBufferMPEG4 *p=(VAPictureParameterBufferMPEG4 *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx,"*VAPictureParameterBufferMPEG4\n"); - va_TraceMsg(trace_ctx,"\tvop_width = %d\n", p->vop_width); - va_TraceMsg(trace_ctx,"\tvop_height = %d\n", p->vop_height); - va_TraceMsg(trace_ctx,"\tforward_reference_picture = %d\n", p->forward_reference_picture); - va_TraceMsg(trace_ctx,"\tbackward_reference_picture = %d\n", p->backward_reference_picture); - va_TraceMsg(trace_ctx,"\tvol_fields value = %d\n", p->vol_fields.value); - va_TraceMsg(trace_ctx,"\tshort_video_header= %d\n", p->vol_fields.bits.short_video_header); - va_TraceMsg(trace_ctx,"\tchroma_format= %d\n", p->vol_fields.bits.chroma_format); - va_TraceMsg(trace_ctx,"\tinterlaced= %d\n", p->vol_fields.bits.interlaced); - va_TraceMsg(trace_ctx,"\tobmc_disable= %d\n", p->vol_fields.bits.obmc_disable); - va_TraceMsg(trace_ctx,"\tsprite_enable= %d\n", p->vol_fields.bits.sprite_enable); - va_TraceMsg(trace_ctx,"\tsprite_warping_accuracy= %d\n", p->vol_fields.bits.sprite_warping_accuracy); - va_TraceMsg(trace_ctx,"\tquant_type= %d\n", p->vol_fields.bits.quant_type); - va_TraceMsg(trace_ctx,"\tquarter_sample= %d\n", p->vol_fields.bits.quarter_sample); - va_TraceMsg(trace_ctx,"\tdata_partitioned= %d\n", p->vol_fields.bits.data_partitioned); - va_TraceMsg(trace_ctx,"\treversible_vlc= %d\n", p->vol_fields.bits.reversible_vlc); - va_TraceMsg(trace_ctx,"\tresync_marker_disable= %d\n", p->vol_fields.bits.resync_marker_disable); - va_TraceMsg(trace_ctx,"\tno_of_sprite_warping_points = %d\n", p->no_of_sprite_warping_points); - va_TraceMsg(trace_ctx,"\tsprite_trajectory_du ="); - for(i=0;i<3;i++) - va_TraceMsg(trace_ctx,"\t%d", p->sprite_trajectory_du[i]); - - va_TraceMsg(trace_ctx,"\n"); - va_TraceMsg(trace_ctx,"\tsprite_trajectory_dv ="); - for(i=0;i<3;i++) - va_TraceMsg(trace_ctx,"\t%d", p->sprite_trajectory_dv[i]); - va_TraceMsg(trace_ctx,"\n"); - va_TraceMsg(trace_ctx,"\tvop_fields value = %d\n", p->vop_fields.value); - va_TraceMsg(trace_ctx,"\tvop_coding_type= %d\n", p->vop_fields.bits.vop_coding_type); - va_TraceMsg(trace_ctx,"\tbackward_reference_vop_coding_type= %d\n", p->vop_fields.bits.backward_reference_vop_coding_type); - va_TraceMsg(trace_ctx,"\tvop_rounding_type= %d\n", p->vop_fields.bits.vop_rounding_type); - va_TraceMsg(trace_ctx,"\tintra_dc_vlc_thr= %d\n", p->vop_fields.bits.intra_dc_vlc_thr); - va_TraceMsg(trace_ctx,"\ttop_field_first= %d\n", p->vop_fields.bits.top_field_first); - va_TraceMsg(trace_ctx,"\talternate_vertical_scan_flag= %d\n", p->vop_fields.bits.alternate_vertical_scan_flag); - va_TraceMsg(trace_ctx,"\tvop_fcode_forward = %d\n", p->vop_fcode_forward); - va_TraceMsg(trace_ctx,"\tvop_fcode_backward = %d\n", p->vop_fcode_backward); - va_TraceMsg(trace_ctx,"\tnum_gobs_in_vop = %d\n", p->num_gobs_in_vop); - va_TraceMsg(trace_ctx,"\tnum_macroblocks_in_gob = %d\n", p->num_macroblocks_in_gob); - va_TraceMsg(trace_ctx,"\tTRB = %d\n", p->TRB); - va_TraceMsg(trace_ctx,"\tTRD = %d\n", p->TRD); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAIQMatrixBufferMPEG4( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAIQMatrixBufferMPEG4 *p=(VAIQMatrixBufferMPEG4 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx,"VAIQMatrixBufferMPEG4\n"); - - va_TraceMsg(trace_ctx,"\tload_intra_quant_mat = %d\n", p->load_intra_quant_mat); - va_TraceMsg(trace_ctx,"\tload_non_intra_quant_mat = %d\n", p->load_non_intra_quant_mat); - va_TraceMsg(trace_ctx,"\tintra_quant_mat =\n"); - for(i=0;i<64;i++) - va_TraceMsg(trace_ctx,"\t\t%d\n", p->intra_quant_mat[i]); - - va_TraceMsg(trace_ctx,"\tnon_intra_quant_mat =\n"); - for(i=0;i<64;i++) - va_TraceMsg(trace_ctx,"\t\t%d\n", p->non_intra_quant_mat[i]); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncSequenceParameterBufferMPEG4( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferMPEG4 *p = (VAEncSequenceParameterBufferMPEG4 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferMPEG4\n"); - - va_TraceMsg(trace_ctx, "\tprofile_and_level_indication = %d\n", p->profile_and_level_indication); - va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period); - va_TraceMsg(trace_ctx, "\tvideo_object_layer_width = %d\n", p->video_object_layer_width); - va_TraceMsg(trace_ctx, "\tvideo_object_layer_height = %d\n", p->video_object_layer_height); - va_TraceMsg(trace_ctx, "\tvop_time_increment_resolution = %d\n", p->vop_time_increment_resolution); - va_TraceMsg(trace_ctx, "\tfixed_vop_rate = %d\n", p->fixed_vop_rate); - va_TraceMsg(trace_ctx, "\tfixed_vop_time_increment = %d\n", p->fixed_vop_time_increment); - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate); - va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp); - va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncPictureParameterBufferMPEG4( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferMPEG4 *p = (VAEncPictureParameterBufferMPEG4 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferMPEG4\n"); - va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture); - va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture); - va_TraceMsg(trace_ctx, "\tcoded_buf = 0x%08x\n", p->coded_buf); - va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width); - va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height); - va_TraceMsg(trace_ctx, "\tmodulo_time_base = %d\n", p->modulo_time_base); - va_TraceMsg(trace_ctx, "\tvop_time_increment = %d\n", p->vop_time_increment); - va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_type); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVASliceParameterBufferMPEG4( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VASliceParameterBufferMPEG4 *p=(VASliceParameterBufferMPEG4 *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - trace_ctx->trace_slice_no++; - - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TraceMsg(trace_ctx,"VASliceParameterBufferMPEG4\n"); - - va_TraceMsg(trace_ctx,"\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx,"\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx,"\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx,"\tmacroblock_offset = %d\n", p->macroblock_offset); - va_TraceMsg(trace_ctx,"\tmacroblock_number = %d\n", p->macroblock_number); - va_TraceMsg(trace_ctx,"\tquant_scale = %d\n", p->quant_scale); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static inline void va_TraceFlagIfNotZero( - struct trace_context *trace_ctx, - const char *name, /* in */ - unsigned int flag /* in */ -) -{ - if (flag != 0) { - va_TraceMsg(trace_ctx, "%s = %x\n", name, flag); - } -} - - -static void va_TraceVAPictureParameterBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAPictureParameterBufferHEVC *p = (VAPictureParameterBufferHEVC*)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TracePrint(trace_ctx, "VAPictureParameterBufferHEVC\n"); - - va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id); - va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %d\n", p->CurrPic.pic_order_cnt); - va_TraceMsg(trace_ctx, "\tCurrPic.flags = %d\n", p->CurrPic.flags); - - va_TraceMsg(trace_ctx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags:\n"); - for (i = 0; i < 15; i++) - { - if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) && - ((p->ReferenceFrames[i].flags & VA_PICTURE_HEVC_INVALID) == 0)) { - va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x\n", - p->ReferenceFrames[i].picture_id, - p->ReferenceFrames[i].pic_order_cnt, - p->ReferenceFrames[i].flags); - } else - va_TraceMsg(trace_ctx, "\t\tinv-inv-inv-inv-inv\n"); - } - va_TraceMsg(trace_ctx, "\n"); - - va_TraceMsg(trace_ctx, "\tpic_width_in_luma_samples = %d\n", p->pic_width_in_luma_samples); - va_TraceMsg(trace_ctx, "\tpic_height_in_luma_samples = %d\n", p->pic_height_in_luma_samples); - va_TraceMsg(trace_ctx, "\tpic_fields = %d\n", p->pic_fields.value); - - va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->pic_fields.bits.chroma_format_idc); - va_TraceMsg(trace_ctx, "\tseparate_colour_plane_flag = %d\n", p->pic_fields.bits.separate_colour_plane_flag); - va_TraceMsg(trace_ctx, "\tpcm_enabled_flag = %d\n", p->pic_fields.bits.pcm_enabled_flag); - va_TraceMsg(trace_ctx, "\tscaling_list_enabled_flag = %d\n", p->pic_fields.bits.scaling_list_enabled_flag); - va_TraceMsg(trace_ctx, "\ttransform_skip_enabled_flag = %d\n", p->pic_fields.bits.transform_skip_enabled_flag); - va_TraceMsg(trace_ctx, "\tamp_enabled_flag = %d\n", p->pic_fields.bits.amp_enabled_flag); - va_TraceMsg(trace_ctx, "\tstrong_intra_smoothing_enabled_flag = %d\n", p->pic_fields.bits.strong_intra_smoothing_enabled_flag); - va_TraceMsg(trace_ctx, "\tsign_data_hiding_enabled_flag = %d\n", p->pic_fields.bits.sign_data_hiding_enabled_flag); - va_TraceMsg(trace_ctx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag); - va_TraceMsg(trace_ctx, "\tcu_qp_delta_enabled_flag = %d\n", p->pic_fields.bits.cu_qp_delta_enabled_flag); - va_TraceMsg(trace_ctx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag); - va_TraceMsg(trace_ctx, "\tweighted_bipred_flag = %d\n", p->pic_fields.bits.weighted_bipred_flag); - va_TraceMsg(trace_ctx, "\ttransquant_bypass_enabled_flag = %d\n", p->pic_fields.bits.transquant_bypass_enabled_flag); - va_TraceMsg(trace_ctx, "\ttiles_enabled_flag = %d\n", p->pic_fields.bits.tiles_enabled_flag); - va_TraceMsg(trace_ctx, "\tentropy_coding_sync_enabled_flag = %d\n", p->pic_fields.bits.entropy_coding_sync_enabled_flag); - va_TraceMsg(trace_ctx, "\tpps_loop_filter_across_slices_enabled_flag = %d\n", p->pic_fields.bits.pps_loop_filter_across_slices_enabled_flag); - va_TraceMsg(trace_ctx, "\tloop_filter_across_tiles_enabled_flag = %d\n", p->pic_fields.bits.loop_filter_across_tiles_enabled_flag); - va_TraceMsg(trace_ctx, "\tpcm_loop_filter_disabled_flag = %d\n", p->pic_fields.bits.pcm_loop_filter_disabled_flag); - va_TraceMsg(trace_ctx, "\tNoPicReorderingFlag = %d\n", p->pic_fields.bits.NoPicReorderingFlag); - va_TraceMsg(trace_ctx, "\tNoBiPredFlag = %d\n", p->pic_fields.bits.NoBiPredFlag); - va_TraceMsg(trace_ctx, "\tReservedBits = %d\n", p->pic_fields.bits.ReservedBits); - - va_TraceMsg(trace_ctx, "\tsps_max_dec_pic_buffering_minus1 = %d\n", p->sps_max_dec_pic_buffering_minus1); - va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8); - va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8); - va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_luma_minus1 = %d\n", p->pcm_sample_bit_depth_luma_minus1); - va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_chroma_minus1 = %d\n", p->pcm_sample_bit_depth_chroma_minus1); - va_TraceMsg(trace_ctx, "\tlog2_min_luma_coding_block_size_minus3 = %d\n", p->log2_min_luma_coding_block_size_minus3); - va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_luma_coding_block_size = %d\n", p->log2_diff_max_min_luma_coding_block_size); - va_TraceMsg(trace_ctx, "\tlog2_min_transform_block_size_minus2 = %d\n", p->log2_min_transform_block_size_minus2); - va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_transform_block_size = %d\n", p->log2_diff_max_min_transform_block_size); - va_TraceMsg(trace_ctx, "\tlog2_min_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_min_pcm_luma_coding_block_size_minus3); - va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_pcm_luma_coding_block_size = %d\n", p->log2_diff_max_min_pcm_luma_coding_block_size); - va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_intra = %d\n", p->max_transform_hierarchy_depth_intra); - va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_inter = %d\n", p->max_transform_hierarchy_depth_inter); - va_TraceMsg(trace_ctx, "\tinit_qp_minus26 = %d\n", p->init_qp_minus26); - va_TraceMsg(trace_ctx, "\tdiff_cu_qp_delta_depth = %d\n", p->diff_cu_qp_delta_depth); - va_TraceMsg(trace_ctx, "\tpps_cb_qp_offset = %d\n", p->pps_cb_qp_offset); - va_TraceMsg(trace_ctx, "\tpps_cr_qp_offset = %d\n", p->pps_cr_qp_offset); - va_TraceMsg(trace_ctx, "\tlog2_parallel_merge_level_minus2 = %d\n", p->log2_parallel_merge_level_minus2); - va_TraceMsg(trace_ctx, "\tnum_tile_columns_minus1 = %d\n", p->num_tile_columns_minus1); - va_TraceMsg(trace_ctx, "\tnum_tile_rows_minus1 = %d\n", p->num_tile_rows_minus1); - - va_TraceMsg(trace_ctx, "\tcolumn_width_minus1[19]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 19; i++) { - va_TracePrint(trace_ctx, "\t%d", p->column_width_minus1[i]); - if ((i + 1) % 8 == 0) - TRACE_NEWLINE(); - } - va_TracePrint(trace_ctx, "\n"); - va_TraceMsg(trace_ctx, "\trow_height_minus1[21]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 21; i++) { - va_TracePrint(trace_ctx, "\t%d", p->row_height_minus1[i]); - if ((i + 1) % 8 == 0) - TRACE_NEWLINE(); - } - va_TracePrint(trace_ctx, "\n"); - - va_TraceMsg(trace_ctx, "\tslice_parsing_fields = %d\n", p->slice_parsing_fields.value); - va_TraceMsg(trace_ctx, "\tlists_modification_present_flag = %d\n", p->slice_parsing_fields.bits.lists_modification_present_flag); - va_TraceMsg(trace_ctx, "\tlong_term_ref_pics_present_flag = %d\n", p->slice_parsing_fields.bits.long_term_ref_pics_present_flag); - va_TraceMsg(trace_ctx, "\tsps_temporal_mvp_enabled_flag = %d\n", p->slice_parsing_fields.bits.sps_temporal_mvp_enabled_flag); - va_TraceMsg(trace_ctx, "\tcabac_init_present_flag = %d\n", p->slice_parsing_fields.bits.cabac_init_present_flag); - va_TraceMsg(trace_ctx, "\toutput_flag_present_flag = %d\n", p->slice_parsing_fields.bits.output_flag_present_flag); - va_TraceMsg(trace_ctx, "\tdependent_slice_segments_enabled_flag = %d\n", p->slice_parsing_fields.bits.dependent_slice_segments_enabled_flag); - va_TraceMsg(trace_ctx, "\tpps_slice_chroma_qp_offsets_present_flag = %d\n", p->slice_parsing_fields.bits.pps_slice_chroma_qp_offsets_present_flag); - va_TraceMsg(trace_ctx, "\tsample_adaptive_offset_enabled_flag = %d\n", p->slice_parsing_fields.bits.sample_adaptive_offset_enabled_flag); - va_TraceMsg(trace_ctx, "\tdeblocking_filter_override_enabled_flag = %d\n", p->slice_parsing_fields.bits.deblocking_filter_override_enabled_flag); - va_TraceMsg(trace_ctx, "\tpps_disable_deblocking_filter_flag = %d\n", p->slice_parsing_fields.bits.pps_disable_deblocking_filter_flag); - va_TraceMsg(trace_ctx, "\tslice_segment_header_extension_present_flag = %d\n", p->slice_parsing_fields.bits.slice_segment_header_extension_present_flag); - va_TraceMsg(trace_ctx, "\tRapPicFlag = %d\n", p->slice_parsing_fields.bits.RapPicFlag); - va_TraceMsg(trace_ctx, "\tIdrPicFlag = %d\n", p->slice_parsing_fields.bits.IdrPicFlag); - va_TraceMsg(trace_ctx, "\tIntraPicFlag = %d\n", p->slice_parsing_fields.bits.IntraPicFlag); - va_TraceMsg(trace_ctx, "\tReservedBits = %d\n", p->slice_parsing_fields.bits.ReservedBits); - - va_TraceMsg(trace_ctx, "\tlog2_max_pic_order_cnt_lsb_minus4 = %d\n", p->log2_max_pic_order_cnt_lsb_minus4); - va_TraceMsg(trace_ctx, "\tnum_short_term_ref_pic_sets = %d\n", p->num_short_term_ref_pic_sets); - va_TraceMsg(trace_ctx, "\tnum_long_term_ref_pic_sps = %d\n", p->num_long_term_ref_pic_sps); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_default_active_minus1 = %d\n", p->num_ref_idx_l0_default_active_minus1); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_default_active_minus1 = %d\n", p->num_ref_idx_l1_default_active_minus1); - va_TraceMsg(trace_ctx, "\tpps_beta_offset_div2 = %d\n", p->pps_beta_offset_div2); - va_TraceMsg(trace_ctx, "\tpps_tc_offset_div2 = %d\n", p->pps_tc_offset_div2); - va_TraceMsg(trace_ctx, "\tnum_extra_slice_header_bits = %d\n", p->num_extra_slice_header_bits); - va_TraceMsg(trace_ctx, "\tst_rps_bits = %d\n", p->st_rps_bits); - - return; -} - -static void va_TraceVASliceParameterBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i,j; - VASliceParameterBufferHEVC* p = (VASliceParameterBufferHEVC*)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - trace_ctx->trace_slice_no++; - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TracePrint(trace_ctx, "VASliceParameterBufferHEVC\n"); - va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx, "\tslice_data_byte_offset = %d\n", p->slice_data_byte_offset); - va_TraceMsg(trace_ctx, "\tslice_segment_address = %d\n", p->slice_segment_address); - - va_TraceMsg(trace_ctx, "\tRefPicList[2][15]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 2; i++) { - for (j = 0; j < 15; j++) { - va_TracePrint(trace_ctx, "\t%d", p->RefPicList[i][j]); - if ((j + 1) % 8 == 0) - TRACE_NEWLINE(); - } - TRACE_NEWLINE(); - } - - va_TracePrint(trace_ctx, "\tLongSliceFlags.value = %d\n", p->LongSliceFlags.value); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.LastSliceOfPic = %d\n", p->LongSliceFlags.fields.LastSliceOfPic); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.dependent_slice_segment_flag = %d\n", p->LongSliceFlags.fields.dependent_slice_segment_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_type = %d\n", p->LongSliceFlags.fields.slice_type); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.color_plane_id = %d\n", p->LongSliceFlags.fields.color_plane_id); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_sao_luma_flag = %d\n", p->LongSliceFlags.fields.slice_sao_luma_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_sao_chroma_flag = %d\n", p->LongSliceFlags.fields.slice_sao_chroma_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.mvd_l1_zero_flag = %d\n", p->LongSliceFlags.fields.mvd_l1_zero_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.cabac_init_flag = %d\n", p->LongSliceFlags.fields.cabac_init_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_temporal_mvp_enabled_flag = %d\n", p->LongSliceFlags.fields.slice_temporal_mvp_enabled_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_deblocking_filter_disabled_flag = %d\n", p->LongSliceFlags.fields.slice_deblocking_filter_disabled_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.collocated_from_l0_flag = %d\n", p->LongSliceFlags.fields.collocated_from_l0_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.slice_loop_filter_across_slices_enabled_flag = %d\n", p->LongSliceFlags.fields.slice_loop_filter_across_slices_enabled_flag); - va_TraceMsg(trace_ctx, "\tLongSliceFlags.fields.reserved = %d\n", p->LongSliceFlags.fields.reserved); - - va_TraceMsg(trace_ctx, "\tcollocated_ref_idx = %d\n", p->collocated_ref_idx); - - va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta); - va_TraceMsg(trace_ctx, "\tslice_cb_qp_offset = %d\n", p->slice_cb_qp_offset); - va_TraceMsg(trace_ctx, "\tslice_cr_qp_offset = %d\n", p->slice_cr_qp_offset); - va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - va_TraceMsg(trace_ctx, "\tslice_tc_offset_div2 = %d\n", p->slice_tc_offset_div2); - va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tdelta_chroma_log2_weight_denom = %d\n", p->delta_chroma_log2_weight_denom); - - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1); - for (i = 0; i <= p->num_ref_idx_l0_active_minus1; i++) { - va_TraceMsg(trace_ctx, "\t% d ", p->delta_luma_weight_l0[i]); - va_TracePrint(trace_ctx, "\t% d ", p->luma_offset_l0[i]); - va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l0[i][0]); - va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l0[i][1]); - va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL0[i][0]); - va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL0[i][1]); - va_TracePrint(trace_ctx, "\n"); - } - - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - for (i = 0; i <= p->num_ref_idx_l1_active_minus1; i++) { - va_TraceMsg(trace_ctx, "\t% d ", p->delta_luma_weight_l1[i]); - va_TracePrint(trace_ctx, "\t% d ", p->luma_offset_l1[i]); - va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l1[i][0]); - va_TracePrint(trace_ctx, "\t% d ", p->delta_chroma_weight_l1[i][1]); - va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL1[i][0]); - va_TracePrint(trace_ctx, "\t% d ", p->ChromaOffsetL1[i][1]); - va_TracePrint(trace_ctx, "\n"); - } - - va_TraceMsg(trace_ctx, "\tfive_minus_max_num_merge_cand = %d\n", p->five_minus_max_num_merge_cand); - - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVAIQMatrixBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - int i, j; - VAIQMatrixBufferHEVC* p = (VAIQMatrixBufferHEVC* )data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TracePrint(trace_ctx, "VAIQMatrixBufferHEVC\n"); - - va_TraceMsg(trace_ctx, "\tScalingList4x4[6][16]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 6; i++) { - for (j = 0; j < 16; j++) { - va_TracePrint(trace_ctx, "\t%d\t", p->ScalingList4x4[i][j]); - if ((j + 1) % 8 == 0) - TRACE_NEWLINE(); - } - } - - va_TracePrint(trace_ctx, "\tScalingList8x8[6][64]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 6; i++) { - for (j = 0; j < 64; j++) { - va_TracePrint(trace_ctx, "\t%d", p->ScalingList8x8[i][j]); - if ((j + 1) % 8 == 0) - TRACE_NEWLINE(); - } - } - - va_TracePrint(trace_ctx, "\tScalingList16x16[6][64]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 6; i++) { - for (j = 0; j < 64; j++) { - va_TracePrint(trace_ctx, "\t%d", p->ScalingList16x16[i][j]); - if ((j + 1) % 8 == 0) - TRACE_NEWLINE(); - } - } - - va_TracePrint(trace_ctx, "\tScalingList32x32[2][64]=\n"); - va_TraceMsg(trace_ctx, ""); - for (i = 0; i < 2; i++) { - for (j = 0; j < 64; j++) { - va_TracePrint(trace_ctx, "\t%d", p->ScalingList32x32[i][j]); - if ((j + 1) % 8 == 0) - TRACE_NEWLINE(); - } - } - - va_TracePrint(trace_ctx, "\tScalingListDC16x16[6]=\n"); - va_TraceMsg(trace_ctx, ""); - for (j = 0; j < 6; j++) { - va_TracePrint(trace_ctx, "\t%d", p->ScalingListDC16x16[j]); - } - va_TracePrint(trace_ctx, "\n"); - va_TraceMsg(trace_ctx, "\tScalingListDC32x32[2]=\n"); - va_TraceMsg(trace_ctx, ""); - for (j = 0; j < 2; j++) { - va_TracePrint(trace_ctx, "\t%d", p->ScalingListDC32x32[j]); - } - va_TracePrint(trace_ctx, "\n"); - - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVAEncSequenceParameterBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferHEVC *p = (VAEncSequenceParameterBufferHEVC *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if(!p) - return; - - va_TracePrint(trace_ctx, "\t--VAEncSequenceParameterBufferHEVC\n"); - - va_TraceMsg(trace_ctx, "\tgeneral_profile_idc = %d\n", p->general_profile_idc); - va_TraceMsg(trace_ctx, "\tgeneral_level_idc = %d\n", p->general_level_idc); - va_TraceMsg(trace_ctx, "\tgeneral_tier_flag = %d\n", p->general_tier_flag); - va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period); - va_TraceMsg(trace_ctx, "\tintra_idr_period = %d\n", p->intra_idr_period); - va_TraceMsg(trace_ctx, "\tip_period = %d\n", p->ip_period); - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\tpic_width_in_luma_samples = %d\n", p->pic_width_in_luma_samples); - va_TraceMsg(trace_ctx, "\tpic_height_in_luma_samples = %d\n", p->pic_height_in_luma_samples); - va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc); - va_TraceMsg(trace_ctx, "\tseparate_colour_plane_flag = %d\n", p->seq_fields.bits.separate_colour_plane_flag); - va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->seq_fields.bits.bit_depth_luma_minus8); - va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->seq_fields.bits.bit_depth_chroma_minus8); - va_TraceMsg(trace_ctx, "\tscaling_list_enabled_flag = %d\n", p->seq_fields.bits.scaling_list_enabled_flag); - va_TraceMsg(trace_ctx, "\tstrong_intra_smoothing_enabled_flag = %d\n", p->seq_fields.bits.strong_intra_smoothing_enabled_flag); - va_TraceMsg(trace_ctx, "\tamp_enabled_flag = %d\n", p->seq_fields.bits.amp_enabled_flag); - va_TraceMsg(trace_ctx, "\tsample_adaptive_offset_enabled_flag = %d\n", p->seq_fields.bits.sample_adaptive_offset_enabled_flag); - va_TraceMsg(trace_ctx, "\tpcm_enabled_flag = %d\n", p->seq_fields.bits.pcm_enabled_flag); - va_TraceMsg(trace_ctx, "\tpcm_loop_filter_disabled_flag = %d\n", p->seq_fields.bits.pcm_loop_filter_disabled_flag); - va_TraceMsg(trace_ctx, "\tsps_temporal_mvp_enabled_flag = %d\n", p->seq_fields.bits.sps_temporal_mvp_enabled_flag); - va_TraceMsg(trace_ctx, "\treserved_bits = %d\n", p->seq_fields.bits.reserved_bits); - va_TraceMsg(trace_ctx, "\tlog2_min_luma_coding_block_size_minus3 = %d\n", p->log2_min_luma_coding_block_size_minus3); - va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_luma_coding_block_size = %d\n", p->log2_diff_max_min_luma_coding_block_size); - va_TraceMsg(trace_ctx, "\tlog2_min_transform_block_size_minus2 = %d\n", p->log2_min_transform_block_size_minus2); - va_TraceMsg(trace_ctx, "\tlog2_diff_max_min_transform_block_size = %d\n", p->log2_diff_max_min_transform_block_size); - va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_inter = %d\n", p->max_transform_hierarchy_depth_inter); - va_TraceMsg(trace_ctx, "\tmax_transform_hierarchy_depth_intra = %d\n", p->max_transform_hierarchy_depth_intra); - va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_luma_minus1 = %d\n", p->pcm_sample_bit_depth_luma_minus1); - va_TraceMsg(trace_ctx, "\tpcm_sample_bit_depth_chroma_minus1 = %d\n", p->pcm_sample_bit_depth_chroma_minus1); - va_TraceMsg(trace_ctx, "\tlog2_min_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_min_pcm_luma_coding_block_size_minus3); - va_TraceMsg(trace_ctx, "\tlog2_max_pcm_luma_coding_block_size_minus3 = %d\n", p->log2_max_pcm_luma_coding_block_size_minus3); - va_TraceMsg(trace_ctx, "\tvui_parameters_present_flag = %d\n", p->vui_parameters_present_flag); - va_TraceMsg(trace_ctx, "\taspect_ratio_info_present_flag = %d\n", p->vui_fields.bits.aspect_ratio_info_present_flag); - va_TraceMsg(trace_ctx, "\tneutral_chroma_indication_flag = %d\n", p->vui_fields.bits.neutral_chroma_indication_flag); - va_TraceMsg(trace_ctx, "\tfield_seq_flag = %d\n", p->vui_fields.bits.field_seq_flag); - va_TraceMsg(trace_ctx, "\tvui_timing_info_present_flag = %d\n", p->vui_fields.bits.vui_timing_info_present_flag); - va_TraceMsg(trace_ctx, "\tbitstream_restriction_flag = %d\n", p->vui_fields.bits.bitstream_restriction_flag); - va_TraceMsg(trace_ctx, "\ttiles_fixed_structure_flag = %d\n", p->vui_fields.bits.tiles_fixed_structure_flag); - va_TraceMsg(trace_ctx, "\tmotion_vectors_over_pic_boundaries_flag = %d\n", p->vui_fields.bits.motion_vectors_over_pic_boundaries_flag); - va_TraceMsg(trace_ctx, "\trestricted_ref_pic_lists_flag = %d\n", p->vui_fields.bits.restricted_ref_pic_lists_flag); - va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_horizontal = %d\n", p->vui_fields.bits.log2_max_mv_length_horizontal); - va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_vertical = %d\n", p->vui_fields.bits.log2_max_mv_length_vertical); - va_TraceMsg(trace_ctx, "\taspect_ratio_idc = %d\n", p->aspect_ratio_idc); - va_TraceMsg(trace_ctx, "\tsar_width = %d\n", p->sar_width); - va_TraceMsg(trace_ctx, "\tsar_height = %d\n", p->sar_height); - va_TraceMsg(trace_ctx, "\tvui_num_units_in_tick = %d\n", p->vui_num_units_in_tick); - va_TraceMsg(trace_ctx, "\tvui_time_scale = %d\n", p->vui_time_scale); - va_TraceMsg(trace_ctx, "\tmin_spatial_segmentation_idc = %d\n", p->min_spatial_segmentation_idc); - va_TraceMsg(trace_ctx, "\tmax_bytes_per_pic_denom = %d\n", p->max_bytes_per_pic_denom); - va_TraceMsg(trace_ctx, "\tmax_bits_per_min_cu_denom = %d\n", p->max_bits_per_min_cu_denom); - - return; -} - -static void va_TraceVAEncPictureParameterBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAEncPictureParameterBufferHEVC *p = (VAEncPictureParameterBufferHEVC *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if(!p) - return; - - va_TracePrint(trace_ctx, "\t--VAEncPictureParameterBufferHEVC\n"); - - va_TraceMsg(trace_ctx, "\tdecoded_curr_pic.picture_id = %d\n", p->decoded_curr_pic.picture_id); - va_TraceMsg(trace_ctx, "\tdecoded_curr_pic.pic_order_cnt = %d\n", p->decoded_curr_pic.pic_order_cnt); - va_TraceMsg(trace_ctx, "\tdecoded_curr_pic.flags = %d\n", p->decoded_curr_pic.flags); - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\treference_frames[%d].picture_id = %d\n", i, p->reference_frames[i].picture_id); - va_TraceMsg(trace_ctx, "\treference_frames[%d].pic_order_cnt = %d\n", i, p->reference_frames[i].pic_order_cnt); - va_TraceMsg(trace_ctx, "\treference_frames[%d].flags = %d\n", i, p->reference_frames[i].flags); - } - - va_TraceMsg(trace_ctx, "\tcoded_buf = %d\n", p->coded_buf); - va_TraceMsg(trace_ctx, "\tcollocated_ref_pic_index = %d\n", p->collocated_ref_pic_index); - va_TraceMsg(trace_ctx, "\tlast_picture = %d\n", p->last_picture); - va_TraceMsg(trace_ctx, "\tpic_init_qp = %d\n", p->pic_init_qp); - va_TraceMsg(trace_ctx, "\tdiff_cu_qp_delta_depth = %d\n", p->diff_cu_qp_delta_depth); - va_TraceMsg(trace_ctx, "\tpps_cb_qp_offset = %d\n", p->pps_cb_qp_offset); - va_TraceMsg(trace_ctx, "\tpps_cr_qp_offset = %d\n", p->pps_cr_qp_offset); - va_TraceMsg(trace_ctx, "\tnum_tile_columns_minus1 = %d\n", p->num_tile_columns_minus1); - va_TraceMsg(trace_ctx, "\tnum_tile_rows_minus1 = %d\n", p->num_tile_rows_minus1); - - for(i = 0; i < 19; i ++) - { - va_TraceMsg(trace_ctx, "\tcolumn_width_minus1[%d] = %d\n", i, p->column_width_minus1[i]); - } - - for(i = 0; i < 21; i ++) - { - va_TraceMsg(trace_ctx, "\trow_height_minus1[%d] = %d\n", i, p->row_height_minus1[i]); - } - - va_TraceMsg(trace_ctx, "\tlog2_parallel_merge_level_minus2 = %d\n", p->log2_parallel_merge_level_minus2); - va_TraceMsg(trace_ctx, "\tctu_max_bitsize_allowed = %d\n", p->ctu_max_bitsize_allowed); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_default_active_minus1 = %d\n", p->num_ref_idx_l0_default_active_minus1); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_default_active_minus1 = %d\n", p->num_ref_idx_l1_default_active_minus1); - va_TraceMsg(trace_ctx, "\tslice_pic_parameter_set_id = %d\n", p->slice_pic_parameter_set_id); - va_TraceMsg(trace_ctx, "\tnal_unit_type = %d\n", p->nal_unit_type); - va_TraceMsg(trace_ctx, "\tidr_pic_flag = %d\n", p->pic_fields.bits.idr_pic_flag); - va_TraceMsg(trace_ctx, "\tcoding_type = %d\n", p->pic_fields.bits.coding_type); - va_TraceMsg(trace_ctx, "\treference_pic_flag = %d\n", p->pic_fields.bits.reference_pic_flag); - va_TraceMsg(trace_ctx, "\tdependent_slice_segments_enabled_flag = %d\n", p->pic_fields.bits.dependent_slice_segments_enabled_flag); - va_TraceMsg(trace_ctx, "\tsign_data_hiding_enabled_flag = %d\n", p->pic_fields.bits.sign_data_hiding_enabled_flag); - va_TraceMsg(trace_ctx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag); - va_TraceMsg(trace_ctx, "\ttransform_skip_enabled_flag = %d\n", p->pic_fields.bits.transform_skip_enabled_flag); - va_TraceMsg(trace_ctx, "\tcu_qp_delta_enabled_flag = %d\n", p->pic_fields.bits.cu_qp_delta_enabled_flag); - va_TraceMsg(trace_ctx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag); - va_TraceMsg(trace_ctx, "\tweighted_bipred_flag = %d\n", p->pic_fields.bits.weighted_bipred_flag); - va_TraceMsg(trace_ctx, "\ttransquant_bypass_enabled_flag = %d\n", p->pic_fields.bits.transquant_bypass_enabled_flag); - va_TraceMsg(trace_ctx, "\ttiles_enabled_flag = %d\n", p->pic_fields.bits.tiles_enabled_flag); - va_TraceMsg(trace_ctx, "\tentropy_coding_sync_enabled_flag = %d\n", p->pic_fields.bits.entropy_coding_sync_enabled_flag); - va_TraceMsg(trace_ctx, "\tloop_filter_across_tiles_enabled_flag = %d\n", p->pic_fields.bits.loop_filter_across_tiles_enabled_flag); - va_TraceMsg(trace_ctx, "\tpps_loop_filter_across_slices_enabled_flag = %d\n", p->pic_fields.bits.pps_loop_filter_across_slices_enabled_flag); - va_TraceMsg(trace_ctx, "\tscaling_list_data_present_flag = %d\n", p->pic_fields.bits.scaling_list_data_present_flag); - va_TraceMsg(trace_ctx, "\tscreen_content_flag = %d\n", p->pic_fields.bits.screen_content_flag); - va_TraceMsg(trace_ctx, "\tenable_gpu_weighted_prediction = %d\n", p->pic_fields.bits.enable_gpu_weighted_prediction); - va_TraceMsg(trace_ctx, "\tno_output_of_prior_pics_flag = %d\n", p->pic_fields.bits.no_output_of_prior_pics_flag); - va_TraceMsg(trace_ctx, "\treserved = %d\n", p->pic_fields.bits.reserved); - - return; -} - -static void va_TraceVAEncSliceParameterBufferHEVC( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAEncSliceParameterBufferHEVC *p = (VAEncSliceParameterBufferHEVC *)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if(!p) - return; - - va_TracePrint(trace_ctx, "\t--VAEncSliceParameterBufferHEVC\n"); - - va_TraceMsg(trace_ctx, "\tslice_segment_address = %d\n", p->slice_segment_address); - va_TraceMsg(trace_ctx, "\tnum_ctu_in_slice = %d\n", p->num_ctu_in_slice); - va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type); - va_TraceMsg(trace_ctx, "\tslice_pic_parameter_set_id = %d\n", p->slice_pic_parameter_set_id); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\tref_pic_list0[%d].picture_id = %d\n", i, p->ref_pic_list0[i].picture_id); - va_TraceMsg(trace_ctx, "\tref_pic_list0[%d].pic_order_cnt = %d\n", i, p->ref_pic_list0[i].pic_order_cnt); - va_TraceMsg(trace_ctx, "\tref_pic_list0[%d].flags = %d\n", i, p->ref_pic_list0[i].flags); - va_TraceMsg(trace_ctx, "\tref_pic_list1[%d].picture_id = %d\n", i, p->ref_pic_list1[i].picture_id); - va_TraceMsg(trace_ctx, "\tref_pic_list1[%d].pic_order_cnt = %d\n", i, p->ref_pic_list1[i].pic_order_cnt); - va_TraceMsg(trace_ctx, "\tref_pic_list1[%d].flags = %d\n", i, p->ref_pic_list1[i].flags); - } - - va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tdelta_chroma_log2_weight_denom = %d\n", p->delta_chroma_log2_weight_denom); - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\tdelta_luma_weight_l0[%d] = %d\n", i, p->delta_luma_weight_l0[i]); - va_TraceMsg(trace_ctx, "\tdelta_luma_weight_l1[%d] = %d\n", i, p->delta_luma_weight_l1[i]); - } - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\tluma_offset_l0[%d] = %d\n", i, p->luma_offset_l0[i]); - va_TraceMsg(trace_ctx, "\tluma_offset_l1[%d] = %d\n", i, p->luma_offset_l1[i]); - } - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\tdelta_chroma_weight_l0[%d][0] = %d\n", i, p->delta_chroma_weight_l0[i][0]); - va_TraceMsg(trace_ctx, "\tdelta_chroma_weight_l0[%d][1] = %d\n", i, p->delta_chroma_weight_l0[i][1]); - va_TraceMsg(trace_ctx, "\tdelta_chroma_weight_l1[%d][0] = %d\n", i, p->delta_chroma_weight_l1[i][0]); - va_TraceMsg(trace_ctx, "\tdelta_chroma_weight_l1[%d][1] = %d\n", i, p->delta_chroma_weight_l1[i][1]); - } - - for(i = 0; i < 15; i ++) - { - va_TraceMsg(trace_ctx, "\tchroma_offset_l0[%d][0] = %d\n", i, p->chroma_offset_l0[i][0]); - va_TraceMsg(trace_ctx, "\tchroma_offset_l0[%d][1] = %d\n", i, p->chroma_offset_l0[i][1]); - va_TraceMsg(trace_ctx, "\tchroma_offset_l1[%d][0] = %d\n", i, p->chroma_offset_l1[i][0]); - va_TraceMsg(trace_ctx, "\tchroma_offset_l1[%d][1] = %d\n", i, p->chroma_offset_l1[i][1]); - } - - va_TraceMsg(trace_ctx, "\tmax_num_merge_cand = %d\n", p->max_num_merge_cand); - va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta); - va_TraceMsg(trace_ctx, "\tslice_cb_qp_offset = %d\n", p->slice_cb_qp_offset); - va_TraceMsg(trace_ctx, "\tslice_cr_qp_offset = %d\n", p->slice_cr_qp_offset); - va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - va_TraceMsg(trace_ctx, "\tslice_tc_offset_div2 = %d\n", p->slice_tc_offset_div2); - va_TraceMsg(trace_ctx, "\tlast_slice_of_pic_flag = %d\n", p->slice_fields.bits.last_slice_of_pic_flag); - va_TraceMsg(trace_ctx, "\tdependent_slice_segment_flag = %d\n", p->slice_fields.bits.dependent_slice_segment_flag); - va_TraceMsg(trace_ctx, "\tcolour_plane_id = %d\n", p->slice_fields.bits.colour_plane_id); - va_TraceMsg(trace_ctx, "\tslice_temporal_mvp_enabled_flag = %d\n", p->slice_fields.bits.slice_temporal_mvp_enabled_flag); - va_TraceMsg(trace_ctx, "\tslice_sao_luma_flag = %d\n", p->slice_fields.bits.slice_sao_luma_flag); - va_TraceMsg(trace_ctx, "\tslice_sao_chroma_flag = %d\n", p->slice_fields.bits.slice_sao_chroma_flag); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_active_override_flag = %d\n", p->slice_fields.bits.num_ref_idx_active_override_flag); - va_TraceMsg(trace_ctx, "\tmvd_l1_zero_flag = %d\n", p->slice_fields.bits.mvd_l1_zero_flag); - va_TraceMsg(trace_ctx, "\tcabac_init_flag = %d\n", p->slice_fields.bits.cabac_init_flag); - va_TraceMsg(trace_ctx, "\tslice_deblocking_filter_disabled_flag = %d\n", p->slice_fields.bits.slice_deblocking_filter_disabled_flag); - va_TraceMsg(trace_ctx, "\tslice_loop_filter_across_slices_enabled_flag = %d\n", p->slice_fields.bits.slice_loop_filter_across_slices_enabled_flag); - va_TraceMsg(trace_ctx, "\tcollocated_from_l0_flag = %d\n", p->slice_fields.bits.collocated_from_l0_flag); - - return; -} - -static void va_TraceVAPictureParameterBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VAPictureParameterBufferH264 *p = (VAPictureParameterBufferH264*)data; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferH264\n"); - - va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id); - va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %u\n", p->CurrPic.frame_idx); - va_TraceMsg(trace_ctx, "\tCurrPic.flags = 0x%08x\n", p->CurrPic.flags); - va_TraceMsg(trace_ctx, "\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt); - va_TraceMsg(trace_ctx, "\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt); - - va_TraceMsg(trace_ctx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags:\n"); - for (i = 0; i < 16; i++) - { - if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) && - ((p->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) == 0)) { - va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08u-0x%08x\n", - p->ReferenceFrames[i].TopFieldOrderCnt, - p->ReferenceFrames[i].BottomFieldOrderCnt, - p->ReferenceFrames[i].picture_id, - p->ReferenceFrames[i].frame_idx, - p->ReferenceFrames[i].flags); - } else - break; - } - va_TraceMsg(trace_ctx, "\tpicture_width_in_mbs_minus1 = %d\n", p->picture_width_in_mbs_minus1); - va_TraceMsg(trace_ctx, "\tpicture_height_in_mbs_minus1 = %d\n", p->picture_height_in_mbs_minus1); - va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8); - va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8); - va_TraceMsg(trace_ctx, "\tnum_ref_frames = %d\n", p->num_ref_frames); - va_TraceMsg(trace_ctx, "\tseq fields = %d\n", p->seq_fields.value); - va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc); - va_TraceMsg(trace_ctx, "\tresidual_colour_transform_flag = %d\n", p->seq_fields.bits.residual_colour_transform_flag); - va_TraceMsg(trace_ctx, "\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag); - va_TraceMsg(trace_ctx, "\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag); - va_TraceMsg(trace_ctx, "\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag); - va_TraceMsg(trace_ctx, "\tMinLumaBiPredSize8x8 = %d\n", p->seq_fields.bits.MinLumaBiPredSize8x8); - va_TraceMsg(trace_ctx, "\tnum_slice_groups_minus1 = %d\n", p->num_slice_groups_minus1); - va_TraceMsg(trace_ctx, "\tslice_group_map_type = %d\n", p->slice_group_map_type); - va_TraceMsg(trace_ctx, "\tslice_group_change_rate_minus1 = %d\n", p->slice_group_change_rate_minus1); - va_TraceMsg(trace_ctx, "\tpic_init_qp_minus26 = %d\n", p->pic_init_qp_minus26); - va_TraceMsg(trace_ctx, "\tpic_init_qs_minus26 = %d\n", p->pic_init_qs_minus26); - va_TraceMsg(trace_ctx, "\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset); - va_TraceMsg(trace_ctx, "\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset); - va_TraceMsg(trace_ctx, "\tpic_fields = 0x%03x\n", p->pic_fields.value); - va_TraceFlagIfNotZero(trace_ctx, "\t\tentropy_coding_mode_flag", p->pic_fields.bits.entropy_coding_mode_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tweighted_pred_flag", p->pic_fields.bits.weighted_pred_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tweighted_bipred_idc", p->pic_fields.bits.weighted_bipred_idc); - va_TraceFlagIfNotZero(trace_ctx, "\t\ttransform_8x8_mode_flag", p->pic_fields.bits.transform_8x8_mode_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tfield_pic_flag", p->pic_fields.bits.field_pic_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tconstrained_intra_pred_flag", p->pic_fields.bits.constrained_intra_pred_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tpic_order_present_flag", p->pic_fields.bits.pic_order_present_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tdeblocking_filter_control_present_flag", p->pic_fields.bits.deblocking_filter_control_present_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\tredundant_pic_cnt_present_flag", p->pic_fields.bits.redundant_pic_cnt_present_flag); - va_TraceFlagIfNotZero(trace_ctx, "\t\treference_pic_flag", p->pic_fields.bits.reference_pic_flag); - va_TraceMsg(trace_ctx, "\tframe_num = %d\n", p->frame_num); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVASliceParameterBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VASliceParameterBufferH264* p = (VASliceParameterBufferH264*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - trace_ctx->trace_slice_no++; - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferH264\n"); - va_TraceMsg(trace_ctx, "\tslice_data_size = %u\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %u\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = 0x%08x\n", p->slice_data_flag); - va_TraceMsg(trace_ctx, "\tslice_data_bit_offset = %d\n", p->slice_data_bit_offset); - va_TraceMsg(trace_ctx, "\tfirst_mb_in_slice = %d\n", p->first_mb_in_slice); - va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type); - va_TraceMsg(trace_ctx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - va_TraceMsg(trace_ctx, "\tcabac_init_idc = %d\n", p->cabac_init_idc); - va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta); - va_TraceMsg(trace_ctx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc); - va_TraceMsg(trace_ctx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2); - va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - - va_TraceMsg(trace_ctx, "\tRefPicList0 =\n"); - for (i = 0; i < 32; i++) { - if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) && - ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0)) - va_TraceMsg(trace_ctx, "%08d-%08d-0x%08x-%08d-0x%08x\n", p->RefPicList0[i].TopFieldOrderCnt, p->RefPicList0[i].BottomFieldOrderCnt, p->RefPicList0[i].picture_id, p->RefPicList0[i].frame_idx, p->RefPicList0[i].flags); - else - break; - } - va_TraceMsg(trace_ctx, "\tRefPicList1 =\n"); - for (i = 0; i < 32; i++) { - if ((p->RefPicList1[i].picture_id != VA_INVALID_SURFACE) && - ((p->RefPicList1[i].flags & VA_PICTURE_H264_INVALID) == 0)) - va_TraceMsg(trace_ctx, "%08d-%08d-0x%08x-%08d-0x%08x\n", p->RefPicList1[i].TopFieldOrderCnt, p->RefPicList1[i].BottomFieldOrderCnt, p->RefPicList1[i].picture_id, p->RefPicList1[i].frame_idx, p->RefPicList1[i].flags); - else - break; - } - - va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag); - - for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\n", - p->luma_weight_l0[i], - p->luma_offset_l0[i]); - } - - - va_TraceMsg(trace_ctx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag); - - for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\t%d\t%d\n", - p->chroma_weight_l0[i][0], - p->chroma_offset_l0[i][0], - p->chroma_weight_l0[i][1], - p->chroma_offset_l0[i][1]); - } - - - va_TraceMsg(trace_ctx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag); - - for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\n", - p->luma_weight_l1[i], - p->luma_offset_l1[i]); - } - - - va_TraceMsg(trace_ctx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag); - - for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\t%d\t%d\n", - p->chroma_weight_l1[i][0], - p->chroma_offset_l1[i][0], - p->chroma_weight_l1[i][1], - p->chroma_offset_l1[i][1]); - - } - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVAIQMatrixBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - int i, j; - VAIQMatrixBufferH264* p = (VAIQMatrixBufferH264* )data; - FILE *fp = NULL; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if(trace_ctx->plog_file) - fp = trace_ctx->plog_file->fp_log; - - va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferH264\n"); - - va_TraceMsg(trace_ctx, "\tScalingList4x4[6][16]=\n"); - for (i = 0; i < 6; i++) { - for (j = 0; j < 16; j++) { - if (fp) { - fprintf(fp, "\t%d", p->ScalingList4x4[i][j]); - if ((j + 1) % 8 == 0) - fprintf(fp, "\n"); - } - } - } - - va_TraceMsg(trace_ctx, "\tScalingList8x8[2][64]=\n"); - for (i = 0; i < 2; i++) { - for (j = 0; j < 64; j++) { - if (fp) { - fprintf(fp,"\t%d", p->ScalingList8x8[i][j]); - if ((j + 1) % 8 == 0) - fprintf(fp, "\n"); - } - } - } - - va_TraceMsg(trace_ctx, NULL); -} - - - -static void va_TraceVAEncSequenceParameterBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - unsigned int i; - - va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH264\n"); - - va_TraceMsg(trace_ctx, "\tseq_parameter_set_id = %d\n", p->seq_parameter_set_id); - va_TraceMsg(trace_ctx, "\tlevel_idc = %d\n", p->level_idc); - va_TraceMsg(trace_ctx, "\tintra_period = %u\n", p->intra_period); - va_TraceMsg(trace_ctx, "\tintra_idr_period = %u\n", p->intra_idr_period); - va_TraceMsg(trace_ctx, "\tip_period = %u\n", p->ip_period); - va_TraceMsg(trace_ctx, "\tbits_per_second = %u\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\tmax_num_ref_frames = %u\n", p->max_num_ref_frames); - va_TraceMsg(trace_ctx, "\tpicture_width_in_mbs = %d\n", p->picture_width_in_mbs); - va_TraceMsg(trace_ctx, "\tpicture_height_in_mbs = %d\n", p->picture_height_in_mbs); - va_TraceMsg(trace_ctx, "\tchroma_format_idc = %d\n", p->seq_fields.bits.chroma_format_idc); - va_TraceMsg(trace_ctx, "\tframe_mbs_only_flag = %d\n", p->seq_fields.bits.frame_mbs_only_flag); - va_TraceMsg(trace_ctx, "\tmb_adaptive_frame_field_flag = %d\n", p->seq_fields.bits.mb_adaptive_frame_field_flag); - va_TraceMsg(trace_ctx, "\tseq_scaling_matrix_present_flag = %d\n", p->seq_fields.bits.seq_scaling_matrix_present_flag); - va_TraceMsg(trace_ctx, "\tdirect_8x8_inference_flag = %d\n", p->seq_fields.bits.direct_8x8_inference_flag); - va_TraceMsg(trace_ctx, "\tlog2_max_frame_num_minus4 = %d\n", p->seq_fields.bits.log2_max_frame_num_minus4); - va_TraceMsg(trace_ctx, "\tpic_order_cnt_type = %d\n", p->seq_fields.bits.pic_order_cnt_type); - va_TraceMsg(trace_ctx, "\tlog2_max_pic_order_cnt_lsb_minus4 = %d\n", p->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4); - va_TraceMsg(trace_ctx, "\tdelta_pic_order_always_zero_flag = %d\n", p->seq_fields.bits.delta_pic_order_always_zero_flag); - va_TraceMsg(trace_ctx, "\tbit_depth_luma_minus8 = %d\n", p->bit_depth_luma_minus8); - va_TraceMsg(trace_ctx, "\tbit_depth_chroma_minus8 = %d\n", p->bit_depth_chroma_minus8); - va_TraceMsg(trace_ctx, "\tnum_ref_frames_in_pic_order_cnt_cycle = %d\n", p->num_ref_frames_in_pic_order_cnt_cycle); - va_TraceMsg(trace_ctx, "\toffset_for_non_ref_pic = %d\n", p->offset_for_non_ref_pic); - va_TraceMsg(trace_ctx, "\toffset_for_top_to_bottom_field = %d\n", p->offset_for_top_to_bottom_field); - for(i = 0; (i < p->max_num_ref_frames) && (i < 32); ++i) - va_TraceMsg(trace_ctx, "\toffset_for_ref_frame[%d] = %d\n", i, p->offset_for_ref_frame[i]); - va_TraceMsg(trace_ctx, "\tframe_cropping_flag = %d\n", p->frame_cropping_flag); - va_TraceMsg(trace_ctx, "\tframe_crop_left_offset = %u\n", p->frame_crop_left_offset); - va_TraceMsg(trace_ctx, "\tframe_crop_right_offset = %u\n", p->frame_crop_right_offset); - va_TraceMsg(trace_ctx, "\tframe_crop_top_offset = %u\n", p->frame_crop_top_offset); - va_TraceMsg(trace_ctx, "\tframe_crop_bottom_offset = %u\n", p->frame_crop_bottom_offset); - va_TraceMsg(trace_ctx, "\tvui_parameters_present_flag = %d\n", p->vui_parameters_present_flag); - va_TraceMsg(trace_ctx, "\taspect_ratio_info_present_flag = %d\n", p->vui_fields.bits.aspect_ratio_info_present_flag); - va_TraceMsg(trace_ctx, "\ttiming_info_present_flag = %d\n", p->vui_fields.bits.timing_info_present_flag); - va_TraceMsg(trace_ctx, "\tbitstream_restriction_flag = %d\n", p->vui_fields.bits.bitstream_restriction_flag); - va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_horizontal = %d\n", p->vui_fields.bits.log2_max_mv_length_horizontal); - va_TraceMsg(trace_ctx, "\tlog2_max_mv_length_vertical = %d\n", p->vui_fields.bits.log2_max_mv_length_vertical); - va_TraceMsg(trace_ctx, "\taspect_ratio_idc = %d\n", p->aspect_ratio_idc); - va_TraceMsg(trace_ctx, "\tsar_width = %u\n", p->sar_width); - va_TraceMsg(trace_ctx, "\tsar_height = %u\n", p->sar_height); - va_TraceMsg(trace_ctx, "\tnum_units_in_tick = %u\n", p->num_units_in_tick); - va_TraceMsg(trace_ctx, "\ttime_scale = %u\n", p->time_scale); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAEncPictureParameterBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferH264 *p = (VAEncPictureParameterBufferH264 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH264\n"); - - va_TraceMsg(trace_ctx, "\tCurrPic.picture_id = 0x%08x\n", p->CurrPic.picture_id); - va_TraceMsg(trace_ctx, "\tCurrPic.frame_idx = %u\n", p->CurrPic.frame_idx); - va_TraceMsg(trace_ctx, "\tCurrPic.flags = 0x%08x\n", p->CurrPic.flags); - va_TraceMsg(trace_ctx, "\tCurrPic.TopFieldOrderCnt = %d\n", p->CurrPic.TopFieldOrderCnt); - va_TraceMsg(trace_ctx, "\tCurrPic.BottomFieldOrderCnt = %d\n", p->CurrPic.BottomFieldOrderCnt); - va_TraceMsg(trace_ctx, "\tReferenceFrames (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n"); - for (i = 0; i < 16; i++) - { - if ((p->ReferenceFrames[i].picture_id != VA_INVALID_SURFACE) && - ((p->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) == 0)) { - va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08u-0x%08x\n", - p->ReferenceFrames[i].TopFieldOrderCnt, - p->ReferenceFrames[i].BottomFieldOrderCnt, - p->ReferenceFrames[i].picture_id, - p->ReferenceFrames[i].frame_idx, - p->ReferenceFrames[i].flags - ); - } else - break; - } - va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf); - va_TraceMsg(trace_ctx, "\tpic_parameter_set_id = %d\n", p->pic_parameter_set_id); - va_TraceMsg(trace_ctx, "\tseq_parameter_set_id = %d\n", p->seq_parameter_set_id); - va_TraceMsg(trace_ctx, "\tlast_picture = 0x%08x\n", p->last_picture); - va_TraceMsg(trace_ctx, "\tframe_num = %d\n", p->frame_num); - va_TraceMsg(trace_ctx, "\tpic_init_qp = %d\n", p->pic_init_qp); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l0_active_minus1 = %d\n", p->num_ref_idx_l0_active_minus1); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - va_TraceMsg(trace_ctx, "\tchroma_qp_index_offset = %d\n", p->chroma_qp_index_offset); - va_TraceMsg(trace_ctx, "\tsecond_chroma_qp_index_offset = %d\n", p->second_chroma_qp_index_offset); - va_TraceMsg(trace_ctx, "\tpic_fields = 0x%03x\n", p->pic_fields.value); - va_TraceMsg(trace_ctx, "\tidr_pic_flag = %d\n", p->pic_fields.bits.idr_pic_flag); - va_TraceMsg(trace_ctx, "\treference_pic_flag = %d\n", p->pic_fields.bits.reference_pic_flag); - va_TraceMsg(trace_ctx, "\tentropy_coding_mode_flag = %d\n", p->pic_fields.bits.entropy_coding_mode_flag); - va_TraceMsg(trace_ctx, "\tweighted_pred_flag = %d\n", p->pic_fields.bits.weighted_pred_flag); - va_TraceMsg(trace_ctx, "\tweighted_bipred_idc = %d\n", p->pic_fields.bits.weighted_bipred_idc); - va_TraceMsg(trace_ctx, "\tconstrained_intra_pred_flag = %d\n", p->pic_fields.bits.constrained_intra_pred_flag); - va_TraceMsg(trace_ctx, "\ttransform_8x8_mode_flag = %d\n", p->pic_fields.bits.transform_8x8_mode_flag); - va_TraceMsg(trace_ctx, "\tdeblocking_filter_control_present_flag = %d\n", p->pic_fields.bits.deblocking_filter_control_present_flag); - va_TraceMsg(trace_ctx, "\tredundant_pic_cnt_present_flag = %d\n", p->pic_fields.bits.redundant_pic_cnt_present_flag); - va_TraceMsg(trace_ctx, "\tpic_order_present_flag = %d\n", p->pic_fields.bits.pic_order_present_flag); - va_TraceMsg(trace_ctx, "\tpic_scaling_matrix_present_flag = %d\n", p->pic_fields.bits.pic_scaling_matrix_present_flag); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncSliceParameterBuffer( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSliceParameterBuffer* p = (VAEncSliceParameterBuffer*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBuffer\n"); - - va_TraceMsg(trace_ctx, "\tstart_row_number = %d\n", p->start_row_number); - va_TraceMsg(trace_ctx, "\tslice_height = %d\n", p->slice_height); - va_TraceMsg(trace_ctx, "\tslice_flags.is_intra = %d\n", p->slice_flags.bits.is_intra); - va_TraceMsg(trace_ctx, "\tslice_flags.disable_deblocking_filter_idc = %d\n", p->slice_flags.bits.disable_deblocking_filter_idc); - va_TraceMsg(trace_ctx, "\tslice_flags.uses_long_term_ref = %d\n", p->slice_flags.bits.uses_long_term_ref); - va_TraceMsg(trace_ctx, "\tslice_flags.is_long_term_ref = %d\n", p->slice_flags.bits.is_long_term_ref); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncSliceParameterBufferH264( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSliceParameterBufferH264* p = (VAEncSliceParameterBufferH264*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - if (!p) - return; - - va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBufferH264\n"); - va_TraceMsg(trace_ctx, "\tmacroblock_address = %u\n", p->macroblock_address); - va_TraceMsg(trace_ctx, "\tnum_macroblocks = %u\n", p->num_macroblocks); - va_TraceMsg(trace_ctx, "\tmacroblock_info = %08x\n", p->macroblock_info); - va_TraceMsg(trace_ctx, "\tslice_type = %d\n", p->slice_type); - va_TraceMsg(trace_ctx, "\tpic_parameter_set_id = %d\n", p->pic_parameter_set_id); - va_TraceMsg(trace_ctx, "\tidr_pic_id = %d\n", p->idr_pic_id); - va_TraceMsg(trace_ctx, "\tpic_order_cnt_lsb = %d\n", p->pic_order_cnt_lsb); - va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt_bottom = %d\n", p->delta_pic_order_cnt_bottom); - va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[0] = %d\n", p->delta_pic_order_cnt[0]); - va_TraceMsg(trace_ctx, "\tdelta_pic_order_cnt[1] = %d\n", p->delta_pic_order_cnt[1]); - va_TraceMsg(trace_ctx, "\tdirect_spatial_mv_pred_flag = %d\n", p->direct_spatial_mv_pred_flag); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_active_override_flag = %d\n", p->num_ref_idx_active_override_flag); - va_TraceMsg(trace_ctx, "\tnum_ref_idx_l1_active_minus1 = %d\n", p->num_ref_idx_l1_active_minus1); - va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - - va_TraceMsg(trace_ctx, "\tRefPicList0 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n"); - - - - for (i = 0; i < 32; i++) { - if ((p->RefPicList0[i].picture_id != VA_INVALID_SURFACE) && - ((p->RefPicList0[i].flags & VA_PICTURE_H264_INVALID) == 0)) - va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08x\n", - p->RefPicList0[i].TopFieldOrderCnt, - p->RefPicList0[i].BottomFieldOrderCnt, - p->RefPicList0[i].picture_id, - p->RefPicList0[i].frame_idx, - p->RefPicList0[i].flags); - else - break; - } - - va_TraceMsg(trace_ctx, "\tRefPicList1 (TopFieldOrderCnt-BottomFieldOrderCnt-picture_id-frame_idx-flags):\n"); - for (i = 0; i < 32; i++) { - if ((p->RefPicList1[i].picture_id != VA_INVALID_SURFACE) && - ((p->RefPicList1[i].flags & VA_PICTURE_H264_INVALID) == 0)) - va_TraceMsg(trace_ctx, "\t\t%08d-%08d-0x%08x-%08d-0x%08d\n", - p->RefPicList1[i].TopFieldOrderCnt, - p->RefPicList1[i].BottomFieldOrderCnt, - p->RefPicList1[i].picture_id, - p->RefPicList1[i].frame_idx, - p->RefPicList1[i].flags - ); - else - break; - } - - va_TraceMsg(trace_ctx, "\tluma_log2_weight_denom = %d\n", p->luma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tchroma_log2_weight_denom = %d\n", p->chroma_log2_weight_denom); - va_TraceMsg(trace_ctx, "\tluma_weight_l0_flag = %d\n", p->luma_weight_l0_flag); - if (p->luma_weight_l0_flag) { - for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\n", - p->luma_weight_l0[i], - p->luma_offset_l0[i]); - } - } - - va_TraceMsg(trace_ctx, "\tchroma_weight_l0_flag = %d\n", p->chroma_weight_l0_flag); - if (p->chroma_weight_l0_flag) { - for (i = 0; (i <= p->num_ref_idx_l0_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\t%d\t%d\n", - p->chroma_weight_l0[i][0], - p->chroma_offset_l0[i][0], - p->chroma_weight_l0[i][1], - p->chroma_offset_l0[i][1]); - } - } - - va_TraceMsg(trace_ctx, "\tluma_weight_l1_flag = %d\n", p->luma_weight_l1_flag); - if (p->luma_weight_l1_flag) { - for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t\t%d\n", - p->luma_weight_l1[i], - p->luma_offset_l1[i]); - } - } - - va_TraceMsg(trace_ctx, "\tchroma_weight_l1_flag = %d\n", p->chroma_weight_l1_flag); - if (p->chroma_weight_l1_flag && p->num_ref_idx_l1_active_minus1 < 32) { - for (i = 0; (i <= p->num_ref_idx_l1_active_minus1) && (i<32); i++) { - va_TraceMsg(trace_ctx, "\t\t%d\t%d\t%d\t%d\n", - p->chroma_weight_l1[i][0], - p->chroma_offset_l1[i][0], - p->chroma_weight_l1[i][1], - p->chroma_offset_l1[i][1]); - } - } - va_TraceMsg(trace_ctx, NULL); - - va_TraceMsg(trace_ctx, "\tcabac_init_idc = %d\n", p->cabac_init_idc); - va_TraceMsg(trace_ctx, "\tslice_qp_delta = %d\n", p->slice_qp_delta); - va_TraceMsg(trace_ctx, "\tdisable_deblocking_filter_idc = %d\n", p->disable_deblocking_filter_idc); - va_TraceMsg(trace_ctx, "\tslice_alpha_c0_offset_div2 = %d\n", p->slice_alpha_c0_offset_div2); - va_TraceMsg(trace_ctx, "\tslice_beta_offset_div2 = %d\n", p->slice_beta_offset_div2); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAEncPackedHeaderParameterBufferType( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPackedHeaderParameterBuffer* p = (VAEncPackedHeaderParameterBuffer*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if (!p) - return; - va_TraceMsg(trace_ctx, "\t--VAEncPackedHeaderParameterBuffer\n"); - va_TraceMsg(trace_ctx, "\ttype = 0x%08x\n", p->type); - va_TraceMsg(trace_ctx, "\tbit_length = %d\n", p->bit_length); - va_TraceMsg(trace_ctx, "\thas_emulation_bytes = %d\n", p->has_emulation_bytes); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncMiscParameterBuffer( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncMiscParameterBuffer* tmp = (VAEncMiscParameterBuffer*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (tmp->type) { - case VAEncMiscParameterTypeFrameRate: - { - VAEncMiscParameterFrameRate *p = (VAEncMiscParameterFrameRate *)tmp->data; - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterFrameRate\n"); - va_TraceMsg(trace_ctx, "\tframerate = %d\n", p->framerate); - - break; - } - case VAEncMiscParameterTypeRateControl: - { - VAEncMiscParameterRateControl *p = (VAEncMiscParameterRateControl *)tmp->data; - - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterRateControl\n"); - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\ttarget_percentage = %d\n", p->target_percentage); - va_TraceMsg(trace_ctx, "\twindow_size = %d\n", p->window_size); - va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp); - va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp); - va_TraceMsg(trace_ctx, "\tbasic_unit_size = %d\n", p->basic_unit_size); - va_TraceMsg(trace_ctx, "\trc_flags.reset = %d \n", p->rc_flags.bits.reset); - va_TraceMsg(trace_ctx, "\trc_flags.disable_frame_skip = %d\n", p->rc_flags.bits.disable_frame_skip); - va_TraceMsg(trace_ctx, "\trc_flags.disable_bit_stuffing = %d\n", p->rc_flags.bits.disable_bit_stuffing); - break; - } - case VAEncMiscParameterTypeMaxSliceSize: - { - VAEncMiscParameterMaxSliceSize *p = (VAEncMiscParameterMaxSliceSize *)tmp->data; - - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterTypeMaxSliceSize\n"); - va_TraceMsg(trace_ctx, "\tmax_slice_size = %d\n", p->max_slice_size); - break; - } - case VAEncMiscParameterTypeAIR: - { - VAEncMiscParameterAIR *p = (VAEncMiscParameterAIR *)tmp->data; - - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterAIR\n"); - va_TraceMsg(trace_ctx, "\tair_num_mbs = %d\n", p->air_num_mbs); - va_TraceMsg(trace_ctx, "\tair_threshold = %d\n", p->air_threshold); - va_TraceMsg(trace_ctx, "\tair_auto = %d\n", p->air_auto); - break; - } - case VAEncMiscParameterTypeHRD: - { - VAEncMiscParameterHRD *p = (VAEncMiscParameterHRD *)tmp->data; - - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterHRD\n"); - va_TraceMsg(trace_ctx, "\tinitial_buffer_fullness = %d\n", p->initial_buffer_fullness); - va_TraceMsg(trace_ctx, "\tbuffer_size = %d\n", p->buffer_size); - break; - } - case VAEncMiscParameterTypeMaxFrameSize: - { - VAEncMiscParameterBufferMaxFrameSize *p = (VAEncMiscParameterBufferMaxFrameSize *)tmp->data; - - va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterTypeMaxFrameSize\n"); - va_TraceMsg(trace_ctx, "\tmax_frame_size = %d\n", p->max_frame_size); - break; - } - default: - va_TraceMsg(trace_ctx, "Unknown VAEncMiscParameterBuffer(type = %d):\n", tmp->type); - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data); - break; - } - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAPictureParameterBufferVC1( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - VAPictureParameterBufferVC1* p = (VAPictureParameterBufferVC1*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVC1\n"); - - va_TraceMsg(trace_ctx, "\tforward_reference_picture = 0x%08x\n", p->forward_reference_picture); - va_TraceMsg(trace_ctx, "\tbackward_reference_picture = 0x%08x\n", p->backward_reference_picture); - va_TraceMsg(trace_ctx, "\tinloop_decoded_picture = 0x%08x\n", p->inloop_decoded_picture); - - va_TraceMsg(trace_ctx, "\tpulldown = %d\n", p->sequence_fields.bits.pulldown); - va_TraceMsg(trace_ctx, "\tinterlace = %d\n", p->sequence_fields.bits.interlace); - va_TraceMsg(trace_ctx, "\ttfcntrflag = %d\n", p->sequence_fields.bits.tfcntrflag); - va_TraceMsg(trace_ctx, "\tfinterpflag = %d\n", p->sequence_fields.bits.finterpflag); - va_TraceMsg(trace_ctx, "\tpsf = %d\n", p->sequence_fields.bits.psf); - va_TraceMsg(trace_ctx, "\tmultires = %d\n", p->sequence_fields.bits.multires); - va_TraceMsg(trace_ctx, "\toverlap = %d\n", p->sequence_fields.bits.overlap); - va_TraceMsg(trace_ctx, "\tsyncmarker = %d\n", p->sequence_fields.bits.syncmarker); - va_TraceMsg(trace_ctx, "\trangered = %d\n", p->sequence_fields.bits.rangered); - va_TraceMsg(trace_ctx, "\tmax_b_frames = %d\n", p->sequence_fields.bits.max_b_frames); - va_TraceMsg(trace_ctx, "\tprofile = %d\n", p->sequence_fields.bits.profile); - va_TraceMsg(trace_ctx, "\tcoded_width = %d\n", p->coded_width); - va_TraceMsg(trace_ctx, "\tcoded_height = %d\n", p->coded_height); - va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry); - va_TraceMsg(trace_ctx, "\tbroken_link = %d\n", p->entrypoint_fields.bits.broken_link); - va_TraceMsg(trace_ctx, "\tclosed_entry = %d\n", p->entrypoint_fields.bits.closed_entry); - va_TraceMsg(trace_ctx, "\tpanscan_flag = %d\n", p->entrypoint_fields.bits.panscan_flag); - va_TraceMsg(trace_ctx, "\tloopfilter = %d\n", p->entrypoint_fields.bits.loopfilter); - va_TraceMsg(trace_ctx, "\tconditional_overlap_flag = %d\n", p->conditional_overlap_flag); - va_TraceMsg(trace_ctx, "\tfast_uvmc_flag = %d\n", p->fast_uvmc_flag); - va_TraceMsg(trace_ctx, "\trange_mapping_luma_flag = %d\n", p->range_mapping_fields.bits.luma_flag); - va_TraceMsg(trace_ctx, "\trange_mapping_luma = %d\n", p->range_mapping_fields.bits.luma); - va_TraceMsg(trace_ctx, "\trange_mapping_chroma_flag = %d\n", p->range_mapping_fields.bits.chroma_flag); - va_TraceMsg(trace_ctx, "\trange_mapping_chroma = %d\n", p->range_mapping_fields.bits.chroma); - va_TraceMsg(trace_ctx, "\tb_picture_fraction = %d\n", p->b_picture_fraction); - va_TraceMsg(trace_ctx, "\tcbp_table = %d\n", p->cbp_table); - va_TraceMsg(trace_ctx, "\tmb_mode_table = %d\n", p->mb_mode_table); - va_TraceMsg(trace_ctx, "\trange_reduction_frame = %d\n", p->range_reduction_frame); - va_TraceMsg(trace_ctx, "\trounding_control = %d\n", p->rounding_control); - va_TraceMsg(trace_ctx, "\tpost_processing = %d\n", p->post_processing); - va_TraceMsg(trace_ctx, "\tpicture_resolution_index = %d\n", p->picture_resolution_index); - va_TraceMsg(trace_ctx, "\tluma_scale = %d\n", p->luma_scale); - va_TraceMsg(trace_ctx, "\tluma_shift = %d\n", p->luma_shift); - va_TraceMsg(trace_ctx, "\tpicture_type = %d\n", p->picture_fields.bits.picture_type); - va_TraceMsg(trace_ctx, "\tframe_coding_mode = %d\n", p->picture_fields.bits.frame_coding_mode); - va_TraceMsg(trace_ctx, "\ttop_field_first = %d\n", p->picture_fields.bits.top_field_first); - va_TraceMsg(trace_ctx, "\tis_first_field = %d\n", p->picture_fields.bits.is_first_field); - va_TraceMsg(trace_ctx, "\tintensity_compensation = %d\n", p->picture_fields.bits.intensity_compensation); - va_TraceMsg(trace_ctx, "\tmv_type_mb = %d\n", p->raw_coding.flags.mv_type_mb); - va_TraceMsg(trace_ctx, "\tdirect_mb = %d\n", p->raw_coding.flags.direct_mb); - va_TraceMsg(trace_ctx, "\tskip_mb = %d\n", p->raw_coding.flags.skip_mb); - va_TraceMsg(trace_ctx, "\tfield_tx = %d\n", p->raw_coding.flags.field_tx); - va_TraceMsg(trace_ctx, "\tforward_mb = %d\n", p->raw_coding.flags.forward_mb); - va_TraceMsg(trace_ctx, "\tac_pred = %d\n", p->raw_coding.flags.ac_pred); - va_TraceMsg(trace_ctx, "\toverflags = %d\n", p->raw_coding.flags.overflags); - va_TraceMsg(trace_ctx, "\tbp_mv_type_mb = %d\n", p->bitplane_present.flags.bp_mv_type_mb); - va_TraceMsg(trace_ctx, "\tbp_direct_mb = %d\n", p->bitplane_present.flags.bp_direct_mb); - va_TraceMsg(trace_ctx, "\tbp_skip_mb = %d\n", p->bitplane_present.flags.bp_skip_mb); - va_TraceMsg(trace_ctx, "\tbp_field_tx = %d\n", p->bitplane_present.flags.bp_field_tx); - va_TraceMsg(trace_ctx, "\tbp_forward_mb = %d\n", p->bitplane_present.flags.bp_forward_mb); - va_TraceMsg(trace_ctx, "\tbp_ac_pred = %d\n", p->bitplane_present.flags.bp_ac_pred); - va_TraceMsg(trace_ctx, "\tbp_overflags = %d\n", p->bitplane_present.flags.bp_overflags); - va_TraceMsg(trace_ctx, "\treference_distance_flag = %d\n", p->reference_fields.bits.reference_distance_flag); - va_TraceMsg(trace_ctx, "\treference_distance = %d\n", p->reference_fields.bits.reference_distance); - va_TraceMsg(trace_ctx, "\tnum_reference_pictures = %d\n", p->reference_fields.bits.num_reference_pictures); - va_TraceMsg(trace_ctx, "\treference_field_pic_indicator = %d\n", p->reference_fields.bits.reference_field_pic_indicator); - va_TraceMsg(trace_ctx, "\tmv_mode = %d\n", p->mv_fields.bits.mv_mode); - va_TraceMsg(trace_ctx, "\tmv_mode2 = %d\n", p->mv_fields.bits.mv_mode2); - va_TraceMsg(trace_ctx, "\tmv_table = %d\n", p->mv_fields.bits.mv_table); - va_TraceMsg(trace_ctx, "\ttwo_mv_block_pattern_table = %d\n", p->mv_fields.bits.two_mv_block_pattern_table); - va_TraceMsg(trace_ctx, "\tfour_mv_switch = %d\n", p->mv_fields.bits.four_mv_switch); - va_TraceMsg(trace_ctx, "\tfour_mv_block_pattern_table = %d\n", p->mv_fields.bits.four_mv_block_pattern_table); - va_TraceMsg(trace_ctx, "\textended_mv_flag = %d\n", p->mv_fields.bits.extended_mv_flag); - va_TraceMsg(trace_ctx, "\textended_mv_range = %d\n", p->mv_fields.bits.extended_mv_range); - va_TraceMsg(trace_ctx, "\textended_dmv_flag = %d\n", p->mv_fields.bits.extended_dmv_flag); - va_TraceMsg(trace_ctx, "\textended_dmv_range = %d\n", p->mv_fields.bits.extended_dmv_range); - va_TraceMsg(trace_ctx, "\tdquant = %d\n", p->pic_quantizer_fields.bits.dquant); - va_TraceMsg(trace_ctx, "\tquantizer = %d\n", p->pic_quantizer_fields.bits.quantizer); - va_TraceMsg(trace_ctx, "\thalf_qp = %d\n", p->pic_quantizer_fields.bits.half_qp); - va_TraceMsg(trace_ctx, "\tpic_quantizer_scale = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_scale); - va_TraceMsg(trace_ctx, "\tpic_quantizer_type = %d\n", p->pic_quantizer_fields.bits.pic_quantizer_type); - va_TraceMsg(trace_ctx, "\tdq_frame = %d\n", p->pic_quantizer_fields.bits.dq_frame); - va_TraceMsg(trace_ctx, "\tdq_profile = %d\n", p->pic_quantizer_fields.bits.dq_profile); - va_TraceMsg(trace_ctx, "\tdq_sb_edge = %d\n", p->pic_quantizer_fields.bits.dq_sb_edge); - va_TraceMsg(trace_ctx, "\tdq_db_edge = %d\n", p->pic_quantizer_fields.bits.dq_db_edge); - va_TraceMsg(trace_ctx, "\tdq_binary_level = %d\n", p->pic_quantizer_fields.bits.dq_binary_level); - va_TraceMsg(trace_ctx, "\talt_pic_quantizer = %d\n", p->pic_quantizer_fields.bits.alt_pic_quantizer); - va_TraceMsg(trace_ctx, "\tvariable_sized_transform_flag = %d\n", p->transform_fields.bits.variable_sized_transform_flag); - va_TraceMsg(trace_ctx, "\tmb_level_transform_type_flag = %d\n", p->transform_fields.bits.mb_level_transform_type_flag); - va_TraceMsg(trace_ctx, "\tframe_level_transform_type = %d\n", p->transform_fields.bits.frame_level_transform_type); - va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx1 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx1); - va_TraceMsg(trace_ctx, "\ttransform_ac_codingset_idx2 = %d\n", p->transform_fields.bits.transform_ac_codingset_idx2); - va_TraceMsg(trace_ctx, "\tintra_transform_dc_table = %d\n", p->transform_fields.bits.intra_transform_dc_table); - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVASliceParameterBufferVC1( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void* data -) -{ - VASliceParameterBufferVC1 *p = (VASliceParameterBufferVC1*)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - trace_ctx->trace_slice_no++; - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVC1\n"); - va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset); - va_TraceMsg(trace_ctx, "\tslice_vertical_position = %d\n", p->slice_vertical_position); - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVAPictureParameterBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - char tmp[1024]; - VAPictureParameterBufferVP8 *p = (VAPictureParameterBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i,j; - - va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVP8\n"); - - va_TraceMsg(trace_ctx, "\tframe_width = %d\n", p->frame_width); - va_TraceMsg(trace_ctx, "\tframe_height = %d\n", p->frame_height); - va_TraceMsg(trace_ctx, "\tlast_ref_frame = %x\n", p->last_ref_frame); - va_TraceMsg(trace_ctx, "\tgolden_ref_frame = %x\n", p->golden_ref_frame); - va_TraceMsg(trace_ctx, "\talt_ref_frame = %x\n", p->alt_ref_frame); - va_TraceMsg(trace_ctx, "\tout_of_loop_frame = %x\n", p->out_of_loop_frame); - - va_TraceMsg(trace_ctx, "\tkey_frame = %d\n", p->pic_fields.bits.key_frame); - va_TraceMsg(trace_ctx, "\tversion = %d\n", p->pic_fields.bits.version); - va_TraceMsg(trace_ctx, "\tsegmentation_enabled = %d\n", p->pic_fields.bits.segmentation_enabled); - va_TraceMsg(trace_ctx, "\tupdate_mb_segmentation_map = %d\n", p->pic_fields.bits.update_mb_segmentation_map); - va_TraceMsg(trace_ctx, "\tupdate_segment_feature_data = %d\n", p->pic_fields.bits.update_segment_feature_data); - va_TraceMsg(trace_ctx, "\tfilter_type = %d\n", p->pic_fields.bits.filter_type); - va_TraceMsg(trace_ctx, "\tsharpness_level = %d\n", p->pic_fields.bits.sharpness_level); - va_TraceMsg(trace_ctx, "\tloop_filter_adj_enable = %d\n", p->pic_fields.bits.loop_filter_adj_enable); - va_TraceMsg(trace_ctx, "\tmode_ref_lf_delta_update = %d\n", p->pic_fields.bits.mode_ref_lf_delta_update); - va_TraceMsg(trace_ctx, "\tsign_bias_golden = %d\n", p->pic_fields.bits.sign_bias_golden); - va_TraceMsg(trace_ctx, "\tsign_bias_alternate = %d\n", p->pic_fields.bits.sign_bias_alternate); - va_TraceMsg(trace_ctx, "\tmb_no_coeff_skip = %d\n", p->pic_fields.bits.mb_no_coeff_skip); - va_TraceMsg(trace_ctx, "\tloop_filter_disable = %d\n", p->pic_fields.bits.loop_filter_disable); - - va_TraceMsg(trace_ctx, "\tmb_segment_tree_probs: 0x%2x, 0x%2x, 0x%2x\n", - p->mb_segment_tree_probs[0], p->mb_segment_tree_probs[1], p->mb_segment_tree_probs[2]); - - va_TraceMsg(trace_ctx, "\tloop_filter_level: %d, %d, %d, %d\n", - p->loop_filter_level[0], p->loop_filter_level[1], p->loop_filter_level[2], p->loop_filter_level[3]); - - va_TraceMsg(trace_ctx, "\tloop_filter_deltas_ref_frame: %d, %d, %d, %d\n", - p->loop_filter_deltas_ref_frame[0], p->loop_filter_deltas_ref_frame[1], p->loop_filter_deltas_ref_frame[2], p->loop_filter_deltas_ref_frame[3]); - - va_TraceMsg(trace_ctx, "\tloop_filter_deltas_mode: %d, %d, %d, %d\n", - p->loop_filter_deltas_mode[0], p->loop_filter_deltas_mode[1], p->loop_filter_deltas_mode[2], p->loop_filter_deltas_mode[3]); - - va_TraceMsg(trace_ctx, "\tprob_skip_false = %2x\n", p->prob_skip_false); - va_TraceMsg(trace_ctx, "\tprob_intra = %2x\n", p->prob_intra); - va_TraceMsg(trace_ctx, "\tprob_last = %2x\n", p->prob_last); - va_TraceMsg(trace_ctx, "\tprob_gf = %2x\n", p->prob_gf); - - va_TraceMsg(trace_ctx, "\ty_mode_probs: 0x%2x, 0x%2x, 0x%2x, 0x%2x\n", - p->y_mode_probs[0], p->y_mode_probs[1], p->y_mode_probs[2], p->y_mode_probs[3]); - - va_TraceMsg(trace_ctx, "\tuv_mode_probs: 0x%2x, 0x%2x, 0x%2x\n", - p->uv_mode_probs[0], p->uv_mode_probs[1], p->uv_mode_probs[2]); - - va_TraceMsg(trace_ctx, "\tmv_probs[2][19]:\n"); - for(i = 0; i<2; ++i) { - memset(tmp, 0, sizeof tmp); - for (j=0; j<19; j++) - sprintf(tmp + strlen(tmp), "%2x ", p->mv_probs[i][j]); - va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp); - } - - va_TraceMsg(trace_ctx, "\tbool_coder_ctx: range = %02x, value = %02x, count = %d\n", - p->bool_coder_ctx.range, p->bool_coder_ctx.value, p->bool_coder_ctx.count); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVASliceParameterBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VASliceParameterBufferVP8 *p = (VASliceParameterBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP8\n"); - - va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset); - va_TraceMsg(trace_ctx, "\tnum_of_partitions = %d\n", p->num_of_partitions); - - for(i = 0; i<9; ++i) - va_TraceMsg(trace_ctx, "\tpartition_size[%d] = %d\n", i, p->partition_size[i]); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAIQMatrixBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - char tmp[1024]; - VAIQMatrixBufferVP8 *p = (VAIQMatrixBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i,j; - - va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferVP8\n"); - - va_TraceMsg(trace_ctx, "\tquantization_index[4][6]=\n"); - for (i = 0; i < 4; i++) { - memset(tmp, 0, sizeof tmp); - for (j = 0; j < 6; j++) - sprintf(tmp + strlen(tmp), "%4x, ", p->quantization_index[i][j]); - va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp); - } - - va_TraceMsg(trace_ctx, NULL); - - return; -} -static void va_TraceVAProbabilityBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - char tmp[1024]; - VAProbabilityDataBufferVP8 *p = (VAProbabilityDataBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i,j,k,l; - - va_TraceMsg(trace_ctx, "\t--VAProbabilityDataBufferVP8\n"); - - for (i = 0; i < 4; i++) - for (j = 0; j < 8; j++) { - memset(tmp, 0, sizeof tmp); - for (k=0; k<3; k++) - for (l=0; l<11; l++) - sprintf(tmp + strlen(tmp), "%2x, ", p->dct_coeff_probs[i][j][k][l]); - va_TraceMsg(trace_ctx,"\t\t[%d, %d] = %s\n", i, j, tmp); - } - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncSequenceParameterBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferVP8 *p = (VAEncSequenceParameterBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferVP8\n"); - - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\terror_resilient = %d\n", p->error_resilient); - va_TraceMsg(trace_ctx, "\tframe_height = %d\n", p->frame_height); - va_TraceMsg(trace_ctx, "\tframe_width = %d\n", p->frame_width); - va_TraceMsg(trace_ctx, "\tframe_height_scale = %d\n", p->frame_height_scale); - va_TraceMsg(trace_ctx, "\tframe_width_scale = %d\n", p->frame_width_scale); - va_TraceMsg(trace_ctx, "\tkf_auto = %d\n", p->kf_auto); - va_TraceMsg(trace_ctx, "\tkf_max_dist = %d\n", p->kf_max_dist); - va_TraceMsg(trace_ctx, "\tkf_min_dist = %d\n", p->kf_min_dist); - va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period); - - for(i = 0; i<4; ++i) - va_TraceMsg(trace_ctx, "\treference_frames[%d] = 0x%08x\n", i, p->reference_frames[i]); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncSequenceParameterBufferVP9( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferVP9 *p = (VAEncSequenceParameterBufferVP9 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferVP9\n"); - - va_TraceMsg(trace_ctx, "\tmax_frame_height = %d\n", p->max_frame_height); - va_TraceMsg(trace_ctx, "\tmax_frame_width = %d\n", p->max_frame_width); - va_TraceMsg(trace_ctx, "\tkf_auto = %d\n", p->kf_auto); - va_TraceMsg(trace_ctx, "\tkf_min_dist = %d\n", p->kf_min_dist); - va_TraceMsg(trace_ctx, "\tkf_max_dist = %d\n", p->kf_max_dist); - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAPictureParameterBufferVP9( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VADecPictureParameterBufferVP9 *p = (VADecPictureParameterBufferVP9 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVP9\n"); - - va_TraceMsg(trace_ctx, "\tframe_width = %d\n", p->frame_width); - va_TraceMsg(trace_ctx, "\tframe_height = %d\n", p->frame_height); - va_TraceMsg(trace_ctx, "\treference_frames[8] =\n"); - for (i = 0; i < 8; i++) { - va_TraceMsg(trace_ctx, "\t\t0x%x\n", p->reference_frames[i]); - } - va_TraceMsg(trace_ctx, "\tsubsampling_x = %d\n", p->pic_fields.bits.subsampling_x); - va_TraceMsg(trace_ctx, "\tsubsampling_y = %d\n", p->pic_fields.bits.subsampling_y); - va_TraceMsg(trace_ctx, "\tframe_type = %d\n", p->pic_fields.bits.frame_type); - va_TraceMsg(trace_ctx, "\tshow_frame = %d\n", p->pic_fields.bits.show_frame); - va_TraceMsg(trace_ctx, "\terror_resilient_mode = %d\n", p->pic_fields.bits.error_resilient_mode); - va_TraceMsg(trace_ctx, "\tintra_only = %d\n", p->pic_fields.bits.intra_only); - va_TraceMsg(trace_ctx, "\tallow_high_precision_mv = %d\n", p->pic_fields.bits.allow_high_precision_mv); - va_TraceMsg(trace_ctx, "\tmcomp_filter_type = %d\n", p->pic_fields.bits.mcomp_filter_type); - va_TraceMsg(trace_ctx, "\tframe_parallel_decoding_mode = %d\n", p->pic_fields.bits.frame_parallel_decoding_mode); - va_TraceMsg(trace_ctx, "\treset_frame_context = %d\n", p->pic_fields.bits.reset_frame_context); - va_TraceMsg(trace_ctx, "\trefresh_frame_context = %d\n", p->pic_fields.bits.refresh_frame_context); - va_TraceMsg(trace_ctx, "\tframe_context_idx = %d\n", p->pic_fields.bits.frame_context_idx); - va_TraceMsg(trace_ctx, "\tsegmentation_enabled = %d\n", p->pic_fields.bits.segmentation_enabled); - va_TraceMsg(trace_ctx, "\tsegmentation_temporal_update = %d\n", p->pic_fields.bits.segmentation_temporal_update); - va_TraceMsg(trace_ctx, "\tsegmentation_update_map = %d\n", p->pic_fields.bits.segmentation_update_map); - va_TraceMsg(trace_ctx, "\tlast_ref_frame = %d\n", p->pic_fields.bits.last_ref_frame); - va_TraceMsg(trace_ctx, "\tlast_ref_frame_sign_bias = %d\n", p->pic_fields.bits.last_ref_frame_sign_bias); - va_TraceMsg(trace_ctx, "\tgolden_ref_frame = %d\n", p->pic_fields.bits.golden_ref_frame); - va_TraceMsg(trace_ctx, "\tgolden_ref_frame_sign_bias = %d\n", p->pic_fields.bits.golden_ref_frame_sign_bias); - va_TraceMsg(trace_ctx, "\talt_ref_frame = %d\n", p->pic_fields.bits.alt_ref_frame); - va_TraceMsg(trace_ctx, "\talt_ref_frame_sign_bias = %d\n", p->pic_fields.bits.alt_ref_frame_sign_bias); - va_TraceMsg(trace_ctx, "\tlossless_flag = %d\n", p->pic_fields.bits.lossless_flag); - - va_TraceMsg(trace_ctx, "\tfilter_level = %d\n", p->filter_level); - va_TraceMsg(trace_ctx, "\tsharpness_level = %d\n", p->sharpness_level); - va_TraceMsg(trace_ctx, "\tlog2_tile_rows = %d\n", p->log2_tile_rows); - va_TraceMsg(trace_ctx, "\tlog2_tile_columns = %d\n", p->log2_tile_columns); - va_TraceMsg(trace_ctx, "\tframe_header_length_in_bytes = %d\n", p->frame_header_length_in_bytes); - va_TraceMsg(trace_ctx, "\tfirst_partition_size = %d\n", p->first_partition_size); - - va_TraceMsg(trace_ctx, "\tmb_segment_tree_probs[7]: [0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x]\n", - p->mb_segment_tree_probs[0], p->mb_segment_tree_probs[1], - p->mb_segment_tree_probs[2], p->mb_segment_tree_probs[3], - p->mb_segment_tree_probs[4], p->mb_segment_tree_probs[5], - p->mb_segment_tree_probs[6]); - - va_TraceMsg(trace_ctx, "\tsegment_pred_probs[3]: [0x%02x, 0x%02x, 0x%02x]\n", p->segment_pred_probs[0], p->segment_pred_probs[1], p->segment_pred_probs[2]); - - va_TraceMsg(trace_ctx, "\tprofile = %d\n", p->profile); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncPictureParameterBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferVP8 *p = (VAEncPictureParameterBufferVP8 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferVP8\n"); - va_TraceMsg(trace_ctx, "\treconstructed_frame = 0x%08x\n", p->reconstructed_frame); - va_TraceMsg(trace_ctx, "\tref_last_frame = 0x%08x\n", p->ref_last_frame); - va_TraceMsg(trace_ctx, "\tref_gf_frame = 0x%08x\n", p->ref_gf_frame); - va_TraceMsg(trace_ctx, "\tref_arf_frame = 0x%08x\n", p->ref_arf_frame); - va_TraceMsg(trace_ctx, "\tcoded_buf = 0x%08x\n", p->coded_buf); - - va_TraceMsg(trace_ctx, "\tref_flags.bits.force_kf = %d\n", p->ref_flags.bits.force_kf); - va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_last = %d\n", p->ref_flags.bits.no_ref_last); - va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_gf = %d\n", p->ref_flags.bits.no_ref_gf); - va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_arf = %d\n", p->ref_flags.bits.no_ref_arf); - va_TraceMsg(trace_ctx, "\tref_flags.bits.no_ref_arf = 0x%08x\n", p->ref_flags.bits.reserved); - - va_TraceMsg(trace_ctx, "\tpic_flags.bits.frame_type = %d\n", p->pic_flags.bits.frame_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.version = %d\n", p->pic_flags.bits.version); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.show_frame = %d\n", p->pic_flags.bits.show_frame); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.color_space = %d\n", p->pic_flags.bits.color_space); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.recon_filter_type = %d\n", p->pic_flags.bits.recon_filter_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.loop_filter_type = %d\n", p->pic_flags.bits.loop_filter_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.auto_partitions = %d\n", p->pic_flags.bits.auto_partitions); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.num_token_partitions = %d\n", p->pic_flags.bits.num_token_partitions); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.clamping_type = %d\n", p->pic_flags.bits.clamping_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.segmentation_enabled = %d\n", p->pic_flags.bits.segmentation_enabled); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.update_mb_segmentation_map = %d\n", p->pic_flags.bits.update_mb_segmentation_map); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.update_segment_feature_data = %d\n", p->pic_flags.bits.update_segment_feature_data); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.loop_filter_adj_enable = %d\n", p->pic_flags.bits.loop_filter_adj_enable); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.refresh_entropy_probs = %d\n", p->pic_flags.bits.refresh_entropy_probs); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.refresh_golden_frame = %d\n", p->pic_flags.bits.refresh_golden_frame); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.refresh_alternate_frame = %d\n", p->pic_flags.bits.refresh_alternate_frame); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.refresh_last = %d\n", p->pic_flags.bits.refresh_last); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.copy_buffer_to_golden = %d\n", p->pic_flags.bits.copy_buffer_to_golden); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.copy_buffer_to_alternate = %d\n", p->pic_flags.bits.copy_buffer_to_alternate); - - va_TraceMsg(trace_ctx, "\tpic_flags.bits.sign_bias_golden = %d\n", p->pic_flags.bits.sign_bias_golden); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.sign_bias_alternate = %d\n", p->pic_flags.bits.sign_bias_alternate); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.mb_no_coeff_skip = %d\n", p->pic_flags.bits.mb_no_coeff_skip); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.forced_lf_adjustment = %d\n", p->pic_flags.bits.forced_lf_adjustment); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.reserved = %d\n", p->pic_flags.bits.reserved); - - for(i=0;i<4;i++) - va_TraceMsg(trace_ctx, "\tloop_filter_level[%d] = %d\n", i, p->loop_filter_level[i]); - for(i=0;i<4;i++) - va_TraceMsg(trace_ctx, "\tref_lf_delta[%d] = %d\n", i, p->ref_lf_delta[i]); - for(i=0;i<4;i++) - va_TraceMsg(trace_ctx, "\tmode_lf_delta[%d] = %d\n", i, p->mode_lf_delta[i]); - - va_TraceMsg(trace_ctx, "\tsharpness_level = %d\n", p->sharpness_level); - va_TraceMsg(trace_ctx, "\tclamp_qindex_high = %d\n", p->clamp_qindex_high); - va_TraceMsg(trace_ctx, "\tclamp_qindex_low = %d\n", p->clamp_qindex_low); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncPictureParameterBufferVP9( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferVP9 *p = (VAEncPictureParameterBufferVP9 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i; - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferVP9\n"); - va_TraceMsg(trace_ctx, "\tframe_width_src = %d\n", p->frame_width_src); - va_TraceMsg(trace_ctx, "\tframe_height_src = %d\n", p->frame_height_src); - va_TraceMsg(trace_ctx, "\tframe_width_dst = %d\n", p->frame_width_dst); - va_TraceMsg(trace_ctx, "\tframe_height_dst = %d\n", p->frame_height_dst); - va_TraceMsg(trace_ctx, "\treconstructed_frame = 0x%08x\n", p->reconstructed_frame); - - for(i=0;i<8;i++) - va_TraceMsg(trace_ctx, "\treference_frames[%d] = 0x%08x\n", i, p->reference_frames[i]); - - va_TraceMsg(trace_ctx, "\tcoded_buf = 0x%x\n", p->coded_buf); - - va_TraceMsg(trace_ctx, "\tref_flags.bits.force_kf = %d\n", p->ref_flags.bits.force_kf); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_frame_ctrl_l0 = %d\n", p->ref_flags.bits.ref_frame_ctrl_l0); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_frame_ctrl_l1 = %d\n", p->ref_flags.bits.ref_frame_ctrl_l1); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_last_idx = %d\n", p->ref_flags.bits.ref_last_idx); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_last_sign_bias = %d\n", p->ref_flags.bits.ref_last_sign_bias); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_gf_idx = %d\n", p->ref_flags.bits.ref_gf_idx); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_gf_sign_bias = %d\n", p->ref_flags.bits.ref_gf_sign_bias); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_arf_idx = %d\n", p->ref_flags.bits.ref_arf_idx); - va_TraceMsg(trace_ctx, "\tref_flags.bits.ref_arf_sign_bias = %d\n", p->ref_flags.bits.ref_arf_sign_bias); - va_TraceMsg(trace_ctx, "\tref_flags.bits.temporal_id = %d\n", p->ref_flags.bits.temporal_id); - va_TraceMsg(trace_ctx, "\tref_flags.bits.reserved = %d\n", p->ref_flags.bits.reserved); - - va_TraceMsg(trace_ctx, "\tpic_flags.bits.frame_type = %d\n", p->pic_flags.bits.frame_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.show_frame = %d\n", p->pic_flags.bits.show_frame); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.error_resilient_mode = %d\n", p->pic_flags.bits.error_resilient_mode); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.intra_only = %d\n", p->pic_flags.bits.intra_only); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.allow_high_precision_mv = %d\n", p->pic_flags.bits.allow_high_precision_mv); - - va_TraceMsg(trace_ctx, "\tpic_flags.bits.mcomp_filter_type = %d\n", p->pic_flags.bits.mcomp_filter_type); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.frame_parallel_decoding_mode = %d\n", p->pic_flags.bits.frame_parallel_decoding_mode); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.reset_frame_context = %d\n", p->pic_flags.bits.reset_frame_context); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.refresh_frame_context = %d\n", p->pic_flags.bits.refresh_frame_context); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.frame_context_idx = %d\n", p->pic_flags.bits.frame_context_idx); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.segmentation_enabled = %d\n", p->pic_flags.bits.segmentation_enabled); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.segmentation_temporal_update = %d\n", p->pic_flags.bits.segmentation_temporal_update); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.segmentation_update_map = %d\n", p->pic_flags.bits.segmentation_update_map); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.lossless_mode = %d\n", p->pic_flags.bits.lossless_mode); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.comp_prediction_mode = %d\n", p->pic_flags.bits.comp_prediction_mode); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.auto_segmentation = %d\n", p->pic_flags.bits.auto_segmentation); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.super_frame_flag = %d\n", p->pic_flags.bits.super_frame_flag); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.reserved = %d\n", p->pic_flags.bits.reserved); - - va_TraceMsg(trace_ctx, "\trefresh_frame_flags = %d\n", p->refresh_frame_flags); - va_TraceMsg(trace_ctx, "\tluma_ac_qindex = %d\n", p->luma_ac_qindex); - va_TraceMsg(trace_ctx, "\tluma_dc_qindex_delta = %d\n", p->luma_dc_qindex_delta); - va_TraceMsg(trace_ctx, "\tchroma_ac_qindex_delta = %d\n", p->chroma_ac_qindex_delta); - va_TraceMsg(trace_ctx, "\tchroma_dc_qindex_delta = %d\n", p->chroma_dc_qindex_delta); - va_TraceMsg(trace_ctx, "\tfilter_level = %d\n", p->filter_level); - va_TraceMsg(trace_ctx, "\tsharpness_level = %d\n", p->sharpness_level); - - for(i=0;i<4;i++) - va_TraceMsg(trace_ctx, "\tref_lf_delta[%d] = %d\n", i, p->ref_lf_delta[i]); - for(i=0;i<2;i++) - va_TraceMsg(trace_ctx, "\tmode_lf_delta[%d] = %d\n", i, p->mode_lf_delta[i]); - - - va_TraceMsg(trace_ctx, "\tbit_offset_ref_lf_delta = %d\n", p->bit_offset_ref_lf_delta); - va_TraceMsg(trace_ctx, "\tbit_offset_mode_lf_delta = %d\n", p->bit_offset_mode_lf_delta); - va_TraceMsg(trace_ctx, "\tbit_offset_lf_level = %d\n", p->bit_offset_lf_level); - va_TraceMsg(trace_ctx, "\tbit_offset_qindex = %d\n", p->bit_offset_qindex); - va_TraceMsg(trace_ctx, "\tbit_offset_first_partition_size = %d\n", p->bit_offset_first_partition_size); - va_TraceMsg(trace_ctx, "\tbit_offset_segmentation = %d\n", p->bit_offset_segmentation); - va_TraceMsg(trace_ctx, "\tbit_size_segmentation = %d\n", p->bit_size_segmentation); - va_TraceMsg(trace_ctx, "\tlog2_tile_rows = %d\n", p->log2_tile_rows); - va_TraceMsg(trace_ctx, "\tlog2_tile_columns = %d\n", p->log2_tile_columns); - va_TraceMsg(trace_ctx, "\tskip_frame_flag = %d\n", p->skip_frame_flag); - va_TraceMsg(trace_ctx, "\tnumber_skip_frames = %d\n", p->number_skip_frames); - va_TraceMsg(trace_ctx, "\tskip_frames_size = %d\n", p->skip_frames_size); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVASliceParameterBufferVP9( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - - VASliceParameterBufferVP9 *p = (VASliceParameterBufferVP9 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - int i, j; - - va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP9\n"); - - va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); - - for (i = 0; i < 8; i++) { - VASegmentParameterVP9* seg = p->seg_param + i; - va_TraceMsg(trace_ctx, "\tseg_param[%d] = \n", i); - va_TraceMsg(trace_ctx, "\t\tsegment_reference_enabled = %d\n", seg->segment_flags.fields.segment_reference_enabled); - va_TraceMsg(trace_ctx, "\t\tsegment_reference = %d\n", seg->segment_flags.fields.segment_reference); - va_TraceMsg(trace_ctx, "\t\tsegment_reference_skipped = %d\n", seg->segment_flags.fields.segment_reference_skipped); - va_TraceMsg(trace_ctx, "\t\tfilter_level[4][2] = \n"); - for (j = 0; j < 4; j++) { - va_TraceMsg(trace_ctx, "\t\t\t[%3d, %3d]\n", seg->filter_level[j][0], seg->filter_level[j][1]); - } - va_TraceMsg(trace_ctx, "\t\tluma_ac_quant_scale = %d\n", seg->luma_ac_quant_scale); - va_TraceMsg(trace_ctx, "\t\tluma_dc_quant_scale = %d\n", seg->luma_dc_quant_scale); - va_TraceMsg(trace_ctx, "\t\tchroma_ac_quant_scale = %d\n", seg->chroma_ac_quant_scale); - va_TraceMsg(trace_ctx, "\t\tchroma_dc_quant_scale = %d\n", seg->chroma_dc_quant_scale); - } - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -void va_TraceBeginPicture( - VADisplay dpy, - VAContextID context, - VASurfaceID render_target -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context); - va_TraceMsg(trace_ctx, "\trender_targets = 0x%08x\n", render_target); - va_TraceMsg(trace_ctx, "\tframe_count = #%d\n", trace_ctx->trace_frame_no); - va_TraceMsg(trace_ctx, NULL); - - trace_ctx->trace_rendertarget = render_target; /* for surface data dump after vaEndPicture */ - - trace_ctx->trace_frame_no++; - trace_ctx->trace_slice_no = 0; -} - -static void va_TraceMPEG2Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VABitPlaneBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceGroupMapBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferMPEG2(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAResidualDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VADeblockingParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - break; - case VAEncPictureParameterBufferType: - break; - case VAEncSliceParameterBufferType: - break; - default: - break; - } -} - -static void va_TraceVAEncSequenceParameterBufferH263( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSequenceParameterBufferH263 *p = (VAEncSequenceParameterBufferH263 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferH263\n"); - - va_TraceMsg(trace_ctx, "\tintra_period = %d\n", p->intra_period); - va_TraceMsg(trace_ctx, "\tbits_per_second = %d\n", p->bits_per_second); - va_TraceMsg(trace_ctx, "\tframe_rate = %d\n", p->frame_rate); - va_TraceMsg(trace_ctx, "\tinitial_qp = %d\n", p->initial_qp); - va_TraceMsg(trace_ctx, "\tmin_qp = %d\n", p->min_qp); - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAEncPictureParameterBufferH263( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferH263 *p = (VAEncPictureParameterBufferH263 *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferH263\n"); - va_TraceMsg(trace_ctx, "\treference_picture = 0x%08x\n", p->reference_picture); - va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture); - va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf); - va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width); - va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height); - va_TraceMsg(trace_ctx, "\tpicture_type = 0x%08x\n", p->picture_type); - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncPictureParameterBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncPictureParameterBufferJPEG *p = (VAEncPictureParameterBufferJPEG *)data; - int i; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncPictureParameterBufferJPEG\n"); - va_TraceMsg(trace_ctx, "\treconstructed_picture = 0x%08x\n", p->reconstructed_picture); - va_TraceMsg(trace_ctx, "\tcoded_buf = %08x\n", p->coded_buf); - va_TraceMsg(trace_ctx, "\tpicture_width = %d\n", p->picture_width); - va_TraceMsg(trace_ctx, "\tpicture_height = %d\n", p->picture_height); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.profile = %d\n", p->pic_flags.bits.profile); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.progressive = %d\n", p->pic_flags.bits.profile); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.huffman = %d\n", p->pic_flags.bits.huffman); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.interleaved = %d\n", p->pic_flags.bits.interleaved); - va_TraceMsg(trace_ctx, "\tpic_flags.bits.differential = %d\n", p->pic_flags.bits.differential); - va_TraceMsg(trace_ctx, "\tsample_bit_depth = %d\n", p->sample_bit_depth); - va_TraceMsg(trace_ctx, "\tnum_scan = %d\n", p->num_scan); - va_TraceMsg(trace_ctx, "\tnum_components = %d\n", p->num_components); - for (i=0; inum_components; i++) - va_TraceMsg(trace_ctx, "\tcomponent_id[%d] = %d\n", i, p->component_id[i]); - - if (p->quality > 0) - va_TraceMsg(trace_ctx, "\tquality = %d\n", p->quality); - else - va_TraceMsg(trace_ctx, "\tquantiser_table_selector[] = %d %d %d %d\n", - p->quantiser_table_selector[0], - p->quantiser_table_selector[1], - p->quantiser_table_selector[2], - p->quantiser_table_selector[3]); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - -static void va_TraceVAEncQMatrixBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAQMatrixBufferJPEG *p = (VAQMatrixBufferJPEG *)data; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAQMatrixBufferJPEG\n"); - va_TraceMsg(trace_ctx, "\tload_lum_quantiser_matrix = %d", p->load_lum_quantiser_matrix); - if (p->load_lum_quantiser_matrix) { - int i; - for (i = 0; i < 64; i++) { - if ((i % 8) == 0) - va_TraceMsg(trace_ctx, "\n\t"); - va_TraceMsg(trace_ctx, "\t0x%02x", p->lum_quantiser_matrix[i]); - } - va_TraceMsg(trace_ctx, "\n"); - } - va_TraceMsg(trace_ctx, "\tload_chroma_quantiser_matrix = %08x\n", p->load_chroma_quantiser_matrix); - if (p->load_chroma_quantiser_matrix) { - int i; - for (i = 0; i < 64; i++) { - if ((i % 8) == 0) - va_TraceMsg(trace_ctx, "\n\t"); - va_TraceMsg(trace_ctx, "\t0x%02x", p->chroma_quantiser_matrix[i]); - } - va_TraceMsg(trace_ctx, "\n"); - } - - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceVAEncSliceParameterBufferJPEG( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - VAEncSliceParameterBufferJPEG *p = (VAEncSliceParameterBufferJPEG *)data; - int i; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAEncSliceParameterBufferJPEG\n"); - va_TraceMsg(trace_ctx, "\trestart_interval = 0x%04x\n", p->restart_interval); - va_TraceMsg(trace_ctx, "\tnum_components = 0x%08x\n", p->num_components); - for (i=0; i<4; i++) { - va_TraceMsg(trace_ctx, "\tcomponents[%i] =\n "); - va_TraceMsg(trace_ctx, "\t\tcomponent_selector = %d\n", p->components[i].component_selector); - va_TraceMsg(trace_ctx, "\t\tdc_table_selector = %d\n", p->components[i].dc_table_selector); - va_TraceMsg(trace_ctx, "\t\tac_table_selector = %d\n", p->components[i].ac_table_selector); - } - - va_TraceMsg(trace_ctx, NULL); - - return; -} - - -static void va_TraceH263Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - switch (type) { - case VAPictureParameterBufferType:/* print MPEG4 buffer */ - va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType:/* print MPEG4 buffer */ - va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VABitPlaneBufferType:/* print MPEG4 buffer */ - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceGroupMapBufferType: - break; - case VASliceParameterBufferType:/* print MPEG4 buffer */ - va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAResidualDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VADeblockingParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferH263(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPackedHeaderParameterBufferType: - va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - - -static void va_TraceJPEGBuf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - switch (type) { - case VABitPlaneBufferType: - case VASliceGroupMapBufferType: - case VASliceDataBufferType: - case VAMacroblockParameterBufferType: - case VAResidualDataBufferType: - case VADeblockingParameterBufferType: - case VAImageBufferType: - case VAProtectedSliceDataBufferType: - case VAEncCodedBufferType: - case VAEncSequenceParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - va_TraceVAEncSliceParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAHuffmanTableBufferType: - va_TraceVAHuffmanTableBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAQMatrixBufferType: - va_TraceVAEncQMatrixBufferJPEG(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceMPEG4Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VABitPlaneBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceGroupMapBufferType: - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAResidualDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VADeblockingParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferMPEG4(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceHEVCBuf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - va_TraceVAEncSliceParameterBufferHEVC(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncMiscParameterBufferType: - va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceH264Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VABitPlaneBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceGroupMapBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAResidualDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VADeblockingParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - if (size == sizeof(VAEncSliceParameterBuffer)) - va_TraceVAEncSliceParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - else - va_TraceVAEncSliceParameterBufferH264(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPackedHeaderParameterBufferType: - va_TraceVAEncPackedHeaderParameterBufferType(dpy, context, buffer, type, size, num_elements, pbuf); - break; - - case VAEncMiscParameterBufferType: - va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceVP8Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - va_TraceVAIQMatrixBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAQMatrixBufferType: - break; - case VABitPlaneBufferType: - break; - case VASliceGroupMapBufferType: - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - break; - case VAProbabilityBufferType: - va_TraceVAProbabilityBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - break; - case VAResidualDataBufferType: - break; - case VADeblockingParameterBufferType: - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - break; - case VAEncPackedHeaderParameterBufferType: - break; - case VAEncMiscParameterBufferType: - va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceVP9Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferVP9(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSequenceParameterBufferType: - va_TraceVAEncSequenceParameterBufferVP9(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVAEncPictureParameterBufferVP9(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferVP9(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncMiscParameterBufferType: - va_TraceVAEncMiscParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void va_TraceVC1Buf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAPictureParameterBufferType: - va_TraceVAPictureParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAIQMatrixBufferType: - break; - case VABitPlaneBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceGroupMapBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceParameterBufferType: - va_TraceVASliceParameterBufferVC1(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VASliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, trace_ctx->trace_slice_size, num_elements, pbuf); - break; - case VAMacroblockParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAResidualDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VADeblockingParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAImageBufferType: - break; - case VAProtectedSliceDataBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncCodedBufferType: - break; - case VAEncSequenceParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncPictureParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - case VAEncSliceParameterBufferType: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -static void -va_TraceProcFilterParameterBufferDeinterlacing( - VADisplay dpy, - VAContextID context, - VAProcFilterParameterBufferBase *base -) -{ - VAProcFilterParameterBufferDeinterlacing *deint = (VAProcFilterParameterBufferDeinterlacing *)base; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t type = %d\n", deint->type); - va_TraceMsg(trace_ctx, "\t algorithm = %d\n", deint->algorithm); - va_TraceMsg(trace_ctx, "\t flags = %d\n", deint->flags); -} - -static void -va_TraceProcFilterParameterBufferColorBalance( - VADisplay dpy, - VAContextID context, - VAProcFilterParameterBufferBase *base -) -{ - VAProcFilterParameterBufferColorBalance *color_balance = (VAProcFilterParameterBufferColorBalance *)base; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t type = %d\n", color_balance->type); - va_TraceMsg(trace_ctx, "\t attrib = %d\n", color_balance->attrib); - va_TraceMsg(trace_ctx, "\t value = %f\n", color_balance->value); -} - -static void -va_TraceProcFilterParameterBufferBase( - VADisplay dpy, - VAContextID context, - VAProcFilterParameterBufferBase *base -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t type = %d\n", base->type); -} - -static void -va_TraceProcFilterParameterBuffer( - VADisplay dpy, - VAContextID context, - VABufferID *filters, - unsigned int num_filters -) -{ - VABufferType type; - unsigned int size; - unsigned int num_elements; - VAProcFilterParameterBufferBase *base_filter = NULL; - int i; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - if (num_filters == 0 || filters == NULL) { - va_TraceMsg(trace_ctx, "\t num_filters = %d\n", num_filters); - va_TraceMsg(trace_ctx, "\t filters = %p\n", filters); - return; - } - - va_TraceMsg(trace_ctx, "\t num_filters = %d\n", num_filters); - - /* get buffer type information */ - for (i = 0; i < num_filters; i++) { - vaBufferInfo(dpy, context, filters[i], &type, &size, &num_elements); - - if (type != VAProcFilterParameterBufferType) { - va_TraceMsg(trace_ctx, "\t filters[%d] = 0x%08x (INVALID)\n", i, filters[i]); - return; - } else { - va_TraceMsg(trace_ctx, "\t filters[%d] = 0x%08x\n", i, filters[i]); - } - - base_filter = NULL; - vaMapBuffer(dpy, filters[i], (void **)&base_filter); - - if (base_filter == NULL) { - vaUnmapBuffer(dpy, filters[i]); - return; - } - - switch (base_filter->type) { - case VAProcFilterDeinterlacing: - va_TraceProcFilterParameterBufferDeinterlacing(dpy, - context, - base_filter); - break; - case VAProcFilterColorBalance: - va_TraceProcFilterParameterBufferColorBalance(dpy, - context, - base_filter); - break; - default: - va_TraceProcFilterParameterBufferBase(dpy, - context, - base_filter); - break; - } - - vaUnmapBuffer(dpy, filters[i]); - } -} - -static void -va_TraceVAProcPipelineParameterBuffer( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - VAProcPipelineParameterBuffer *p = (VAProcPipelineParameterBuffer *)data; - int i; - - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - va_TraceMsg(trace_ctx, "\t--VAProcPipelineParameterBuffer\n"); - - va_TraceMsg(trace_ctx, "\t surface = 0x%08x\n", p->surface); - - if (p->surface_region) { - va_TraceMsg(trace_ctx, "\t surface_region\n"); - va_TraceMsg(trace_ctx, "\t x = %d\n", p->surface_region->x); - va_TraceMsg(trace_ctx, "\t y = %d\n", p->surface_region->y); - va_TraceMsg(trace_ctx, "\t width = %d\n", p->surface_region->width); - va_TraceMsg(trace_ctx, "\t height = %d\n", p->surface_region->height); - } else { - va_TraceMsg(trace_ctx, "\t surface_region = (NULL)\n"); - } - - va_TraceMsg(trace_ctx, "\t surface_color_standard = %d\n", p->surface_color_standard); - - if (p->output_region) { - va_TraceMsg(trace_ctx, "\t output_region\n"); - va_TraceMsg(trace_ctx, "\t x = %d\n", p->output_region->x); - va_TraceMsg(trace_ctx, "\t y = %d\n", p->output_region->y); - va_TraceMsg(trace_ctx, "\t width = %d\n", p->output_region->width); - va_TraceMsg(trace_ctx, "\t height = %d\n", p->output_region->height); - } else { - va_TraceMsg(trace_ctx, "\t output_region = (NULL)\n"); - } - - va_TraceMsg(trace_ctx, "\t output_background_color = 0x%08x\n", p->output_background_color); - va_TraceMsg(trace_ctx, "\t output_color_standard = %d\n", p->output_color_standard); - va_TraceMsg(trace_ctx, "\t pipeline_flags = 0x%08x\n", p->pipeline_flags); - va_TraceMsg(trace_ctx, "\t filter_flags = 0x%08x\n", p->filter_flags); - - va_TraceProcFilterParameterBuffer(dpy, context, p->filters, p->num_filters); - - va_TraceMsg(trace_ctx, "\t num_forward_references = 0x%08x\n", p->num_forward_references); - - if (p->num_forward_references) { - va_TraceMsg(trace_ctx, "\t forward_references\n"); - - if (p->forward_references) { - /* only dump the first 5 forward references */ - for (i = 0; i < p->num_forward_references && i < 5; i++) { - va_TraceMsg(trace_ctx, "\t forward_references[%d] = 0x%08x\n", i, p->forward_references[i]); - } - } else { - for (i = 0; i < p->num_forward_references && i < 5; i++) { - va_TraceMsg(trace_ctx, "\t forward_references[%d] = (NULL)\n", i); - } - } - } - - va_TraceMsg(trace_ctx, "\t num_backward_references = 0x%08x\n", p->num_backward_references); - - if (p->num_backward_references) { - va_TraceMsg(trace_ctx, "\t backward_references\n"); - - if (p->backward_references) { - /* only dump the first 5 backward references */ - for (i = 0; i < p->num_backward_references && i < 5; i++) { - va_TraceMsg(trace_ctx, "\t backward_references[%d] = 0x%08x\n", i, p->backward_references[i]); - } - } else { - for (i = 0; i < p->num_backward_references && i < 5; i++) { - va_TraceMsg(trace_ctx, "\t backward_references[%d] = (NULL)\n", i); - } - } - } - - /* FIXME: add other info later */ - - va_TraceMsg(trace_ctx, NULL); -} - -static void -va_TraceNoneBuf( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *pbuf -) -{ - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - switch (type) { - case VAProcPipelineParameterBufferType: - va_TraceVAProcPipelineParameterBuffer(dpy, context, buffer, type, size, num_elements, pbuf); - break; - default: - va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); - break; - } -} - -void va_TraceRenderPicture( - VADisplay dpy, - VAContextID context, - VABufferID *buffers, - int num_buffers -) -{ - VABufferType type; - unsigned int size; - unsigned int num_elements; - int i; - DPY2TRACECTX(dpy, context, VA_INVALID_ID); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\tcontext = 0x%08x\n", context); - va_TraceMsg(trace_ctx, "\tnum_buffers = %d\n", num_buffers); - if (buffers == NULL) - return; - - for (i = 0; i < num_buffers; i++) { - unsigned char *pbuf = NULL; - unsigned int j; - - /* get buffer type information */ - vaBufferInfo(dpy, context, buffers[i], &type, &size, &num_elements); - - va_TraceMsg(trace_ctx, "\t---------------------------\n"); - va_TraceMsg(trace_ctx, "\tbuffers[%d] = 0x%08x\n", i, buffers[i]); - va_TraceMsg(trace_ctx, "\t type = %s\n", buffer_type_to_string(type)); - va_TraceMsg(trace_ctx, "\t size = %d\n", size); - va_TraceMsg(trace_ctx, "\t num_elements = %d\n", num_elements); - - vaMapBuffer(dpy, buffers[i], (void **)&pbuf); - if (pbuf == NULL) - continue; - - switch (trace_ctx->trace_profile) { - case VAProfileMPEG2Simple: - case VAProfileMPEG2Main: - for (j=0; jtrace_rendertarget); - - /* avoid to create so many empty files */ - encode = (trace_ctx->trace_entrypoint == VAEntrypointEncSlice); - decode = (trace_ctx->trace_entrypoint == VAEntrypointVLD); - jpeg = (trace_ctx->trace_entrypoint == VAEntrypointEncPicture); - - /* trace encode source surface, can do it before HW completes rendering */ - if ((encode && (trace_flag & VA_TRACE_FLAG_SURFACE_ENCODE))|| - (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) - va_TraceSurface(dpy, context); - - /* trace decoded surface, do it after HW completes rendering */ - if (decode && ((trace_flag & VA_TRACE_FLAG_SURFACE_DECODE))) { - vaSyncSurface(dpy, trace_ctx->trace_rendertarget); - va_TraceSurface(dpy, context); - } - - va_TraceMsg(trace_ctx, NULL); -} - - -void va_TraceSyncSurface( - VADisplay dpy, - VASurfaceID render_target -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target); - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceQuerySurfaceAttributes( - VADisplay dpy, - VAConfigID config, - VASurfaceAttrib *attrib_list, - unsigned int *num_attribs -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tconfig = 0x%08x\n", config); - va_TraceSurfaceAttributes(trace_ctx, attrib_list, num_attribs); - - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - - -void va_TraceQuerySurfaceStatus( - VADisplay dpy, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\trender_target = 0x%08x\n", render_target); - if (status) - va_TraceMsg(trace_ctx, "\tstatus = 0x%08x\n", *status); - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - - -void va_TraceQuerySurfaceError( - VADisplay dpy, - VASurfaceID surface, - VAStatus error_status, - void **error_info /*out*/ -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tsurface = 0x%08x\n", surface); - va_TraceMsg(trace_ctx, "\terror_status = 0x%08x\n", error_status); - if (error_info && (error_status == VA_STATUS_ERROR_DECODING_ERROR)) { - VASurfaceDecodeMBErrors *p = *error_info; - while (p && (p->status != -1)) { - va_TraceMsg(trace_ctx, "\t\tstatus = %d\n", p->status); - va_TraceMsg(trace_ctx, "\t\tstart_mb = %d\n", p->start_mb); - va_TraceMsg(trace_ctx, "\t\tend_mb = %d\n", p->end_mb); - p++; /* next error record */ - } - } - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceMaxNumDisplayAttributes ( - VADisplay dpy, - int number -) -{ - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - - va_TraceMsg(trace_ctx, "\tmax_display_attributes = %d\n", number); - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - -void va_TraceQueryDisplayAttributes ( - VADisplay dpy, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ -) -{ - int i; - - if (attr_list == NULL || num_attributes == NULL) - return; - - DPY2TRACE_VIRCTX(dpy); - - TRACE_FUNCNAME(idx); - va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", *num_attributes); - - for (i=0; i<*num_attributes; i++) { - va_TraceMsg(trace_ctx, "\tattr_list[%d] =\n", i); - va_TraceMsg(trace_ctx, "\t type = 0x%08x\n", attr_list[i].type); - va_TraceMsg(trace_ctx, "\t min_value = %d\n", attr_list[i].min_value); - va_TraceMsg(trace_ctx, "\t max_value = %d\n", attr_list[i].max_value); - va_TraceMsg(trace_ctx, "\t value = %d\n", attr_list[i].value); - va_TraceMsg(trace_ctx, "\t flags = %d\n", attr_list[i].flags); - } - va_TraceMsg(trace_ctx, NULL); - - DPY2TRACE_VIRCTX_EXIT(pva_trace); -} - - -static void va_TraceDisplayAttributes ( - struct trace_context *trace_ctx, - VADisplayAttribute *attr_list, - int num_attributes -) -{ - int i; - - if (attr_list == NULL) - return; - - va_TraceMsg(trace_ctx, "\tnum_attributes = %d\n", num_attributes); - - for (i=0; i (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_vpp.h b/va/va_vpp.h deleted file mode 100644 index 082f1d5..0000000 --- a/va/va_vpp.h +++ /dev/null @@ -1,744 +0,0 @@ -/* - * Copyright (c) 2007-2011 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 INTEL 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. - */ - -/** - * \file va_vpp.h - * \brief The video processing API - * - * This file contains the \ref api_vpp "Video processing API". - */ - -#ifndef VA_VPP_H -#define VA_VPP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_vpp Video processing API - * - * @{ - * - * The video processing API uses the same paradigm as for decoding: - * - Query for supported filters; - * - Set up a video processing pipeline; - * - Send video processing parameters through VA buffers. - * - * \section api_vpp_caps Query for supported filters - * - * Checking whether video processing is supported can be performed - * with vaQueryConfigEntrypoints() and the profile argument set to - * #VAProfileNone. If video processing is supported, then the list of - * returned entry-points will include #VAEntrypointVideoProc. - * - * \code - * VAEntrypoint *entrypoints; - * int i, num_entrypoints, supportsVideoProcessing = 0; - * - * num_entrypoints = vaMaxNumEntrypoints(); - * entrypoints = malloc(num_entrypoints * sizeof(entrypoints[0]); - * vaQueryConfigEntrypoints(va_dpy, VAProfileNone, - * entrypoints, &num_entrypoints); - * - * for (i = 0; !supportsVideoProcessing && i < num_entrypoints; i++) { - * if (entrypoints[i] == VAEntrypointVideoProc) - * supportsVideoProcessing = 1; - * } - * \endcode - * - * Then, the vaQueryVideoProcFilters() function is used to query the - * list of video processing filters. - * - * \code - * VAProcFilterType filters[VAProcFilterCount]; - * unsigned int num_filters = VAProcFilterCount; - * - * // num_filters shall be initialized to the length of the array - * vaQueryVideoProcFilters(va_dpy, vpp_ctx, &filters, &num_filters); - * \endcode - * - * Finally, individual filter capabilities can be checked with - * vaQueryVideoProcFilterCaps(). - * - * \code - * VAProcFilterCap denoise_caps; - * unsigned int num_denoise_caps = 1; - * vaQueryVideoProcFilterCaps(va_dpy, vpp_ctx, - * VAProcFilterNoiseReduction, - * &denoise_caps, &num_denoise_caps - * ); - * - * VAProcFilterCapDeinterlacing deinterlacing_caps[VAProcDeinterlacingCount]; - * unsigned int num_deinterlacing_caps = VAProcDeinterlacingCount; - * vaQueryVideoProcFilterCaps(va_dpy, vpp_ctx, - * VAProcFilterDeinterlacing, - * &deinterlacing_caps, &num_deinterlacing_caps - * ); - * \endcode - * - * \section api_vpp_setup Set up a video processing pipeline - * - * A video processing pipeline buffer is created for each source - * surface we want to process. However, buffers holding filter - * parameters can be created once and for all. Rationale is to avoid - * multiple creation/destruction chains of filter buffers and also - * because filter parameters generally won't change frame after - * frame. e.g. this makes it possible to implement a checkerboard of - * videos where the same filters are applied to each video source. - * - * The general control flow is demonstrated by the following pseudo-code: - * \code - * // Create filters - * VABufferID denoise_filter, deint_filter; - * VABufferID filter_bufs[VAProcFilterCount]; - * unsigned int num_filter_bufs; - * - * for (i = 0; i < num_filters; i++) { - * switch (filters[i]) { - * case VAProcFilterNoiseReduction: { // Noise reduction filter - * VAProcFilterParameterBuffer denoise; - * denoise.type = VAProcFilterNoiseReduction; - * denoise.value = 0.5; - * vaCreateBuffer(va_dpy, vpp_ctx, - * VAProcFilterParameterBufferType, sizeof(denoise), 1, - * &denoise, &denoise_filter - * ); - * filter_bufs[num_filter_bufs++] = denoise_filter; - * break; - * } - * - * case VAProcFilterDeinterlacing: // Motion-adaptive deinterlacing - * for (j = 0; j < num_deinterlacing_caps; j++) { - * VAProcFilterCapDeinterlacing * const cap = &deinterlacing_caps[j]; - * if (cap->type != VAProcDeinterlacingMotionAdaptive) - * continue; - * - * VAProcFilterParameterBufferDeinterlacing deint; - * deint.type = VAProcFilterDeinterlacing; - * deint.algorithm = VAProcDeinterlacingMotionAdaptive; - * vaCreateBuffer(va_dpy, vpp_ctx, - * VAProcFilterParameterBufferType, sizeof(deint), 1, - * &deint, &deint_filter - * ); - * filter_bufs[num_filter_bufs++] = deint_filter; - * } - * } - * } - * \endcode - * - * Once the video processing pipeline is set up, the caller shall check the - * implied capabilities and requirements with vaQueryVideoProcPipelineCaps(). - * This function can be used to validate the number of reference frames are - * needed by the specified deinterlacing algorithm, the supported color - * primaries, etc. - * \code - * // Create filters - * VAProcPipelineCaps pipeline_caps; - * VASurfaceID *forward_references; - * unsigned int num_forward_references; - * VASurfaceID *backward_references; - * unsigned int num_backward_references; - * VAProcColorStandardType in_color_standards[VAProcColorStandardCount]; - * VAProcColorStandardType out_color_standards[VAProcColorStandardCount]; - * - * pipeline_caps.input_color_standards = NULL; - * pipeline_caps.num_input_color_standards = ARRAY_ELEMS(in_color_standards); - * pipeline_caps.output_color_standards = NULL; - * pipeline_caps.num_output_color_standards = ARRAY_ELEMS(out_color_standards); - * vaQueryVideoProcPipelineCaps(va_dpy, vpp_ctx, - * filter_bufs, num_filter_bufs, - * &pipeline_caps - * ); - * - * num_forward_references = pipeline_caps.num_forward_references; - * forward_references = - * malloc(num__forward_references * sizeof(VASurfaceID)); - * num_backward_references = pipeline_caps.num_backward_references; - * backward_references = - * malloc(num_backward_references * sizeof(VASurfaceID)); - * \endcode - * - * \section api_vpp_submit Send video processing parameters through VA buffers - * - * Video processing pipeline parameters are submitted for each source - * surface to process. Video filter parameters can also change, per-surface. - * e.g. the list of reference frames used for deinterlacing. - * - * \code - * foreach (iteration) { - * vaBeginPicture(va_dpy, vpp_ctx, vpp_surface); - * foreach (surface) { - * VARectangle output_region; - * VABufferID pipeline_buf; - * VAProcPipelineParameterBuffer *pipeline_param; - * - * vaCreateBuffer(va_dpy, vpp_ctx, - * VAProcPipelineParameterBuffer, sizeof(*pipeline_param), 1, - * NULL, &pipeline_buf - * ); - * - * // Setup output region for this surface - * // e.g. upper left corner for the first surface - * output_region.x = BORDER; - * output_region.y = BORDER; - * output_region.width = - * (vpp_surface_width - (Nx_surfaces + 1) * BORDER) / Nx_surfaces; - * output_region.height = - * (vpp_surface_height - (Ny_surfaces + 1) * BORDER) / Ny_surfaces; - * - * vaMapBuffer(va_dpy, pipeline_buf, &pipeline_param); - * pipeline_param->surface = surface; - * pipeline_param->surface_region = NULL; - * pipeline_param->output_region = &output_region; - * pipeline_param->output_background_color = 0; - * if (first surface to render) - * pipeline_param->output_background_color = 0xff000000; // black - * pipeline_param->filter_flags = VA_FILTER_SCALING_HQ; - * pipeline_param->filters = filter_bufs; - * pipeline_param->num_filters = num_filter_bufs; - * vaUnmapBuffer(va_dpy, pipeline_buf); - * - * // Update reference frames for deinterlacing, if necessary - * pipeline_param->forward_references = forward_references; - * pipeline_param->num_forward_references = num_forward_references_used; - * pipeline_param->backward_references = backward_references; - * pipeline_param->num_backward_references = num_bacward_references_used; - * - * // Apply filters - * vaRenderPicture(va_dpy, vpp_ctx, &pipeline_buf, 1); - * } - * vaEndPicture(va_dpy, vpp_ctx); - * } - * \endcode - */ - -/** \brief Video filter types. */ -typedef enum _VAProcFilterType { - VAProcFilterNone = 0, - /** \brief Noise reduction filter. */ - VAProcFilterNoiseReduction, - /** \brief Deinterlacing filter. */ - VAProcFilterDeinterlacing, - /** \brief Sharpening filter. */ - VAProcFilterSharpening, - /** \brief Color balance parameters. */ - VAProcFilterColorBalance, - /** \brief Skin Tone Enhancement. */ - VAProcFilterSkinToneEnhancement, - VAProcFilterCount -} VAProcFilterType; - -/** \brief Deinterlacing types. */ -typedef enum _VAProcDeinterlacingType { - VAProcDeinterlacingNone = 0, - /** \brief Bob deinterlacing algorithm. */ - VAProcDeinterlacingBob, - /** \brief Weave deinterlacing algorithm. */ - VAProcDeinterlacingWeave, - /** \brief Motion adaptive deinterlacing algorithm. */ - VAProcDeinterlacingMotionAdaptive, - /** \brief Motion compensated deinterlacing algorithm. */ - VAProcDeinterlacingMotionCompensated, - /** \brief Number of deinterlacing algorithms. */ - VAProcDeinterlacingCount -} VAProcDeinterlacingType; - -/** \brief Color balance types. */ -typedef enum _VAProcColorBalanceType { - VAProcColorBalanceNone = 0, - /** \brief Hue. */ - VAProcColorBalanceHue, - /** \brief Saturation. */ - VAProcColorBalanceSaturation, - /** \brief Brightness. */ - VAProcColorBalanceBrightness, - /** \brief Contrast. */ - VAProcColorBalanceContrast, - /** \brief Automatically adjusted saturation. */ - VAProcColorBalanceAutoSaturation, - /** \brief Automatically adjusted brightness. */ - VAProcColorBalanceAutoBrightness, - /** \brief Automatically adjusted contrast. */ - VAProcColorBalanceAutoContrast, - /** \brief Number of color balance attributes. */ - VAProcColorBalanceCount -} VAProcColorBalanceType; - -/** \brief Color standard types. */ -typedef enum _VAProcColorStandardType { - VAProcColorStandardNone = 0, - /** \brief ITU-R BT.601. */ - VAProcColorStandardBT601, - /** \brief ITU-R BT.709. */ - VAProcColorStandardBT709, - /** \brief ITU-R BT.470-2 System M. */ - VAProcColorStandardBT470M, - /** \brief ITU-R BT.470-2 System B, G. */ - VAProcColorStandardBT470BG, - /** \brief SMPTE-170M. */ - VAProcColorStandardSMPTE170M, - /** \brief SMPTE-240M. */ - VAProcColorStandardSMPTE240M, - /** \brief Generic film. */ - VAProcColorStandardGenericFilm, - /** \brief Number of color standards. */ - VAProcColorStandardCount -} VAProcColorStandardType; - -/** @name Video pipeline flags */ -/**@{*/ -/** \brief Specifies whether to apply subpictures when processing a surface. */ -#define VA_PROC_PIPELINE_SUBPICTURES 0x00000001 -/** - * \brief Specifies whether to apply power or performance - * optimizations to a pipeline. - * - * When processing several surfaces, it may be necessary to prioritize - * more certain pipelines than others. This flag is only a hint to the - * video processor so that it can omit certain filters to save power - * for example. Typically, this flag could be used with video surfaces - * decoded from a secondary bitstream. - */ -#define VA_PROC_PIPELINE_FAST 0x00000002 -/**@}*/ - -/** @name Video filter flags */ -/**@{*/ -/** \brief Specifies whether the filter shall be present in the pipeline. */ -#define VA_PROC_FILTER_MANDATORY 0x00000001 -/**@}*/ - -/** @name Pipeline end flags */ -/**@{*/ -/** \brief Specifies the pipeline is the last. */ -#define VA_PIPELINE_FLAG_END 0x00000004 -/**@}*/ - -/** \brief Video processing pipeline capabilities. */ -typedef struct _VAProcPipelineCaps { - /** \brief Pipeline flags. See VAProcPipelineParameterBuffer::pipeline_flags. */ - unsigned int pipeline_flags; - /** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */ - unsigned int filter_flags; - /** \brief Number of forward reference frames that are needed. */ - unsigned int num_forward_references; - /** \brief Number of backward reference frames that are needed. */ - unsigned int num_backward_references; - /** \brief List of color standards supported on input. */ - VAProcColorStandardType *input_color_standards; - /** \brief Number of elements in \ref input_color_standards array. */ - unsigned int num_input_color_standards; - /** \brief List of color standards supported on output. */ - VAProcColorStandardType *output_color_standards; - /** \brief Number of elements in \ref output_color_standards array. */ - unsigned int num_output_color_standards; -} VAProcPipelineCaps; - -/** \brief Specification of values supported by the filter. */ -typedef struct _VAProcFilterValueRange { - /** \brief Minimum value supported, inclusive. */ - float min_value; - /** \brief Maximum value supported, inclusive. */ - float max_value; - /** \brief Default value. */ - float default_value; - /** \brief Step value that alters the filter behaviour in a sensible way. */ - float step; -} VAProcFilterValueRange; - -/** - * \brief Video processing pipeline configuration. - * - * This buffer defines a video processing pipeline. The actual filters to - * be applied are provided in the \c filters field, they can be re-used - * in other processing pipelines. - * - * The target surface is specified by the \c render_target argument of - * \c vaBeginPicture(). The general usage model is described as follows: - * - \c vaBeginPicture(): specify the target surface that receives the - * processed output; - * - \c vaRenderPicture(): specify a surface to be processed and composed - * into the \c render_target. Use as many \c vaRenderPicture() calls as - * necessary surfaces to compose ; - * - \c vaEndPicture(): tell the driver to start processing the surfaces - * with the requested filters. - * - * If a filter (e.g. noise reduction) needs to be applied with different - * values for multiple surfaces, the application needs to create as many - * filter parameter buffers as necessary. i.e. the filter parameters shall - * not change between two calls to \c vaRenderPicture(). - * - * For composition usage models, the first surface to process will generally - * use an opaque background color, i.e. \c output_background_color set with - * the most significant byte set to \c 0xff. For instance, \c 0xff000000 for - * a black background. Then, subsequent surfaces would use a transparent - * background color. - */ -typedef struct _VAProcPipelineParameterBuffer { - /** - * \brief Source surface ID. - * - * ID of the source surface to process. If subpictures are associated - * with the video surfaces then they shall be rendered to the target - * surface, if the #VA_PROC_PIPELINE_SUBPICTURES pipeline flag is set. - */ - VASurfaceID surface; - /** - * \brief Region within the source surface to be processed. - * - * Pointer to a #VARectangle defining the region within the source - * surface to be processed. If NULL, \c surface_region implies the - * whole surface. - */ - const VARectangle *surface_region; - /** - * \brief Requested input color primaries. - * - * Color primaries are implicitly converted throughout the processing - * pipeline. The video processor chooses the best moment to apply - * this conversion. The set of supported color primaries primaries - * for input shall be queried with vaQueryVideoProcPipelineCaps(). - */ - VAProcColorStandardType surface_color_standard; - /** - * \brief Region within the output surface. - * - * Pointer to a #VARectangle defining the region within the output - * surface that receives the processed pixels. If NULL, \c output_region - * implies the whole surface. - * - * Note that any pixels residing outside the specified region will - * be filled in with the \ref output_background_color. - */ - const VARectangle *output_region; - /** - * \brief Background color. - * - * Background color used to fill in pixels that reside outside of the - * specified \ref output_region. The color is specified in ARGB format: - * [31:24] alpha, [23:16] red, [15:8] green, [7:0] blue. - * - * Unless the alpha value is zero or the \ref output_region represents - * the whole target surface size, implementations shall not render the - * source surface to the target surface directly. Rather, in order to - * maintain the exact semantics of \ref output_background_color, the - * driver shall use a temporary surface and fill it in with the - * appropriate background color. Next, the driver will blend this - * temporary surface into the target surface. - */ - unsigned int output_background_color; - /** - * \brief Requested output color primaries. - */ - VAProcColorStandardType output_color_standard; - /** - * \brief Pipeline filters. See video pipeline flags. - * - * Flags to control the pipeline, like whether to apply subpictures - * or not, notify the driver that it can opt for power optimizations, - * should this be needed. - */ - unsigned int pipeline_flags; - /** - * \brief Extra filter flags. See vaPutSurface() flags. - * - * Filter flags are used as a fast path, wherever possible, to use - * vaPutSurface() flags instead of explicit filter parameter buffers. - * - * Allowed filter flags API-wise. Use vaQueryVideoProcPipelineCaps() - * to check for implementation details: - * - Bob-deinterlacing: \c VA_FRAME_PICTURE, \c VA_TOP_FIELD, - * \c VA_BOTTOM_FIELD. Note that any deinterlacing filter - * (#VAProcFilterDeinterlacing) will override those flags. - * - Color space conversion: \c VA_SRC_BT601, \c VA_SRC_BT709, - * \c VA_SRC_SMPTE_240. - * - Scaling: \c VA_FILTER_SCALING_DEFAULT, \c VA_FILTER_SCALING_FAST, - * \c VA_FILTER_SCALING_HQ, \c VA_FILTER_SCALING_NL_ANAMORPHIC. - */ - unsigned int filter_flags; - /** - * \brief Array of filters to apply to the surface. - * - * The list of filters shall be ordered in the same way the driver expects - * them. i.e. as was returned from vaQueryVideoProcFilters(). - * Otherwise, a #VA_STATUS_ERROR_INVALID_FILTER_CHAIN is returned - * from vaRenderPicture() with this buffer. - * - * #VA_STATUS_ERROR_UNSUPPORTED_FILTER is returned if the list - * contains an unsupported filter. - * - */ - VABufferID *filters; - /** \brief Actual number of filters. */ - unsigned int num_filters; - /** \brief Array of forward reference frames. */ - VASurfaceID *forward_references; - /** \brief Number of forward reference frames that were supplied. */ - unsigned int num_forward_references; - /** \brief Array of backward reference frames. */ - VASurfaceID *backward_references; - /** \brief Number of backward reference frames that were supplied. */ - unsigned int num_backward_references; -} VAProcPipelineParameterBuffer; - -/** - * \brief Filter parameter buffer base. - * - * This is a helper structure used by driver implementations only. - * Users are not supposed to allocate filter parameter buffers of this - * type. - */ -typedef struct _VAProcFilterParameterBufferBase { - /** \brief Filter type. */ - VAProcFilterType type; -} VAProcFilterParameterBufferBase; - -/** - * \brief Default filter parametrization. - * - * Unless there is a filter-specific parameter buffer, - * #VAProcFilterParameterBuffer is the default type to use. - */ -typedef struct _VAProcFilterParameterBuffer { - /** \brief Filter type. */ - VAProcFilterType type; - /** \brief Value. */ - float value; -} VAProcFilterParameterBuffer; - -/** @name De-interlacing flags */ -/**@{*/ -/** - * \brief Bottom field first in the input frame. - * if this is not set then assumes top field first. - */ -#define VA_DEINTERLACING_BOTTOM_FIELD_FIRST 0x0001 -/** - * \brief Bottom field used in deinterlacing. - * if this is not set then assumes top field is used. - */ -#define VA_DEINTERLACING_BOTTOM_FIELD 0x0002 -/** - * \brief A single field is stored in the input frame. - * if this is not set then assumes the frame contains two interleaved fields. - */ -#define VA_DEINTERLACING_ONE_FIELD 0x0004 -/**@}*/ - -/** \brief Deinterlacing filter parametrization. */ -typedef struct _VAProcFilterParameterBufferDeinterlacing { - /** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */ - VAProcFilterType type; - /** \brief Deinterlacing algorithm. */ - VAProcDeinterlacingType algorithm; - /** \brief Deinterlacing flags. */ - unsigned int flags; -} VAProcFilterParameterBufferDeinterlacing; - -/** - * \brief Color balance filter parametrization. - * - * This buffer defines color balance attributes. A VA buffer can hold - * several color balance attributes by creating a VA buffer of desired - * number of elements. This can be achieved by the following pseudo-code: - * - * \code - * enum { kHue, kSaturation, kBrightness, kContrast }; - * - * // Initial color balance parameters - * static const VAProcFilterParameterBufferColorBalance colorBalanceParams[4] = - * { - * [kHue] = - * { VAProcFilterColorBalance, VAProcColorBalanceHue, 0.5 }, - * [kSaturation] = - * { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 }, - * [kBrightness] = - * { VAProcFilterColorBalance, VAProcColorBalanceBrightness, 0.5 }, - * [kSaturation] = - * { VAProcFilterColorBalance, VAProcColorBalanceSaturation, 0.5 } - * }; - * - * // Create buffer - * VABufferID colorBalanceBuffer; - * vaCreateBuffer(va_dpy, vpp_ctx, - * VAProcFilterParameterBufferType, sizeof(*pColorBalanceParam), 4, - * colorBalanceParams, - * &colorBalanceBuffer - * ); - * - * VAProcFilterParameterBufferColorBalance *pColorBalanceParam; - * vaMapBuffer(va_dpy, colorBalanceBuffer, &pColorBalanceParam); - * { - * // Change brightness only - * pColorBalanceBuffer[kBrightness].value = 0.75; - * } - * vaUnmapBuffer(va_dpy, colorBalanceBuffer); - * \endcode - */ -typedef struct _VAProcFilterParameterBufferColorBalance { - /** \brief Filter type. Shall be set to #VAProcFilterColorBalance. */ - VAProcFilterType type; - /** \brief Color balance attribute. */ - VAProcColorBalanceType attrib; - /** - * \brief Color balance value. - * - * Special case for automatically adjusted attributes. e.g. - * #VAProcColorBalanceAutoSaturation, - * #VAProcColorBalanceAutoBrightness, - * #VAProcColorBalanceAutoContrast. - * - If \ref value is \c 1.0 +/- \c FLT_EPSILON, the attribute is - * automatically adjusted and overrides any other attribute of - * the same type that would have been set explicitly; - * - If \ref value is \c 0.0 +/- \c FLT_EPSILON, the attribute is - * disabled and other attribute of the same type is used instead. - */ - float value; -} VAProcFilterParameterBufferColorBalance; - -/** - * \brief Default filter cap specification (single range value). - * - * Unless there is a filter-specific cap structure, #VAProcFilterCap is the - * default type to use for output caps from vaQueryVideoProcFilterCaps(). - */ -typedef struct _VAProcFilterCap { - /** \brief Range of supported values for the filter. */ - VAProcFilterValueRange range; -} VAProcFilterCap; - -/** \brief Capabilities specification for the deinterlacing filter. */ -typedef struct _VAProcFilterCapDeinterlacing { - /** \brief Deinterlacing algorithm. */ - VAProcDeinterlacingType type; -} VAProcFilterCapDeinterlacing; - -/** \brief Capabilities specification for the color balance filter. */ -typedef struct _VAProcFilterCapColorBalance { - /** \brief Color balance operation. */ - VAProcColorBalanceType type; - /** \brief Range of supported values for the specified operation. */ - VAProcFilterValueRange range; -} VAProcFilterCapColorBalance; - -/** - * \brief Queries video processing filters. - * - * This function returns the list of video processing filters supported - * by the driver. The \c filters array is allocated by the user and - * \c num_filters shall be initialized to the number of allocated - * elements in that array. Upon successful return, the actual number - * of filters will be overwritten into \c num_filters. Otherwise, - * \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and \c num_filters - * is adjusted to the number of elements that would be returned if enough - * space was available. - * - * The list of video processing filters supported by the driver shall - * be ordered in the way they can be iteratively applied. This is needed - * for both correctness, i.e. some filters would not mean anything if - * applied at the beginning of the pipeline; but also for performance - * since some filters can be applied in a single pass (e.g. noise - * reduction + deinterlacing). - * - * @param[in] dpy the VA display - * @param[in] context the video processing context - * @param[out] filters the output array of #VAProcFilterType elements - * @param[in,out] num_filters the number of elements allocated on input, - * the number of elements actually filled in on output - */ -VAStatus -vaQueryVideoProcFilters( - VADisplay dpy, - VAContextID context, - VAProcFilterType *filters, - unsigned int *num_filters -); - -/** - * \brief Queries video filter capabilities. - * - * This function returns the list of capabilities supported by the driver - * for a specific video filter. The \c filter_caps array is allocated by - * the user and \c num_filter_caps shall be initialized to the number - * of allocated elements in that array. Upon successful return, the - * actual number of filters will be overwritten into \c num_filter_caps. - * Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned and - * \c num_filter_caps is adjusted to the number of elements that would be - * returned if enough space was available. - * - * @param[in] dpy the VA display - * @param[in] context the video processing context - * @param[in] type the video filter type - * @param[out] filter_caps the output array of #VAProcFilterCap elements - * @param[in,out] num_filter_caps the number of elements allocated on input, - * the number of elements actually filled in output - */ -VAStatus -vaQueryVideoProcFilterCaps( - VADisplay dpy, - VAContextID context, - VAProcFilterType type, - void *filter_caps, - unsigned int *num_filter_caps -); - -/** - * \brief Queries video processing pipeline capabilities. - * - * This function returns the video processing pipeline capabilities. The - * \c filters array defines the video processing pipeline and is an array - * of buffers holding filter parameters. - * - * Note: the #VAProcPipelineCaps structure contains user-provided arrays. - * If non-NULL, the corresponding \c num_* fields shall be filled in on - * input with the number of elements allocated. Upon successful return, - * the actual number of elements will be overwritten into the \c num_* - * fields. Otherwise, \c VA_STATUS_ERROR_MAX_NUM_EXCEEDED is returned - * and \c num_* fields are adjusted to the number of elements that would - * be returned if enough space was available. - * - * @param[in] dpy the VA display - * @param[in] context the video processing context - * @param[in] filters the array of VA buffers defining the video - * processing pipeline - * @param[in] num_filters the number of elements in filters - * @param[in,out] pipeline_caps the video processing pipeline capabilities - */ -VAStatus -vaQueryVideoProcPipelineCaps( - VADisplay dpy, - VAContextID context, - VABufferID *filters, - unsigned int num_filters, - VAProcPipelineCaps *pipeline_caps -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_VPP_H */ diff --git a/va/va_x11.h b/va/va_x11.h deleted file mode 100644 index c9be38d..0000000 --- a/va/va_x11.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -#ifndef _VA_X11_H_ -#define _VA_X11_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Returns a suitable VADisplay for VA API - */ -VADisplay vaGetDisplay ( - Display *dpy -); - -/* - * Output rendering - * Following is the rendering interface for X windows, - * to get the decode output surface to a X drawable - * It basically performs a de-interlacing (if needed), - * color space conversion and scaling to the destination - * rectangle - */ -VAStatus vaPutSurface ( - VADisplay dpy, - VASurfaceID surface, - Drawable draw, /* X Drawable */ - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth, - VARectangle *cliprects, /* client supplied destination clip list */ - unsigned int number_cliprects, /* number of clip rects in the clip list */ - unsigned int flags /* PutSurface flags */ -); - -#ifdef __cplusplus -} -#endif - -#endif /* _VA_X11_H_ */ diff --git a/va/wayland/Makefile.am b/va/wayland/Makefile.am deleted file mode 100644 index 4f8262c..0000000 --- a/va/wayland/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2012 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. - -AM_CPPFLAGS = \ - -DLINUX \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - $(WAYLAND_CFLAGS) \ - $(DRM_CFLAGS) \ - $(NULL) - -source_c = \ - va_wayland.c \ - va_wayland_drm.c \ - va_wayland_emgd.c \ - $(top_srcdir)/va/drm/va_drm_utils.c \ - $(NULL) - -source_h = \ - va_backend_wayland.h \ - va_wayland.h \ - $(NULL) - -source_h_priv = \ - va_wayland_drm.h \ - va_wayland_emgd.h \ - va_wayland_private.h \ - $(NULL) - -protocol_source_h = \ - wayland-drm-client-protocol.h \ - $(NULL) - -noinst_LTLIBRARIES = libva_wayland.la -libva_waylandincludedir = ${includedir}/va -libva_waylandinclude_HEADERS = $(source_h) -libva_wayland_la_SOURCES = $(source_c) $(protocol_source_h) -noinst_HEADERS = $(source_h_priv) - -# Wayland protocol -va_wayland_drm.c: $(protocol_source_h) -%-client-protocol.h : %.xml - $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@ - -EXTRA_DIST = \ - wayland-drm.xml \ - $(NULL) - -# Extra clean files so that maintainer-clean removes *everything* -MAINTAINERCLEANFILES = Makefile.in diff --git a/va/wayland/va_backend_wayland.h b/va/wayland/va_backend_wayland.h deleted file mode 100644 index 67d0004..0000000 --- a/va/wayland/va_backend_wayland.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * va_backend_wayland.h - VA driver implementation hooks for Wayland - * - * Copyright (c) 2012 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 INTEL 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_BACKEND_WAYLAND_H -#define VA_BACKEND_WAYLAND_H - -#include -#include - -/** \brief VA/Wayland API version. */ -#define VA_WAYLAND_API_VERSION (0x574c4400) /* WLD0 */ - -/* Forward declarations */ -struct VADriverContext; - -/** \brief VA/Wayland implementation hooks. */ -struct VADriverVTableWayland { - /** - * \brief Interface version. - * - * Implementations shall set this field to \ref VA_WAYLAND_API_VERSION. - */ - unsigned int version; - - /** \brief Hook to return Wayland buffer associated with the VA surface. */ - VAStatus (*vaGetSurfaceBufferWl)( - struct VADriverContext *ctx, - VASurfaceID surface, - unsigned int flags, - struct wl_buffer **out_buffer - ); - - /** \brief Hook to return Wayland buffer associated with the VA image. */ - VAStatus (*vaGetImageBufferWl)( - struct VADriverContext *ctx, - VAImageID image, - unsigned int flags, - struct wl_buffer **out_buffer - ); - - /** \brief Indicate whether buffer sharing with prime fd is supported. */ - unsigned int has_prime_sharing; -}; - -#endif /* VA_BACKEND_WAYLAND_H */ diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c deleted file mode 100644 index 88a841f..0000000 --- a/va/wayland/va_wayland.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * va_wayland.c - Wayland API - * - * Copyright (c) 2012 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 INTEL 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. - */ - -#include "sysdeps.h" -#include -#include "va_wayland.h" -#include "va_wayland_drm.h" -#include "va_wayland_emgd.h" -#include "va_wayland_private.h" -#include "va_backend.h" -#include "va_backend_wayland.h" - -static inline VADriverContextP -get_driver_context(VADisplay dpy) -{ - if (!vaDisplayIsValid(dpy)) - return NULL; - return ((VADisplayContextP)dpy)->pDriverContext; -} - -void -va_wayland_error(const char *format, ...) -{ - va_list args; - - va_start(args, format); - fprintf(stderr, "VA error: wayland: "); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); - va_end(args); -} - -static int -va_DisplayContextIsValid(VADisplayContextP pDisplayContext) -{ - VADriverContextP const pDriverContext = pDisplayContext->pDriverContext; - - return (pDriverContext && - pDriverContext->display_type == VA_DISPLAY_WAYLAND); -} - -static void -va_DisplayContextDestroy(VADisplayContextP pDisplayContext) -{ - VADriverContextP pDriverContext; - VADisplayContextWaylandP pDisplayContextWl; - - if (!pDisplayContext) - return; - - pDisplayContextWl = pDisplayContext->opaque; - if (pDisplayContextWl && pDisplayContextWl->destroy) - pDisplayContextWl->destroy(pDisplayContext); - - pDriverContext = pDisplayContext->pDriverContext; - if (pDriverContext) { - free(pDriverContext->vtable_wayland); - pDriverContext->vtable_wayland = NULL; - free(pDriverContext); - pDisplayContext->pDriverContext = NULL; - } - - free(pDisplayContext->opaque); - pDisplayContext->opaque = NULL; - free(pDisplayContext); -} - -static VAStatus -va_DisplayContextGetDriverName(VADisplayContextP pDisplayContext, char **name) -{ - *name = NULL; - return VA_STATUS_ERROR_UNKNOWN; -} - -/* -------------------------------------------------------------------------- */ -/* --- Public interface --- */ -/* -------------------------------------------------------------------------- */ - -struct va_wayland_backend { - VADisplayContextCreateFunc create; - VADisplayContextDestroyFunc destroy; -}; - -static const struct va_wayland_backend g_backends[] = { - { va_wayland_drm_create, - va_wayland_drm_destroy }, - { va_wayland_emgd_create, - va_wayland_emgd_destroy }, - { NULL, } -}; - -VADisplay -vaGetDisplayWl(struct wl_display *display) -{ - VADisplayContextP pDisplayContext = NULL; - VADriverContextP pDriverContext; - struct VADriverVTableWayland *vtable; - unsigned int i; - - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); - if (!pDisplayContext) - return NULL; - - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - pDisplayContext->vaIsValid = va_DisplayContextIsValid; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - - pDriverContext = calloc(1, sizeof(*pDriverContext)); - if (!pDriverContext) - goto error; - pDisplayContext->pDriverContext = pDriverContext; - - pDriverContext->native_dpy = display; - pDriverContext->display_type = VA_DISPLAY_WAYLAND; - - vtable = calloc(1, sizeof(*vtable)); - if (!vtable) - goto error; - pDriverContext->vtable_wayland = vtable; - - vtable->version = VA_WAYLAND_API_VERSION; - - for (i = 0; g_backends[i].create != NULL; i++) { - if (g_backends[i].create(pDisplayContext)) - break; - g_backends[i].destroy(pDisplayContext); - } - - return (VADisplay)pDisplayContext; - -error: - va_DisplayContextDestroy(pDisplayContext); - return NULL; -} - -VAStatus -vaGetSurfaceBufferWl( - VADisplay dpy, - VASurfaceID surface, - unsigned int flags, - struct wl_buffer **out_buffer -) -{ - VADriverContextP const ctx = get_driver_context(dpy); - - if (!ctx) - return VA_STATUS_ERROR_INVALID_DISPLAY; - if (!ctx->vtable_wayland || !ctx->vtable_wayland->vaGetSurfaceBufferWl) - return VA_STATUS_ERROR_UNIMPLEMENTED; - return ctx->vtable_wayland->vaGetSurfaceBufferWl(ctx, surface, flags, - out_buffer); -} - -VAStatus -vaGetImageBufferWl( - VADisplay dpy, - VAImageID image, - unsigned int flags, - struct wl_buffer **out_buffer -) -{ - VADriverContextP const ctx = get_driver_context(dpy); - - if (!ctx) - return VA_STATUS_ERROR_INVALID_DISPLAY; - if (!ctx->vtable_wayland || !ctx->vtable_wayland->vaGetImageBufferWl) - return VA_STATUS_ERROR_UNIMPLEMENTED; - return ctx->vtable_wayland->vaGetImageBufferWl(ctx, image, flags, - out_buffer); -} diff --git a/va/wayland/va_wayland.h b/va/wayland/va_wayland.h deleted file mode 100644 index 46fbf2c..0000000 --- a/va/wayland/va_wayland.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * va_wayland.h - Wayland API - * - * Copyright (c) 2012 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 INTEL 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_WAYLAND_H -#define VA_WAYLAND_H - -#include -#include - -/** - * \file va_wayland.h - * \brief The Wayland rendering API - * - * This file contains the \ref api_wayland "Wayland rendering API". - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \defgroup api_wayland Wayland rendering API - * - * @{ - * - * Theory of operations: - * - Create a VA display for an active Wayland display ; - * - Perform normal VA-API operations, e.g. decode to a VA surface ; - * - Get wl_buffer associated to the VA surface ; - * - Attach wl_buffer to wl_surface ; - */ - -/** - * \brief Returns a VA display wrapping the specified Wayland display. - * - * This functions returns a (possibly cached) VA display from the - * specified Wayland @display. - * - * @param[in] display the native Wayland display - * @return the VA display - */ -VADisplay -vaGetDisplayWl(struct wl_display *display); - -/** - * \brief Returns the Wayland buffer associated with a VA surface. - * - * This function returns a wl_buffer handle that can be used as an - * argument to wl_surface_attach(). This buffer references the - * underlying VA @surface. As such, the VA @surface and Wayland - * @out_buffer have the same size and color format. Should specific - * color conversion be needed, then VA/VPP API can fulfill this - * purpose. - * - * The @flags describe the desired picture structure. This is useful - * to expose a de-interlaced buffer. If the VA driver does not support - * any of the supplied flags, then #VA_STATUS_ERROR_FLAG_NOT_SUPPORTED - * is returned. The following flags are allowed: \c VA_FRAME_PICTURE, - * \c VA_TOP_FIELD, \c VA_BOTTOM_FIELD. - * - * @param[in] dpy the VA display - * @param[in] surface the VA surface - * @param[in] flags the deinterlacing flags - * @param[out] out_buffer a wl_buffer wrapping the VA @surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus -vaGetSurfaceBufferWl( - VADisplay dpy, - VASurfaceID surface, - unsigned int flags, - struct wl_buffer **out_buffer -); - -/** - * \brief Returns the Wayland buffer associated with a VA image. - * - * This function returns a wl_buffer handle that can be used as an - * argument to wl_surface_attach(). This buffer references the - * underlying VA @image. As such, the VA @image and Wayland - * @out_buffer have the same size and color format. Should specific - * color conversion be needed, then VA/VPP API can fulfill this - * purpose. - * - * The @flags describe the desired picture structure. See - * vaGetSurfaceBufferWl() description for more details. - * - * @param[in] dpy the VA display - * @param[in] image the VA image - * @param[in] flags the deinterlacing flags - * @param[out] out_buffer a wl_buffer wrapping the VA @image - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus -vaGetImageBufferWl( - VADisplay dpy, - VAImageID image, - unsigned int flags, - struct wl_buffer **out_buffer -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* VA_WAYLAND_H */ diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c deleted file mode 100644 index 958ea85..0000000 --- a/va/wayland/va_wayland_drm.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * va_wayland_drm.c - Wayland/DRM helpers - * - * Copyright (c) 2012 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 INTEL 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. - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include -#include -#include "va_drmcommon.h" -#include "drm/va_drm_utils.h" -#include "va_wayland_drm.h" -#include "va_wayland_private.h" -#include "wayland-drm-client-protocol.h" - -/* XXX: Wayland/DRM support currently lives in Mesa libEGL.so.* library */ -#define LIBWAYLAND_DRM_NAME "libEGL.so.1" - -typedef struct va_wayland_drm_context { - struct va_wayland_context base; - void *handle; - struct wl_drm *drm; - struct wl_registry *registry; - void *drm_interface; - unsigned int is_authenticated : 1; -} VADisplayContextWaylandDRM; - -static void -drm_handle_device(void *data, struct wl_drm *drm, const char *device) -{ - VADisplayContextP const pDisplayContext = data; - VADriverContextP const ctx = pDisplayContext->pDriverContext; - VADisplayContextWaylandDRM * const wl_drm_ctx = pDisplayContext->opaque; - struct drm_state * const drm_state = ctx->drm_state; - drm_magic_t magic; - struct stat st; - - if (stat(device, &st) < 0) { - va_wayland_error("failed to identify %s: %s (errno %d)", - device, strerror(errno), errno); - return; - } - - if (!S_ISCHR(st.st_mode)) { - va_wayland_error("%s is not a device", device); - return; - } - - drm_state->fd = open(device, O_RDWR); - if (drm_state->fd < 0) { - va_wayland_error("failed to open %s: %s (errno %d)", - device, strerror(errno), errno); - return; - } - - drmGetMagic(drm_state->fd, &magic); - wl_drm_authenticate(wl_drm_ctx->drm, magic); -} - -static void -drm_handle_format(void *data, struct wl_drm *drm, uint32_t format) -{ -} - -static void -drm_handle_authenticated(void *data, struct wl_drm *drm) -{ - VADisplayContextP const pDisplayContext = data; - VADriverContextP const ctx = pDisplayContext->pDriverContext; - VADisplayContextWaylandDRM * const wl_drm_ctx = pDisplayContext->opaque; - struct drm_state * const drm_state = ctx->drm_state; - - wl_drm_ctx->is_authenticated = 1; - drm_state->auth_type = VA_DRM_AUTH_CUSTOM; -} - -static void -drm_handle_capabilities(void *data, struct wl_drm *wl_drm, uint32_t value) -{ - VADisplayContextP const pDisplayContext = data; - VADriverContextP const ctx = pDisplayContext->pDriverContext; - struct VADriverVTableWayland *vtable = ctx->vtable_wayland; - - vtable->has_prime_sharing = !!(value & WL_DRM_CAPABILITY_PRIME); -} - -static const struct wl_drm_listener drm_listener = { - drm_handle_device, - drm_handle_format, - drm_handle_authenticated, - drm_handle_capabilities, -}; - -static VAStatus -va_DisplayContextGetDriverName( - VADisplayContextP pDisplayContext, - char **driver_name_ptr -) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - - return VA_DRM_GetDriverName(ctx, driver_name_ptr); -} - -void -va_wayland_drm_destroy(VADisplayContextP pDisplayContext) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - struct va_wayland_drm_context * const wl_drm_ctx = pDisplayContext->opaque; - struct drm_state * const drm_state = ctx->drm_state; - struct VADriverVTableWayland *vtable = ctx->vtable_wayland; - - vtable->has_prime_sharing = 0; - - if (wl_drm_ctx->drm) { - wl_drm_destroy(wl_drm_ctx->drm); - wl_drm_ctx->drm = NULL; - } - wl_drm_ctx->is_authenticated = 0; - - if (wl_drm_ctx->handle) { - dlclose(wl_drm_ctx->handle); - wl_drm_ctx->handle = NULL; - } - - if (drm_state) { - if (drm_state->fd >= 0) { - close(drm_state->fd); - drm_state->fd = -1; - } - free(ctx->drm_state); - ctx->drm_state = NULL; - } -} - -static void -registry_handle_global( - void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version -) -{ - struct va_wayland_drm_context *wl_drm_ctx = data; - - if (strcmp(interface, "wl_drm") == 0) { - wl_drm_ctx->drm = - wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface, 2); - } -} - -static const struct wl_registry_listener registry_listener = { - registry_handle_global, - NULL, -}; - -bool -va_wayland_drm_create(VADisplayContextP pDisplayContext) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - struct va_wayland_drm_context *wl_drm_ctx; - struct drm_state *drm_state; - struct VADriverVTableWayland *vtable = ctx->vtable_wayland; - - wl_drm_ctx = malloc(sizeof(*wl_drm_ctx)); - if (!wl_drm_ctx) - return false; - wl_drm_ctx->base.destroy = va_wayland_drm_destroy; - wl_drm_ctx->handle = NULL; - wl_drm_ctx->drm = NULL; - wl_drm_ctx->drm_interface = NULL; - wl_drm_ctx->is_authenticated = 0; - pDisplayContext->opaque = wl_drm_ctx; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - - drm_state = calloc(1, sizeof(struct drm_state)); - if (!drm_state) - return false; - drm_state->fd = -1; - drm_state->auth_type = 0; - ctx->drm_state = drm_state; - vtable->has_prime_sharing = 0; - - wl_drm_ctx->handle = dlopen(LIBWAYLAND_DRM_NAME, RTLD_LAZY|RTLD_LOCAL); - if (!wl_drm_ctx->handle) - return false; - - wl_drm_ctx->drm_interface = - dlsym(wl_drm_ctx->handle, "wl_drm_interface"); - if (!wl_drm_ctx->drm_interface) - return false; - - wl_drm_ctx->registry = wl_display_get_registry(ctx->native_dpy); - wl_registry_add_listener(wl_drm_ctx->registry, ®istry_listener, wl_drm_ctx); - wl_display_roundtrip(ctx->native_dpy); - - /* registry_handle_global should have been called by the - * wl_display_roundtrip above - */ - - if (!wl_drm_ctx->drm) - return false; - - wl_drm_add_listener(wl_drm_ctx->drm, &drm_listener, pDisplayContext); - wl_display_roundtrip(ctx->native_dpy); - if (drm_state->fd < 0) - return false; - - wl_display_roundtrip(ctx->native_dpy); - if (!wl_drm_ctx->is_authenticated) - return false; - return true; -} diff --git a/va/wayland/va_wayland_drm.h b/va/wayland/va_wayland_drm.h deleted file mode 100644 index 6fb8f52..0000000 --- a/va/wayland/va_wayland_drm.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * va_wayland_drm.h - Wayland/DRM helpers - * - * Copyright (c) 2012 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 INTEL 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_WAYLAND_DRM_H -#define VA_WAYLAND_DRM_H - -#include -#include "va_wayland.h" -#include "va_backend.h" -#include "va_backend_wayland.h" - -/** - * \brief Initializes Wayland/DRM layer. - * - * This is an internal function used to initialize the VA/DRM subsystem - * if the application is running on a DRM-based server. - * - * @param[in] pDisplayContext the VA display context - * @return true if successful - */ -DLL_HIDDEN -bool -va_wayland_drm_create(VADisplayContextP pDisplayContext); - -DLL_HIDDEN -void -va_wayland_drm_destroy(VADisplayContextP pDisplayContext); - -#endif /* VA_WAYLAND_DRM_H */ diff --git a/va/wayland/va_wayland_emgd.c b/va/wayland/va_wayland_emgd.c deleted file mode 100644 index fb8a136..0000000 --- a/va/wayland/va_wayland_emgd.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * va_wayland_emgd.c - Wayland/EMGD helpers - * - * Copyright (c) 2012 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 INTEL 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. - */ - -#include "sysdeps.h" -#include -#include -#include "va_drmcommon.h" -#include "va_wayland_emgd.h" -#include "va_wayland_private.h" - -/* XXX: Wayland/EMGD support currently lives in libwayland-emgd.so.* library */ -#define LIBWAYLAND_EMGD_NAME "libwayland-emgd.so.1" - -typedef struct va_wayland_emgd_context { - struct va_wayland_context base; - void *handle; - struct wl_emgd *emgd; - void *emgd_interface; - unsigned int is_created : 1; - struct wl_registry *registry; -} VADisplayContextWaylandEMGD; - -static inline void -wl_emgd_destroy(struct wl_emgd *emgd) -{ - wl_proxy_destroy((struct wl_proxy *)emgd); -} - -static VAStatus -va_DisplayContextGetDriverName( - VADisplayContextP pDisplayContext, - char **driver_name_ptr -) -{ - *driver_name_ptr = strdup("emgd"); - return VA_STATUS_SUCCESS; -} - -void -va_wayland_emgd_destroy(VADisplayContextP pDisplayContext) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - VADisplayContextWaylandEMGD * const wl_emgd_ctx = pDisplayContext->opaque; - struct drm_state * const drm_state = ctx->drm_state; - - if (wl_emgd_ctx->emgd) { - wl_emgd_destroy(wl_emgd_ctx->emgd); - wl_emgd_ctx->emgd = NULL; - } - wl_emgd_ctx->is_created = 0; - - if (wl_emgd_ctx->handle) { - dlclose(wl_emgd_ctx->handle); - wl_emgd_ctx->handle = NULL; - } - - if (drm_state) { - if (drm_state->fd >= 0) { - close(drm_state->fd); - drm_state->fd = -1; - } - free(ctx->drm_state); - ctx->drm_state = NULL; - } -} - -static void -registry_handle_global( - void *data, - struct wl_registry *registry, - uint32_t id, - const char *interface, - uint32_t version -) -{ - VADisplayContextWaylandEMGD *wl_emgd_ctx = data; - - if (strcmp(interface, "wl_emgd") == 0) { - wl_emgd_ctx->emgd = - wl_registry_bind(registry, id, wl_emgd_ctx->emgd_interface, 1); - } -} - -static const struct wl_registry_listener registry_listener = { - registry_handle_global, - NULL, -}; - -bool -va_wayland_emgd_create(VADisplayContextP pDisplayContext) -{ - VADriverContextP const ctx = pDisplayContext->pDriverContext; - VADisplayContextWaylandEMGD *wl_emgd_ctx; - struct drm_state *drm_state; - - wl_emgd_ctx = malloc(sizeof(*wl_emgd_ctx)); - if (!wl_emgd_ctx) - return false; - wl_emgd_ctx->base.destroy = va_wayland_emgd_destroy; - wl_emgd_ctx->handle = NULL; - wl_emgd_ctx->emgd = NULL; - wl_emgd_ctx->emgd_interface = NULL; - wl_emgd_ctx->is_created = 0; - pDisplayContext->opaque = wl_emgd_ctx; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - - drm_state = calloc(1, sizeof(struct drm_state)); - if (!drm_state) - return false; - drm_state->fd = -1; - drm_state->auth_type = 0; - ctx->drm_state = drm_state; - - wl_emgd_ctx->handle = dlopen(LIBWAYLAND_EMGD_NAME, RTLD_LAZY|RTLD_LOCAL); - if (!wl_emgd_ctx->handle) - return false; - - wl_emgd_ctx->emgd_interface = - dlsym(wl_emgd_ctx->handle, "wl_emgd_interface"); - if (!wl_emgd_ctx->emgd_interface) - return false; - - wl_emgd_ctx->registry = wl_display_get_registry(ctx->native_dpy); - wl_registry_add_listener(wl_emgd_ctx->registry, ®istry_listener, wl_emgd_ctx); - wl_display_roundtrip(ctx->native_dpy); - - /* registry_handle_global should have been called by the - * wl_display_roundtrip above - */ - if (!wl_emgd_ctx->emgd) - return false; - return true; -} diff --git a/va/wayland/va_wayland_emgd.h b/va/wayland/va_wayland_emgd.h deleted file mode 100644 index 053b6b4..0000000 --- a/va/wayland/va_wayland_emgd.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * va_wayland_emgd.h - Wayland/EMGD helpers - * - * Copyright (c) 2012 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 INTEL 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_WAYLAND_EMGD_H -#define VA_WAYLAND_EMGD_H - -#include -#include "va_wayland.h" -#include "va_backend.h" -#include "va_backend_wayland.h" - -/** - * \brief Initializes Wayland/EMGD layer. - * - * This is an internal function used to initialize the VA/EMGD subsystem - * if the application is running on an EMGD-based server. - * - * @param[in] pDisplayContext the VA display context - * @return true if successful - */ -DLL_HIDDEN -bool -va_wayland_emgd_create(VADisplayContextP pDisplayContext); - -DLL_HIDDEN -void -va_wayland_emgd_destroy(VADisplayContextP pDisplayContext); - -#endif /* VA_WAYLAND_EMGD_H */ diff --git a/va/wayland/va_wayland_private.h b/va/wayland/va_wayland_private.h deleted file mode 100644 index f09f4b7..0000000 --- a/va/wayland/va_wayland_private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * va_wayland_private.h - Wayland private API - * - * Copyright (c) 2012 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 INTEL 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_WAYLAND_PRIVATE_H -#define VA_WAYLAND_PRIVATE_H - -struct va_wayland_context; - -typedef bool (*VADisplayContextCreateFunc)(VADisplayContextP pDisplayContext); -typedef void (*VADisplayContextDestroyFunc)(VADisplayContextP pDisplayContext); - -/* VA/Wayland base display context */ -typedef struct va_wayland_context { - VADisplayContextDestroyFunc destroy; -} VADisplayContextWayland, *VADisplayContextWaylandP; - -DLL_HIDDEN -void -va_wayland_error(const char *format, ...); - -#endif /* VA_WAYLAND_PRIVATE_H */ diff --git a/va/wayland/wayland-drm-client-protocol.h b/va/wayland/wayland-drm-client-protocol.h deleted file mode 100644 index da267e8..0000000 --- a/va/wayland/wayland-drm-client-protocol.h +++ /dev/null @@ -1,290 +0,0 @@ -/* Generated by wayland-scanner 1.11.90 */ - -#ifndef DRM_CLIENT_PROTOCOL_H -#define DRM_CLIENT_PROTOCOL_H - -#include -#include -#include "wayland-client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @page page_drm The drm protocol - * @section page_ifaces_drm Interfaces - * - @subpage page_iface_wl_drm - - * @section page_copyright_drm Copyright - *
- *
- * Copyright © 2008-2011 Kristian Høgsberg
- * Copyright © 2010-2011 Intel Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this
- * software and its documentation for any purpose is hereby granted
- * without fee, provided that\n the above copyright notice appear in
- * all copies and that both that copyright notice and this permission
- * notice appear in supporting documentation, and that the name of
- * the copyright holders not be used in advertising or publicity
- * pertaining to distribution of the software without specific,
- * written prior permission.  The copyright holders make no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied
- * warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
- * THIS SOFTWARE.
- * 
- */ -struct wl_buffer; -struct wl_drm; - -/** - * @page page_iface_wl_drm wl_drm - * @section page_iface_wl_drm_api API - * See @ref iface_wl_drm. - */ -/** - * @defgroup iface_wl_drm The wl_drm interface - */ -extern const struct wl_interface wl_drm_interface; - -#ifndef WL_DRM_ERROR_ENUM -#define WL_DRM_ERROR_ENUM -enum wl_drm_error { - WL_DRM_ERROR_AUTHENTICATE_FAIL = 0, - WL_DRM_ERROR_INVALID_FORMAT = 1, - WL_DRM_ERROR_INVALID_NAME = 2, -}; -#endif /* WL_DRM_ERROR_ENUM */ - -#ifndef WL_DRM_FORMAT_ENUM -#define WL_DRM_FORMAT_ENUM -enum wl_drm_format { - WL_DRM_FORMAT_C8 = 0x20203843, - WL_DRM_FORMAT_RGB332 = 0x38424752, - WL_DRM_FORMAT_BGR233 = 0x38524742, - WL_DRM_FORMAT_XRGB4444 = 0x32315258, - WL_DRM_FORMAT_XBGR4444 = 0x32314258, - WL_DRM_FORMAT_RGBX4444 = 0x32315852, - WL_DRM_FORMAT_BGRX4444 = 0x32315842, - WL_DRM_FORMAT_ARGB4444 = 0x32315241, - WL_DRM_FORMAT_ABGR4444 = 0x32314241, - WL_DRM_FORMAT_RGBA4444 = 0x32314152, - WL_DRM_FORMAT_BGRA4444 = 0x32314142, - WL_DRM_FORMAT_XRGB1555 = 0x35315258, - WL_DRM_FORMAT_XBGR1555 = 0x35314258, - WL_DRM_FORMAT_RGBX5551 = 0x35315852, - WL_DRM_FORMAT_BGRX5551 = 0x35315842, - WL_DRM_FORMAT_ARGB1555 = 0x35315241, - WL_DRM_FORMAT_ABGR1555 = 0x35314241, - WL_DRM_FORMAT_RGBA5551 = 0x35314152, - WL_DRM_FORMAT_BGRA5551 = 0x35314142, - WL_DRM_FORMAT_RGB565 = 0x36314752, - WL_DRM_FORMAT_BGR565 = 0x36314742, - WL_DRM_FORMAT_RGB888 = 0x34324752, - WL_DRM_FORMAT_BGR888 = 0x34324742, - WL_DRM_FORMAT_XRGB8888 = 0x34325258, - WL_DRM_FORMAT_XBGR8888 = 0x34324258, - WL_DRM_FORMAT_RGBX8888 = 0x34325852, - WL_DRM_FORMAT_BGRX8888 = 0x34325842, - WL_DRM_FORMAT_ARGB8888 = 0x34325241, - WL_DRM_FORMAT_ABGR8888 = 0x34324241, - WL_DRM_FORMAT_RGBA8888 = 0x34324152, - WL_DRM_FORMAT_BGRA8888 = 0x34324142, - WL_DRM_FORMAT_XRGB2101010 = 0x30335258, - WL_DRM_FORMAT_XBGR2101010 = 0x30334258, - WL_DRM_FORMAT_RGBX1010102 = 0x30335852, - WL_DRM_FORMAT_BGRX1010102 = 0x30335842, - WL_DRM_FORMAT_ARGB2101010 = 0x30335241, - WL_DRM_FORMAT_ABGR2101010 = 0x30334241, - WL_DRM_FORMAT_RGBA1010102 = 0x30334152, - WL_DRM_FORMAT_BGRA1010102 = 0x30334142, - WL_DRM_FORMAT_YUYV = 0x56595559, - WL_DRM_FORMAT_YVYU = 0x55595659, - WL_DRM_FORMAT_UYVY = 0x59565955, - WL_DRM_FORMAT_VYUY = 0x59555956, - WL_DRM_FORMAT_AYUV = 0x56555941, - WL_DRM_FORMAT_NV12 = 0x3231564e, - WL_DRM_FORMAT_NV21 = 0x3132564e, - WL_DRM_FORMAT_NV16 = 0x3631564e, - WL_DRM_FORMAT_NV61 = 0x3136564e, - WL_DRM_FORMAT_YUV410 = 0x39565559, - WL_DRM_FORMAT_YVU410 = 0x39555659, - WL_DRM_FORMAT_YUV411 = 0x31315559, - WL_DRM_FORMAT_YVU411 = 0x31315659, - WL_DRM_FORMAT_YUV420 = 0x32315559, - WL_DRM_FORMAT_YVU420 = 0x32315659, - WL_DRM_FORMAT_YUV422 = 0x36315559, - WL_DRM_FORMAT_YVU422 = 0x36315659, - WL_DRM_FORMAT_YUV444 = 0x34325559, - WL_DRM_FORMAT_YVU444 = 0x34325659, -}; -#endif /* WL_DRM_FORMAT_ENUM */ - -#ifndef WL_DRM_CAPABILITY_ENUM -#define WL_DRM_CAPABILITY_ENUM -/** - * @ingroup iface_wl_drm - * wl_drm capability bitmask - * - * Bitmask of capabilities. - */ -enum wl_drm_capability { - /** - * wl_drm prime available - */ - WL_DRM_CAPABILITY_PRIME = 1, -}; -#endif /* WL_DRM_CAPABILITY_ENUM */ - -/** - * @ingroup iface_wl_drm - * @struct wl_drm_listener - */ -struct wl_drm_listener { - /** - */ - void (*device)(void *data, - struct wl_drm *wl_drm, - const char *name); - /** - */ - void (*format)(void *data, - struct wl_drm *wl_drm, - uint32_t format); - /** - */ - void (*authenticated)(void *data, - struct wl_drm *wl_drm); - /** - */ - void (*capabilities)(void *data, - struct wl_drm *wl_drm, - uint32_t value); -}; - -/** - * @ingroup wl_drm_iface - */ -static inline int -wl_drm_add_listener(struct wl_drm *wl_drm, - const struct wl_drm_listener *listener, void *data) -{ - return wl_proxy_add_listener((struct wl_proxy *) wl_drm, - (void (**)(void)) listener, data); -} - -#define WL_DRM_AUTHENTICATE 0 -#define WL_DRM_CREATE_BUFFER 1 -#define WL_DRM_CREATE_PLANAR_BUFFER 2 -#define WL_DRM_CREATE_PRIME_BUFFER 3 - -/** - * @ingroup iface_wl_drm - */ -#define WL_DRM_AUTHENTICATE_SINCE_VERSION 1 -/** - * @ingroup iface_wl_drm - */ -#define WL_DRM_CREATE_BUFFER_SINCE_VERSION 1 -/** - * @ingroup iface_wl_drm - */ -#define WL_DRM_CREATE_PLANAR_BUFFER_SINCE_VERSION 1 -/** - * @ingroup iface_wl_drm - */ -#define WL_DRM_CREATE_PRIME_BUFFER_SINCE_VERSION 2 - -/** @ingroup iface_wl_drm */ -static inline void -wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data); -} - -/** @ingroup iface_wl_drm */ -static inline void * -wl_drm_get_user_data(struct wl_drm *wl_drm) -{ - return wl_proxy_get_user_data((struct wl_proxy *) wl_drm); -} - -static inline uint32_t -wl_drm_get_version(struct wl_drm *wl_drm) -{ - return wl_proxy_get_version((struct wl_proxy *) wl_drm); -} - -/** @ingroup iface_wl_drm */ -static inline void -wl_drm_destroy(struct wl_drm *wl_drm) -{ - wl_proxy_destroy((struct wl_proxy *) wl_drm); -} - -/** - * @ingroup iface_wl_drm - */ -static inline void -wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id) -{ - wl_proxy_marshal((struct wl_proxy *) wl_drm, - WL_DRM_AUTHENTICATE, id); -} - -/** - * @ingroup iface_wl_drm - */ -static inline struct wl_buffer * -wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm, - WL_DRM_CREATE_BUFFER, &wl_buffer_interface, NULL, name, width, height, stride, format); - - return (struct wl_buffer *) id; -} - -/** - * @ingroup iface_wl_drm - */ -static inline struct wl_buffer * -wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm, - WL_DRM_CREATE_PLANAR_BUFFER, &wl_buffer_interface, NULL, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2); - - return (struct wl_buffer *) id; -} - -/** - * @ingroup iface_wl_drm - */ -static inline struct wl_buffer * -wl_drm_create_prime_buffer(struct wl_drm *wl_drm, int32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_drm, - WL_DRM_CREATE_PRIME_BUFFER, &wl_buffer_interface, NULL, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2); - - return (struct wl_buffer *) id; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/va/wayland/wayland-drm.xml b/va/wayland/wayland-drm.xml deleted file mode 100644 index 5e64622..0000000 --- a/va/wayland/wayland-drm.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - - Copyright © 2008-2011 Kristian Høgsberg - Copyright © 2010-2011 Intel Corporation - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that\n the above copyright notice appear in - all copies and that both that copyright notice and this permission - notice appear in supporting documentation, and that the name of - the copyright holders not be used in advertising or publicity - pertaining to distribution of the software without specific, - written prior permission. The copyright holders make no - representations about the suitability of this software for any - purpose. It is provided "as is" without express or implied - warranty. - - THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY - SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF - THIS SOFTWARE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bitmask of capabilities. - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am deleted file mode 100644 index 0853016..0000000 --- a/va/x11/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# 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. - -AM_CPPFLAGS = \ - -DLINUX \ - -I$(top_srcdir) \ - -I$(top_srcdir)/va \ - $(X11_CFLAGS) \ - $(XEXT_CFLAGS) \ - $(XFIXES_CFLAGS) \ - $(DRM_CFLAGS) \ - $(NULL) - -source_c = \ - dri2_util.c \ - va_dri2.c \ - va_dricommon.c \ - va_fglrx.c \ - va_nvctrl.c \ - va_x11.c \ - $(NULL) - -source_h = \ - va_dri2.h \ - va_dricommon.h \ - $(NULL) - -source_h_priv = \ - va_dri2str.h \ - va_dri2tokens.h \ - va_fglrx.h \ - va_nvctrl.h \ - $(NULL) - -noinst_LTLIBRARIES = libva_x11.la -libva_x11includedir = ${includedir}/va -libva_x11include_HEADERS = $(source_h) -libva_x11_la_SOURCES = $(source_c) -noinst_HEADERS = $(source_h_priv) diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c deleted file mode 100644 index 4fddf37..0000000 --- a/va/x11/dri2_util.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -#include -#include -#include -#include - -#include - -#include -#include -#include "va.h" -#include "va_backend.h" - -#include "va_dri2.h" -#include "va_dri2tokens.h" -#include "va_dricommon.h" - -#define __DRI_BUFFER_FRONT_LEFT 0 -#define __DRI_BUFFER_BACK_LEFT 1 -#define __DRI_BUFFER_FRONT_RIGHT 2 -#define __DRI_BUFFER_BACK_RIGHT 3 -#define __DRI_BUFFER_DEPTH 4 -#define __DRI_BUFFER_STENCIL 5 -#define __DRI_BUFFER_ACCUM 6 -#define __DRI_BUFFER_FAKE_FRONT_LEFT 7 -#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8 - -struct dri2_drawable -{ - struct dri_drawable base; - union dri_buffer buffers[5]; - int width; - int height; - int has_backbuffer; - int back_index; - int front_index; -}; - -static int gsDRI2SwapAvailable; - -static struct dri_drawable * -dri2CreateDrawable(VADriverContextP ctx, XID x_drawable) -{ - struct dri2_drawable *dri2_drawable; - - dri2_drawable = calloc(1, sizeof(*dri2_drawable)); - - if (!dri2_drawable) - return NULL; - - dri2_drawable->base.x_drawable = x_drawable; - dri2_drawable->base.x = 0; - dri2_drawable->base.y = 0; - VA_DRI2CreateDrawable(ctx->native_dpy, x_drawable); - - return &dri2_drawable->base; -} - -static void -dri2DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - VA_DRI2DestroyDrawable(ctx->native_dpy, dri_drawable->x_drawable); - free(dri_drawable); -} - -static void -dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable; - XRectangle xrect; - XserverRegion region; - - if (dri2_drawable->has_backbuffer) { - if (gsDRI2SwapAvailable) { - CARD64 ret; - VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable, - 0, 1, 0, - &ret); - } else { - xrect.x = 0; - xrect.y = 0; - xrect.width = dri2_drawable->width; - xrect.height = dri2_drawable->height; - - region = XFixesCreateRegion(ctx->native_dpy, &xrect, 1); - VA_DRI2CopyRegion(ctx->native_dpy, dri_drawable->x_drawable, region, - DRI2BufferFrontLeft, DRI2BufferBackLeft); - XFixesDestroyRegion(ctx->native_dpy, region); - } - } -} - -static union dri_buffer * -dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable; - int i; - int count; - unsigned int attachments[5]; - VA_DRI2Buffer *buffers; - - i = 0; - if (dri_drawable->is_window) - attachments[i++] = __DRI_BUFFER_BACK_LEFT; - else - attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - - buffers = VA_DRI2GetBuffers(ctx->native_dpy, dri_drawable->x_drawable, - &dri2_drawable->width, &dri2_drawable->height, - attachments, i, &count); - assert(buffers); - if (buffers == NULL) - return NULL; - - dri2_drawable->has_backbuffer = 0; - - for (i = 0; i < count; i++) { - dri2_drawable->buffers[i].dri2.attachment = buffers[i].attachment; - dri2_drawable->buffers[i].dri2.name = buffers[i].name; - dri2_drawable->buffers[i].dri2.pitch = buffers[i].pitch; - dri2_drawable->buffers[i].dri2.cpp = buffers[i].cpp; - dri2_drawable->buffers[i].dri2.flags = buffers[i].flags; - - if (buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) { - dri2_drawable->has_backbuffer = 1; - dri2_drawable->back_index = i; - } - - if (buffers[i].attachment == __DRI_BUFFER_FRONT_LEFT) - dri2_drawable->front_index = i; - } - - dri_drawable->width = dri2_drawable->width; - dri_drawable->height = dri2_drawable->height; - Xfree(buffers); - - if (dri2_drawable->has_backbuffer) - return &dri2_drawable->buffers[dri2_drawable->back_index]; - - return &dri2_drawable->buffers[dri2_drawable->front_index]; -} - -static void -dri2Close(VADriverContextP ctx) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - - free_drawable_hashtable(ctx); - - if (dri_state->base.fd >= 0) - close(dri_state->base.fd); -} - -Bool -isDRI2Connected(VADriverContextP ctx, char **driver_name) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - int major, minor; - int error_base; - int event_base; - char *device_name = NULL; - drm_magic_t magic; - *driver_name = NULL; - dri_state->base.fd = -1; - dri_state->base.auth_type = VA_NONE; - if (!VA_DRI2QueryExtension(ctx->native_dpy, &event_base, &error_base)) - goto err_out; - - if (!VA_DRI2QueryVersion(ctx->native_dpy, &major, &minor)) - goto err_out; - - - if (!VA_DRI2Connect(ctx->native_dpy, RootWindow(ctx->native_dpy, ctx->x11_screen), - driver_name, &device_name)) - goto err_out; - - dri_state->base.fd = open(device_name, O_RDWR); - - if (dri_state->base.fd < 0) - goto err_out; - - if (drmGetMagic(dri_state->base.fd, &magic)) - goto err_out; - - if (!VA_DRI2Authenticate(ctx->native_dpy, RootWindow(ctx->native_dpy, ctx->x11_screen), - magic)) - goto err_out; - - dri_state->base.auth_type = VA_DRI2; - dri_state->createDrawable = dri2CreateDrawable; - dri_state->destroyDrawable = dri2DestroyDrawable; - dri_state->swapBuffer = dri2SwapBuffer; - dri_state->getRenderingBuffer = dri2GetRenderingBuffer; - dri_state->close = dri2Close; - gsDRI2SwapAvailable = (minor >= 2); - - if (device_name) - Xfree(device_name); - - return True; - -err_out: - if (device_name) - Xfree(device_name); - - if (*driver_name) - Xfree(*driver_name); - - if (dri_state->base.fd >= 0) - close(dri_state->base.fd); - - *driver_name = NULL; - dri_state->base.fd = -1; - - return False; -} - diff --git a/va/x11/va_dri2.c b/va/x11/va_dri2.c deleted file mode 100644 index a395260..0000000 --- a/va/x11/va_dri2.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - - -#define NEED_REPLIES -#include -#include -#include -#include "xf86drm.h" -#include "va_dri2.h" -#include "va_dri2str.h" -#include "va_dri2tokens.h" - -#ifndef DRI2DriverDRI -#define DRI2DriverDRI 0 -#endif - -static int -VA_DRI2Error(Display *dpy, xError *err, XExtCodes *codes, int *ret_code); - -static VA_DRI2Buffer * -VA_DRI2GetBuffers_internal(XExtDisplayInfo *info, - Display *dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, - int count, - int *outCount); - -static char va_dri2ExtensionName[] = DRI2_NAME; -static XExtensionInfo _va_dri2_info_data; -static XExtensionInfo *va_dri2Info = &_va_dri2_info_data; -static XEXT_GENERATE_CLOSE_DISPLAY (VA_DRI2CloseDisplay, va_dri2Info) -static /* const */ XExtensionHooks va_dri2ExtensionHooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - VA_DRI2CloseDisplay, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - VA_DRI2Error, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, va_dri2Info, - va_dri2ExtensionName, - &va_dri2ExtensionHooks, - 0, NULL) - -static CARD32 _va_resource_x_error_drawable = 0; -static Bool _va_resource_x_error_matched = False; - -#define VA_EnterResourceError(drawable) \ - do { \ - _va_resource_x_error_drawable = (drawable); \ - _va_resource_x_error_matched = False; \ - } while (0) - -#define VA_LeaveResourceError() \ - do { \ - _va_resource_x_error_drawable = 0; \ - } while (0) - -#define VA_ResourceErrorMatched() \ - (_va_resource_x_error_matched) - -static int -VA_DRI2Error(Display *dpy, xError *err, XExtCodes *codes, int *ret_code) -{ - if (_va_resource_x_error_drawable == err->resourceID) { - _va_resource_x_error_matched = True; - return True; - } - - return False; -} - -Bool VA_DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - - if (XextHasExtension(info)) { - *eventBase = info->codes->first_event; - *errorBase = info->codes->first_error; - return True; - } - - return False; -} - -Bool VA_DRI2QueryVersion(Display *dpy, int *major, int *minor) -{ - XExtDisplayInfo *info = DRI2FindDisplay (dpy); - xDRI2QueryVersionReply rep; - xDRI2QueryVersionReq *req; - - XextCheckExtension (dpy, info, va_dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2QueryVersion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2QueryVersion; - req->majorVersion = DRI2_MAJOR; - req->minorVersion = DRI2_MINOR; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *major = rep.majorVersion; - *minor = rep.minorVersion; - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool VA_DRI2Connect(Display *dpy, XID window, - char **driverName, char **deviceName) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2ConnectReply rep; - xDRI2ConnectReq *req; - - XextCheckExtension (dpy, info, va_dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Connect, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Connect; - req->window = window; - req->driverType = DRI2DriverDRI; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *driverName = Xmalloc(rep.driverNameLength + 1); - if (*driverName == NULL) { - _XEatData(dpy, - ((rep.driverNameLength + 3) & ~3) + - ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *driverName, rep.driverNameLength); - (*driverName)[rep.driverNameLength] = '\0'; - - *deviceName = Xmalloc(rep.deviceNameLength + 1); - if (*deviceName == NULL) { - Xfree(*driverName); - _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - _XReadPad(dpy, *deviceName, rep.deviceNameLength); - (*deviceName)[rep.deviceNameLength] = '\0'; - - UnlockDisplay(dpy); - SyncHandle(); - - return True; -} - -Bool VA_DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2AuthenticateReq *req; - xDRI2AuthenticateReply rep; - - XextCheckExtension (dpy, info, va_dri2ExtensionName, False); - - LockDisplay(dpy); - GetReq(DRI2Authenticate, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2Authenticate; - req->window = window; - req->magic = magic; - - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return rep.authenticated; -} - -void VA_DRI2CreateDrawable(Display *dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CreateDrawableReq *req; - - XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CreateDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -void VA_DRI2DestroyDrawable(Display *dpy, XID drawable) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2DestroyDrawableReq *req; - unsigned int attachement = 0; // FRONT_LEFT - VA_DRI2Buffer *buffers; - - XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName); - - XSync(dpy, False); - - LockDisplay(dpy); - /* - * We have no way of catching DRI2DestroyDrawable errors because - * this message doesn't have a defined answer. So we test whether - * the drawable is still alive by sending DRIGetBuffers first and - * checking whether we get an error. - */ - VA_EnterResourceError(drawable); - - buffers = VA_DRI2GetBuffers_internal(info, dpy, drawable, - NULL, NULL, - &attachement, 1, NULL); - VA_LeaveResourceError(); - if (buffers) - XFree(buffers); - if (VA_ResourceErrorMatched()) { - UnlockDisplay(dpy); - SyncHandle(); - return; - } - - GetReq(DRI2DestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2DestroyDrawable; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); -} - -VA_DRI2Buffer *VA_DRI2GetBuffers_internal(XExtDisplayInfo *info, - Display *dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, - int *outCount) -{ - xDRI2GetBuffersReply rep; - xDRI2GetBuffersReq *req; - VA_DRI2Buffer *buffers; - xDRI2Buffer repBuffer; - CARD32 *p; - int i; - - GetReqExtra(DRI2GetBuffers, count * 4, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffers; - req->drawable = drawable; - req->count = count; - p = (CARD32 *) &req[1]; - for (i = 0; i < count; i++) - p[i] = attachments[i]; - - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { - return NULL; - } - - if (width) - *width = rep.width; - if (height) - *height = rep.height; - if (outCount) - *outCount = rep.count; - - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - return NULL; - } - - for (i = 0; i < rep.count; i++) { - _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; - } - - return buffers; -} - -VA_DRI2Buffer *VA_DRI2GetBuffers(Display *dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, - int *outCount) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - VA_DRI2Buffer *buffers; - - XextCheckExtension (dpy, info, va_dri2ExtensionName, False); - - LockDisplay(dpy); - - buffers = VA_DRI2GetBuffers_internal(info, dpy, drawable, width, height, - attachments, count, outCount); - - UnlockDisplay(dpy); - SyncHandle(); - - return buffers; -} - -void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region, - CARD32 dest, CARD32 src) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2CopyRegionReq *req; - xDRI2CopyRegionReply rep; - - XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2CopyRegion, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2CopyRegion; - req->drawable = drawable; - req->region = region; - req->dest = dest; - req->src = src; - - _XReply(dpy, (xReply *)&rep, 0, xFalse); - - UnlockDisplay(dpy); - SyncHandle(); -} - -static void -load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor, - CARD64 remainder) -{ - req->target_msc_hi = target >> 32; - req->target_msc_lo = target & 0xffffffff; - req->divisor_hi = divisor >> 32; - req->divisor_lo = divisor & 0xffffffff; - req->remainder_hi = remainder >> 32; - req->remainder_lo = remainder & 0xffffffff; -} - -static CARD64 -vals_to_card64(CARD32 lo, CARD32 hi) -{ - return (CARD64)hi << 32 | lo; -} - -void VA_DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, - CARD64 divisor, CARD64 remainder, CARD64 *count) -{ - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2SwapBuffersReq *req; - xDRI2SwapBuffersReply rep; - - XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName); - - LockDisplay(dpy); - GetReq(DRI2SwapBuffers, req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2SwapBuffers; - req->drawable = drawable; - load_swap_req(req, target_msc, divisor, remainder); - - _XReply(dpy, (xReply *)&rep, 0, xFalse); - - *count = vals_to_card64(rep.swap_lo, rep.swap_hi); - - UnlockDisplay(dpy); - SyncHandle(); -} diff --git a/va/x11/va_dri2.h b/va/x11/va_dri2.h deleted file mode 100644 index 165f3fe..0000000 --- a/va/x11/va_dri2.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2007,2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifndef _VA_DRI2_H_ -#define _VA_DRI2_H_ - -#include -#include -#include -#include - -typedef struct { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; -} VA_DRI2Buffer; - -extern Bool -VA_DRI2QueryExtension(Display *display, int *eventBase, int *errorBase); -extern Bool -VA_DRI2QueryVersion(Display *display, int *major, int *minor); -extern Bool -VA_DRI2Connect(Display *display, XID window, - char **driverName, char **deviceName); -extern Bool -VA_DRI2Authenticate(Display *display, XID window, drm_magic_t magic); -extern void -VA_DRI2CreateDrawable(Display *display, XID drawable); -extern void -VA_DRI2DestroyDrawable(Display *display, XID handle); -extern VA_DRI2Buffer * -VA_DRI2GetBuffers(Display *dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, - int *outCount); -extern void -VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region, - CARD32 dest, CARD32 src); -extern void -VA_DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor, - CARD64 remainder, CARD64 *count); -#endif diff --git a/va/x11/va_dri2str.h b/va/x11/va_dri2str.h deleted file mode 100644 index 1515eeb..0000000 --- a/va/x11/va_dri2str.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifndef _DRI2_PROTO_H_ -#define _DRI2_PROTO_H_ - -#define DRI2_NAME "DRI2" -#define DRI2_MAJOR 1 -#define DRI2_MINOR 2 - -#define DRI2NumberErrors 0 -#define DRI2NumberEvents 2 -#define DRI2NumberRequests 13 - -#define X_DRI2QueryVersion 0 -#define X_DRI2Connect 1 -#define X_DRI2Authenticate 2 -#define X_DRI2CreateDrawable 3 -#define X_DRI2DestroyDrawable 4 -#define X_DRI2GetBuffers 5 -#define X_DRI2CopyRegion 6 -#define X_DRI2GetBuffersWithFormat 7 -#define X_DRI2SwapBuffers 8 -#define X_DRI2GetMSC 9 -#define X_DRI2WaitMSC 10 -#define X_DRI2WaitSBC 11 -#define X_DRI2SwapInterval 12 - -typedef struct { - CARD32 attachment B32; - CARD32 name B32; - CARD32 pitch B32; - CARD32 cpp B32; - CARD32 flags B32; -} xDRI2Buffer; - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 majorVersion B32; - CARD32 minorVersion B32; -} xDRI2QueryVersionReq; -#define sz_xDRI2QueryVersionReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 majorVersion B32; - CARD32 minorVersion B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xDRI2QueryVersionReply; -#define sz_xDRI2QueryVersionReply 32 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 window B32; - CARD32 driverType B32; -} xDRI2ConnectReq; -#define sz_xDRI2ConnectReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 driverNameLength B32; - CARD32 deviceNameLength B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xDRI2ConnectReply; -#define sz_xDRI2ConnectReply 32 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 window B32; - CARD32 magic B32; -} xDRI2AuthenticateReq; -#define sz_xDRI2AuthenticateReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xDRI2AuthenticateReply; -#define sz_xDRI2AuthenticateReply 32 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 drawable B32; -} xDRI2CreateDrawableReq; -#define sz_xDRI2CreateDrawableReq 8 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 drawable B32; -} xDRI2DestroyDrawableReq; -#define sz_xDRI2DestroyDrawableReq 8 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 drawable B32; - CARD32 count B32; -} xDRI2GetBuffersReq; -#define sz_xDRI2GetBuffersReq 12 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 width B32; - CARD32 height B32; - CARD32 count B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; -} xDRI2GetBuffersReply; -#define sz_xDRI2GetBuffersReply 32 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 drawable B32; - CARD32 region B32; - CARD32 dest B32; - CARD32 src B32; -} xDRI2CopyRegionReq; -#define sz_xDRI2CopyRegionReq 20 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xDRI2CopyRegionReply; -#define sz_xDRI2CopyRegionReply 32 - -typedef struct { - CARD8 reqType; - CARD8 dri2ReqType; - CARD16 length B16; - CARD32 drawable B32; - CARD32 target_msc_hi B32; - CARD32 target_msc_lo B32; - CARD32 divisor_hi B32; - CARD32 divisor_lo B32; - CARD32 remainder_hi B32; - CARD32 remainder_lo B32; -} xDRI2SwapBuffersReq; -#define sz_xDRI2SwapBuffersReq 32 - -typedef struct { - BYTE type; /* X_Reply */ - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 swap_hi B32; - CARD32 swap_lo B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xDRI2SwapBuffersReply; -#define sz_xDRI2SwapBuffersReply 32 - -#endif diff --git a/va/x11/va_dri2tokens.h b/va/x11/va_dri2tokens.h deleted file mode 100644 index 087159f..0000000 --- a/va/x11/va_dri2tokens.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2008 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Soft- - * ware"), to deal in the Software without restriction, including without - * limitation the rights to use, copy, modify, merge, publish, distribute, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, provided that the above copyright - * notice(s) and this permission notice appear in all copies of the Soft- - * ware and that both the above copyright notice(s) and this permission - * notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- - * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY - * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN - * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- - * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- - * MANCE OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder shall - * not be used in advertising or otherwise to promote the sale, use or - * other dealings in this Software without prior written authorization of - * the copyright holder. - * - * Authors: - * Kristian Høgsberg (krh@redhat.com) - */ - -#ifndef _DRI2_TOKENS_H_ -#define _DRI2_TOKENS_H_ - -#define DRI2BufferFrontLeft 0 -#define DRI2BufferBackLeft 1 -#define DRI2BufferFrontRight 2 -#define DRI2BufferBackRight 3 -#define DRI2BufferDepth 4 -#define DRI2BufferStencil 5 -#define DRI2BufferAccum 6 -#define DRI2BufferFakeFrontLeft 7 -#define DRI2BufferFakeFrontRight 8 - -#define DRI2DriverDRI 0 - -#endif diff --git a/va/x11/va_dricommon.c b/va/x11/va_dricommon.c deleted file mode 100644 index 379e3d4..0000000 --- a/va/x11/va_dricommon.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -#include "va_dricommon.h" - -// X error trap -static int x11_error_code = 0; -static int (*old_error_handler)(Display *, XErrorEvent *); - -static int -error_handler(Display *dpy, XErrorEvent *error) -{ - x11_error_code = error->error_code; - return 0; -} - -static void -x11_trap_errors(void) -{ - x11_error_code = 0; - old_error_handler = XSetErrorHandler(error_handler); -} - -static int -x11_untrap_errors(void) -{ - XSetErrorHandler(old_error_handler); - return x11_error_code; -} - -static int -is_window(Display *dpy, Drawable drawable) -{ - XWindowAttributes wattr; - - x11_trap_errors(); - XGetWindowAttributes(dpy, drawable, &wattr); - return x11_untrap_errors() == 0; -} - -static struct dri_drawable * -do_drawable_hash(VADriverContextP ctx, XID drawable) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - int index = drawable % DRAWABLE_HASH_SZ; - struct dri_drawable *dri_drawable = dri_state->drawable_hash[index]; - - while (dri_drawable) { - if (dri_drawable->x_drawable == drawable) - return dri_drawable; - dri_drawable = dri_drawable->next; - } - - dri_drawable = dri_state->createDrawable(ctx, drawable); - dri_drawable->x_drawable = drawable; - dri_drawable->is_window = is_window(ctx->native_dpy, drawable); - dri_drawable->next = dri_state->drawable_hash[index]; - dri_state->drawable_hash[index] = dri_drawable; - - return dri_drawable; -} - -void -free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - int i = 0; - - while (i < DRAWABLE_HASH_SZ) { - if (dri_drawable == dri_state->drawable_hash[i]) { - dri_state->destroyDrawable(ctx, dri_drawable); - dri_state->drawable_hash[i] = NULL; - } - i++; - } -} - -void -free_drawable_hashtable(VADriverContextP ctx) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - int i; - struct dri_drawable *dri_drawable, *prev; - - for (i = 0; i < DRAWABLE_HASH_SZ; i++) { - dri_drawable = dri_state->drawable_hash[i]; - - while (dri_drawable) { - prev = dri_drawable; - dri_drawable = prev->next; - dri_state->destroyDrawable(ctx, prev); - } - - dri_state->drawable_hash[i] = NULL; - } -} - -struct dri_drawable * -dri_get_drawable(VADriverContextP ctx, XID drawable) -{ - return do_drawable_hash(ctx, drawable); -} - -void -dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - - dri_state->swapBuffer(ctx, dri_drawable); -} - -union dri_buffer * -dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->drm_state; - - return dri_state->getRenderingBuffer(ctx, dri_drawable); -} diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h deleted file mode 100644 index eb6ddad..0000000 --- a/va/x11/va_dricommon.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ -#ifndef _VA_DRICOMMON_H_ -#define _VA_DRICOMMON_H_ - -#ifndef ANDROID -#include -#include -#include -#include -#endif - -#include -#include - -#ifdef ANDROID -#define XID unsigned int -#define Bool int -#endif - -enum { - /* Compatibility. Do not use for newly-written code. */ - VA_NONE = VA_DRM_AUTH_NONE, - VA_DRI1 = VA_DRM_AUTH_DRI1, - VA_DRI2 = VA_DRM_AUTH_DRI2, - VA_DUMMY = VA_DRM_AUTH_CUSTOM -}; - -union dri_buffer -{ - struct { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; - } dri2; -}; - -struct dri_drawable -{ - XID x_drawable; - int is_window; - int x; - int y; - unsigned int width; - unsigned int height; - struct dri_drawable *next; -}; - -#define DRAWABLE_HASH_SZ 32 -struct dri_state -{ - struct drm_state base; -#ifndef ANDROID - struct dri_drawable *drawable_hash[DRAWABLE_HASH_SZ]; - - struct dri_drawable *(*createDrawable)(VADriverContextP ctx, XID x_drawable); - void (*destroyDrawable)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - void (*swapBuffer)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - union dri_buffer *(*getRenderingBuffer)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - void (*close)(VADriverContextP ctx); -#endif -}; - -Bool isDRI2Connected(VADriverContextP ctx, char **driver_name); -void free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable); -void free_drawable_hashtable(VADriverContextP ctx); -struct dri_drawable *dri_get_drawable(VADriverContextP ctx, XID drawable); -void dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable); -union dri_buffer *dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable); - -#endif /* _VA_DRICOMMON_H_ */ diff --git a/va/x11/va_fglrx.c b/va/x11/va_fglrx.c deleted file mode 100644 index 058e23d..0000000 --- a/va/x11/va_fglrx.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#include "sysdeps.h" -#include -#include -#include -#include -#include - -#define ADL_OK 0 -#define ADL_MAX_PATH 256 - -/* - * Based on public AMD Display Library (ADL) SDK: - * - */ -typedef struct AdapterInfo { - int iSize; - int iAdapterIndex; - char strUDID[ADL_MAX_PATH]; - int iBusNumber; - int iDeviceNumber; - int iFunctionNumber; - int iVendorID; - char strAdapterName[ADL_MAX_PATH]; - char strDisplayName[ADL_MAX_PATH]; - int iPresent; - int iXScreenNum; - int iDrvIndex; - char strXScreenConfigName[ADL_MAX_PATH]; -} AdapterInfo, *LPAdapterInfo; - -typedef struct XScreenInfo { - int iXScreenNum; - char strXScreenConfigName[ADL_MAX_PATH]; -} XScreenInfo, *LPXScreenInfo; - -typedef void *(*ADL_MAIN_MALLOC_CALLBACK)(int); -typedef int (*ADL_MAIN_CONTROL_CREATE)(ADL_MAIN_MALLOC_CALLBACK, int); -typedef int (*ADL_MAIN_CONTROL_DESTROY)(void); -typedef int (*ADL_ADAPTER_NUMBEROFADAPTERS_GET)(int *); -typedef int (*ADL_ADAPTER_ADAPTERINFO_GET)(LPAdapterInfo, int); -typedef int (*ADL_ADAPTER_XSCREENINFO_GET)(LPXScreenInfo, int); - -static void *ADL_Main_Memory_Alloc(int iSize) -{ - return malloc(iSize); -} - -static void ADL_Main_Memory_Free(void *arg) -{ - void ** const lpBuffer = arg; - - if (lpBuffer && *lpBuffer) { - free(*lpBuffer); - *lpBuffer = NULL; - } -} - -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); - 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); - - 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; -} - -Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ) -{ - ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create; - ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy; - ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get; - ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get; - ADL_ADAPTER_XSCREENINFO_GET ADL_Adapter_XScreenInfo_Get; - - LPAdapterInfo lpAdapterInfo = NULL; - LPXScreenInfo lpXScreenInfo = NULL; - void *libadl_handle = NULL; - Bool success = False; - int is_adl_initialized = 0; - int i, num_adapters, lpAdapterInfo_size, lpXScreenInfo_size; - - if (ddxDriverMajorVersion) - *ddxDriverMajorVersion = 0; - if (ddxDriverMinorVersion) - *ddxDriverMinorVersion = 0; - if (ddxDriverPatchVersion) - *ddxDriverPatchVersion = 0; - if (clientDriverName) - *clientDriverName = NULL; - - libadl_handle = dlopen("libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); - if (!libadl_handle) - goto end; - - dlerror(); - ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) - dlsym(libadl_handle,"ADL_Main_Control_Create"); - if (dlerror()) - goto end; - - ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) - dlsym(libadl_handle,"ADL_Main_Control_Destroy"); - if (dlerror()) - goto end; - - ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) - dlsym(libadl_handle,"ADL_Adapter_NumberOfAdapters_Get"); - if (dlerror()) - goto end; - - ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) - dlsym(libadl_handle,"ADL_Adapter_AdapterInfo_Get"); - if (dlerror()) - goto end; - - ADL_Adapter_XScreenInfo_Get = (ADL_ADAPTER_XSCREENINFO_GET) - dlsym(libadl_handle,"ADL_Adapter_XScreenInfo_Get"); - if (dlerror()) - goto end; - - if (ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1) != ADL_OK) - goto end; - is_adl_initialized = 1; - - if (ADL_Adapter_NumberOfAdapters_Get(&num_adapters) != ADL_OK) - goto end; - if (num_adapters <= 0) - goto end; - - lpAdapterInfo_size = num_adapters * sizeof(*lpAdapterInfo); - lpAdapterInfo = ADL_Main_Memory_Alloc(lpAdapterInfo_size); - if (!lpAdapterInfo) - goto end; - memset(lpAdapterInfo, 0, lpAdapterInfo_size); - - for (i = 0; i < num_adapters; i++) - lpAdapterInfo[i].iSize = sizeof(lpAdapterInfo[i]); - - lpXScreenInfo_size = num_adapters * sizeof(*lpXScreenInfo); - lpXScreenInfo = ADL_Main_Memory_Alloc(lpXScreenInfo_size); - if (!lpXScreenInfo) - goto end; - memset(lpXScreenInfo, 0, lpXScreenInfo_size); - - if (ADL_Adapter_AdapterInfo_Get(lpAdapterInfo, lpAdapterInfo_size) != ADL_OK) - goto end; - - if (ADL_Adapter_XScreenInfo_Get(lpXScreenInfo, lpXScreenInfo_size) != ADL_OK) - goto end; - - for (i = 0; i < num_adapters; i++) { - LPXScreenInfo const lpCurrXScreenInfo = &lpXScreenInfo[i]; - LPAdapterInfo const lpCurrAdapterInfo = &lpAdapterInfo[i]; - if (!lpCurrAdapterInfo->iPresent) - continue; -#if 0 - printf("Adapter %d:\n", i); - printf(" iAdapterIndex: %d\n", lpCurrAdapterInfo->iAdapterIndex); - printf(" strUDID: '%s'\n", lpCurrAdapterInfo->strUDID); - printf(" iBusNumber: %d\n", lpCurrAdapterInfo->iBusNumber); - printf(" iDeviceNumber: %d\n", lpCurrAdapterInfo->iDeviceNumber); - printf(" iFunctionNumber: %d\n", lpCurrAdapterInfo->iFunctionNumber); - printf(" iVendorID: 0x%04x\n", lpCurrAdapterInfo->iVendorID); - printf(" strAdapterName: '%s'\n", lpCurrAdapterInfo->strAdapterName); - printf(" strDisplayName: '%s'\n", lpCurrAdapterInfo->strDisplayName); - printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent); - printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum); -#endif - if (screen == lpCurrXScreenInfo->iXScreenNum && - match_display_name(dpy, lpCurrAdapterInfo->strDisplayName)) { - if (clientDriverName) - *clientDriverName = strdup("fglrx"); - success = True; - break; - } - } - -end: - if (lpXScreenInfo) - ADL_Main_Memory_Free(&lpXScreenInfo); - if (lpAdapterInfo) - ADL_Main_Memory_Free(&lpAdapterInfo); - if (is_adl_initialized) - ADL_Main_Control_Destroy(); - if (libadl_handle) - dlclose(libadl_handle); - return success; -} diff --git a/va/x11/va_fglrx.h b/va/x11/va_fglrx.h deleted file mode 100644 index 93ddd4b..0000000 --- a/va/x11/va_fglrx.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2010 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_FGLRX_H -#define VA_FGLRX_H - -#include - -DLL_HIDDEN -Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ); - -#endif /* VA_FGLRX_H */ diff --git a/va/x11/va_nvctrl.c b/va/x11/va_nvctrl.c deleted file mode 100644 index 20c63d5..0000000 --- a/va/x11/va_nvctrl.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Copyright (c) 2008 NVIDIA, Corporation - * - * 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, sublicense, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include - -#define NEED_REPLIES -#include -#include -#include -#include -#include -#include "va_nvctrl.h" - -#define NV_CONTROL_ERRORS 0 -#define NV_CONTROL_EVENTS 5 -#define NV_CONTROL_NAME "NV-CONTROL" - -#define NV_CTRL_TARGET_TYPE_X_SCREEN 0 -#define NV_CTRL_TARGET_TYPE_GPU 1 -#define NV_CTRL_TARGET_TYPE_FRAMELOCK 2 -#define NV_CTRL_TARGET_TYPE_VCSC 3 /* Visual Computing System */ - -#define NV_CTRL_STRING_NVIDIA_DRIVER_VERSION 3 /* R--G */ - -#define X_nvCtrlQueryExtension 0 -#define X_nvCtrlIsNv 1 -#define X_nvCtrlQueryStringAttribute 4 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; -} xnvCtrlQueryExtensionReq; -#define sz_xnvCtrlQueryExtensionReq 4 - -typedef struct { - BYTE type; /* X_Reply */ - CARD8 padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 major B16; - CARD16 minor B16; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xnvCtrlQueryExtensionReply; -#define sz_xnvCtrlQueryExtensionReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD32 screen B32; -} xnvCtrlIsNvReq; -#define sz_xnvCtrlIsNvReq 8 - -typedef struct { - BYTE type; /* X_Reply */ - CARD8 padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 isnv B32; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xnvCtrlIsNvReply; -#define sz_xnvCtrlIsNvReply 32 - -typedef struct { - CARD8 reqType; - CARD8 nvReqType; - CARD16 length B16; - CARD16 target_id B16; /* X screen number or GPU number */ - CARD16 target_type B16; /* X screen or GPU */ - CARD32 display_mask B32; - CARD32 attribute B32; -} xnvCtrlQueryStringAttributeReq; -#define sz_xnvCtrlQueryStringAttributeReq 16 - -typedef struct { - BYTE type; - BYTE pad0; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 n B32; /* Length of string */ - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xnvCtrlQueryStringAttributeReply; -#define sz_xnvCtrlQueryStringAttributeReply 32 - -#define NVCTRL_EXT_NEED_CHECK (XPointer)(~0) -#define NVCTRL_EXT_NEED_NOTHING (XPointer)(0) -#define NVCTRL_EXT_NEED_TARGET_SWAP (XPointer)(1) - -static XExtensionInfo _nvctrl_ext_info_data; -static XExtensionInfo *nvctrl_ext_info = &_nvctrl_ext_info_data; -static /* const */ char *nvctrl_extension_name = NV_CONTROL_NAME; - -#define XNVCTRLCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, nvctrl_extension_name, val) -#define XNVCTRLSimpleCheckExtension(dpy,i) \ - XextSimpleCheckExtension (dpy, i, nvctrl_extension_name) - -static int close_display(); -static /* const */ XExtensionHooks nvctrl_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (find_display, nvctrl_ext_info, - nvctrl_extension_name, - &nvctrl_extension_hooks, - NV_CONTROL_EVENTS, NVCTRL_EXT_NEED_CHECK) - -static XEXT_GENERATE_CLOSE_DISPLAY (close_display, nvctrl_ext_info) - -static Bool XNVCTRLQueryVersion (Display *dpy, int *major, int *minor); - -/* - * NV-CONTROL versions 1.8 and 1.9 pack the target_type and target_id - * fields in reversed order. In order to talk to one of these servers, - * we need to swap these fields. - */ -static void XNVCTRLCheckTargetData(Display *dpy, XExtDisplayInfo *info, - int *target_type, int *target_id) -{ - /* Find out what the server's NV-CONTROL version is and - * setup for swapping if we need to. - */ - if (info->data == NVCTRL_EXT_NEED_CHECK) { - int major, minor; - - if (XNVCTRLQueryVersion(dpy, &major, &minor)) { - if (major == 1 && - (minor == 8 || minor == 9)) { - info->data = NVCTRL_EXT_NEED_TARGET_SWAP; - } else { - info->data = NVCTRL_EXT_NEED_NOTHING; - } - } else { - info->data = NVCTRL_EXT_NEED_NOTHING; - } - } - - /* We need to swap the target_type and target_id */ - if (info->data == NVCTRL_EXT_NEED_TARGET_SWAP) { - int tmp; - tmp = *target_type; - *target_type = *target_id; - *target_id = tmp; - } -} - - -static Bool XNVCTRLQueryExtension ( - Display *dpy, - int *event_basep, - int *error_basep -){ - XExtDisplayInfo *info = find_display (dpy); - - if (XextHasExtension(info)) { - if (event_basep) *event_basep = info->codes->first_event; - if (error_basep) *error_basep = info->codes->first_error; - return True; - } else { - return False; - } -} - - -static Bool XNVCTRLQueryVersion ( - Display *dpy, - int *major, - int *minor -){ - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryExtensionReply rep; - xnvCtrlQueryExtensionReq *req; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlQueryExtension, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryExtension; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - if (major) *major = rep.major; - if (minor) *minor = rep.minor; - UnlockDisplay (dpy); - SyncHandle (); - return True; -} - - -static Bool XNVCTRLIsNvScreen ( - Display *dpy, - int screen -){ - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlIsNvReply rep; - xnvCtrlIsNvReq *req; - Bool isnv; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (nvCtrlIsNv, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlIsNv; - req->screen = screen; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - isnv = rep.isnv; - UnlockDisplay (dpy); - SyncHandle (); - return isnv; -} - - -static Bool XNVCTRLQueryTargetStringAttribute ( - Display *dpy, - int target_type, - int target_id, - unsigned int display_mask, - unsigned int attribute, - char **ptr -){ - XExtDisplayInfo *info = find_display (dpy); - xnvCtrlQueryStringAttributeReply rep; - xnvCtrlQueryStringAttributeReq *req; - Bool exists; - int length, numbytes, slop; - - if (!ptr) return False; - - if(!XextHasExtension(info)) - return False; - - XNVCTRLCheckExtension (dpy, info, False); - XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); - - LockDisplay (dpy); - GetReq (nvCtrlQueryStringAttribute, req); - req->reqType = info->codes->major_opcode; - req->nvReqType = X_nvCtrlQueryStringAttribute; - req->target_type = target_type; - req->target_id = target_id; - req->display_mask = display_mask; - req->attribute = attribute; - if (!_XReply (dpy, (xReply *) &rep, 0, False)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - length = rep.length; - numbytes = rep.n; - slop = numbytes & 3; - *ptr = (char *) Xmalloc(numbytes); - if (! *ptr) { - _XEatData(dpy, length); - UnlockDisplay (dpy); - SyncHandle (); - return False; - } else { - _XRead(dpy, (char *) *ptr, numbytes); - if (slop) _XEatData(dpy, 4-slop); - } - exists = rep.flags; - UnlockDisplay (dpy); - SyncHandle (); - return exists; -} - -static Bool XNVCTRLQueryStringAttribute ( - Display *dpy, - int screen, - unsigned int display_mask, - unsigned int attribute, - char **ptr -){ - return XNVCTRLQueryTargetStringAttribute(dpy, NV_CTRL_TARGET_TYPE_X_SCREEN, - screen, display_mask, - attribute, ptr); -} - - -Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ) -{ - int event_base; - int error_base; - - if (isCapable) - *isCapable = False; - - if (!XNVCTRLQueryExtension(dpy, &event_base, &error_base)) - return False; - - if (isCapable && XNVCTRLIsNvScreen(dpy, screen)) - *isCapable = True; - - return True; -} - -Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ) -{ - if (ddxDriverMajorVersion) - *ddxDriverMajorVersion = 0; - if (ddxDriverMinorVersion) - *ddxDriverMinorVersion = 0; - if (ddxDriverPatchVersion) - *ddxDriverPatchVersion = 0; - if (clientDriverName) - *clientDriverName = NULL; - - char *nvidia_driver_version = NULL; - if (!XNVCTRLQueryStringAttribute(dpy, screen, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, &nvidia_driver_version)) - return False; - - char *end, *str = nvidia_driver_version; - unsigned long v = strtoul(str, &end, 10); - if (end && end != str) { - if (ddxDriverMajorVersion) - *ddxDriverMajorVersion = v; - if (*(str = end) == '.') { - v = strtoul(str + 1, &end, 10); - if (end && end != str && (*end == '.' || *end == '\0')) { - if (ddxDriverMinorVersion) - *ddxDriverMinorVersion = v; - if (*(str = end) == '.') { - v = strtoul(str + 1, &end, 10); - if (end && end != str && *end == '\0') { - if (ddxDriverPatchVersion) - *ddxDriverPatchVersion = v; - } - } - } - } - } - Xfree(nvidia_driver_version); - - if (clientDriverName) - *clientDriverName = strdup("nvidia"); - - return True; -} diff --git a/va/x11/va_nvctrl.h b/va/x11/va_nvctrl.h deleted file mode 100644 index 3617537..0000000 --- a/va/x11/va_nvctrl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008 NVIDIA, Corporation - * - * 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, sublicense, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS 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_NVCTRLLIB_H -#define VA_NVCTRLLIB_H - -#include - -DLL_HIDDEN -Bool VA_NVCTRLQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ); - -DLL_HIDDEN -Bool VA_NVCTRLGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ); - -#endif /* VA_NVCTRLLIB_H */ diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c deleted file mode 100644 index a8db4c8..0000000 --- a/va/x11/va_x11.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * 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. - */ - -#define _GNU_SOURCE 1 -#include "sysdeps.h" -#include "va.h" -#include "va_backend.h" -#include "va_trace.h" -#include "va_fool.h" -#include "va_x11.h" -#include "va_dri2.h" -#include "va_dricommon.h" -#include "va_nvctrl.h" -#include "va_fglrx.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int va_DisplayContextIsValid ( - VADisplayContextP pDisplayContext -) -{ - return (pDisplayContext != NULL && - pDisplayContext->pDriverContext != NULL); -} - -static void va_DisplayContextDestroy ( - VADisplayContextP pDisplayContext -) -{ - VADriverContextP ctx; - struct dri_state *dri_state; - - if (pDisplayContext == NULL) - return; - - ctx = pDisplayContext->pDriverContext; - dri_state = ctx->drm_state; - - if (dri_state && dri_state->close) - dri_state->close(ctx); - - free(pDisplayContext->pDriverContext->drm_state); - free(pDisplayContext->pDriverContext); - free(pDisplayContext); -} - - -static VAStatus va_DRI2GetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VADriverContextP ctx = pDisplayContext->pDriverContext; - - if (!isDRI2Connected(ctx, driver_name)) - return VA_STATUS_ERROR_UNKNOWN; - - return VA_STATUS_SUCCESS; -} - -static VAStatus va_NVCTRL_GetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VADriverContextP ctx = pDisplayContext->pDriverContext; - int direct_capable, driver_major, driver_minor, driver_patch; - Bool result; - - result = VA_NVCTRLQueryDirectRenderingCapable(ctx->native_dpy, ctx->x11_screen, - &direct_capable); - if (!result || !direct_capable) - return VA_STATUS_ERROR_UNKNOWN; - - result = VA_NVCTRLGetClientDriverName(ctx->native_dpy, ctx->x11_screen, - &driver_major, &driver_minor, - &driver_patch, driver_name); - if (!result) - return VA_STATUS_ERROR_UNKNOWN; - - return VA_STATUS_SUCCESS; -} - -static VAStatus va_FGLRX_GetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VADriverContextP ctx = pDisplayContext->pDriverContext; - int driver_major, driver_minor, driver_patch; - Bool result; - - result = VA_FGLRXGetClientDriverName(ctx->native_dpy, ctx->x11_screen, - &driver_major, &driver_minor, - &driver_patch, driver_name); - if (!result) - return VA_STATUS_ERROR_UNKNOWN; - - return VA_STATUS_SUCCESS; -} - -static VAStatus va_DisplayContextGetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VAStatus vaStatus; - - if (driver_name) - *driver_name = NULL; - else - return VA_STATUS_ERROR_UNKNOWN; - - vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); - if (vaStatus != VA_STATUS_SUCCESS) - vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name); - if (vaStatus != VA_STATUS_SUCCESS) - vaStatus = va_FGLRX_GetDriverName(pDisplayContext, driver_name); - return vaStatus; -} - - -VADisplay vaGetDisplay ( - Display *native_dpy /* implementation specific */ -) -{ - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext; - - if (!native_dpy) - return NULL; - - if (!dpy) - { - /* create new entry */ - VADriverContextP pDriverContext; - struct dri_state *dri_state; - pDisplayContext = calloc(1, sizeof(*pDisplayContext)); - pDriverContext = calloc(1, sizeof(*pDriverContext)); - dri_state = calloc(1, sizeof(*dri_state)); - if (pDisplayContext && pDriverContext && dri_state) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - pDriverContext->native_dpy = (void *)native_dpy; - pDriverContext->x11_screen = XDefaultScreen(native_dpy); - pDriverContext->display_type = VA_DISPLAY_X11; - pDisplayContext->pDriverContext = pDriverContext; - pDisplayContext->vaIsValid = va_DisplayContextIsValid; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - pDisplayContext->opaque = NULL; - pDriverContext->drm_state = dri_state; - dpy = (VADisplay)pDisplayContext; - } - else - { - if (pDisplayContext) - free(pDisplayContext); - if (pDriverContext) - free(pDriverContext); - if (dri_state) - free(dri_state); - } - } - - return dpy; -} - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } - -void va_TracePutSurface ( - VADisplay dpy, - VASurfaceID surface, - void *draw, /* the target Drawable */ - 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 vaPutSurface ( - VADisplay dpy, - VASurfaceID surface, - Drawable draw, /* X Drawable */ - 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 */ -) -{ - VADriverContextP ctx; - - if (fool_postp) - return VA_STATUS_SUCCESS; - - CHECK_DISPLAY(dpy); - ctx = CTX(dpy); - - VA_TRACE_LOG(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, - destx, desty, destw, desth, - cliprects, number_cliprects, flags ); -} -- cgit v1.2.3