diff options
author | 2010-04-24 17:27:00 -0400 | |
---|---|---|
committer | 2010-04-24 17:27:00 -0400 | |
commit | bd1c4e26a2c6ca07657bca598cc458301b4d8a1e (patch) | |
tree | e4c1377710eab84a22c029503fd455b0cf0168e4 | |
download | xhub-bd1c4e26a2c6ca07657bca598cc458301b4d8a1e.tar.gz xhub-bd1c4e26a2c6ca07657bca598cc458301b4d8a1e.tar.bz2 xhub-bd1c4e26a2c6ca07657bca598cc458301b4d8a1e.zip |
Initial import
35 files changed, 7919 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/dev-python/mechanize/Manifest b/dev-python/mechanize/Manifest new file mode 100644 index 0000000..b430b30 --- /dev/null +++ b/dev-python/mechanize/Manifest @@ -0,0 +1,3 @@ +DIST mechanize-0.2.0.tar.gz 378487 RMD160 21fb32522945e9380b36de8fb7b472fe05bd2caa SHA1 d95456ba625c8a152a1e01ddfb7d3570d62a53af SHA256 af26a30f16d9f7d53ef9b000ca0bcf173ba5ba1c108f7fdd218f1e90fedc6221 +EBUILD mechanize-0.2.0.ebuild 1469 RMD160 1e113776e6321a00f0736507ea17d6cb0cb4b80d SHA1 433017a6d3995f4444fccb2942cdaea35b9ab12c SHA256 2860054094a8283fab8f2f90e280ccb388d0a0916ea2129dc4074478ca6ea3ce +MISC metadata.xml 791 RMD160 cf985c27f79156886aa162185fd8aac175639a4b SHA1 093dcb8ca0afca8a49df42e9c6b5be710a58a0f8 SHA256 8a1186c5e48058b31202900e47ed5e2938f5e53d3a419828a9049e6cb9d3b87f diff --git a/dev-python/mechanize/mechanize-0.2.0.ebuild b/dev-python/mechanize/mechanize-0.2.0.ebuild new file mode 100644 index 0000000..4668534 --- /dev/null +++ b/dev-python/mechanize/mechanize-0.2.0.ebuild @@ -0,0 +1,49 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/mechanize/mechanize-0.2.0.ebuild,v 1.1 2010/04/24 10:33:34 djc Exp $ + +EAPI="2" +SUPPORT_PYTHON_ABIS="1" + +inherit distutils eutils + +DESCRIPTION="Stateful programmatic web browsing in Python" +HOMEPAGE="http://wwwsearch.sourceforge.net/mechanize/ http://pypi.python.org/pypi/mechanize" +SRC_URI="http://wwwsearch.sourceforge.net/${PN}/src/${P}.tar.gz" + +LICENSE="|| ( BSD ZPL )" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~sparc ~x86 ~amd64-linux ~ia64-linux ~x86-linux ~x86-macos" +IUSE="" + +DEPEND="" +RDEPEND="" +RESTRICT_PYTHON_ABIS="3.*" + +DOCS="docs/*.txt" + +src_prepare() { + # Use distutils instead of setuptools. + # (This can't be removed in the same ${PV} due to file->directory replacement.) + sed -e 's/not hasattr(sys, "version_info")/True/' -i setup.py || die "sed in setup.py failed" + + # We don't run coverage tests or functional_tests + # which access the network, just doctests and unit tests + sed -e '/import coverage/d' -i test.py || die "sed in test.py failed" +} + +src_test() { + testing() { + # ignore warnings http://github.com/jjlee/mechanize/issues/issue/13 + PYTHONPATH="build-${PYTHON_ABI}/lib" "$(PYTHON)" -Wignore test.py + } + python_execute_function testing +} + +src_install() { + # Fix some paths. + sed -i -e 's:../styles/:styles/:g' docs/html/* + dohtml -r docs/html/ docs/styles + + distutils_src_install +} diff --git a/dev-python/mechanize/metadata.xml b/dev-python/mechanize/metadata.xml new file mode 100644 index 0000000..0a3f10c --- /dev/null +++ b/dev-python/mechanize/metadata.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <herd>python</herd> + <longdescription lang="en"> + mechanize is a Python module for static programmatic web browsing in + Python, after Andy Lester's Perl module WWW::Mechanize. With the Browser + subclass any url can be opened - not just http - and UserAgentBase + offers easy dynamic configuration of user-agent features like protocol, + cookie, redirection and robots.txt handling. Other functionalities + include easy HTML form filling using ClientForm interface, convenient + link parsing and following, browser history with .back() and .reload() + methods and automatic handling of HTTP-Equiv and Refresh. + </longdescription> +</pkgmetadata> diff --git a/dev-tex/tkz-berge/Manifest b/dev-tex/tkz-berge/Manifest new file mode 100644 index 0000000..d1297b7 --- /dev/null +++ b/dev-tex/tkz-berge/Manifest @@ -0,0 +1,3 @@ +DIST tkz-arith.sty 10317 RMD160 4001e1d8b12f22152629dd0b90e059db97454153 SHA1 1b1eeda635a29307b7b550423df01a8384dfe09f SHA256 117bc99116eff00a4ab0cbcafa6f2caf5a6b4e5e7b63dcc2013d2ddf713d17a2 +DIST tkz-berge.sty 78194 RMD160 1910b787ee89222cdb936dda4420095482de04a7 SHA1 aa509422f4069917e5a55439a46d32acb33e99ad SHA256 2b1179596307dc173f954bfff52bcff1f798bfeaf6acbe3eefa036637f7264d9 +EBUILD tkz-berge-2.8.ebuild 767 RMD160 e7055e0bbdb747b39b704c1ce972a0fc419bb241 SHA1 79f66a14b5b24e949451074aa9367ab73ccb52b4 SHA256 eb45b9c46472ee6373c6c1c88c4f22b08eaf6247f3a6ece00fdb3ee9740906e3 diff --git a/dev-tex/tkz-berge/tkz-berge-2.8.ebuild b/dev-tex/tkz-berge/tkz-berge-2.8.ebuild new file mode 100644 index 0000000..bcadb1f --- /dev/null +++ b/dev-tex/tkz-berge/tkz-berge-2.8.ebuild @@ -0,0 +1,36 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit latex-package + +DESCRIPTION="This is a sample skeleton ebuild file" +HOMEPAGE="http://altermundus.com/pages/graphtheory.html" +SRC_URI="http://altermundus.com/downloads/packages/tkz-arith.sty + http://altermundus.com/downloads/packages/${PN}.sty" + +# TODO: no license found + +LICENSE="" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86" +IUSE="" + +# TODO: examples + +RESTRICT="mirror" + +# TODO: check dependencies + +DEPEND=">=dev-tex/tkz-graph-2.7d" +RDEPEND="${DEPEND}" + +# TODO: is there a more convenient way to do the following ? + +src_unpack() { + mkdir "${S}" || die "mkdir failed" + + for i in ${A} ; do + cp "${DISTDIR}"/${i} "${S}" || die "cp failed" + done +} diff --git a/dev-tex/tkz-graph/Manifest b/dev-tex/tkz-graph/Manifest new file mode 100644 index 0000000..2b13456 --- /dev/null +++ b/dev-tex/tkz-graph/Manifest @@ -0,0 +1,2 @@ +DIST tkz-graph.sty 43480 RMD160 41d2a4379a90dd233243e3d0b625018e0989d774 SHA1 f731af8bc47435d779f45918a049dbb39f6e0f78 SHA256 38e499f1b59452f9d93d7c6f3f2499050da4d929e9b8479e7ec6c9066bfe9c68 +EBUILD tkz-graph-2.7d.ebuild 681 RMD160 6ec4e57f71d298e3dd55463acc8a4433b515bc23 SHA1 61053b7769ef66d413a9436670a4318bb5b71faf SHA256 2396b84a3bef38f4ba977d1b35f09458bc855eaf27dc0d6eee320856880d3550 diff --git a/dev-tex/tkz-graph/tkz-graph-2.7d.ebuild b/dev-tex/tkz-graph/tkz-graph-2.7d.ebuild new file mode 100644 index 0000000..e237e2e --- /dev/null +++ b/dev-tex/tkz-graph/tkz-graph-2.7d.ebuild @@ -0,0 +1,32 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +inherit latex-package + +DESCRIPTION="tkz-graph is a set of convenient macros for drawing graphs" +HOMEPAGE="http://altermundus.com/pages/graph.html" +SRC_URI="http://altermundus.com/downloads/packages/${PN}.sty" + +# TODO: could not find a license + +LICENSE="" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~x86" +IUSE="" + +# TODO: examples + +RESTRICT="mirror" + +# TODO: check dependencies + +DEPEND="" +RDEPEND="${DEPEND}" + +# TODO: is there a more convenient way to do the following ? + +src_unpack() { + mkdir "${S}" || die "mkdir failed" + cp "${DISTDIR}"/${A} "${S}" || die "cp failed" +} diff --git a/kde-misc/basket/Manifest b/kde-misc/basket/Manifest new file mode 100644 index 0000000..669bbb5 --- /dev/null +++ b/kde-misc/basket/Manifest @@ -0,0 +1,3 @@ +AUX basket-1.80-crypt.patch 878 RMD160 28873c7d93f53a8a775cc92705f8141c14d8baa6 SHA1 df119c18f39830cb42b2f0c8ba1ae77009800c4e SHA256 fede246f73c51eccc72347f652e9bf52b6de14126663844d21c96f51bc363d8f +DIST basket-1.80.tar.bz2 4167408 RMD160 410bfdf64486ad01c459438fb29fc60b09b3fc40 SHA1 ffc3cadee631240e10f03c870de1fd1a10a8149c SHA256 7358dfb9722c38e98369d5ef783f684dc4f9179ddb157d65bd348648b071016f +EBUILD basket-1.80.ebuild 629 RMD160 876d54e946406e0b5bb2f4c6e2eeca209c479474 SHA1 81b4af796f23318b9779cb2f297f0f664602cbc4 SHA256 650e5be5e9a428c6887c694e816b0c766e3ebfe272cb0f4f541629f949c8da62 diff --git a/kde-misc/basket/basket-1.80.ebuild b/kde-misc/basket/basket-1.80.ebuild new file mode 100644 index 0000000..82c4c3a --- /dev/null +++ b/kde-misc/basket/basket-1.80.ebuild @@ -0,0 +1,33 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" + +inherit kde4-base + +DESCRIPTION="A DropDrawers clone. Multiple information organizer" +HOMEPAGE="http://basket.kde.org/" +SRC_URI="http://${PN}.kde.org/downloads/${P}.tar.bz2" + +LICENSE="GPL-2" +KEYWORDS="~amd64" +SLOT="4" + +IUSE="debug crypt" + +DEPEND=" + >=kde-base/kdelibs-4.4.0 + >=kde-base/kdepimlibs-4.4.0 + crypt? ( >=app-crypt/gpgme-1.0 ) +" +RDEPEND=${DEPEND} + +PATCHES=( "${FILESDIR}/${P}-crypt.patch" ) + +src_configure() { + mycmakeargs=( + $(cmake-utils_use_enable crypt) + ) + kde4-base_src_configure +} diff --git a/kde-misc/basket/files/basket-1.80-crypt.patch b/kde-misc/basket/files/basket-1.80-crypt.patch new file mode 100644 index 0000000..dc8aa68 --- /dev/null +++ b/kde-misc/basket/files/basket-1.80-crypt.patch @@ -0,0 +1,30 @@ +diff -r -u basket-1.80-vanilla/CMakeLists.txt basket-1.80/CMakeLists.txt +--- basket-1.80-vanilla/CMakeLists.txt 2010-03-20 21:20:57.000000000 +0100 ++++ basket-1.80/CMakeLists.txt 2010-03-28 22:04:43.000000000 +0200 +@@ -1,5 +1,7 @@ + cmake_minimum_required(VERSION 2.4) + ++OPTION(ENABLE_CRYPT "build encryption support" ON) ++ + find_package(KDE4 REQUIRED) + find_package(QImageBlitz REQUIRED) + find_package(Gpgme) +@@ -15,13 +17,14 @@ + + include(MacroLibrary) + +-IF(GPGME_FOUND) ++IF(GPGME_FOUND AND ENABLE_CRYPT) + SET(HAVE_LIBGPGME 1) + SET(LARGEFILE_SOURCE_1) + ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) +-ELSE(GPGME_FOUND) +- MESSAGE("GPG not found, configuring without") +-ENDIF(GPGME_FOUND) ++ MESSAGE("Configuring with GPG support") ++ELSE(GPGME_FOUND AND ENABLE_CRYPT) ++ MESSAGE("Configuring without GPG support") ++ENDIF(GPGME_FOUND AND ENABLE_CRYPT) + + #TODO: find meinproc + diff --git a/media-tv/v4l2ucp/Manifest b/media-tv/v4l2ucp/Manifest new file mode 100644 index 0000000..42a36f1 --- /dev/null +++ b/media-tv/v4l2ucp/Manifest @@ -0,0 +1,2 @@ +DIST v4l2ucp-2.0.2.tar.bz2 41380 RMD160 c82e139f5733843087832968a8c11df64ab93a1b SHA1 12960ae7b8bceaff017ac26d377fe4ef13628289 SHA256 e525add8788fa9ce613705a2a88947d4d1ef1c2bde8aa9f3e8ef19207271c1be +EBUILD v4l2ucp-2.0.2.ebuild 423 RMD160 0928c2743a7ae76136cf7d7da89f9f6bec6198c2 SHA1 b77a2e7f45ae41c6b480bd5b01bc1ae9a96d8e68 SHA256 4f84dda44c6c8c828d0b395517f9a3dd4c3cf9f798a5d065fa4097765cf15091 diff --git a/media-tv/v4l2ucp/v4l2ucp-2.0.2.ebuild b/media-tv/v4l2ucp/v4l2ucp-2.0.2.ebuild new file mode 100644 index 0000000..98ebcb0 --- /dev/null +++ b/media-tv/v4l2ucp/v4l2ucp-2.0.2.ebuild @@ -0,0 +1,19 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=2 +inherit cmake-utils + +DESCRIPTION="A universal control panel for all Video for Linux Two (V4L2) +devices" +HOMEPAGE="http://v4l2ucp.sf.net/" +SRC_URI="mirror://sourceforge/v4l2ucp/${P}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +DEPEND="x11-libs/qt-gui:4 + media-libs/libv4l" diff --git a/media-video/ffmpeg/Manifest b/media-video/ffmpeg/Manifest new file mode 100644 index 0000000..c8db9da --- /dev/null +++ b/media-video/ffmpeg/Manifest @@ -0,0 +1,3 @@ +DIST ffmpeg-0.5_p22846.tar.bz2 3675057 RMD160 3ebd997321d59fa0baf87329518e925ccbed3cf8 SHA1 d207570ed009b63c94485ccc64439107cf700f39 SHA256 a52d82476afa7c8ed62c1a52760e49907947c1ef1ecfc3e9022fa713e9783f2f +EBUILD ffmpeg-0.5_p22846.ebuild 7655 RMD160 76a3dbc9ba1f52d8f8aa8d1aac3ce5bd16d359d3 SHA1 7e20bdff4d08f92ee407f6f96db9876d32c023e2 SHA256 85e5cc2848fcbabfd3bc3d585bd58536044847b34af63ffaeb4f061a08d2bcc0 +MISC metadata.xml 1876 RMD160 3fed4cfedd4cd693c1053bd4ea90c75260aa2815 SHA1 827e1fc2f346f5c8695d45c4697dbcd4fbc47462 SHA256 a2b6f4fce6ae13c3cdc007124cea38857942efeb7fac9779487d087b6068ca52 diff --git a/media-video/ffmpeg/ffmpeg-0.5_p22846.ebuild b/media-video/ffmpeg/ffmpeg-0.5_p22846.ebuild new file mode 100644 index 0000000..4d36b2f --- /dev/null +++ b/media-video/ffmpeg/ffmpeg-0.5_p22846.ebuild @@ -0,0 +1,248 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/media-video/ffmpeg/ffmpeg-0.5_p22846.ebuild,v 1.2 2010/04/23 12:53:48 ssuominen Exp $ + +EAPI=2 +SCM="" +if [ "${PV#9999}" != "${PV}" ] ; then + SCM=subversion + ESVN_REPO_URI="svn://svn.ffmpeg.org/ffmpeg/trunk" +fi + +inherit eutils flag-o-matic multilib toolchain-funcs ${SCM} + +DESCRIPTION="Complete solution to record, convert and stream audio and video. Includes libavcodec." +HOMEPAGE="http://ffmpeg.org/" +if [ "${PV#9999}" != "${PV}" ] ; then + SRC_URI="" +elif [ "${PV%_p*}" != "${PV}" ] ; then # Snapshot + SRC_URI="mirror://gentoo/${P}.tar.bz2" +else # Release + SRC_URI="http://ffmpeg.org/releases/${P}.tar.bz2" +fi +FFMPEG_REVISION="${PV#*_p}" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd" +IUSE="+3dnow +3dnowext alsa altivec cpudetection custom-cflags debug dirac + doc ieee1394 +encode faac faad gsm jack +mmx +mmxext vorbis test + theora threads x264 xvid network zlib sdl X mp3 amr + oss pic schroedinger +hardcoded-tables bindist v4l v4l2 + speex +ssse3 jpeg2k vdpau vaapi" + +VIDEO_CARDS="nvidia" + +for x in ${VIDEO_CARDS}; do + IUSE="${IUSE} video_cards_${x}" +done + +RDEPEND="sdl? ( >=media-libs/libsdl-1.2.10 ) + alsa? ( media-libs/alsa-lib ) + encode? ( + faac? ( media-libs/faac ) + mp3? ( media-sound/lame ) + vorbis? ( media-libs/libvorbis media-libs/libogg ) + theora? ( >=media-libs/libtheora-1.1.1[encode] media-libs/libogg ) + x264? ( >=media-libs/x264-0.0.20100118 ) + xvid? ( >=media-libs/xvid-1.1.0 ) ) + faad? ( >=media-libs/faad2-2.6.1 ) + zlib? ( sys-libs/zlib ) + ieee1394? ( media-libs/libdc1394 + sys-libs/libraw1394 ) + dirac? ( media-video/dirac ) + gsm? ( >=media-sound/gsm-1.0.12-r1 ) + jpeg2k? ( >=media-libs/openjpeg-1.3-r2 ) + amr? ( media-libs/opencore-amr ) + schroedinger? ( media-libs/schroedinger ) + speex? ( >=media-libs/speex-1.2_beta3 ) + jack? ( media-sound/jack-audio-connection-kit ) + vaapi? ( x11-libs/libva ) + X? ( x11-libs/libX11 x11-libs/libXext ) + video_cards_nvidia? ( + vdpau? ( x11-libs/libvdpau ) + )" + +DEPEND="${RDEPEND} + >=sys-devel/make-3.81 + dirac? ( dev-util/pkgconfig ) + schroedinger? ( dev-util/pkgconfig ) + mmx? ( dev-lang/yasm ) + doc? ( app-text/texi2html ) + test? ( net-misc/wget ) + v4l? ( sys-kernel/linux-headers ) + v4l2? ( sys-kernel/linux-headers )" + +src_prepare() { + if [[ ${PV} = *9999* ]]; then + # Set SVN version manually + subversion_wc_info + sed -i s/UNKNOWN/SVN-r${ESVN_WC_REVISION}/ "${S}/version.sh" + elif [ "${PV%_p*}" != "${PV}" ] ; then # Snapshot + sed -i s/UNKNOWN/SVN-r${FFMPEG_REVISION}/ "${S}/version.sh" + fi +} + +src_configure() { + local myconf="${EXTRA_FFMPEG_CONF}" + + # enabled by default + use debug || myconf="${myconf} --disable-debug" + use zlib || myconf="${myconf} --disable-zlib" + use sdl || myconf="${myconf} --disable-ffplay" + use network || myconf="${myconf} --disable-network" + + use custom-cflags && myconf="${myconf} --disable-optimizations" + use cpudetection && myconf="${myconf} --enable-runtime-cpudetect" + + # enabled by default + if use encode + then + use mp3 && myconf="${myconf} --enable-libmp3lame" + use vorbis && myconf="${myconf} --enable-libvorbis" + use theora && myconf="${myconf} --enable-libtheora" + use x264 && myconf="${myconf} --enable-libx264" + use xvid && myconf="${myconf} --enable-libxvid" + if use bindist + then + use faac && ewarn "faac is nonfree and cannot be distributed; + disabling faac support." + else + use faac && myconf="${myconf} --enable-libfaac --enable-nonfree" + fi + else + myconf="${myconf} --disable-encoders" + fi + + # libavdevice options + use ieee1394 && myconf="${myconf} --enable-libdc1394" + # Indevs + for i in v4l v4l2 alsa oss jack ; do + use $i || myconf="${myconf} --disable-indev=$i" + done + # Outdevs + for i in alsa oss ; do + use $i || myconf="${myconf} --disable-outdev=$i" + done + use X && myconf="${myconf} --enable-x11grab" + + # Threads; we only support pthread for now but ffmpeg supports more + use threads && myconf="${myconf} --enable-pthreads" + + # Decoders + use amr && myconf="${myconf} --enable-libopencore-amrwb + --enable-libopencore-amrnb" + for i in gsm faad dirac schroedinger speex; do + use $i && myconf="${myconf} --enable-lib$i" + done + use jpeg2k && myconf="${myconf} --enable-libopenjpeg" + + #for i in h264_vdpau mpeg1_vdpau mpeg_vdpau vc1_vdpau wmv3_vdpau; do + # use video_cards_nvidia || myconf="${myconf} --disable-decoder=$i" + # use vdpau || myconf="${myconf} --disable-decoder=$i" + #done + use video_cards_nvidia || myconf="${myconf} --disable-vdpau" + use vdpau || myconf="${myconf} --disable-vdpau" + use vaapi || myconf="${myconf} --disable-vaapi" + + # CPU features + for i in mmx ssse3 altivec ; do + use $i || myconf="${myconf} --disable-$i" + done + use mmxext || myconf="${myconf} --disable-mmx2" + use 3dnow || myconf="${myconf} --disable-amd3dnow" + use 3dnowext || myconf="${myconf} --disable-amd3dnowext" + # disable mmx accelerated code if PIC is required + # as the provided asm decidedly is not PIC. + if gcc-specs-pie ; then + myconf="${myconf} --disable-mmx --disable-mmx2" + fi + + # Option to force building pic + use pic && myconf="${myconf} --enable-pic" + + # Try to get cpu type based on CFLAGS. + # Bug #172723 + # We need to do this so that features of that CPU will be better used + # If they contain an unknown CPU it will not hurt since ffmpeg's configure + # will just ignore it. + for i in $(get-flag march) $(get-flag mcpu) $(get-flag mtune) ; do + [ "${i}" = "native" ] && i="host" # bug #273421 + [[ ${i} = *-sse3 ]] && i="${i%-sse3}" # bug 283968 + myconf="${myconf} --cpu=$i" + break + done + + # Mandatory configuration + myconf="${myconf} --enable-gpl --enable-version3 --enable-postproc \ + --enable-avfilter --enable-avfilter-lavf \ + --disable-stripping" + + # cross compile support + if tc-is-cross-compiler ; then + myconf="${myconf} --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}-" + case ${CHOST} in + *freebsd*) + myconf="${myconf} --target-os=freebsd" + ;; + mingw32*) + myconf="${myconf} --target-os=mingw32" + ;; + *linux*) + myconf="${myconf} --target-os=linux" + ;; + esac + fi + + # Misc stuff + use hardcoded-tables && myconf="${myconf} --enable-hardcoded-tables" + use doc || myconf="${myconf} --disable-doc" + + # Specific workarounds for too-few-registers arch... + if [[ $(tc-arch) == "x86" ]]; then + filter-flags -fforce-addr -momit-leaf-frame-pointer + append-flags -fomit-frame-pointer + is-flag -O? || append-flags -O2 + if (use debug); then + # no need to warn about debug if not using debug flag + ewarn "" + ewarn "Debug information will be almost useless as the frame pointer is omitted." + ewarn "This makes debugging harder, so crashes that has no fixed behavior are" + ewarn "difficult to fix. Please have that in mind." + ewarn "" + fi + fi + + cd "${S}" + ./configure \ + --prefix=/usr \ + --libdir=/usr/$(get_libdir) \ + --shlibdir=/usr/$(get_libdir) \ + --mandir=/usr/share/man \ + --enable-static --enable-shared \ + --cc="$(tc-getCC)" \ + ${myconf} || die "configure failed" +} + +src_compile() { + emake version.h || die #252269 + emake || die "make failed" +} + +src_install() { + emake DESTDIR="${D}" install install-man || die "Install Failed" + + dodoc Changelog README INSTALL + dodoc doc/* +} + +src_test() { + if use encode ; then + for t in codectest lavftest seektest ; do + LD_LIBRARY_PATH="${S}/libpostproc:${S}/libswscale:${S}/libavcodec:${S}/libavdevice:${S}/libavfilter:${S}/libavformat:${S}/libavutil" \ + emake ${t} || die "Some tests in ${t} failed" + done + else + ewarn "Tests fail without USE=encode, skipping" + fi +} diff --git a/media-video/ffmpeg/metadata.xml b/media-video/ffmpeg/metadata.xml new file mode 100644 index 0000000..95a667d --- /dev/null +++ b/media-video/ffmpeg/metadata.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <herd>video</herd> + <maintainer> + <email>media-video@gentoo.org</email> + </maintainer> + <use> + <flag name="3dnowext"> + Enable manually-optimised routines using the AMD 3DNow!Ex SIMD + instruction set, present in modern AMD CPUs. (Check for + 3dnowext in /proc/cpuinfo to know whehter you support it). + </flag> + <flag name="amr">Enables Adaptive Multi-Rate Audio support</flag> + <flag name="cpudetection">Enables runtime cpudetection (useful for bindist, compatability on other CPUs)</flag> + <flag name="dirac">Enable Dirac video support (an advanced royalty-free video compression format) via the reference library: dirac.</flag> + <flag name="faac">Use external faac library for AAC encoding</flag> + <flag name="faad">Use external faad library for AAC decoding (instead of internal libavcodec support)</flag> + <flag name="hardcoded-tables">Use pre-calculated tables rather than calculating them on the fly.</flag> + <flag name="mmxext">Enables mmx2 support</flag> + <flag name="network">Enables network streaming support</flag> + <flag name="opencore-amr">Enables Adaptive Multi-Rate format support</flag> + <flag name="pic">Force shared libraries to be built as PIC (this is slower)</flag> + <flag name="schroedinger">Enable Dirac video support (an advanced royalty-free video compression format) via libschroedinger (high-speed implementation in C of the Dirac codec).</flag> + <flag name="ssse3">faster floating point optimization for SSSE3 capable chips (Intel Core 2 and later chips)</flag> + <flag name="vdpau">Enables VDPAU decoders (requires nVidia video cards to offload CPU processing to video card</flag> + <flag name="vhook">Enables video hooking support.</flag> + </use> +</pkgmetadata> diff --git a/media-video/mplayer/Manifest b/media-video/mplayer/Manifest new file mode 100644 index 0000000..9e2858c --- /dev/null +++ b/media-video/mplayer/Manifest @@ -0,0 +1,12 @@ +AUX vaapi/01-mplayer-vaapi.patch 108582 RMD160 b3303e75660ac6ed77ee6f849cc572a88d76322c SHA1 8525c1f682cc98db3f8cdeeeaf8030e7212d17f9 SHA256 800f9e83c9249f69ebf7ba328a5dcfc295af4c7b355a49763a4d7f0d28642699 +AUX vaapi/02-mplayer-vaapi-gma500-workaround.patch 2994 RMD160 cc3911d951c42ec1468eae4b8976697f47df050a SHA1 408c6783aae243fdb60fa7ea851cb5ec6184d4f4 SHA256 c145b2f8523bc99340d097f17c57538197b9c49175fce0b38d6eced3e06828a5 +AUX vaapi/03-mplayer-vaapi-0.29.patch 46225 RMD160 0b8ee4f9eddc9114ebc913e0e15034582bb530cb SHA1 ae12d2f93ba22c5a31145c2a06961837bdaca753 SHA256 2dbcfb4b8d83f2901a879176d82a7bcb494974d50505c701019365e17da9b307 +AUX vaapi/04-mplayer-vdpau.patch 42951 RMD160 4345ce35262156f4fd1f50164bfff7fe8856d87d SHA1 f1726ec589f50bc1d9055cd4414dc5a475ac495c SHA256 98aa3f7e5cc094b74cbcfc03104cfee4fb1b347f163a9ceca81c44f83fa0ee3f +DIST Blue-1.7.tar.bz2 222567 RMD160 1f8c539ccadc54eea5e6678839bcc8ae1e16e6eb SHA1 45e5ee7a5541a5f1cfd2678a6c9b5911ca473cb9 SHA256 8bcd39a5755c44df778ebca3119c922347abfdadb101dcef011ce2566c1fb1d8 +DIST font-arial-cp1250.tar.bz2 249705 RMD160 a2fc7ae07b0d80936ea58e168e1047efccb9eb91 SHA1 ccf11dce5d0fb72fd3af97f788b7471cd0cd0b68 SHA256 423a07e780bb130cd8e4730715545c5d919c248dda595aab7a0a01de3c83fd12 +DIST font-arial-iso-8859-1.tar.bz2 234242 RMD160 666697cd5efd9387057a898c714175e7c2aacbcd SHA1 152c40bf20de34aa8802d7f80d34d673b0b67212 SHA256 9730f481764f367c9089d0166fb6ccf9148808ffbbfeca635cf0e6db75765d29 +DIST font-arial-iso-8859-2.tar.bz2 222208 RMD160 562d4d92c4f5f3d537340fde3ad8d1495ac41acb SHA1 7b99bbe0e9ba89a57eccbea8f93c453c4f268181 SHA256 71debfc960007c2f6242dfc91e8b1c005b30a99e129aeb00ab8c03f4371b41c1 +DIST mplayer-1.0_rc4_p20100213.tbz2 8811960 RMD160 b6991ef2dde9497bcffa32687f484598956db983 SHA1 350d39f2b42f5c5065abe7d64a4d759a9efa56f4 SHA256 59c09f6388ad15d12f74ae18ebe07945392e40d9096d5598bd496f857722bcb0 +DIST svgalib_helper-1.9.17-mplayer.tar.gz 7583 RMD160 927ff34f187e4fa9528e2e48208173d98b3d1d1b SHA1 bf789706d1d79c695f781644c7ea6d57c3eed4c3 SHA256 a6f803f3df4cd4544751d3a3ee936a8bf0e20e32a452639b3f7c7d9e73e65938 +EBUILD mplayer-1.0_rc4_p20100213-r50.ebuild 19997 RMD160 62eb81a0e2d191ea8f9b1885c41713dccfab64d9 SHA1 dccd864a627578c99771854b3e2658cbf051ff8d SHA256 33b92a21393826a39e4438af0df8a3153cd03b84ba5c3571425a43c7b454b185 +MISC metadata.xml 3591 RMD160 883e9161526d98f546d5b790a76da78ae6b03b94 SHA1 bf3ab6509cfa4a72a088ba005c9a92e44bac6df1 SHA256 956383713923533a4caa6e39fbe8067b2afa7c7aecc3e52c9dd0715435226ef8 diff --git a/media-video/mplayer/files/vaapi/01-mplayer-vaapi.patch b/media-video/mplayer/files/vaapi/01-mplayer-vaapi.patch new file mode 100644 index 0000000..f75e945 --- /dev/null +++ b/media-video/mplayer/files/vaapi/01-mplayer-vaapi.patch @@ -0,0 +1,3368 @@ +diff --git a/Makefile b/Makefile +index 49de59b..da1a2a4 100644 +--- a/Makefile ++++ b/Makefile +@@ -631,6 +631,7 @@ SRCS_MPLAYER-$(TDFXVID) += libvo/vo_tdfx_vid.c + SRCS_MPLAYER-$(TGA) += libvo/vo_tga.c + SRCS_MPLAYER-$(V4L2) += libvo/vo_v4l2.c + SRCS_MPLAYER-$(V4L2) += libao2/ao_v4l2.c ++SRCS_MPLAYER-$(VAAPI) += libvo/vo_vaapi.c + SRCS_MPLAYER-$(VDPAU) += libvo/vo_vdpau.c + SRCS_MPLAYER-$(VESA) += libvo/gtf.c libvo/vo_vesa.c libvo/vesa_lvo.c + SRCS_MPLAYER-$(VIDIX) += libvo/vo_cvidix.c \ +@@ -684,6 +685,7 @@ SRCS_MPLAYER = command.c \ + libvo/aspect.c \ + libvo/geometry.c \ + libvo/spuenc.c \ ++ libvo/stats.c \ + libvo/video_out.c \ + libvo/vo_mpegpes.c \ + libvo/vo_null.c \ +diff --git a/cfg-common-opts.h b/cfg-common-opts.h +index dd9b691..2e30132 100644 +--- a/cfg-common-opts.h ++++ b/cfg-common-opts.h +@@ -246,6 +246,7 @@ + // {"ac", &audio_codec, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"ac", &audio_codec_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, + {"vc", &video_codec_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, ++ {"va", &video_hwaccel_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, + + // postprocessing: + #ifdef CONFIG_LIBAVCODEC +diff --git a/codec-cfg.c b/codec-cfg.c +index 5d79627..692258e 100644 +--- a/codec-cfg.c ++++ b/codec-cfg.c +@@ -214,6 +214,13 @@ static int add_to_format(char *s, char *alias,unsigned int *fourcc, unsigned int + {"IDCT_MPEG2",IMGFMT_XVMC_IDCT_MPEG2}, + {"MOCO_MPEG2",IMGFMT_XVMC_MOCO_MPEG2}, + ++ {"VAAPI_MPEG2", IMGFMT_VAAPI_MPEG2}, ++ {"VAAPI_MPEG4", IMGFMT_VAAPI_MPEG4}, ++ {"VAAPI_H263", IMGFMT_VAAPI_H263}, ++ {"VAAPI_H264", IMGFMT_VAAPI_H264}, ++ {"VAAPI_WMV3", IMGFMT_VAAPI_WMV3}, ++ {"VAAPI_VC1", IMGFMT_VAAPI_VC1}, ++ + {"VDPAU_MPEG1",IMGFMT_VDPAU_MPEG1}, + {"VDPAU_MPEG2",IMGFMT_VDPAU_MPEG2}, + {"VDPAU_H264",IMGFMT_VDPAU_H264}, +diff --git a/configure b/configure +index ab3a347..8a3c7ba 100755 +--- a/configure ++++ b/configure +@@ -357,6 +357,9 @@ Codecs: + --disable-muxer=MUXER disable specified FFmpeg muxer + --enable-muxer=MUXER enable specified FFmpeg muxer + ++Hardware acceleration: ++ --enable-vaapi enable VA API acceleration [disable] ++ + Video output: + --disable-vidix disable VIDIX [for x86 *nix] + --with-vidix-drivers[=*] list of VIDIX drivers to be compiled in +@@ -556,8 +559,7 @@ _libavparsers=$_libavparsers_all + _libavbsfs_all=$(sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]') + _libavbsfs=$_libavbsfs_all + _libavhwaccels_all=$(sed -n 's/^[^#]*HWACCEL.*(.*, *\(.*\)).*/\1_hwaccel/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]') +-# Disable all hardware accelerators for now. +-_libavhwaccels= ++_libavhwaccels=$(for h in $_libavhwaccels_all; do case $h in (*_VAAPI_HWACCEL) echo $h;; esac; done) + _libavdemuxers_all=$(sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]') + _libavdemuxers=$(echo $_libavdemuxers_all | sed -e 's/ LIB[A-Z0-9_]*_DEMUXER//g' -e s/REDIR_DEMUXER// -e s/AVISYNTH_DEMUXER//) + _libavmuxers_all=$(sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]') +@@ -574,6 +576,9 @@ _libswscale_so=auto + _libavcodec_mpegaudio_hp=yes + _mencoder=yes + _mplayer=yes ++_vaapi=auto ++_vaapi_glx=no ++_libgtop=auto + _x11=auto + _xshape=auto + _xss=auto +@@ -932,6 +937,8 @@ for ac_option do + --disable-xv) _xv=no ;; + --enable-xvmc) _xvmc=yes ;; + --disable-xvmc) _xvmc=no ;; ++ --enable-vaapi) _vaapi=yes ;; ++ --disable-vaapi) _vaapi=no ;; + --enable-vdpau) _vdpau=yes ;; + --disable-vdpau) _vdpau=no ;; + --enable-sdl) _sdl=yes ;; +@@ -4012,6 +4019,28 @@ fi + echores "$_gettimeofday" + + ++echocheck "clock_gettime()" ++cat > $TMPC << EOF ++#include <time.h> ++int main(void) { ++ struct timespec t; ++ clock_gettime(CLOCK_REALTIME, &t); ++ return 0; ++} ++EOF ++_clock_gettime=no ++cc_check -lrt && _clock_gettime=yes ++if test "$_clock_gettime" = yes ; then ++ def_clock_gettime='#define HAVE_CLOCK_GETTIME 1' ++ extra_ldflags="$extra_ldflags -lrt" ++ _need_clock_gettime=no ++else ++ def_clock_gettime='#undef HAVE_CLOCK_GETTIME' ++ _need_clock_gettime=yes ++fi ++echores "$_clock_gettime" ++ ++ + echocheck "glob()" + cat > $TMPC << EOF + #include <stdio.h> +@@ -4440,7 +4469,7 @@ else + _novomodules="x11 $_novomodules" + _res_comment="check if the dev(el) packages are installed" + # disable stuff that depends on X +- _xv=no ; _xvmc=no ; _xinerama=no ; _vm=no ; _xf86keysym=no ; _vdpau=no ++ _xv=no ; _xvmc=no ; _xinerama=no ; _vm=no ; _xf86keysym=no ; _vaapi=no ; _vdpau=no + fi + echores "$_x11" + +@@ -4571,7 +4600,7 @@ if test "$_vdpau" = yes ; then + else + def_vdpau='#define CONFIG_VDPAU 0' + _novomodules="vdpau $_novomodules" +- _libavdecoders=$(echo $_libavdecoders | sed -e s/MPEG_VDPAU_DECODER// -e s/MPEG1_VDPAU_DECODER// -e s/H264_VDPAU_DECODER// -e s/WMV3_VDPAU_DECODER// -e s/VC1_VDPAU_DECODER// -e s/MPEG4_VDPAU_DECODER//) ++ _libavdecoders=$(echo $_libavdecoders | sed -e "s/\(MPEG\|MPEG[124]\|H26[34]\|WMV3\|VC1\)_VDPAU_DECODER//g") + fi + echores "$_vdpau" + +@@ -5159,6 +5188,65 @@ else + fi + echores "$_gl" + ++echocheck "OpenGL utilities (GLU)" ++_glu=no ++if test "$_gl" = yes; then ++ cat > $TMPC << EOF ++#include <GL/glu.h> ++int main(void) { ++ gluPerspective(0.0, 0.0, 0.0, 0.0); ++ return 0; ++} ++EOF ++ cc_check -lGLU && _glu=yes ++fi ++if test "$_glu" = yes; then ++ libs_mplayer="$libs_mplayer -lGLU" ++fi ++echores "$_glu" ++ ++ ++echocheck "VA API" ++if test "$_vaapi" = yes -o "$_vaapi" = auto; then ++ _vaapi=no ++ cat > $TMPC <<EOF ++#include <va/va_x11.h> ++int main(void) { (void) vaGetDisplay(0); return 0; } ++EOF ++ cc_check -lva-x11 && _vaapi=yes ++fi ++ ++if test "$_vaapi" = yes ; then ++ def_vaapi='#define CONFIG_VAAPI 1' ++ libs_mencoder="$libs_mencoder -lva" ++ libs_mplayer="$libs_mplayer -lva-x11" ++ _vomodules="vaapi $_vomodules" ++else ++ def_vaapi='#define CONFIG_VAAPI 0' ++ _novomodules="vaapi $_novomodules" ++ _libavhwaccels=`echo $_libavhwaccels | sed -e "s/\(MPEG[124]\|H26[34]\|WMV3\|VC1\)_VAAPI_HWACCEL//g"` ++fi ++echores "$_vaapi" ++ ++echocheck "VA API (with GLX support)" ++if test "$_vaapi" = yes; then ++ _vaapi_glx=no ++ if test "$_gl" = "yes" -a "$_glu" = yes; then ++ cat > $TMPC <<EOF ++#include <va/va_glx.h> ++int main(void) { (void) vaGetDisplayGLX(0); return 0; } ++EOF ++ cc_check -lva-glx && _vaapi_glx=yes ++ fi ++fi ++if test "$_vaapi_glx" = yes; then ++ def_vaapi_glx='#define CONFIG_VAAPI_GLX 1' ++ libs_mplayer="$libs_mplayer -lva-glx" ++else ++ def_vaapi_glx='#define CONFIG_VAAPI_GLX 0' ++fi ++echores "$_vaapi_glx" ++ + + echocheck "MatrixView" + if test "$_gl" = no ; then +@@ -5174,6 +5262,31 @@ fi + echores "$matrixview" + + ++echocheck "libgtop" ++if test "$_libgtop" = auto ; then ++ _libgtop=no ++ if $_pkg_config --exists 'libgtop-2.0' ; then ++ ++cat > $TMPC << EOF ++#include <glibtop/cpu.h> ++#include <glibtop/proctime.h> ++int main(void) { return 0; } ++EOF ++cc_check $($_pkg_config --libs --cflags libgtop-2.0) && tmp_run && _libgtop=yes ++ ++ fi ++fi ++echores "$_libgtop" ++ ++if test "$_libgtop" = yes ; then ++ def_libgtop='#define CONFIG_LIBGTOP 1' ++ libs_mplayer="$libs_mplayer $($_pkg_config --libs libgtop-2.0)" ++ extra_cflags="$extra_cflags $($_pkg_config --cflags libgtop-2.0)" ++else ++ def_libgtop='#define CONFIG_LIBGTOP 0' ++fi ++ ++ + echocheck "PNG support" + if test "$_png" = auto ; then + _png=no +@@ -8676,6 +8789,7 @@ TV_V4L2 = $_tv_v4l2 + TWOLAME=$_twolame + UNRAR_EXEC = $_unrar_exec + V4L2 = $_v4l2 ++VAAPI = $_vaapi + VCD = $_vcd + VDPAU = $_vdpau + VESA = $_vesa +@@ -8761,6 +8875,7 @@ CONFIG_GPL=yes + CONFIG_LIBDIRAC_DECODER=$_libdirac_lavc + CONFIG_LIBDIRAC_ENCODER=$_libdirac_lavc + CONFIG_LIBFAAC_ENCODER=$_faac_lavc ++CONFIG_LIBGTOP=$_libgtop + CONFIG_LIBMP3LAME_ENCODER=$_mp3lame_lavc + CONFIG_LIBOPENCORE_AMRNB_DECODER=$_libopencore_amrnb + CONFIG_LIBOPENCORE_AMRNB_ENCODER=$_libopencore_amrnb +@@ -8777,6 +8892,7 @@ CONFIG_MUXERS=$_mencoder + CONFIG_POSTPROC = yes + # Prevent building libavcodec/imgresample.c with conflicting symbols + CONFIG_SWSCALE=yes ++CONFIG_VAAPI=$_vaapi + CONFIG_VDPAU=$_vdpau + CONFIG_XVMC=$_xvmc + CONFIG_ZLIB=$_zlib +@@ -8893,6 +9009,7 @@ $def_winsock2_h + + + /* system functions */ ++$def_clock_gettime + $def_gethostbyname2 + $def_gettimeofday + $def_glob +@@ -8923,6 +9040,7 @@ $def_extern_asm + $def_extern_prefix + $def_iconv + $def_kstat ++$def_libgtop + $def_macosx_bundle + $def_macosx_finder + $def_maemo +@@ -9153,6 +9271,8 @@ $def_tdfxfb + $def_tdfxvid + $def_tga + $def_v4l2 ++$def_vaapi ++$def_vaapi_glx + $def_vdpau + $def_vesa + $def_vidix +diff --git a/etc/codecs.conf b/etc/codecs.conf +index 26a0529..615f069 100644 +--- a/etc/codecs.conf ++++ b/etc/codecs.conf +@@ -190,6 +190,7 @@ videocodec ffmpeg2 + fourcc slif ; SoftLab MPEG-2 I-frames Codec + driver ffmpeg + dll "mpeg2video" ++ out VAAPI_MPEG2 + out YV12,I420,IYUV + out 422P,444P + +@@ -888,6 +889,7 @@ videocodec ffwmv3 + fourcc WMV3,wmv3 + driver ffmpeg + dll wmv3 ++ out VAAPI_WMV3 + out YV12,I420,IYUV + + videocodec ffwmv3vdpau +@@ -905,6 +907,7 @@ videocodec ffvc1 + fourcc vc-1,VC-1 + driver ffmpeg + dll vc1 ++ out VAAPI_VC1 + out YV12,I420,IYUV + + videocodec ffvc1vdpau +@@ -926,6 +929,7 @@ videocodec ffh264 + format 0x10000005 + driver ffmpeg + dll h264 ++ out VAAPI_H264 + out YV12,I420,IYUV + + videocodec ffh264vdpau +@@ -994,6 +998,7 @@ videocodec ffodivx + fourcc uldx,ULDX,VSPX + driver ffmpeg + dll mpeg4 ;opendivx ++ out VAAPI_MPEG4 + out YV12,I420,IYUV + + videocodec ffodivxvdpau +@@ -1561,6 +1566,7 @@ videocodec ffh263 + fourcc VX1K ; Agora Labs VX1000S H263 + driver ffmpeg + dll h263 ++ out VAAPI_H263 + out YV12,I420,IYUV + + videocodec ffzygo +diff --git a/fmt-conversion.c b/fmt-conversion.c +index 013e3fe..f053dc8 100644 +--- a/fmt-conversion.c ++++ b/fmt-conversion.c +@@ -18,12 +18,14 @@ + + #include "mp_msg.h" + #include "libavutil/avutil.h" ++#include "libavcodec/avcodec.h" + #include "libmpcodecs/img_format.h" + #include "fmt-conversion.h" + + static const struct { + int fmt; + enum PixelFormat pix_fmt; ++ enum CodecID codec_id; + } conversion_map[] = { + {IMGFMT_ARGB, PIX_FMT_ARGB}, + {IMGFMT_BGRA, PIX_FMT_BGRA}, +@@ -91,6 +93,17 @@ static const struct { + {IMGFMT_VDPAU_WMV3, PIX_FMT_VDPAU_WMV3}, + {IMGFMT_VDPAU_VC1, PIX_FMT_VDPAU_VC1}, + {IMGFMT_VDPAU_MPEG4, PIX_FMT_VDPAU_MPEG4}, ++ ++ /* VA API formats */ ++ {IMGFMT_VAAPI_MPEG2, PIX_FMT_VAAPI_VLD, CODEC_ID_MPEG2VIDEO}, ++ {IMGFMT_VAAPI_MPEG2_IDCT,PIX_FMT_VAAPI_IDCT, CODEC_ID_MPEG2VIDEO}, ++ {IMGFMT_VAAPI_MPEG2_MOCO,PIX_FMT_VAAPI_MOCO, CODEC_ID_MPEG2VIDEO}, ++ {IMGFMT_VAAPI_MPEG4, PIX_FMT_VAAPI_VLD, CODEC_ID_MPEG4}, ++ {IMGFMT_VAAPI_H263, PIX_FMT_VAAPI_VLD, CODEC_ID_H263}, ++ {IMGFMT_VAAPI_H264, PIX_FMT_VAAPI_VLD, CODEC_ID_H264}, ++ {IMGFMT_VAAPI_WMV3, PIX_FMT_VAAPI_VLD, CODEC_ID_WMV3}, ++ {IMGFMT_VAAPI_VC1, PIX_FMT_VAAPI_VLD, CODEC_ID_VC1}, ++ + {0, PIX_FMT_NONE} + }; + +@@ -107,12 +120,14 @@ enum PixelFormat imgfmt2pixfmt(int fmt) + return pix_fmt; + } + +-int pixfmt2imgfmt(enum PixelFormat pix_fmt) ++int pixfmt2imgfmt(enum PixelFormat pix_fmt, int codec_id) + { + int i; + int fmt; + for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++) +- if (conversion_map[i].pix_fmt == pix_fmt) ++ if (conversion_map[i].pix_fmt == pix_fmt && ++ (conversion_map[i].codec_id == 0 || ++ conversion_map[i].codec_id == codec_id)) + break; + fmt = conversion_map[i].fmt; + if (!fmt) +diff --git a/fmt-conversion.h b/fmt-conversion.h +index 9e133a8..962ca4e 100644 +--- a/fmt-conversion.h ++++ b/fmt-conversion.h +@@ -23,6 +23,6 @@ + #include "libavutil/avutil.h" + + enum PixelFormat imgfmt2pixfmt(int fmt); +-int pixfmt2imgfmt(enum PixelFormat pix_fmt); ++int pixfmt2imgfmt(enum PixelFormat pix_fmt, int codec_id); + + #endif /* MPLAYER_FMT_CONVERSION_H */ +diff --git a/gui/mplayer/gtk/opts.c b/gui/mplayer/gtk/opts.c +index f086819..3a02a9f 100644 +--- a/gui/mplayer/gtk/opts.c ++++ b/gui/mplayer/gtk/opts.c +@@ -64,9 +64,11 @@ static GtkWidget * CLVDrivers; + GtkWidget * prEFontName; + GtkWidget * prEDVDDevice; + GtkWidget * prECDRomDevice; ++static GtkWidget * EVHW; + static GtkWidget * EVFM; + static GtkWidget * EAFM; + ++static GtkWidget * CBVHW; + static GtkWidget * CBVFM; + static GtkWidget * CBAFM; + static GtkWidget * CBAudioEqualizer; +@@ -354,6 +356,26 @@ void ShowPreferences( void ) + // -- 5. page + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBNonInterlaved ),force_ni ); + if ( index_mode == 1 ) gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBIndex ),1 ); ++ ++ { ++ int i; ++ GList * Items = NULL; ++ char * name = NULL; ++ ++ Items = g_list_append(Items, MSGTR_PREFERENCES_None); ++ for (i = 0; i < HWACCEL_COUNT; i++) { ++ const char *hwaccel_name = get_video_hwaccel_name(i); ++ if (!hwaccel_name) ++ continue; ++ Items = g_list_append(Items, hwaccel_name); ++ if (video_hwaccel_name && !gstrcmp(video_hwaccel_name, get_video_hwaccel_short_name(i) ) ) name = hwaccel_name; ++ } ++ gtk_combo_set_popdown_strings(GTK_COMBO(CBVHW), Items); ++ g_list_free(Items); ++ if (name) ++ gtk_entry_set_text(GTK_ENTRY(EVHW), name); ++ } ++ + { + int i; + GList * Items = NULL; +@@ -600,6 +622,17 @@ static void prButton( GtkButton * button, gpointer user_data ) + if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBIndex ) ) ) index_mode=1; + + { ++ int i; ++ const char *tmp = gtk_entry_get_text(GTK_ENTRY(EVHW)); ++ for (i = 0; i < HWACCEL_COUNT; i++) { ++ if (!gstrcmp(tmp, get_video_hwaccel_name(i))) { ++ video_hwaccel_name = get_video_hwaccel_short_name(i); ++ break; ++ } ++ } ++ } ++ ++ { + int i; + const char * tmp = gtk_entry_get_text( GTK_ENTRY( EVFM ) ); + for( i=0;mpcodecs_vd_drivers[i];i++ ) +@@ -1199,6 +1232,20 @@ GtkWidget * create_Preferences( void ) + + hbox5=AddHBox( vbox602,1 ); + ++ AddLabel( MSGTR_PREFERENCES_VideoHardwareAcceleration,hbox5 ); ++ ++ CBVHW=gtk_combo_new(); ++ gtk_widget_set_name( CBVHW,"CBVHW" ); ++ gtk_widget_show( CBVHW ); ++ gtk_box_pack_start( GTK_BOX( hbox5 ),CBVHW,TRUE,TRUE,0 ); ++ ++ EVHW=GTK_COMBO( CBVHW )->entry; ++ gtk_widget_set_name( EVHW,"CEVHW" ); ++ gtk_entry_set_editable( GTK_ENTRY( EVHW ),FALSE ); ++ gtk_widget_show( EVHW ); ++ ++ hbox5=AddHBox( vbox602,1 ); ++ + AddLabel( MSGTR_PREFERENCES_VideoCodecFamily,hbox5 ); + + CBVFM=gtk_combo_new(); +diff --git a/help/help_mp-en.h b/help/help_mp-en.h +index 3b8cbd8..162d6cb 100644 +--- a/help/help_mp-en.h ++++ b/help/help_mp-en.h +@@ -719,6 +719,7 @@ static const char help_text[]= + #define MSGTR_PREFERENCES_IDX "Rebuild index table, if needed" + #define MSGTR_PREFERENCES_VideoCodecFamily "Video codec family:" + #define MSGTR_PREFERENCES_AudioCodecFamily "Audio codec family:" ++#define MSGTR_PREFERENCES_VideoHardwareAcceleration "Video hardware acceleration:" + #define MSGTR_PREFERENCES_FRAME_OSD_Level "OSD level" + #define MSGTR_PREFERENCES_FRAME_Subtitle "Subtitle" + #define MSGTR_PREFERENCES_FRAME_Font "Font" +@@ -1659,6 +1660,7 @@ static const char help_text[]= + #define MSGTR_MPCODECS_UnexpectedInitVoError "[VD_FFMPEG] Unexpected init_vo error.\n" + #define MSGTR_MPCODECS_UnrecoverableErrorRenderBuffersNotTaken "[VD_FFMPEG] Unrecoverable error, render buffers not taken.\n" + #define MSGTR_MPCODECS_OnlyBuffersAllocatedByVoXvmcAllowed "[VD_FFMPEG] Only buffers allocated by vo_xvmc allowed.\n" ++#define MSGTR_MPCODECS_VAAPIAcceleratedCodec "[VD_FFMPEG] VA API accelerated codec.\n" + + // libmpcodecs/ve_lavc.c + #define MSGTR_MPCODECS_HighQualityEncodingSelected "[VE_LAVC] High quality encoding selected (non-realtime)!\n" +diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c +index 3572565..aef04d2 100644 +--- a/libmpcodecs/dec_video.c ++++ b/libmpcodecs/dec_video.c +@@ -56,9 +56,47 @@ extern double vout_time_usage; + int field_dominance=-1; + + int divx_quality=0; ++char *video_hwaccel_name=NULL; + + vd_functions_t* mpvdec=NULL; + ++int get_video_hwaccel(void) ++{ ++ static int video_hwaccel = -1; ++ if (video_hwaccel < 0) { ++ video_hwaccel = HWACCEL_NONE; ++ if (video_hwaccel_name) { ++ if (!strcmp(video_hwaccel_name,"xvmc")) ++ video_hwaccel = HWACCEL_XVMC; ++ else if (!strcmp(video_hwaccel_name,"vaapi")) ++ video_hwaccel = HWACCEL_VAAPI; ++ else if (!strcmp(video_hwaccel_name,"vdpau")) ++ video_hwaccel = HWACCEL_VDPAU; ++ } ++ } ++ return video_hwaccel; ++} ++ ++const char *get_video_hwaccel_name(int hwaccel) ++{ ++ switch (hwaccel) { ++ case HWACCEL_XVMC: return "XvMC"; ++ case HWACCEL_VAAPI: return "VA API"; ++ case HWACCEL_VDPAU: return "VDPAU"; ++ } ++ return NULL; ++} ++ ++const char *get_video_hwaccel_short_name(int hwaccel) ++{ ++ switch (hwaccel) { ++ case HWACCEL_XVMC: return "xvmc"; ++ case HWACCEL_VAAPI: return "vaapi"; ++ case HWACCEL_VDPAU: return "vdpau"; ++ } ++ return NULL; ++} ++ + int get_video_quality_max(sh_video_t *sh_video){ + vf_instance_t* vf=sh_video->vfilter; + if(vf){ +diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h +index 8b28202..bf727cd 100644 +--- a/libmpcodecs/dec_video.h ++++ b/libmpcodecs/dec_video.h +@@ -21,6 +21,14 @@ + + #include "libmpdemux/stheader.h" + ++enum { ++ HWACCEL_NONE = 0, ++ HWACCEL_XVMC, ++ HWACCEL_VAAPI, ++ HWACCEL_VDPAU, ++ HWACCEL_COUNT ++}; ++ + // dec_video.c: + void vfm_help(void); + +@@ -39,6 +47,11 @@ int set_rectangle(sh_video_t *sh_video, int param, int value); + void resync_video_stream(sh_video_t *sh_video); + int get_current_video_decoder_lag(sh_video_t *sh_video); + ++int get_video_hwaccel(void); ++const char *get_video_hwaccel_name(int hwaccel); ++const char *get_video_hwaccel_short_name(int hwaccel); ++ + extern int divx_quality; ++extern char *video_hwaccel_name; + + #endif /* MPLAYER_DEC_VIDEO_H */ +diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c +index 5b858fa..d3b158b 100644 +--- a/libmpcodecs/img_format.c ++++ b/libmpcodecs/img_format.c +@@ -94,6 +94,14 @@ const char *vo_format_name(int format) + case IMGFMT_ZRMJPEGIB: return "Zoran MJPEG bottom field first"; + case IMGFMT_XVMC_MOCO_MPEG2: return "MPEG1/2 Motion Compensation"; + case IMGFMT_XVMC_IDCT_MPEG2: return "MPEG1/2 Motion Compensation and IDCT"; ++ case IMGFMT_VAAPI_MPEG2: return "MPEG-2 VA API Acceleration"; ++ case IMGFMT_VAAPI_MPEG2_IDCT: return "MPEG-2 VA API Acceleration (Motion Compensation and IDCT)"; ++ case IMGFMT_VAAPI_MPEG2_MOCO: return "MPEG-2 VA API Acceleration (Motion Compensation)"; ++ case IMGFMT_VAAPI_MPEG4: return "MPEG-4 VA API Acceleration"; ++ case IMGFMT_VAAPI_H263: return "H.263 VA API Acceleration"; ++ case IMGFMT_VAAPI_H264: return "H.264 VA API Acceleration"; ++ case IMGFMT_VAAPI_WMV3: return "WMV3 VA API Acceleration"; ++ case IMGFMT_VAAPI_VC1: return "VC-1 VA API Acceleration"; + case IMGFMT_VDPAU_MPEG1: return "MPEG1 VDPAU acceleration"; + case IMGFMT_VDPAU_MPEG2: return "MPEG2 VDPAU acceleration"; + case IMGFMT_VDPAU_H264: return "H.264 VDPAU acceleration"; +diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h +index 2c4db36..37b0132 100644 +--- a/libmpcodecs/img_format.h ++++ b/libmpcodecs/img_format.h +@@ -172,6 +172,26 @@ + #define IMGFMT_XVMC_MOCO_MPEG2 (IMGFMT_XVMC|0x02) + #define IMGFMT_XVMC_IDCT_MPEG2 (IMGFMT_XVMC|0x82) + ++/* VA API Formats */ ++ ++#define IMGFMT_VAAPI 0x56410000 /* 'VA'00 */ ++#define IMGFMT_VAAPI_MASK 0xFFFF0000 ++#define IMGFMT_IS_VAAPI(fmt) (((fmt) & IMGFMT_VAAPI_MASK) == IMGFMT_VAAPI) ++#define IMGFMT_VAAPI_CODEC_MASK 0x000000F0 ++#define IMGFMT_VAAPI_CODEC(fmt) ((fmt) & IMGFMT_VAAPI_CODEC_MASK) ++#define IMGFMT_VAAPI_CODEC_MPEG2 (0x10) ++#define IMGFMT_VAAPI_CODEC_MPEG4 (0x20) ++#define IMGFMT_VAAPI_CODEC_H264 (0x30) ++#define IMGFMT_VAAPI_CODEC_VC1 (0x40) ++#define IMGFMT_VAAPI_MPEG2 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2) ++#define IMGFMT_VAAPI_MPEG2_IDCT (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2|1) ++#define IMGFMT_VAAPI_MPEG2_MOCO (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG2|2) ++#define IMGFMT_VAAPI_MPEG4 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG4) ++#define IMGFMT_VAAPI_H263 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_MPEG4|1) ++#define IMGFMT_VAAPI_H264 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_H264) ++#define IMGFMT_VAAPI_VC1 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_VC1) ++#define IMGFMT_VAAPI_WMV3 (IMGFMT_VAAPI|IMGFMT_VAAPI_CODEC_VC1|1) ++ + // VDPAU specific format. + #define IMGFMT_VDPAU 0x1DC80000 + #define IMGFMT_VDPAU_MASK 0xFFFF0000 +diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h +index ba69e72..86ace62 100644 +--- a/libmpcodecs/mp_image.h ++++ b/libmpcodecs/mp_image.h +@@ -129,6 +129,7 @@ static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){ + // compressed formats + if(out_fmt == IMGFMT_MPEGPES || + out_fmt == IMGFMT_ZRMJPEGNI || out_fmt == IMGFMT_ZRMJPEGIT || out_fmt == IMGFMT_ZRMJPEGIB || ++ IMGFMT_IS_VAAPI(out_fmt) || + IMGFMT_IS_VDPAU(out_fmt) || IMGFMT_IS_XVMC(out_fmt)){ + mpi->bpp=0; + return; +diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c +index 6f18ed3..4bbd3cd 100644 +--- a/libmpcodecs/vd.c ++++ b/libmpcodecs/vd.c +@@ -373,3 +373,12 @@ void mpcodecs_draw_slice(sh_video_t *sh, unsigned char** src, int* stride, int w + if(vf->draw_slice) + vf->draw_slice(vf,src,stride,w,h,x,y); + } ++ ++void *mpcodecs_get_hwaccel_context(sh_video_t *sh) ++{ ++ void *ctx = NULL; ++ struct vf_instance_s *vf = sh->vfilter; ++ if (vf->control(vf, VFCTRL_GET_HWACCEL_CONTEXT, &ctx) == CONTROL_TRUE) ++ return ctx; ++ return NULL; ++} +diff --git a/libmpcodecs/vd.h b/libmpcodecs/vd.h +index 33d9ec5..63e0b8a 100644 +--- a/libmpcodecs/vd.h ++++ b/libmpcodecs/vd.h +@@ -53,6 +53,7 @@ extern float movie_aspect; + int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt); + mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); + void mpcodecs_draw_slice(sh_video_t *sh, unsigned char** src, int* stride, int w,int h, int x, int y); ++void *mpcodecs_get_hwaccel_context(sh_video_t *sh); + + #define VDFLAGS_DROPFRAME 3 + +diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c +index 8c1e9ae..7a42160 100644 +--- a/libmpcodecs/vd_ffmpeg.c ++++ b/libmpcodecs/vd_ffmpeg.c +@@ -32,6 +32,7 @@ + #include "fmt-conversion.h" + + #include "vd_internal.h" ++#include "dec_video.h" + + static const vd_info_t info = { + "FFmpeg's libavcodec codec family", +@@ -227,8 +228,8 @@ static void set_format_params(struct AVCodecContext *avctx, enum PixelFormat fmt + int imgfmt; + if (fmt == PIX_FMT_NONE) + return; +- imgfmt = pixfmt2imgfmt(fmt); +- if (IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt)) { ++ imgfmt = pixfmt2imgfmt(fmt, avctx->codec_id); ++ if (IMGFMT_IS_XVMC(imgfmt) || IMGFMT_IS_VDPAU(imgfmt) || IMGFMT_IS_VAAPI(imgfmt)) { + sh_video_t *sh = avctx->opaque; + vd_ffmpeg_ctx *ctx = sh->context; + ctx->do_dr1 = 1; +@@ -285,6 +286,12 @@ static int init(sh_video_t *sh){ + avctx->codec_type = CODEC_TYPE_VIDEO; + avctx->codec_id = lavc_codec->id; + ++#if CONFIG_VAAPI ++ if(get_video_hwaccel() == HWACCEL_VAAPI){ ++ mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_VAAPIAcceleratedCodec); ++ avctx->get_format = get_format; ++ } ++#endif /* CONFIG_VAAPI */ + #if CONFIG_VDPAU + if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){ + avctx->get_format = get_format; +@@ -478,7 +485,7 @@ static void draw_slice(struct AVCodecContext *s, + const AVFrame *src, int offset[4], + int y, int type, int height){ + sh_video_t *sh = s->opaque; +- uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2]}; ++ uint8_t *source[MP_MAX_PLANES]= {src->data[0] + offset[0], src->data[1] + offset[1], src->data[2] + offset[2], src->data[3] + offset[3]}; + #if 0 + int start=0, i; + int width= s->width; +@@ -544,9 +551,10 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){ + sh->disp_w = width; + sh->disp_h = height; + ctx->pix_fmt = pix_fmt; +- ctx->best_csp = pixfmt2imgfmt(pix_fmt); ++ ctx->best_csp = pixfmt2imgfmt(pix_fmt, avctx->codec_id); + if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, ctx->best_csp)) + return -1; ++ avctx->hwaccel_context = mpcodecs_get_hwaccel_context(sh); + ctx->vo_initialized = 1; + } + return 0; +@@ -597,7 +605,9 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ + return avctx->get_buffer(avctx, pic); + } + +- if (IMGFMT_IS_XVMC(ctx->best_csp) || IMGFMT_IS_VDPAU(ctx->best_csp)) { ++ if (IMGFMT_IS_XVMC(ctx->best_csp) || ++ IMGFMT_IS_VAAPI(ctx->best_csp) || ++ IMGFMT_IS_VDPAU(ctx->best_csp)) { + type = MP_IMGTYPE_NUMBERED | (0xffff << 16); + } else + if (!pic->buffer_hints) { +@@ -629,6 +639,11 @@ static int get_buffer(AVCodecContext *avctx, AVFrame *pic){ + avctx->draw_horiz_band= draw_slice; + } else + avctx->draw_horiz_band= NULL; ++#if CONFIG_VAAPI ++ if(IMGFMT_IS_VAAPI(mpi->imgfmt)) { ++ avctx->draw_horiz_band= draw_slice; ++ } ++#endif + if(IMGFMT_IS_VDPAU(mpi->imgfmt)) { + avctx->draw_horiz_band= draw_slice; + } +@@ -940,24 +955,62 @@ static mp_image_t *decode(sh_video_t *sh, void *data, int len, int flags){ + return mpi; + } + +-#if CONFIG_XVMC || CONFIG_VDPAU ++#if CONFIG_XVMC || CONFIG_VAAPI || CONFIG_VDPAU ++static inline int is_hwaccel_format(int imgfmt) ++{ ++ switch (get_video_hwaccel()) { ++ case HWACCEL_VAAPI: return IMGFMT_IS_VAAPI(imgfmt) != 0; ++ case HWACCEL_VDPAU: return IMGFMT_IS_VDPAU(imgfmt) != 0; ++ case HWACCEL_XVMC: return IMGFMT_IS_XVMC(imgfmt) != 0; ++ } ++ return 0; ++} ++ ++static int query_format(sh_video_t *sh, int fmt) ++{ ++ vd_ffmpeg_ctx * const ctx = sh->context; ++ AVCodecContext * const avctx = ctx->avctx; ++ int r, width, height; ++ /* XXX: some codecs have not initialized width and height yet at ++ this point, so we are faking the dimensions so that init_vo() ++ doesn't fail because of 0x0 size */ ++ if ((width = avctx->width) == 0) ++ avctx->width = 64; ++ if ((height = avctx->height) == 0) ++ avctx->height = 64; ++ r = init_vo(sh, fmt); ++ avctx->width = width; ++ avctx->height = height; ++ return r; ++} ++ + static enum PixelFormat get_format(struct AVCodecContext *avctx, +- const enum PixelFormat *fmt){ +- enum PixelFormat selected_format; ++ const enum PixelFormat *fmt){ ++ enum PixelFormat selected_format = PIX_FMT_NONE; + int imgfmt; + sh_video_t *sh = avctx->opaque; +- int i; +- +- for(i=0;fmt[i]!=PIX_FMT_NONE;i++){ +- imgfmt = pixfmt2imgfmt(fmt[i]); +- if(!IMGFMT_IS_XVMC(imgfmt) && !IMGFMT_IS_VDPAU(imgfmt)) continue; +- mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); +- if(init_vo(sh, fmt[i]) >= 0) { +- break; ++ int i, try_hwaccel; ++ ++ for (try_hwaccel = 1; try_hwaccel >= 0; --try_hwaccel) { ++ for (i = 0; fmt[i] != PIX_FMT_NONE; i++){ ++ imgfmt = pixfmt2imgfmt(fmt[i], avctx->codec_id); ++ if ((try_hwaccel ^ is_hwaccel_format(imgfmt)) != 0) ++ continue; ++ mp_msg(MSGT_DECVIDEO, MSGL_INFO, MSGTR_MPCODECS_TryingPixfmt, i); ++ if (query_format(sh, fmt[i]) >= 0) { ++ if (try_hwaccel) { ++ /* don't allow format conversion for HW acceleration */ ++ if (sh->codec->outfmt[sh->outfmtidx] != imgfmt) ++ continue; ++ } ++ selected_format = fmt[i]; ++ break; ++ } + } ++ if (selected_format != PIX_FMT_NONE) ++ break; + } +- selected_format = fmt[i]; + set_format_params(avctx, selected_format); + return selected_format; + } +-#endif /* CONFIG_XVMC || CONFIG_VDPAU */ ++#endif /* CONFIG_XVMC || CONFIG_VAAPI || CONFIG_VDPAU */ +diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h +index 91a57f2..00de007 100644 +--- a/libmpcodecs/vf.h ++++ b/libmpcodecs/vf.h +@@ -107,6 +107,7 @@ typedef struct vf_seteq_s + #define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/ + #define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */ + #define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */ ++#define VFCTRL_GET_HWACCEL_CONTEXT 20 /* Get HW accelerator context */ + + #include "vfcap.h" + +diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c +index fafdc1b..c75cace 100644 +--- a/libmpcodecs/vf_vo.c ++++ b/libmpcodecs/vf_vo.c +@@ -173,6 +173,12 @@ static int control(struct vf_instance_s* vf, int request, void* data) + *(double *)data = vf->priv->pts; + return CONTROL_TRUE; + } ++ case VFCTRL_GET_HWACCEL_CONTEXT: ++ { ++ if(!video_out) return CONTROL_FALSE; // vo not configured? ++ return(video_out->control(VOCTRL_GET_HWACCEL_CONTEXT, data) ++ == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE; ++ } + } + // return video_out->control(request,data); + return CONTROL_UNKNOWN; +@@ -192,6 +198,7 @@ static void get_image(struct vf_instance_s* vf, + if(!vo_config_count) return; + // GET_IMAGE is required for hardware-accelerated formats + if(vo_directrendering || ++ IMGFMT_IS_VAAPI(mpi->imgfmt) || + IMGFMT_IS_XVMC(mpi->imgfmt) || IMGFMT_IS_VDPAU(mpi->imgfmt)) + video_out->control(VOCTRL_GET_IMAGE,mpi); + } +diff --git a/libvo/stats.c b/libvo/stats.c +new file mode 100644 +index 0000000..c4ff0ca +--- /dev/null ++++ b/libvo/stats.c +@@ -0,0 +1,217 @@ ++#include "config.h" ++#include "stats.h" ++#include <time.h> ++#include <stdio.h> ++#include <string.h> ++#include <unistd.h> ++#include <locale.h> ++#include <inttypes.h> ++ ++#if CONFIG_LIBGTOP ++#include <glibtop/cpu.h> ++#include <glibtop/proctime.h> ++#include <glibtop/procstate.h> ++#endif ++ ++// Process statistics ++struct proc_stats { ++ uint64_t utime; ++ uint64_t stime; ++ uint64_t cutime; ++ uint64_t cstime; ++ uint64_t frequency; ++ uint64_t cpu_time; ++ uint64_t start_time; ++ uint64_t current_time; ++}; ++ ++// Get current process stats ++static int get_proc_stats(struct proc_stats *pstats); ++ ++void stats_init(void) ++{ ++#if CONFIG_LIBGTOP ++ glibtop_init(); ++#endif ++} ++ ++void stats_exit(void) ++{ ++#if CONFIG_LIBGTOP ++ glibtop_close(); ++#endif ++} ++ ++// Get CPU frequency ++unsigned int get_cpu_frequency(void) ++{ ++ unsigned int freq = 0; ++#if defined __linux__ ++ { ++ FILE *proc_file = fopen("/proc/cpuinfo", "r"); ++ if (proc_file) { ++ char line[256]; ++ char *old_locale = setlocale(LC_NUMERIC, NULL); ++ setlocale(LC_NUMERIC, "C"); ++ while(fgets(line, sizeof(line), proc_file)) { ++ float f; ++ int len = strlen(line); ++ if (len == 0) ++ continue; ++ line[len - 1] = 0; ++ if (sscanf(line, "cpu MHz : %f", &f) == 1) ++ freq = (unsigned int)f; ++ } ++ setlocale(LC_NUMERIC, old_locale); ++ fclose(proc_file); ++ } ++ } ++#endif ++ return freq; ++} ++ ++// Get CPU usage in percent ++static float get_cpu_usage_1(void) ++{ ++ static struct proc_stats prev_stats; ++ struct proc_stats curr_stats; ++ uint64_t prev_proc_time = 0, curr_proc_time = 0; ++ float pcpu = 0.0f; ++ ++ if (get_proc_stats(&curr_stats) == 0) { ++ prev_proc_time += prev_stats.utime; ++ prev_proc_time += prev_stats.stime; ++ prev_proc_time += prev_stats.cutime; ++ prev_proc_time += prev_stats.cstime; ++ curr_proc_time += curr_stats.utime; ++ curr_proc_time += curr_stats.stime; ++ curr_proc_time += curr_stats.cutime; ++ curr_proc_time += curr_stats.cstime; ++ if (prev_stats.start_time > 0) ++ pcpu = 100.0 * ((float)(curr_proc_time - prev_proc_time) / ++ (float)(curr_stats.cpu_time - prev_stats.cpu_time)); ++ prev_stats = curr_stats; ++ } ++ return pcpu; ++} ++ ++float get_cpu_usage(enum CpuUsageType type) ++{ ++ static float pcpu_total = 0.0; ++ static unsigned int n_samples; ++ float pcpu; ++ ++ pcpu = get_cpu_usage_1(); ++ pcpu_total += pcpu / 100.0; ++ ++n_samples; ++ ++ if (type == CPU_USAGE_AVERAGE) ++ pcpu = 100.0 * (pcpu_total / n_samples); ++ return pcpu; ++} ++ ++// For ELF executable, notes are pushed before environment and args ++static int find_elf_note(unsigned long match, unsigned long *pval) ++{ ++ unsigned long *ep = (unsigned long *)__environ; ++ while (*ep++); ++ for (; *ep != 0; ep += 2) { ++ if (ep[0] == match) { ++ *pval = ep[1]; ++ return 0; ++ } ++ } ++ return -1; ++} ++ ++#ifndef AT_CLKTCK ++#define AT_CLKTCK 17 ++#endif ++ ++// Get current process stats ++int get_proc_stats(struct proc_stats *pstats) ++{ ++ int error = -1; ++ char line[256], *str, *end; ++ char vc; ++ int vi; ++ unsigned long vul; ++ unsigned long long vull; ++ float vf; ++#if defined __linux__ ++ { ++ FILE *proc_file = fopen("/proc/self/stat", "r"); ++ if (proc_file) { ++ if (fgets(line, sizeof(line), proc_file)) { ++ unsigned long utime, stime, cutime, cstime, start_time; ++ str = strrchr(line, ')'); ++ if (str && sscanf(str + 2, ++ "%c " ++ "%d %d %d %d %d " ++ "%lu %lu %lu %lu %lu %lu %lu " ++ "%ld %ld %ld %ld %ld %ld " ++ "%lu %lu ", ++ &vc, ++ &vi, &vi, &vi, &vi, &vi, ++ &vul, &vul, &vul, &vul, &vul, &utime, &stime, ++ &cutime, &cstime, &vul, &vul, &vul, &vul, ++ &start_time, &vul) == 21) { ++ pstats->utime = utime; ++ pstats->stime = stime; ++ pstats->cutime = cutime; ++ pstats->cstime = cstime; ++ pstats->start_time = start_time; ++ error = 0; ++ } ++ } ++ fclose(proc_file); ++ } ++ if (error) ++ return error; ++ error = -1; ++ ++ if (find_elf_note(AT_CLKTCK, &vul) == 0) { ++ pstats->frequency = vul; ++ error = 0; ++ } ++ if (error) ++ return error; ++ error = -1; ++ ++ proc_file = fopen("/proc/uptime", "r"); ++ if (proc_file) { ++ if (fgets(line, sizeof(line), proc_file)) { ++ char *old_locale = setlocale(LC_NUMERIC, NULL); ++ setlocale(LC_NUMERIC, "C"); ++ if (sscanf(line, "%f", &vf) == 1) { ++ pstats->cpu_time = (uint64_t)(vf * (float)pstats->frequency); ++ error = 0; ++ } ++ setlocale(LC_NUMERIC, old_locale); ++ } ++ fclose(proc_file); ++ } ++ } ++#elif CONFIG_LIBGTOP ++ { ++ glibtop_cpu cpu; ++ glibtop_proc_time proc_time; ++ glibtop_proc_state proc_state; ++ ++ glibtop_get_cpu(&cpu); ++ glibtop_get_proc_state(&proc_state, getpid()); ++ pstats->cpu_time = cpu.xcpu_total[proc_state.processor]; ++ ++ glibtop_get_proc_time(&proc_time, getpid()); ++ pstats->utime = proc_time.utime; ++ pstats->stime = proc_time.stime; ++ pstats->cutime = proc_time.cutime; ++ pstats->cstime = proc_time.cstime; ++ pstats->start_time = proc_time.start_time; ++ pstats->frequency = proc_time.frequency; ++ ++ error = 0; ++ } ++#endif ++ return error; ++} +diff --git a/libvo/stats.h b/libvo/stats.h +new file mode 100644 +index 0000000..62e7412 +--- /dev/null ++++ b/libvo/stats.h +@@ -0,0 +1,21 @@ ++#ifndef MPLAYER_STATS_H ++#define MPLAYER_STATS_H ++ ++#include <stdint.h> ++ ++void stats_init(void); ++void stats_exit(void); ++ ++/// CPU usage model ++enum CpuUsageType { ++ CPU_USAGE_QUANTUM = 1, ///< CPU usage since the last call to cpu_get_usage() ++ CPU_USAGE_AVERAGE ///< CPU usage average'd since program start ++}; ++ ++/// Get CPU frequency ++unsigned int get_cpu_frequency(void); ++ ++/// Get CPU usage in percent ++float get_cpu_usage(enum CpuUsageType type); ++ ++#endif /* MPLAYER_STATS_H */ +diff --git a/libvo/video_out.c b/libvo/video_out.c +index 6db664a..8259927 100644 +--- a/libvo/video_out.c ++++ b/libvo/video_out.c +@@ -138,6 +138,7 @@ extern vo_functions_t video_out_corevideo; + extern vo_functions_t video_out_quartz; + extern vo_functions_t video_out_pnm; + extern vo_functions_t video_out_md5sum; ++extern vo_functions_t video_out_vaapi; + + const vo_functions_t* const video_out_drivers[] = + { +@@ -283,6 +284,9 @@ const vo_functions_t* const video_out_drivers[] = + #ifdef CONFIG_MD5SUM + &video_out_md5sum, + #endif ++#if CONFIG_VAAPI ++ &video_out_vaapi, ++#endif + NULL + }; + +diff --git a/libvo/video_out.h b/libvo/video_out.h +index 1fce2c2..0d3f00a 100644 +--- a/libvo/video_out.h ++++ b/libvo/video_out.h +@@ -98,6 +98,10 @@ typedef struct { + int w,h; + } mp_win_t; + ++// Return current HW acceleration context ++// void *get_hwaccel_context(void); ++#define VOCTRL_GET_HWACCEL_CONTEXT 33 ++ + #define VO_TRUE 1 + #define VO_FALSE 0 + #define VO_ERROR -1 +diff --git a/libvo/vo_vaapi.c b/libvo/vo_vaapi.c +new file mode 100644 +index 0000000..ddc9eac +--- /dev/null ++++ b/libvo/vo_vaapi.c +@@ -0,0 +1,2201 @@ ++/* ++ * VA API output module ++ * ++ * Copyright (C) 2008-2009 Splitted-Desktop Systems ++ * ++ * This file is part of MPlayer. ++ * ++ * MPlayer is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * MPlayer is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with MPlayer; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ */ ++ ++#include "config.h" ++#include "mp_msg.h" ++#include "help_mp.h" ++#include "subopt-helper.h" ++#include "video_out.h" ++#include "video_out_internal.h" ++#include "fastmemcpy.h" ++#include "sub.h" ++#include "x11_common.h" ++#include "libavutil/common.h" ++#include "libavcodec/vaapi.h" ++#include "gui/interface.h" ++#include "stats.h" ++#include "libass/ass_mp.h" ++#include <stdarg.h> ++ ++#if CONFIG_GL ++#include "gl_common.h" ++#include <GL/glu.h> ++#include <GL/glx.h> ++#endif ++ ++#include <assert.h> ++#include <X11/Xlib.h> ++#include <X11/Xutil.h> ++#include <va/va_x11.h> ++#if CONFIG_VAAPI_GLX ++#include <va/va_glx.h> ++#endif ++ ++/* Compatibility glue with VA-API >= 0.30 */ ++#ifndef VA_INVALID_ID ++#define VA_INVALID_ID 0xffffffff ++#endif ++#ifndef VA_FOURCC ++#define VA_FOURCC(ch0, ch1, ch2, ch3) \ ++ ((uint32_t)(uint8_t)(ch0) | \ ++ ((uint32_t)(uint8_t)(ch1) << 8) | \ ++ ((uint32_t)(uint8_t)(ch2) << 16) | \ ++ ((uint32_t)(uint8_t)(ch3) << 24 )) ++#endif ++#if defined VA_SRC_BT601 && defined VA_SRC_BT709 ++#define USE_VAAPI_COLORSPACE 1 ++#else ++#define USE_VAAPI_COLORSPACE 0 ++#endif ++ ++/* Defined to 1 if VA/GLX 'bind' API is available */ ++#define USE_VAAPI_GLX_BIND \ ++ (VA_MAJOR_VERSION == 0 && \ ++ ((VA_MINOR_VERSION == 30 && \ ++ VA_MICRO_VERSION == 4 && VA_SDS_VERSION >= 5) || \ ++ (VA_MINOR_VERSION == 31 && \ ++ VA_MICRO_VERSION == 0 && VA_SDS_VERSION < 5))) ++ ++/* Compatibility glue with VA-API >= 0.31 */ ++#if defined VA_CHECK_VERSION ++#if VA_CHECK_VERSION(0,31,0) ++#define vaPutImage2 vaPutImage ++#define vaAssociateSubpicture2 vaAssociateSubpicture ++#endif ++#endif ++ ++static vo_info_t info = { ++ "VA API with X11", ++ "vaapi", ++ "Gwenole Beauchesne <gbeauchesne@splitted-desktop.com>", ++ "" ++}; ++ ++LIBVO_EXTERN(vaapi) ++ ++/* Numbers of video surfaces */ ++#define MAX_OUTPUT_SURFACES 2 /* Maintain synchronisation points in flip_page() */ ++#define MAX_VIDEO_SURFACES 21 /* Maintain free surfaces in a queue (use least-recently-used) */ ++#define NUM_VIDEO_SURFACES_MPEG2 3 /* 1 decode frame, up to 2 references */ ++#define NUM_VIDEO_SURFACES_MPEG4 3 /* 1 decode frame, up to 2 references */ ++#define NUM_VIDEO_SURFACES_H264 21 /* 1 decode frame, up to 20 references */ ++#define NUM_VIDEO_SURFACES_VC1 3 /* 1 decode frame, up to 2 references */ ++ ++typedef void (*draw_alpha_func)(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride); ++ ++typedef void (*eosd_draw_alpha_func)(unsigned char *src, ++ int src_w, int src_h, int src_stride, ++ int dst_x, int dst_y, ++ uint32_t color); ++ ++struct vaapi_surface { ++ VASurfaceID id; ++ VAImage image; ++}; ++ ++struct vaapi_equalizer { ++ VADisplayAttribute brightness; ++ VADisplayAttribute contrast; ++ VADisplayAttribute hue; ++ VADisplayAttribute saturation; ++}; ++ ++static int g_is_paused; ++static uint32_t g_image_width; ++static uint32_t g_image_height; ++static uint32_t g_image_format; ++static struct vo_rect g_output_rect; ++static struct vaapi_surface *g_output_surfaces[MAX_OUTPUT_SURFACES]; ++static unsigned int g_output_surface; ++static int g_top_field_first; ++static int g_deint; ++static int g_deint_type; ++static int g_colorspace; ++ ++#if CONFIG_GL ++static MPGLContext gl_context; ++static int gl_enabled; ++static int gl_binding; ++static int gl_reflect; ++static GLuint gl_texture; ++static GLuint gl_font_base; ++#endif ++ ++#if CONFIG_VAAPI_GLX ++static int gl_visual_attr[] = { ++ GLX_RGBA, ++ GLX_RED_SIZE, 1, ++ GLX_GREEN_SIZE, 1, ++ GLX_BLUE_SIZE, 1, ++ GLX_DOUBLEBUFFER, ++ GL_NONE ++}; ++static void *gl_surface; ++#endif ++ ++static struct vaapi_context *va_context; ++static VAProfile *va_profiles; ++static int va_num_profiles; ++static VAEntrypoint *va_entrypoints; ++static int va_num_entrypoints; ++static VASurfaceID *va_surface_ids; ++static int va_num_surfaces; ++static struct vaapi_surface **va_free_surfaces; ++static int va_free_surfaces_head_index; ++static int va_free_surfaces_tail_index; ++static VAImageFormat *va_image_formats; ++static int va_num_image_formats; ++static VAImageFormat *va_subpic_formats; ++static unsigned int *va_subpic_flags; ++static int va_num_subpic_formats; ++static VAImage va_osd_image; ++static uint8_t *va_osd_image_data; ++static struct vo_rect va_osd_image_dirty_rect; ++static VASubpictureID va_osd_subpicture; ++static int va_osd_associated; ++static draw_alpha_func va_osd_draw_alpha; ++static uint8_t *va_osd_palette; ++static struct vaapi_equalizer va_equalizer; ++static VAImage va_eosd_image; ++static uint8_t *va_eosd_image_data; ++static VASubpictureID va_eosd_subpicture; ++static int va_eosd_associated; ++static eosd_draw_alpha_func va_eosd_draw_alpha; ++ ++///< Flag: direct surface mapping: use mpi->number to select free VA surface? ++static int va_dm; ++ ++///< Flag: gather run-time statistics (CPU usage, frequency) ++static int cpu_stats; ++static unsigned int cpu_frequency; ++static float cpu_usage; ++ ++static int check_status(VAStatus status, const char *msg) ++{ ++ if (status != VA_STATUS_SUCCESS) { ++ mp_msg(MSGT_VO, MSGL_ERR, "[vo_vaapi] %s: %s\n", msg, vaErrorStr(status)); ++ return 0; ++ } ++ return 1; ++} ++ ++static const char *string_of_VAImageFormat(VAImageFormat *imgfmt) ++{ ++ static char str[5]; ++ str[0] = imgfmt->fourcc; ++ str[1] = imgfmt->fourcc >> 8; ++ str[2] = imgfmt->fourcc >> 16; ++ str[3] = imgfmt->fourcc >> 24; ++ str[4] = '\0'; ++ return str; ++} ++ ++static const char *string_of_VAProfile(VAProfile profile) ++{ ++ switch (profile) { ++#define PROFILE(profile) \ ++ case VAProfile##profile: return "VAProfile" #profile ++ PROFILE(MPEG2Simple); ++ PROFILE(MPEG2Main); ++ PROFILE(MPEG4Simple); ++ PROFILE(MPEG4AdvancedSimple); ++ PROFILE(MPEG4Main); ++ PROFILE(H264Baseline); ++ PROFILE(H264Main); ++ PROFILE(H264High); ++ PROFILE(VC1Simple); ++ PROFILE(VC1Main); ++ PROFILE(VC1Advanced); ++#undef PROFILE ++ } ++ return "<unknown>"; ++} ++ ++static const char *string_of_VAEntrypoint(VAEntrypoint entrypoint) ++{ ++ switch (entrypoint) { ++#define ENTRYPOINT(entrypoint) \ ++ case VAEntrypoint##entrypoint: return "VAEntrypoint" #entrypoint ++ ENTRYPOINT(VLD); ++ ENTRYPOINT(IZZ); ++ ENTRYPOINT(IDCT); ++ ENTRYPOINT(MoComp); ++ ENTRYPOINT(Deblocking); ++#undef ENTRYPOINT ++ } ++ return "<unknown>"; ++} ++ ++static int has_profile(VAProfile profile) ++{ ++ if (va_profiles && va_num_profiles > 0) { ++ int i; ++ for (i = 0; i < va_num_profiles; i++) { ++ if (va_profiles[i] == profile) ++ return 1; ++ } ++ } ++ return 0; ++} ++ ++static int VAProfile_from_imgfmt(uint32_t format) ++{ ++ static const int mpeg2_profiles[] = ++ { VAProfileMPEG2Main, VAProfileMPEG2Simple, -1 }; ++ static const int mpeg4_profiles[] = ++ { VAProfileMPEG4Main, VAProfileMPEG4AdvancedSimple, VAProfileMPEG4Simple, -1 }; ++ static const int h264_profiles[] = ++ { VAProfileH264High, VAProfileH264Main, VAProfileH264Baseline, -1 }; ++ static const int wmv3_profiles[] = ++ { VAProfileVC1Main, VAProfileVC1Simple, -1 }; ++ static const int vc1_profiles[] = ++ { VAProfileVC1Advanced, -1 }; ++ ++ const int *profiles = NULL; ++ switch (IMGFMT_VAAPI_CODEC(format)) { ++ case IMGFMT_VAAPI_CODEC_MPEG2: ++ profiles = mpeg2_profiles; ++ break; ++ case IMGFMT_VAAPI_CODEC_MPEG4: ++ profiles = mpeg4_profiles; ++ break; ++ case IMGFMT_VAAPI_CODEC_H264: ++ profiles = h264_profiles; ++ break; ++ case IMGFMT_VAAPI_CODEC_VC1: ++ switch (format) { ++ case IMGFMT_VAAPI_WMV3: ++ profiles = wmv3_profiles; ++ break; ++ case IMGFMT_VAAPI_VC1: ++ profiles = vc1_profiles; ++ break; ++ } ++ break; ++ } ++ ++ if (profiles) { ++ for (int i = 0; profiles[i] != -1; i++) { ++ if (has_profile(profiles[i])) ++ return profiles[i]; ++ } ++ } ++ return -1; ++} ++ ++static int has_entrypoint(VAEntrypoint entrypoint) ++{ ++ if (va_entrypoints && va_num_entrypoints > 0) { ++ int i; ++ for (i = 0; i < va_num_entrypoints; i++) { ++ if (va_entrypoints[i] == entrypoint) ++ return 1; ++ } ++ } ++ return 0; ++} ++ ++static int VAEntrypoint_from_imgfmt(uint32_t format) ++{ ++ int entrypoint = 0; ++ switch (format) { ++ case IMGFMT_VAAPI_MPEG2: ++ case IMGFMT_VAAPI_MPEG4: ++ case IMGFMT_VAAPI_H263: ++ case IMGFMT_VAAPI_H264: ++ case IMGFMT_VAAPI_WMV3: ++ case IMGFMT_VAAPI_VC1: ++ entrypoint = VAEntrypointVLD; ++ break; ++ case IMGFMT_VAAPI_MPEG2_IDCT: ++ entrypoint = VAEntrypointIDCT; ++ break; ++ case IMGFMT_VAAPI_MPEG2_MOCO: ++ entrypoint = VAEntrypointMoComp; ++ break; ++ } ++ ++ if (entrypoint) ++ return has_entrypoint(entrypoint); ++ ++ return -1; ++} ++ ++static VAImageFormat *find_image_format(uint32_t fourcc) ++{ ++ if (va_image_formats && va_num_image_formats > 0) { ++ int i; ++ for (i = 0; i < va_num_image_formats; i++) { ++ if (va_image_formats[i].fourcc == fourcc) ++ return &va_image_formats[i]; ++ } ++ } ++ return NULL; ++} ++ ++static VAImageFormat *VAImageFormat_from_imgfmt(uint32_t format) ++{ ++ uint32_t fourcc = 0; ++ ++ switch (format) { ++ case IMGFMT_NV12: fourcc = VA_FOURCC('N','V','1','2'); break; ++ case IMGFMT_YV12: fourcc = VA_FOURCC('Y','V','1','2'); break; ++ case IMGFMT_I420: fourcc = VA_FOURCC('I','4','2','0'); break; ++ case IMGFMT_IYUV: fourcc = VA_FOURCC('I','Y','U','V'); break; ++ } ++ ++ if (fourcc) ++ return find_image_format(fourcc); ++ ++ return NULL; ++} ++ ++static struct vaapi_surface *alloc_vaapi_surface(unsigned int width, ++ unsigned int height, ++ unsigned int format) ++{ ++ struct vaapi_surface *surface = NULL; ++ struct vaapi_surface **surfaces; ++ VASurfaceID *surface_ids; ++ VAStatus status; ++ ++ surface = malloc(sizeof(*surface)); ++ if (!surface) ++ goto error; ++ ++ surfaces = realloc(va_free_surfaces, ++ (1 + va_num_surfaces) * sizeof(surfaces[0])); ++ if (!surfaces) ++ goto error; ++ ++ surface_ids = realloc(va_surface_ids, ++ (1 + va_num_surfaces) * sizeof(surface_ids[0])); ++ if (!surface_ids) ++ goto error; ++ ++ status = vaCreateSurfaces(va_context->display, width, height, format, ++ 1, &surface->id); ++ if (!check_status(status, "vaCreateSurfaces()")) ++ goto error; ++ ++ va_surface_ids = surface_ids; ++ va_surface_ids[va_num_surfaces] = surface->id; ++ va_free_surfaces = surfaces; ++ va_free_surfaces[va_num_surfaces] = surface; ++ surface->image.image_id = VA_INVALID_ID; ++ surface->image.buf = VA_INVALID_ID; ++ ++va_num_surfaces; ++ return surface; ++error: ++ free(surface); ++ return NULL; ++} ++ ++static void resize(void) ++{ ++ struct vo_rect src; ++ ++ calc_src_dst_rects(g_image_width, g_image_height, ++ &src, &g_output_rect, NULL, NULL); ++ ++ vo_x11_clearwindow(mDisplay, vo_window); ++ ++#if CONFIG_GL ++#define FOVY 60.0f ++#define ASPECT 1.0f ++#define Z_NEAR 0.1f ++#define Z_FAR 100.0f ++#define Z_CAMERA 0.869f ++ ++ if (gl_enabled) { ++ glViewport(0, 0, vo_dwidth, vo_dheight); ++ glMatrixMode(GL_PROJECTION); ++ glLoadIdentity(); ++ gluPerspective(FOVY, ASPECT, Z_NEAR, Z_FAR); ++ glMatrixMode(GL_MODELVIEW); ++ glLoadIdentity(); ++ ++ glTranslatef(-0.5f, -0.5f, -Z_CAMERA); ++ glScalef(1.0f / (GLfloat)vo_dwidth, ++ -1.0f / (GLfloat)vo_dheight, ++ 1.0f / (GLfloat)vo_dwidth); ++ glTranslatef(0.0f, -1.0f * (GLfloat)vo_dheight, 0.0f); ++ } ++#endif ++ ++ flip_page(); ++} ++ ++#if CONFIG_GL ++static int gl_build_font(void) ++{ ++ XFontStruct *fi; ++ ++ gl_font_base = glGenLists(96); ++ ++ fi = XLoadQueryFont(mDisplay, "-adobe-helvetica-medium-r-normal--16-*-*-*-p-*-iso8859-1" ); ++ if (!fi) { ++ fi = XLoadQueryFont(mDisplay, "fixed"); ++ if (!fi) ++ return -1; ++ } ++ ++ glXUseXFont(fi->fid, 32, 96, gl_font_base); ++ XFreeFont(mDisplay, fi); ++ return 0; ++} ++ ++static void gl_printf(const char *format, ...) ++{ ++ va_list args; ++ char *text; ++ int textlen; ++ ++ va_start(args, format); ++ textlen = vsnprintf(NULL, 0, format, args); ++ va_end(args); ++ ++ text = malloc(textlen + 1); ++ if (!text) ++ return; ++ ++ va_start(args, format); ++ vsprintf(text, format, args); ++ va_end(args); ++ ++ glPushAttrib(GL_LIST_BIT); ++ glListBase(gl_font_base - 32); ++ glCallLists(textlen, GL_UNSIGNED_BYTE, text); ++ glPopAttrib(); ++ free(text); ++} ++ ++static void gl_draw_rectangle(int x, int y, int w, int h, unsigned int rgba) ++{ ++ glColor4f((GLfloat)((rgba >> 24) & 0xff) / 255.0, ++ (GLfloat)((rgba >> 16) & 0xff) / 255.0, ++ (GLfloat)((rgba >> 8) & 0xff) / 255.0, ++ (GLfloat)(rgba & 0xff) / 255.0); ++ ++ glTranslatef((GLfloat)x, (GLfloat)y, 0.0f); ++ glBegin(GL_QUADS); ++ { ++ glVertex2i(0, 0); ++ glVertex2i(w, 0); ++ glVertex2i(w, h); ++ glVertex2i(0, h); ++ } ++ glEnd(); ++} ++#endif ++ ++static inline unsigned char *get_osd_image_data(int x0, int y0) ++{ ++ return (va_osd_image_data + ++ va_osd_image.offsets[0] + ++ va_osd_image.pitches[0] * y0 + ++ x0 * ((va_osd_image.format.bits_per_pixel + 7) / 8)); ++} ++ ++static inline void set_osd_image_dirty_rect(int x, int y, int w, int h) ++{ ++ struct vo_rect * const dirty_rect = &va_osd_image_dirty_rect; ++ dirty_rect->left = x + w; ++ dirty_rect->top = y + h; ++ dirty_rect->right = x; ++ dirty_rect->bottom = y; ++ dirty_rect->width = w; ++ dirty_rect->height = h; ++} ++ ++static inline void update_osd_image_dirty_rect(int x, int y, int w, int h) ++{ ++ struct vo_rect * const dirty_rect = &va_osd_image_dirty_rect; ++ dirty_rect->left = FFMIN(dirty_rect->left, x); ++ dirty_rect->top = FFMIN(dirty_rect->top, y); ++ dirty_rect->right = FFMAX(dirty_rect->right, x + w); ++ dirty_rect->bottom = FFMAX(dirty_rect->bottom, y + h); ++ dirty_rect->width = dirty_rect->right - dirty_rect->left; ++ dirty_rect->height = dirty_rect->bottom - dirty_rect->top; ++} ++ ++static void draw_alpha_rgb32(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride) ++{ ++ int x, y; ++ const unsigned int dststride = va_osd_image.pitches[0]; ++ unsigned char *dst = get_osd_image_data(x0, y0); ++ ++ update_osd_image_dirty_rect(x0, y0, w, h); ++ ++ for (y = 0; y < h; y++, dst += dststride, src += stride, srca += stride) ++ for (x = 0; x < w; x++) { ++ const unsigned char c = src[x]; ++ dst[4*x + 0] = c; ++ dst[4*x + 1] = c; ++ dst[4*x + 2] = c; ++ dst[4*x + 3] = -srca[x]; ++ } ++} ++ ++static void draw_alpha_IA44(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride) ++{ ++ int x, y; ++ const unsigned int dststride = va_osd_image.pitches[0]; ++ unsigned char *dst = get_osd_image_data(x0, y0); ++ ++ update_osd_image_dirty_rect(x0, y0, w, h); ++ ++ for (y = 0; y < h; y++, dst += dststride) ++ for (x = 0; x < w; x++) ++ dst[x] = (src[y*stride + x] & 0xf0) | (-srca[y*stride + x] >> 4); ++} ++ ++static void draw_alpha_AI44(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride) ++{ ++ int x, y; ++ const unsigned int dststride = va_osd_image.pitches[0]; ++ unsigned char *dst = get_osd_image_data(x0, y0); ++ ++ update_osd_image_dirty_rect(x0, y0, w, h); ++ ++ for (y = 0; y < h; y++, dst += dststride) ++ for (x = 0; x < w; x++) ++ dst[x] = (src[y*stride + x] >> 4) | (-srca[y*stride + x] & 0xf0); ++} ++ ++static void draw_alpha_IA88(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride) ++{ ++ int x, y; ++ const unsigned int dststride = va_osd_image.pitches[0]; ++ unsigned char *dst = get_osd_image_data(x0, y0); ++ ++ update_osd_image_dirty_rect(x0, y0, w, h); ++ ++ for (y = 0; y < h; y++, dst += dststride) ++ for (x = 0; x < w; x++) { ++ dst[2*x + 0] = src [y*stride + x]; ++ dst[2*x + 1] = -srca[y*stride + x]; ++ } ++} ++ ++static void draw_alpha_AI88(int x0, int y0, int w, int h, ++ unsigned char *src, unsigned char *srca, ++ int stride) ++{ ++ int x, y; ++ const unsigned int dststride = va_osd_image.pitches[0]; ++ unsigned char *dst = get_osd_image_data(x0, y0); ++ ++ update_osd_image_dirty_rect(x0, y0, w, h); ++ ++ for (y = 0; y < h; y++, dst += dststride) ++ for (x = 0; x < w; x++) { ++ dst[2*x + 0] = -srca[y*stride + x]; ++ dst[2*x + 1] = src [y*stride + x]; ++ } ++} ++ ++///< List of subpicture formats in preferred order ++static const struct { ++ uint32_t format; ++ draw_alpha_func draw_alpha; ++} ++va_osd_info[] = { ++ { VA_FOURCC('I','A','4','4'), draw_alpha_IA44 }, ++ { VA_FOURCC('A','I','4','4'), draw_alpha_AI44 }, ++ { VA_FOURCC('I','A','8','8'), draw_alpha_IA88 }, ++ { VA_FOURCC('A','I','8','8'), draw_alpha_AI88 }, ++ { VA_FOURCC('B','G','R','A'), draw_alpha_rgb32 }, ++ { VA_FOURCC('R','G','B','A'), draw_alpha_rgb32 }, ++ { 0, NULL } ++}; ++ ++static uint8_t *gen_osd_palette(const VAImage *image) ++{ ++ uint8_t *palette; ++ int i, is_rgb; ++ int r_idx = -1, g_idx = -1, b_idx = -1; ++ int y_idx = -1, u_idx = -1, v_idx = -1; ++ int i_idx = -1, a_idx = -1; ++ ++ if (image->num_palette_entries < 1) ++ return NULL; ++ ++ palette = malloc(image->num_palette_entries * image->entry_bytes); ++ if (!palette) ++ return NULL; ++ ++ for (i = 0; i < image->entry_bytes; i++) { ++ switch (image->component_order[i]) { ++ case 'R': r_idx = i; is_rgb = 1; break; ++ case 'G': g_idx = i; is_rgb = 1; break; ++ case 'B': b_idx = i; is_rgb = 1; break; ++ case 'Y': y_idx = i; is_rgb = 0; break; ++ case 'U': u_idx = i; is_rgb = 0; break; ++ case 'V': v_idx = i; is_rgb = 0; break; ++ case 'I': i_idx = i; break; ++ case 'A': a_idx = i; break; ++ } ++ } ++ ++ if (r_idx != -1 && g_idx != -1 && b_idx != -1) { /* RGB format */ ++ for (i = 0; i < image->num_palette_entries; i++) { ++ const int n = i * image->entry_bytes; ++ palette[n + r_idx] = i * 0xff / (image->num_palette_entries - 1); ++ palette[n + g_idx] = i * 0xff / (image->num_palette_entries - 1); ++ palette[n + b_idx] = i * 0xff / (image->num_palette_entries - 1); ++ } ++ } ++ else if (y_idx != -1 && u_idx != -1 && v_idx != -1) { /* YUV format */ ++ for (i = 0; i < image->num_palette_entries; i++) { ++ const int n = i * image->entry_bytes; ++ palette[n + y_idx] = i * 0xff / (image->num_palette_entries - 1); ++ palette[n + u_idx] = 0x80; ++ palette[n + v_idx] = 0x80; ++ } ++ } ++ else if (i_idx != -1 && a_idx != -1) {/* AYUV format (GMA500 "psb" bug) */ ++ for (i = 0; i < image->num_palette_entries; i++) { ++ const int n = i * image->entry_bytes; ++ palette[n + 0] = 0x80; ++ palette[n + 1] = 0x80; ++ palette[n + 2] = 16 + i * 220 / (image->num_palette_entries - 1); ++ palette[n + 3] = 0; ++ } ++ } ++ else { ++ mp_msg(MSGT_VO, MSGL_ERR, "[vo_vaapi] Could not set up subpicture palette\n"); ++ free(palette); ++ palette = NULL; ++ } ++ return palette; ++} ++ ++static void disable_osd(void) ++{ ++ if (!va_osd_associated) ++ return; ++ ++ vaDeassociateSubpicture(va_context->display, ++ va_osd_subpicture, ++ va_surface_ids, va_num_surfaces); ++ ++ va_osd_associated = 0; ++} ++ ++static int enable_osd(const struct vo_rect *src_rect, ++ const struct vo_rect *dst_rect) ++{ ++ VAStatus status; ++ ++ disable_osd(); ++ ++ status = vaAssociateSubpicture2(va_context->display, ++ va_osd_subpicture, ++ va_surface_ids, va_num_surfaces, ++ src_rect->left, ++ src_rect->top, ++ src_rect->right - src_rect->left, ++ src_rect->bottom - src_rect->top, ++ dst_rect->left, ++ dst_rect->top, ++ dst_rect->right - dst_rect->left, ++ dst_rect->bottom - dst_rect->top, ++ 0); ++ if (!check_status(status, "vaAssociateSubpicture()")) ++ return -1; ++ ++ va_osd_associated = 1; ++ return 0; ++} ++ ++static inline unsigned char *get_eosd_image_data(int x0, int y0) ++{ ++ return (va_eosd_image_data + ++ va_eosd_image.offsets[0] + ++ va_eosd_image.pitches[0] * y0 + ++ x0 * ((va_eosd_image.format.bits_per_pixel + 7) / 8)); ++} ++ ++static void eosd_draw_alpha_bgra(unsigned char *src, ++ int src_w, int src_h, int src_stride, ++ int dst_x, int dst_y, ++ uint32_t color) ++{ ++ int x, y; ++ const unsigned int dst_stride = va_eosd_image.pitches[0]; ++ unsigned char *dst = get_eosd_image_data(dst_x, dst_y); ++ const unsigned int r = (color >> 24) & 0xff; ++ const unsigned int g = (color >> 16) & 0xff; ++ const unsigned int b = (color >> 8) & 0xff; ++ const unsigned int a = 0xff - (color & 0xff); ++ ++ for (y = 0; y < src_h; y++, dst += dst_stride, src += src_stride) ++ for (x = 0; x < src_w; x++) { ++ const unsigned int v = src[x]; ++ dst[4*x + 0] = (b * v + dst[4*x + 0] * (0xff - v)) / 255; ++ dst[4*x + 1] = (g * v + dst[4*x + 1] * (0xff - v)) / 255; ++ dst[4*x + 2] = (r * v + dst[4*x + 2] * (0xff - v)) / 255; ++ dst[4*x + 3] = (a * v + dst[4*x + 3] * (0xff - v)) / 255; ++ } ++} ++ ++static void eosd_draw_alpha_rgba(unsigned char *src, ++ int src_w, int src_h, int src_stride, ++ int dst_x, int dst_y, ++ uint32_t color) ++{ ++ int x, y; ++ const unsigned int dst_stride = va_eosd_image.pitches[0]; ++ unsigned char *dst = get_eosd_image_data(dst_x, dst_y); ++ const unsigned int r = (color >> 24) & 0xff; ++ const unsigned int g = (color >> 16) & 0xff; ++ const unsigned int b = (color >> 8) & 0xff; ++ const unsigned int a = 0xff - (color & 0xff); ++ ++ for (y = 0; y < src_h; y++, dst += dst_stride, src += src_stride) ++ for (x = 0; x < src_w; x++) { ++ const unsigned int v = src[x]; ++ dst[4*x + 0] = (r * v + dst[4*x + 0] * (0xff - v)) / 255; ++ dst[4*x + 1] = (g * v + dst[4*x + 1] * (0xff - v)) / 255; ++ dst[4*x + 2] = (b * v + dst[4*x + 2] * (0xff - v)) / 255; ++ dst[4*x + 3] = (a * v + dst[4*x + 3] * (0xff - v)) / 255; ++ } ++} ++ ++static void disable_eosd(void) ++{ ++ if (!va_eosd_associated) ++ return; ++ ++ vaDeassociateSubpicture(va_context->display, ++ va_eosd_subpicture, ++ va_surface_ids, va_num_surfaces); ++ ++ va_eosd_associated = 0; ++} ++ ++static int enable_eosd(void) ++{ ++ VAStatus status; ++ ++ if (va_eosd_associated) ++ return 0; ++ ++ status = vaAssociateSubpicture2(va_context->display, ++ va_eosd_subpicture, ++ va_surface_ids, va_num_surfaces, ++ 0, 0, g_image_width, g_image_height, ++ 0, 0, g_image_width, g_image_height, ++ 0); ++ if (!check_status(status, "vaAssociateSubpicture()")) ++ return -1; ++ ++ va_eosd_associated = 1; ++ return 0; ++} ++ ++///< List of subpicture formats in preferred order ++static const struct { ++ uint32_t format; ++ eosd_draw_alpha_func draw_alpha; ++} ++va_eosd_info[] = { ++ { VA_FOURCC('B','G','R','A'), eosd_draw_alpha_bgra }, ++ { VA_FOURCC('R','G','B','A'), eosd_draw_alpha_rgba }, ++ { 0, NULL } ++}; ++ ++static int is_direct_mapping_init(void) ++{ ++ VADisplayAttribute attr; ++ VAStatus status; ++ ++ if (va_dm < 2) ++ return va_dm; ++ ++ /* If the driver doesn't make a copy of the VA surface for ++ display, then we have to retain it until it's no longer the ++ visible surface. In other words, if the driver is using ++ DirectSurface mode, we don't want to decode the new surface ++ into the previous one that was used for display. */ ++ attr.type = VADisplayAttribDirectSurface; ++ attr.flags = VA_DISPLAY_ATTRIB_GETTABLE; ++ ++ status = vaGetDisplayAttributes(va_context->display, &attr, 1); ++ if (status == VA_STATUS_SUCCESS) ++ return !attr.value; ++ return 0; ++} ++ ++static inline int is_direct_mapping(void) ++{ ++ static int dm = -1; ++ if (dm < 0) { ++ dm = is_direct_mapping_init(); ++ if (dm) ++ mp_msg(MSGT_VO, MSGL_INFO, ++ "[vo_vaapi] Using 1:1 VA surface mapping\n"); ++ } ++ return dm; ++} ++ ++static int int_012(int *n) ++{ ++ return *n >= 0 && *n <= 2; ++} ++ ++static const opt_t subopts[] = { ++ { "dm", OPT_ARG_INT, &va_dm, (opt_test_f)int_012 }, ++ { "stats", OPT_ARG_BOOL, &cpu_stats, NULL }, ++ { "deint", OPT_ARG_INT, &g_deint, (opt_test_f)int_012 }, ++#if USE_VAAPI_COLORSPACE ++ { "colorspace", OPT_ARG_INT, &g_colorspace, (opt_test_f)int_012 }, ++#endif ++#if CONFIG_GL ++ { "gl", OPT_ARG_BOOL, &gl_enabled, NULL }, ++#if USE_VAAPI_GLX_BIND ++ { "bind", OPT_ARG_BOOL, &gl_binding, NULL }, ++#endif ++ { "reflect", OPT_ARG_BOOL, &gl_reflect, NULL }, ++#endif ++ { NULL, } ++}; ++ ++static int preinit(const char *arg) ++{ ++ VADisplayAttribute *display_attrs; ++ VAStatus status; ++ int va_major_version, va_minor_version; ++ int i, max_image_formats, max_subpic_formats, max_profiles; ++ int num_display_attrs, max_display_attrs; ++ ++ va_dm = 2; ++ g_deint = 0; ++ g_deint_type = 2; ++ g_colorspace = 1; ++ if (subopt_parse(arg, subopts) != 0) { ++ mp_msg(MSGT_VO, MSGL_FATAL, ++ "\n-vo vaapi command line help:\n" ++ "Example: mplayer -vo vaapi:gl\n" ++ "\nOptions:\n" ++ " dm\n" ++ " 0: use least-recently-used VA surface\n" ++ " 1: identify VA surface with MPI index\n" ++ " 2: auto-detect use of direct surface mapping (default)\n" ++ " deint (all modes > 0 respect -field-dominance)\n" ++ " 0: no deinterlacing (default)\n" ++ " 1: only show first field\n" ++ " 2: bob deinterlacing\n" ++ " colorspace\n" ++ " 0: guess based on video resolution\n" ++ " 1: ITU-R BT.601 (default)\n" ++ " 2: ITU-R BT.709\n" ++#if CONFIG_GL ++ " gl\n" ++ " Enable OpenGL rendering\n" ++#if USE_VAAPI_GLX_BIND ++ " bind\n" ++ " Use VA surface binding instead of copy\n" ++#endif ++ " reflect\n" ++ " Enable OpenGL reflection effects\n" ++#endif ++ "\n" ); ++ return -1; ++ } ++ if (g_deint) ++ g_deint_type = g_deint; ++#if CONFIG_GL ++ if (gl_enabled) ++ mp_msg(MSGT_VO, MSGL_INFO, "[vo_vaapi] Using OpenGL rendering%s\n", ++ gl_reflect ? ", with reflection effects" : ""); ++#endif ++ ++ stats_init(); ++ ++#if CONFIG_GL ++ if (gl_enabled && !init_mpglcontext(&gl_context, GLTYPE_X11)) ++ return -1; ++ else ++#endif ++ if (!vo_init()) ++ return -1; ++ ++ va_context = calloc(1, sizeof(*va_context)); ++ if (!va_context) ++ return -1; ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_enabled) ++ va_context->display = vaGetDisplayGLX(mDisplay); ++ else ++#endif ++ va_context->display = vaGetDisplay(mDisplay); ++ if (!va_context->display) ++ return -1; ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] preinit(): VA display %p\n", va_context->display); ++ ++ status = vaInitialize(va_context->display, &va_major_version, &va_minor_version); ++ if (!check_status(status, "vaInitialize()")) ++ return -1; ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] preinit(): VA API version %d.%d\n", ++ va_major_version, va_minor_version); ++ ++ max_image_formats = vaMaxNumImageFormats(va_context->display); ++ va_image_formats = calloc(max_image_formats, sizeof(*va_image_formats)); ++ if (!va_image_formats) ++ return -1; ++ status = vaQueryImageFormats(va_context->display, va_image_formats, &va_num_image_formats); ++ if (!check_status(status, "vaQueryImageFormats()")) ++ return -1; ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] preinit(): %d image formats available\n", ++ va_num_image_formats); ++ for (i = 0; i < va_num_image_formats; i++) ++ mp_msg(MSGT_VO, MSGL_DBG2, " %s\n", string_of_VAImageFormat(&va_image_formats[i])); ++ ++ max_subpic_formats = vaMaxNumSubpictureFormats(va_context->display); ++ va_subpic_formats = calloc(max_subpic_formats, sizeof(*va_subpic_formats)); ++ if (!va_subpic_formats) ++ return -1; ++ va_subpic_flags = calloc(max_subpic_formats, sizeof(*va_subpic_flags)); ++ if (!va_subpic_flags) ++ return -1; ++ status = vaQuerySubpictureFormats(va_context->display, va_subpic_formats, va_subpic_flags, &va_num_subpic_formats); ++ if (!check_status(status, "vaQuerySubpictureFormats()")) ++ va_num_subpic_formats = 0; /* XXX: don't error out for IEGD */ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] preinit(): %d subpicture formats available\n", ++ va_num_subpic_formats); ++ for (i = 0; i < va_num_subpic_formats; i++) ++ mp_msg(MSGT_VO, MSGL_DBG2, " %s, flags 0x%x\n", string_of_VAImageFormat(&va_subpic_formats[i]), va_subpic_flags[i]); ++ ++ max_profiles = vaMaxNumProfiles(va_context->display); ++ va_profiles = calloc(max_profiles, sizeof(*va_profiles)); ++ if (!va_profiles) ++ return -1; ++ status = vaQueryConfigProfiles(va_context->display, va_profiles, &va_num_profiles); ++ if (!check_status(status, "vaQueryConfigProfiles()")) ++ return -1; ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] preinit(): %d profiles available\n", ++ va_num_profiles); ++ for (i = 0; i < va_num_profiles; i++) ++ mp_msg(MSGT_VO, MSGL_DBG2, " %s\n", string_of_VAProfile(va_profiles[i])); ++ ++ va_osd_subpicture = VA_INVALID_ID; ++ va_osd_image.image_id = VA_INVALID_ID; ++ va_eosd_subpicture = VA_INVALID_ID; ++ va_eosd_image.image_id = VA_INVALID_ID; ++ ++ max_display_attrs = vaMaxNumDisplayAttributes(va_context->display); ++ display_attrs = calloc(max_display_attrs, sizeof(*display_attrs)); ++ if (display_attrs) { ++ num_display_attrs = 0; ++ status = vaQueryDisplayAttributes(va_context->display, ++ display_attrs, &num_display_attrs); ++ if (check_status(status, "vaQueryDisplayAttributes()")) { ++ for (i = 0; i < num_display_attrs; i++) { ++ VADisplayAttribute *attr; ++ switch (display_attrs[i].type) { ++ case VADisplayAttribBrightness: ++ attr = &va_equalizer.brightness; ++ break; ++ case VADisplayAttribContrast: ++ attr = &va_equalizer.contrast; ++ break; ++ case VADisplayAttribHue: ++ attr = &va_equalizer.hue; ++ break; ++ case VADisplayAttribSaturation: ++ attr = &va_equalizer.saturation; ++ break; ++ default: ++ attr = NULL; ++ break; ++ } ++ if (attr) ++ *attr = display_attrs[i]; ++ } ++ } ++ free(display_attrs); ++ } ++ return 0; ++} ++ ++static void free_video_specific(void) ++{ ++ int i; ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_surface) { ++ VAStatus status; ++ status = vaDestroySurfaceGLX(va_context->display, gl_surface); ++ check_status(status, "vaDestroySurfaceGLX()"); ++ gl_surface = NULL; ++ } ++#endif ++ ++ if (va_context && va_context->context_id) { ++ vaDestroyContext(va_context->display, va_context->context_id); ++ va_context->context_id = 0; ++ } ++ ++ if (va_free_surfaces) { ++ for (i = 0; i < va_num_surfaces; i++) { ++ if (!va_free_surfaces[i]) ++ continue; ++ if (va_free_surfaces[i]->image.image_id != VA_INVALID_ID) { ++ vaDestroyImage(va_context->display, ++ va_free_surfaces[i]->image.image_id); ++ va_free_surfaces[i]->image.image_id = VA_INVALID_ID; ++ } ++ free(va_free_surfaces[i]); ++ va_free_surfaces[i] = NULL; ++ } ++ free(va_free_surfaces); ++ va_free_surfaces = NULL; ++ va_free_surfaces_head_index = 0; ++ va_free_surfaces_tail_index = 0; ++ } ++ ++ g_output_surface = 0; ++ memset(g_output_surfaces, 0, sizeof(g_output_surfaces)); ++ ++ if (va_osd_palette) { ++ free(va_osd_palette); ++ va_osd_palette = NULL; ++ } ++ ++ disable_eosd(); ++ disable_osd(); ++ ++ if (va_eosd_subpicture != VA_INVALID_ID) { ++ vaDestroySubpicture(va_context->display, va_eosd_subpicture); ++ va_eosd_subpicture = VA_INVALID_ID; ++ } ++ ++ if (va_eosd_image.image_id != VA_INVALID_ID) { ++ vaDestroyImage(va_context->display, va_eosd_image.image_id); ++ va_eosd_image.image_id = VA_INVALID_ID; ++ } ++ ++ if (va_osd_subpicture != VA_INVALID_ID) { ++ vaDestroySubpicture(va_context->display, va_osd_subpicture); ++ va_osd_subpicture = VA_INVALID_ID; ++ } ++ ++ if (va_osd_image.image_id != VA_INVALID_ID) { ++ vaDestroyImage(va_context->display, va_osd_image.image_id); ++ va_osd_image.image_id = VA_INVALID_ID; ++ } ++ ++ if (va_surface_ids) { ++ vaDestroySurfaces(va_context->display, va_surface_ids, va_num_surfaces); ++ free(va_surface_ids); ++ va_surface_ids = NULL; ++ va_num_surfaces = 0; ++ } ++ ++ if (va_context && va_context->config_id) { ++ vaDestroyConfig(va_context->display, va_context->config_id); ++ va_context->config_id = 0; ++ } ++ ++ if (va_entrypoints) { ++ free(va_entrypoints); ++ va_entrypoints = NULL; ++ } ++ ++#if CONFIG_GL ++ if (gl_texture) { ++ glDeleteTextures(1, &gl_texture); ++ gl_texture = GL_NONE; ++ } ++#endif ++} ++ ++static void uninit(void) ++{ ++ if (!vo_config_count) ++ return; ++ ++ free_video_specific(); ++ ++ if (va_profiles) { ++ free(va_profiles); ++ va_profiles = NULL; ++ } ++ ++ if (va_subpic_flags) { ++ free(va_subpic_flags); ++ va_subpic_flags = NULL; ++ } ++ ++ if (va_subpic_formats) { ++ free(va_subpic_formats); ++ va_subpic_formats = NULL; ++ } ++ ++ if (va_image_formats) { ++ free(va_image_formats); ++ va_image_formats = NULL; ++ } ++ ++ if (va_context && va_context->display) { ++ vaTerminate(va_context->display); ++ va_context->display = NULL; ++ } ++ ++ if (va_context) { ++ free(va_context); ++ va_context = NULL; ++ } ++ ++#ifdef CONFIG_XF86VM ++ vo_vm_close(); ++#endif ++#if CONFIG_GL ++ if (gl_enabled) ++ uninit_mpglcontext(&gl_context); ++ else ++#endif ++ vo_x11_uninit(); ++ ++ stats_exit(); ++} ++ ++static int config_x11(uint32_t width, uint32_t height, ++ uint32_t display_width, uint32_t display_height, ++ uint32_t flags, char *title) ++{ ++ Colormap cmap; ++ XVisualInfo visualInfo; ++ XVisualInfo *vi; ++ XSetWindowAttributes xswa; ++ unsigned long xswa_mask; ++ XWindowAttributes wattr; ++ int depth; ++ ++#ifdef CONFIG_GUI ++ if (use_gui) ++ guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize our window ++ else ++#endif ++ { ++#ifdef CONFIG_XF86VM ++ if (flags & VOFLAG_MODESWITCHING) ++ vo_vm_switch(); ++#endif ++ XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &wattr); ++ depth = wattr.depth; ++ if (depth != 15 && depth != 16 && depth != 24 && depth != 32) ++ depth = 24; ++ XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &visualInfo); ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_enabled) { ++ vi = glXChooseVisual(mDisplay, mScreen, gl_visual_attr); ++ if (!vi) ++ return -1; ++ cmap = XCreateColormap(mDisplay, mRootWin, vi->visual, AllocNone); ++ if (cmap == None) ++ return -1; ++ } ++ else ++#endif ++ { ++ vi = &visualInfo; ++ XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, vi); ++ cmap = CopyFromParent; ++ } ++ ++ vo_x11_create_vo_window(vi, ++ vo_dx, vo_dy, display_width, display_height, ++ flags, cmap, "vaapi", title); ++ ++ if (vi != &visualInfo) ++ XFree(vi); ++ ++ xswa_mask = CWBorderPixel | CWBackPixel; ++ xswa.border_pixel = 0; ++ xswa.background_pixel = 0; ++ XChangeWindowAttributes(mDisplay, vo_window, xswa_mask, &xswa); ++ ++#ifdef CONFIG_XF86VM ++ if (flags & VOFLAG_MODESWITCHING) { ++ /* Grab the mouse pointer in our window */ ++ if (vo_grabpointer) ++ XGrabPointer(mDisplay, vo_window, True, 0, ++ GrabModeAsync, GrabModeAsync, ++ vo_window, None, CurrentTime); ++ XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); ++ } ++#endif ++ } ++ ++ if ((flags & VOFLAG_FULLSCREEN) && WinID <= 0) ++ vo_fs = VO_TRUE; ++ return 0; ++} ++ ++#if CONFIG_VAAPI_GLX ++static int config_glx(unsigned int width, unsigned int height) ++{ ++ if (gl_context.setGlWindow(&gl_context) == SET_WINDOW_FAILED) ++ return -1; ++ ++ glDisable(GL_DEPTH_TEST); ++ glDepthMask(GL_FALSE); ++ glDisable(GL_CULL_FACE); ++ glEnable(GL_TEXTURE_2D); ++ glDrawBuffer(vo_doublebuffering ? GL_BACK : GL_FRONT); ++ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); ++ glEnable(GL_BLEND); ++ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ++ ++ /* Create OpenGL texture */ ++ /* XXX: assume GL_ARB_texture_non_power_of_two is available */ ++ glEnable(GL_TEXTURE_2D); ++ glGenTextures(1, &gl_texture); ++ BindTexture(GL_TEXTURE_2D, gl_texture); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); ++ glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, ++ GL_BGRA, GL_UNSIGNED_BYTE, NULL); ++ BindTexture(GL_TEXTURE_2D, 0); ++ glDisable(GL_TEXTURE_2D); ++ ++ glClearColor(0.0, 0.0, 0.0, 1.0); ++ glClear(GL_COLOR_BUFFER_BIT); ++ ++ if (gl_build_font() < 0) ++ return -1; ++ return 0; ++} ++#endif ++ ++static int config_vaapi(uint32_t width, uint32_t height, uint32_t format) ++{ ++ VAConfigAttrib attrib; ++ VAStatus status; ++ int i, j, profile, entrypoint, max_entrypoints, num_surfaces; ++ ++ /* Create video surfaces */ ++ if (!IMGFMT_IS_VAAPI(format)) ++ num_surfaces = MAX_OUTPUT_SURFACES; ++ else { ++ switch (IMGFMT_VAAPI_CODEC(format)) { ++ case IMGFMT_VAAPI_CODEC_MPEG2: ++ num_surfaces = NUM_VIDEO_SURFACES_MPEG2; ++ break; ++ case IMGFMT_VAAPI_CODEC_MPEG4: ++ num_surfaces = NUM_VIDEO_SURFACES_MPEG4; ++ break; ++ case IMGFMT_VAAPI_CODEC_H264: ++ num_surfaces = NUM_VIDEO_SURFACES_H264; ++ break; ++ case IMGFMT_VAAPI_CODEC_VC1: ++ num_surfaces = NUM_VIDEO_SURFACES_VC1; ++ break; ++ default: ++ num_surfaces = 0; ++ break; ++ } ++ if (num_surfaces == 0) ++ return -1; ++ if (!is_direct_mapping()) ++ num_surfaces = FFMIN(2 * num_surfaces, MAX_VIDEO_SURFACES); ++ } ++ for (i = 0; i < num_surfaces; i++) { ++ struct vaapi_surface *surface; ++ surface = alloc_vaapi_surface(width, height, VA_RT_FORMAT_YUV420); ++ if (!surface) ++ return -1; ++ } ++ assert(va_num_surfaces == num_surfaces); ++ ++#if CONFIG_VAAPI_GLX ++ /* Create GLX surfaces */ ++ if (gl_enabled) { ++ status = vaCreateSurfaceGLX(va_context->display, ++ GL_TEXTURE_2D, gl_texture, ++ &gl_surface); ++ if (!check_status(status, "vaCreateSurfaceGLX()")) ++ return -1; ++ } ++#endif ++ ++ /* Create OSD data */ ++ va_osd_draw_alpha = NULL; ++ va_osd_image.image_id = VA_INVALID_ID; ++ va_osd_image.buf = VA_INVALID_ID; ++ va_osd_subpicture = VA_INVALID_ID; ++ for (i = 0; va_osd_info[i].format; i++) { ++ for (j = 0; j < va_num_subpic_formats; j++) ++ if (va_subpic_formats[j].fourcc == va_osd_info[i].format) ++ break; ++ if (j < va_num_subpic_formats && ++ vaCreateImage(va_context->display, &va_subpic_formats[j], ++ width, height, &va_osd_image) == VA_STATUS_SUCCESS) { ++ va_osd_palette = gen_osd_palette(&va_osd_image); ++ if (((!va_osd_image.num_palette_entries) ^ (!va_osd_palette)) == 0) ++ break; ++ } ++ } ++ if (va_osd_info[i].format && ++ vaCreateSubpicture(va_context->display, va_osd_image.image_id, ++ &va_osd_subpicture) == VA_STATUS_SUCCESS) { ++ va_osd_draw_alpha = va_osd_info[i].draw_alpha; ++ if (va_osd_palette) { ++ status = vaSetImagePalette(va_context->display, ++ va_osd_image.image_id, va_osd_palette); ++ check_status(status, "vaSetImagePalette()"); ++ } ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] Using %s surface for OSD\n", ++ string_of_VAImageFormat(&va_osd_image.format)); ++ } ++ ++ /* Create EOSD data */ ++ va_eosd_draw_alpha = NULL; ++ va_eosd_image.image_id = VA_INVALID_ID; ++ va_eosd_image.buf = VA_INVALID_ID; ++ va_eosd_subpicture = VA_INVALID_ID; ++ for (i = 0; va_eosd_info[i].format; i++) { ++ for (j = 0; j < va_num_subpic_formats; j++) ++ if (va_subpic_formats[j].fourcc == va_eosd_info[i].format) ++ break; ++ if (j < va_num_subpic_formats && ++ vaCreateImage(va_context->display, &va_subpic_formats[j], ++ width, height, &va_eosd_image) == VA_STATUS_SUCCESS) ++ break; ++ } ++ if (va_eosd_info[i].format && ++ vaCreateSubpicture(va_context->display, va_eosd_image.image_id, ++ &va_eosd_subpicture) == VA_STATUS_SUCCESS) { ++ va_eosd_draw_alpha = va_eosd_info[i].draw_alpha; ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] Using %s surface for EOSD\n", ++ string_of_VAImageFormat(&va_eosd_image.format)); ++ } ++ ++ /* Allocate VA images */ ++ if (!IMGFMT_IS_VAAPI(format)) { ++ VAImageFormat *image_format = VAImageFormat_from_imgfmt(format); ++ if (!image_format) ++ return -1; ++ for (i = 0; i < va_num_surfaces; i++) { ++ status = vaCreateImage(va_context->display, image_format, ++ width, height, &va_free_surfaces[i]->image); ++ if (!check_status(status, "vaCreateImage()")) ++ return -1; ++ } ++ return 0; ++ } ++ ++ /* Check profile */ ++ profile = VAProfile_from_imgfmt(format); ++ if (profile < 0) ++ return -1; ++ ++ /* Check entry-point (only VLD for now) */ ++ max_entrypoints = vaMaxNumEntrypoints(va_context->display); ++ va_entrypoints = calloc(max_entrypoints, sizeof(*va_entrypoints)); ++ if (!va_entrypoints) ++ return -1; ++ ++ status = vaQueryConfigEntrypoints(va_context->display, profile, ++ va_entrypoints, &va_num_entrypoints); ++ if (!check_status(status, "vaQueryConfigEntrypoints()")) ++ return -1; ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] config_vaapi(%s): %d entrypoints available\n", ++ string_of_VAProfile(profile), va_num_entrypoints); ++ for (i = 0; i < va_num_entrypoints; i++) ++ mp_msg(MSGT_VO, MSGL_DBG2, " %s\n", string_of_VAEntrypoint(va_entrypoints[i])); ++ ++ entrypoint = VAEntrypoint_from_imgfmt(format); ++ if (entrypoint != VAEntrypointVLD) ++ return -1; ++ ++ /* Check chroma format (only 4:2:0 for now) */ ++ attrib.type = VAConfigAttribRTFormat; ++ status = vaGetConfigAttributes(va_context->display, profile, entrypoint, &attrib, 1); ++ if (!check_status(status, "vaGetConfigAttributes()")) ++ return -1; ++ if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) ++ return -1; ++ ++ /* Create a configuration for the decode pipeline */ ++ status = vaCreateConfig(va_context->display, profile, entrypoint, &attrib, 1, &va_context->config_id); ++ if (!check_status(status, "vaCreateConfig()")) ++ return -1; ++ ++ /* Create a context for the decode pipeline */ ++ status = vaCreateContext(va_context->display, va_context->config_id, ++ width, height, VA_PROGRESSIVE, ++ va_surface_ids, va_num_surfaces, ++ &va_context->context_id); ++ if (!check_status(status, "vaCreateContext()")) ++ return -1; ++ return 0; ++} ++ ++static int config(uint32_t width, uint32_t height, ++ uint32_t display_width, uint32_t display_height, ++ uint32_t flags, char *title, uint32_t format) ++{ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] config(): size %dx%d, display size %dx%d, flags %x, title '%s', format %x (%s)\n", ++ width, height, display_width, display_height, flags, title, format, vo_format_name(format)); ++ ++ free_video_specific(); ++ ++ if (config_x11(width, height, display_width, display_height, flags, title) < 0) ++ return -1; ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_enabled && config_glx(width, height) < 0) ++ return -1; ++#endif ++ ++ if (config_vaapi(width, height, format) < 0) ++ return -1; ++ ++ g_is_paused = 0; ++ g_image_width = width; ++ g_image_height = height; ++ g_image_format = format; ++ resize(); ++ return 0; ++} ++ ++static int query_format(uint32_t format) ++{ ++ const int default_caps = (VFCAP_CSP_SUPPORTED | ++ VFCAP_CSP_SUPPORTED_BY_HW | ++ VFCAP_HWSCALE_UP | ++ VFCAP_HWSCALE_DOWN | ++ VFCAP_OSD | ++ VFCAP_EOSD); ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] query_format(): format %x (%s)\n", ++ format, vo_format_name(format)); ++ ++ switch (format) { ++ case IMGFMT_VAAPI_MPEG2: ++ case IMGFMT_VAAPI_MPEG4: ++ case IMGFMT_VAAPI_H263: ++ case IMGFMT_VAAPI_H264: ++ case IMGFMT_VAAPI_WMV3: ++ case IMGFMT_VAAPI_VC1: ++ return default_caps | VOCAP_NOSLICES; ++ case IMGFMT_NV12: ++ case IMGFMT_YV12: ++ case IMGFMT_I420: ++ case IMGFMT_IYUV: ++ if (VAImageFormat_from_imgfmt(format)) ++ return default_caps; ++ break; ++ } ++ return 0; ++} ++ ++static inline int get_field_flags(int i) ++{ ++ return (g_deint ? ++ ((g_top_field_first ^ i) == 0 ? ++ VA_BOTTOM_FIELD : VA_TOP_FIELD) : VA_FRAME_PICTURE); ++} ++ ++static inline int get_colorspace_flags(void) ++{ ++ int csp = 0; ++#if USE_VAAPI_COLORSPACE ++ switch (g_colorspace) { ++ case 0: ++ csp = ((g_image_width >= 1280 || g_image_height > 576) ? ++ VA_SRC_BT709 : VA_SRC_BT601); ++ break; ++ case 1: ++ csp = VA_SRC_BT601; ++ break; ++ case 2: ++ csp = VA_SRC_BT709; ++ break; ++ default: ++ assert(0); ++ break; ++ } ++#endif ++ return csp; ++} ++ ++static void put_surface_x11(struct vaapi_surface *surface) ++{ ++ VAStatus status; ++ int i; ++ ++ for (i = 0; i <= !!(g_deint > 1); i++) { ++ status = vaPutSurface(va_context->display, ++ surface->id, ++ vo_window, ++ 0, 0, g_image_width, g_image_height, ++ g_output_rect.left, ++ g_output_rect.top, ++ g_output_rect.width, ++ g_output_rect.height, ++ NULL, 0, ++ get_field_flags(i) | get_colorspace_flags()); ++ if (!check_status(status, "vaPutSurface()")) ++ return; ++ } ++} ++ ++#if CONFIG_VAAPI_GLX ++static void put_surface_glx(struct vaapi_surface *surface) ++{ ++ VAStatus status; ++ int i; ++ ++ if (gl_binding) { ++#if USE_VAAPI_GLX_BIND ++ for (i = 0; i <= !!(g_deint > 1); i++) { ++ status = vaAssociateSurfaceGLX(va_context->display, ++ gl_surface, ++ surface->id, ++ get_field_flags(i) | get_colorspace_flags()); ++ if (!check_status(status, "vaAssociateSurfaceGLX()")) ++ return; ++ } ++#else ++ mp_msg(MSGT_VO, MSGL_WARN, "vaAssociateSurfaceGLX() is not implemented\n"); ++ gl_binding = 0; ++#endif ++ } ++ ++ if (!gl_binding) { ++ for (i = 0; i <= !!(g_deint > 1); i++) { ++ status = vaCopySurfaceGLX(va_context->display, ++ gl_surface, ++ surface->id, ++ get_field_flags(i) | get_colorspace_flags()); ++ ++ if (status == VA_STATUS_ERROR_UNIMPLEMENTED) { ++ mp_msg(MSGT_VO, MSGL_WARN, ++ "[vo_vaapi] vaCopySurfaceGLX() is not implemented\n"); ++ gl_binding = 1; ++ } ++ else { ++ if (!check_status(status, "vaCopySurfaceGLX()")) ++ return; ++ } ++ } ++ } ++ g_output_surfaces[g_output_surface] = surface; ++} ++ ++static int glx_bind_texture(void) ++{ ++ VAStatus status; ++ ++ glEnable(GL_TEXTURE_2D); ++ BindTexture(GL_TEXTURE_2D, gl_texture); ++ ++#if USE_VAAPI_GLX_BIND ++ if (gl_binding) { ++ status = vaBeginRenderSurfaceGLX(va_context->display, gl_surface); ++ if (!check_status(status, "vaBeginRenderSurfaceGLX()")) ++ return -1; ++ } ++#endif ++ return 0; ++} ++ ++static int glx_unbind_texture(void) ++{ ++ VAStatus status; ++ ++#if USE_VAAPI_GLX_BIND ++ if (gl_binding) { ++ status = vaEndRenderSurfaceGLX(va_context->display, gl_surface); ++ if (!check_status(status, "vaEndRenderSurfaceGLX()")) ++ return -1; ++ } ++#endif ++ ++ BindTexture(GL_TEXTURE_2D, 0); ++ glDisable(GL_TEXTURE_2D); ++ return 0; ++} ++ ++static void render_background(void) ++{ ++ /* Original code from Mirco Muller (MacSlow): ++ <http://cgit.freedesktop.org/~macslow/gl-gst-player/> */ ++ GLfloat fStartX = 0.0f; ++ GLfloat fStartY = 0.0f; ++ GLfloat fWidth = (GLfloat)vo_dwidth; ++ GLfloat fHeight = (GLfloat)vo_dheight; ++ ++ glBegin(GL_QUADS); ++ { ++ /* top third, darker grey to white */ ++ glColor3f(0.85f, 0.85f, 0.85f); ++ glVertex3f(fStartX, fStartY, 0.0f); ++ glColor3f(0.85f, 0.85f, 0.85f); ++ glVertex3f(fStartX + fWidth, fStartY, 0.0f); ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glVertex3f(fStartX + fWidth, fStartY + fHeight / 3.0f, 0.0f); ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glVertex3f(fStartX, fStartY + fHeight / 3.0f, 0.0f); ++ ++ /* middle third, just plain white */ ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glVertex3f(fStartX, fStartY + fHeight / 3.0f, 0.0f); ++ glVertex3f(fStartX + fWidth, fStartY + fHeight / 3.0f, 0.0f); ++ glVertex3f(fStartX + fWidth, fStartY + 2.0f * fHeight / 3.0f, 0.0f); ++ glVertex3f(fStartX, fStartY + 2.0f * fHeight / 3.0f, 0.0f); ++ ++ /* bottom third, white to lighter grey */ ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glVertex3f(fStartX, fStartY + 2.0f * fHeight / 3.0f, 0.0f); ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glVertex3f(fStartX + fWidth, fStartY + 2.0f * fHeight / 3.0f, 0.0f); ++ glColor3f(0.62f, 0.66f, 0.69f); ++ glVertex3f(fStartX + fWidth, fStartY + fHeight, 0.0f); ++ glColor3f(0.62f, 0.66f, 0.69f); ++ glVertex3f(fStartX, fStartY + fHeight, 0.0f); ++ } ++ glEnd(); ++} ++ ++static void render_frame(void) ++{ ++ struct vo_rect * const r = &g_output_rect; ++ ++ if (glx_bind_texture() < 0) ++ return; ++ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); ++ glBegin(GL_QUADS); ++ { ++ glTexCoord2f(0.0f, 0.0f); glVertex2i(r->left, r->top); ++ glTexCoord2f(0.0f, 1.0f); glVertex2i(r->left, r->bottom); ++ glTexCoord2f(1.0f, 1.0f); glVertex2i(r->right, r->bottom); ++ glTexCoord2f(1.0f, 0.0f); glVertex2i(r->right, r->top); ++ } ++ glEnd(); ++ if (glx_unbind_texture() < 0) ++ return; ++} ++ ++static void render_reflection(void) ++{ ++ struct vo_rect * const r = &g_output_rect; ++ const unsigned int rh = g_output_rect.height / 5; ++ GLfloat ry = 1.0f - (GLfloat)rh / (GLfloat)r->height; ++ ++ if (glx_bind_texture() < 0) ++ return; ++ glBegin(GL_QUADS); ++ { ++ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); ++ glTexCoord2f(0.0f, 1.0f); glVertex2i(r->left, r->top); ++ glTexCoord2f(1.0f, 1.0f); glVertex2i(r->right, r->top); ++ ++ glColor4f(1.0f, 1.0f, 1.0f, 0.0f); ++ glTexCoord2f(1.0f, ry); glVertex2i(r->right, r->top + rh); ++ glTexCoord2f(0.0f, ry); glVertex2i(r->left, r->top + rh); ++ } ++ glEnd(); ++ if (glx_unbind_texture() < 0) ++ return; ++} ++ ++static void flip_page_glx(void) ++{ ++ glClear(GL_COLOR_BUFFER_BIT); ++ ++ if (gl_reflect) { ++ render_background(); ++ ++ glPushMatrix(); ++ glRotatef(20.0f, 0.0f, 1.0f, 0.0f); ++ glTranslatef(50.0f, 0.0f, 0.0f); ++ } ++ ++ render_frame(); ++ ++ if (gl_reflect) { ++ glPushMatrix(); ++ glTranslatef(0.0, (GLfloat)g_output_rect.height + 5.0f, 0.0f); ++ render_reflection(); ++ glPopMatrix(); ++ glPopMatrix(); ++ } ++ ++ if (cpu_stats) { ++ gl_draw_rectangle(0, 0, vo_dwidth, 32, 0x000000ff); ++ glColor3f(1.0f, 1.0f, 1.0f); ++ glRasterPos2i(16, 20); ++ gl_printf("MPlayer: %.1f%% of CPU @ %u MHz", cpu_usage, cpu_frequency); ++ } ++ ++ gl_context.swapGlBuffers(&gl_context); ++ ++ if (vo_fs) /* avoid flickering borders in fullscreen mode */ ++ glClear(GL_COLOR_BUFFER_BIT); ++} ++#endif ++ ++static void put_surface(struct vaapi_surface *surface) ++{ ++ if (!surface || surface->id == VA_INVALID_SURFACE) ++ return; ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_enabled) ++ put_surface_glx(surface); ++ else ++#endif ++ put_surface_x11(surface); ++} ++ ++static int draw_slice(uint8_t * image[], int stride[], ++ int w, int h, int x, int y) ++{ ++ struct vaapi_surface * const surface = va_free_surfaces[g_output_surface]; ++ VAImage * const va_image = &surface->image; ++ VAStatus status; ++ uint8_t *image_data = NULL; ++ uint8_t *dst[3] = { 0, }; ++ unsigned int dst_stride[3]; ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] draw_slice(): location (%d,%d), size %dx%d\n", x, y, w, h); ++ ++ status = vaMapBuffer(va_context->display, va_image->buf, &image_data); ++ if (!check_status(status, "vaMapBuffer()")) ++ return VO_FALSE; ++ ++ dst_stride[0] = va_image->pitches[0]; ++ dst[0] = image_data + va_image->offsets[0] + y * dst_stride[0] + x; ++ ++ memcpy_pic(dst[0], image[0], w, h, dst_stride[0], stride[0]); ++ ++ x /= 2; ++ y /= 2; ++ w /= 2; ++ h /= 2; ++ ++ if (g_image_format == IMGFMT_YV12) { ++ /* MPlayer's YV12 is actually I420, so swap U/V components */ ++ dst_stride[1] = va_image->pitches[2]; ++ dst[1] = image_data + va_image->offsets[2] + y * dst_stride[1] + x; ++ dst_stride[2] = va_image->pitches[1]; ++ dst[2] = image_data + va_image->offsets[1] + y * dst_stride[2] + x; ++ } ++ else { ++ if (image[1]) { ++ dst_stride[1] = va_image->pitches[1]; ++ dst[1] = image_data + va_image->offsets[1] + y * dst_stride[1] + x; ++ } ++ if (image[2]) { ++ dst_stride[2] = va_image->pitches[2]; ++ dst[2] = image_data + va_image->offsets[2] + y * dst_stride[2] + x; ++ } ++ } ++ ++ if (image[1]) /* RGBA only has a single plane */ ++ memcpy_pic(dst[1], image[1], w, h, dst_stride[1], stride[1]); ++ ++ if (image[2]) /* NV12 only has two planes */ ++ memcpy_pic(dst[2], image[2], w, h, dst_stride[2], stride[2]); ++ ++ status = vaUnmapBuffer(va_context->display, surface->image.buf); ++ if (!check_status(status, "vaUnmapBuffer()")) ++ return VO_FALSE; ++ ++ return VO_TRUE; ++} ++ ++static int draw_frame(uint8_t * src[]) ++{ ++ mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_X11_DrawFrameCalled); ++ ++ return -1; ++} ++ ++static void draw_osd(void) ++{ ++ VAStatus status; ++ ++ if (!va_osd_draw_alpha) ++ return; ++ ++ if (!vo_update_osd(g_image_width, g_image_height)) ++ return; ++ ++ if (!vo_osd_check_range_update(0, 0, g_image_width, g_image_height)) { ++ disable_osd(); ++ return; ++ } ++ ++ status = vaMapBuffer(va_context->display, va_osd_image.buf, ++ &va_osd_image_data); ++ if (!check_status(status, "vaMapBuffer()")) ++ return; ++ ++ memset(va_osd_image_data, 0, va_osd_image.data_size); ++ ++ set_osd_image_dirty_rect(0, 0, g_image_width, g_image_height); ++ vo_draw_text(g_image_width, g_image_height, va_osd_draw_alpha); ++ ++ status = vaUnmapBuffer(va_context->display, va_osd_image.buf); ++ if (!check_status(status, "vaUnmapBuffer()")) ++ return; ++ va_osd_image_data = NULL; ++ ++ enable_osd(&va_osd_image_dirty_rect, &va_osd_image_dirty_rect); ++} ++ ++static void draw_eosd(mp_eosd_images_t *imgs) ++{ ++ ass_image_t *img = imgs->imgs; ++ ass_image_t *i; ++ VAStatus status; ++ ++ if (!va_eosd_draw_alpha) ++ return; ++ ++ // Nothing changed, no need to redraw ++ if (imgs->changed == 0) ++ return; ++ ++ // There's nothing to render! ++ if (!img) { ++ disable_eosd(); ++ return; ++ } ++ ++ if (imgs->changed == 1) ++ goto eosd_skip_upload; ++ ++ status = vaMapBuffer(va_context->display, va_eosd_image.buf, ++ &va_eosd_image_data); ++ if (!check_status(status, "vaMapBuffer()")) ++ return; ++ ++ memset(va_eosd_image_data, 0, va_eosd_image.data_size); ++ ++ for (i = img; i; i = i->next) ++ va_eosd_draw_alpha(i->bitmap, i->w, i->h, i->stride, ++ i->dst_x, i->dst_y, i->color); ++ ++ status = vaUnmapBuffer(va_context->display, va_eosd_image.buf); ++ if (!check_status(status, "vaUnmapBuffer()")) ++ return; ++ va_eosd_image_data = NULL; ++ ++eosd_skip_upload: ++ enable_eosd(); ++} ++ ++static void flip_page(void) ++{ ++ struct vaapi_surface *surface; ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] flip_page()\n"); ++ ++ surface = g_output_surfaces[g_output_surface]; ++ if (surface) ++ put_surface(surface); ++ g_output_surface = (g_output_surface + 1) % MAX_OUTPUT_SURFACES; ++ ++#if CONFIG_VAAPI_GLX ++ if (gl_enabled && surface) ++ flip_page_glx(); ++#endif ++} ++ ++static struct vaapi_surface *get_surface(mp_image_t *mpi) ++{ ++ struct vaapi_surface *surface; ++ ++ if (mpi->type == MP_IMGTYPE_NUMBERED && is_direct_mapping()) { ++ assert(mpi->number < va_num_surfaces); ++ surface = va_free_surfaces[mpi->number]; ++ return surface; ++ } ++ ++ /* Push current surface to a free slot */ ++ if (mpi->priv) { ++ assert(!va_free_surfaces[va_free_surfaces_tail_index]); ++ va_free_surfaces[va_free_surfaces_tail_index] = mpi->priv; ++ va_free_surfaces_tail_index = (va_free_surfaces_tail_index + 1) % va_num_surfaces; ++ } ++ ++ /* Pop the least recently used free surface */ ++ assert(va_free_surfaces[va_free_surfaces_head_index]); ++ surface = va_free_surfaces[va_free_surfaces_head_index]; ++ va_free_surfaces[va_free_surfaces_head_index] = NULL; ++ va_free_surfaces_head_index = (va_free_surfaces_head_index + 1) % va_num_surfaces; ++ return surface; ++} ++ ++static uint32_t get_image(mp_image_t *mpi) ++{ ++ struct vaapi_surface *surface; ++ ++ if (mpi->type != MP_IMGTYPE_NUMBERED) ++ return VO_FALSE; ++ ++ if (!IMGFMT_IS_VAAPI(g_image_format)) ++ return VO_FALSE; ++ ++ surface = get_surface(mpi); ++ if (!surface) ++ return VO_FALSE; ++ ++ mpi->flags |= MP_IMGFLAG_DIRECT; ++ mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = mpi->stride[3] = 0; ++ mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = mpi->planes[3] = NULL; ++ mpi->planes[0] = (char *)surface; ++ mpi->planes[3] = (char *)(uintptr_t)surface->id; ++ mpi->num_planes = 1; ++ mpi->priv = surface; ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] get_image(): surface 0x%08x\n", surface->id); ++ ++ return VO_TRUE; ++} ++ ++static int put_image(mp_image_t *mpi, struct vaapi_surface *surface) ++{ ++ VAStatus status; ++ ++ if ((mpi->flags & (MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV)) != (MP_IMGFLAG_PLANAR|MP_IMGFLAG_YUV)) ++ return VO_FALSE; ++ ++ if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) { ++ if (!draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0)) ++ return VO_FALSE; ++ } ++ ++ status = vaPutImage2(va_context->display, ++ surface->id, ++ surface->image.image_id, ++ mpi->x, mpi->y, mpi->w, mpi->h, ++ mpi->x, mpi->y, mpi->w, mpi->h); ++ if (!check_status(status, "vaPutImage()")) ++ return VO_FALSE; ++ ++ return VO_TRUE; ++} ++ ++static uint32_t draw_image(mp_image_t *mpi) ++{ ++ struct vaapi_surface *surface = (struct vaapi_surface *)mpi->priv; ++ ++ if (!IMGFMT_IS_VAAPI(mpi->imgfmt)) { ++ /* XXX: no direct rendering in non-accelerated mode */ ++ surface = va_free_surfaces[g_output_surface]; ++ if (!put_image(mpi, surface)) ++ return VO_FALSE; ++ } ++ ++ mp_msg(MSGT_VO, MSGL_DBG2, "[vo_vaapi] draw_image(): surface 0x%08x\n", surface->id); ++ ++ g_output_surfaces[g_output_surface] = surface; ++ ++ if (mpi->fields & MP_IMGFIELD_ORDERED) ++ g_top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST); ++ else ++ g_top_field_first = 1; ++ ++ if (cpu_stats) { ++ static uint64_t ticks; ++ if ((ticks++ % 30) == 0) { ++ cpu_frequency = get_cpu_frequency(); ++ cpu_usage = get_cpu_usage(CPU_USAGE_QUANTUM); ++ } ++ } ++ return VO_TRUE; ++} ++ ++static void check_events(void) ++{ ++ int events = vo_x11_check_events(mDisplay); ++ ++ if (events & VO_EVENT_RESIZE) ++ resize(); ++ ++ if ((events & (VO_EVENT_EXPOSE|VO_EVENT_RESIZE)) && g_is_paused) { ++ struct vaapi_surface *surface = g_output_surfaces[g_output_surface]; ++ if (surface) ++ put_surface(surface); ++ } ++} ++ ++static VADisplayAttribute *get_display_attribute(const char *name) ++{ ++ VADisplayAttribute *attr; ++ if (!strcasecmp(name, "brightness")) ++ attr = &va_equalizer.brightness; ++ else if (!strcasecmp(name, "contrast")) ++ attr = &va_equalizer.contrast; ++ else if (!strcasecmp(name, "saturation")) ++ attr = &va_equalizer.saturation; ++ else if (!strcasecmp(name, "hue")) ++ attr = &va_equalizer.hue; ++ else ++ attr = NULL; ++ return attr; ++} ++ ++static int get_equalizer(const char *name, int *value) ++{ ++ VADisplayAttribute * const attr = get_display_attribute(name); ++ int r; ++ ++ if (!attr || !(attr->flags & VA_DISPLAY_ATTRIB_GETTABLE)) ++ return VO_NOTIMPL; ++ ++ /* normalize to -100 .. 100 range */ ++ r = attr->max_value - attr->min_value; ++ if (r == 0) ++ return VO_NOTIMPL; ++ *value = ((attr->value - attr->min_value) * 200) / r - 100; ++ return VO_TRUE; ++} ++ ++static int set_equalizer(const char *name, int value) ++{ ++ VADisplayAttribute * const attr = get_display_attribute(name); ++ VAStatus status; ++ int r; ++ ++ if (!attr || !(attr->flags & VA_DISPLAY_ATTRIB_SETTABLE)) ++ return VO_NOTIMPL; ++ ++ /* normalize to attribute value range */ ++ r = attr->max_value - attr->min_value; ++ if (r == 0) ++ return VO_NOTIMPL; ++ attr->value = ((value + 100) * r) / 200 + attr->min_value; ++ ++ status = vaSetDisplayAttributes(va_context->display, attr, 1); ++ if (!check_status(status, "vaSetDisplayAttributes()")) ++ return VO_FALSE; ++ return VO_TRUE; ++} ++ ++static int control(uint32_t request, void *data, ...) ++{ ++ switch (request) { ++ case VOCTRL_GET_DEINTERLACE: ++ *(int*)data = g_deint; ++ return VO_TRUE; ++ case VOCTRL_SET_DEINTERLACE: ++ g_deint = *(int*)data; ++ if (g_deint) ++ g_deint = g_deint_type; ++ return VO_TRUE; ++ case VOCTRL_PAUSE: ++ return (g_is_paused = 1); ++ case VOCTRL_RESUME: ++ return (g_is_paused = 0); ++ case VOCTRL_QUERY_FORMAT: ++ return query_format(*((uint32_t *)data)); ++ case VOCTRL_GET_IMAGE: ++ return get_image(data); ++ case VOCTRL_DRAW_IMAGE: ++ return draw_image(data); ++ case VOCTRL_GUISUPPORT: ++ return VO_TRUE; ++ case VOCTRL_BORDER: ++ vo_x11_border(); ++ resize(); ++ return VO_TRUE; ++ case VOCTRL_FULLSCREEN: ++ vo_x11_fullscreen(); ++ resize(); ++ return VO_TRUE; ++ case VOCTRL_SET_EQUALIZER: { ++ va_list ap; ++ int value; ++ ++ va_start(ap, data); ++ value = va_arg(ap, int); ++ ++ va_end(ap); ++ return set_equalizer(data, value); ++ } ++ case VOCTRL_GET_EQUALIZER: { ++ va_list ap; ++ int *value; ++ ++ va_start(ap, data); ++ value = va_arg(ap, int *); ++ ++ va_end(ap); ++ return get_equalizer(data, value); ++ } ++ case VOCTRL_ONTOP: ++ vo_x11_ontop(); ++ return VO_TRUE; ++ case VOCTRL_UPDATE_SCREENINFO: ++ update_xinerama_info(); ++ return VO_TRUE; ++ case VOCTRL_GET_PANSCAN: ++ return VO_TRUE; ++ case VOCTRL_SET_PANSCAN: ++ resize(); ++ return VO_TRUE; ++ case VOCTRL_GET_HWACCEL_CONTEXT: ++ *((void **)data) = va_context; ++ return VO_TRUE; ++ case VOCTRL_DRAW_EOSD: ++ if (!data) ++ return VO_FALSE; ++ draw_eosd(data); ++ return VO_TRUE; ++ case VOCTRL_GET_EOSD_RES: { ++ mp_eosd_res_t *r = data; ++ r->mt = r->mb = r->ml = r->mr = 0; ++ r->srcw = g_image_width; ++ r->srch = g_image_height; ++ r->w = g_image_width; ++ r->h = g_image_height; ++ return VO_TRUE; ++ } ++ } ++ return VO_NOTIMPL; ++} diff --git a/media-video/mplayer/files/vaapi/02-mplayer-vaapi-gma500-workaround.patch b/media-video/mplayer/files/vaapi/02-mplayer-vaapi-gma500-workaround.patch new file mode 100644 index 0000000..88ca8da --- /dev/null +++ b/media-video/mplayer/files/vaapi/02-mplayer-vaapi-gma500-workaround.patch @@ -0,0 +1,97 @@ +commit 7d70d28f190e37cfa3a9a827877ddd6bb81408d3 +Author: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com> +Date: Mon Dec 28 08:52:56 2009 +0000 + + Add GMA500 workaround for H.264 DPB. This is disabled by default. Enable with GMA500_WORKAROUND=yes environment variable. + +diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c +index 9f440c0..0139d64 100644 +--- a/libavcodec/vaapi_h264.c ++++ b/libavcodec/vaapi_h264.c +@@ -28,6 +28,60 @@ + * structures for H.264 decoding. + */ + ++/** Parses ENV environment variable expecting "yes" | "no" values. */ ++static int getenv_yesno(const char *env, int *pval) ++{ ++ int val; ++ const char *env_str; ++ ++ env_str = getenv(env); ++ if (!env_str) ++ return -1; ++ ++ if (strcmp(env_str, "1") == 0 || strcmp(env_str, "yes") == 0) ++ val = 1; ++ else if (strcmp(env_str, "0") == 0 || strcmp(env_str, "no") == 0) ++ val = 0; ++ else ++ return -1; ++ ++ if (pval) ++ *pval = val; ++ return 0; ++} ++ ++/** ++ * Use old GMA500 workaround for DPB. It requires other pictures than ++ * those marked as "used for reference". ++ */ ++static int get_use_gma500_workaround(struct vaapi_context *vactx) ++{ ++ int gma500_workaround_env; ++ const char *vendor_string; ++ ++ if (getenv_yesno("GMA500_WORKAROUND", &gma500_workaround_env) < 0) ++ return 0; ++ if (!gma500_workaround_env) ++ return 0; ++ ++ vendor_string = vaQueryVendorString(vactx->display); ++ if (vendor_string && strstr(vendor_string, "Intel")) { ++ if (strstr(vendor_string, "GMA500")) ++ return 1; ++ if (strstr(vendor_string, "Embedded Graphics Driver")) ++ return 1; ++ } ++ return 0; ++} ++ ++static inline int use_gma500_workaround(struct vaapi_context *vactx) ++{ ++ static int gma500_workaround = -1; ++ if (gma500_workaround < 0) ++ gma500_workaround = get_use_gma500_workaround(vactx); ++ return gma500_workaround; ++} ++ + /** + * Initializes an empty VA API picture. + * +@@ -123,6 +177,7 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, + { + DPB dpb; + int i; ++ unsigned int list; + + dpb.size = 0; + dpb.max_size = FF_ARRAY_ELEMS(pic_param->ReferenceFrames); +@@ -130,6 +185,17 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, + for (i = 0; i < dpb.max_size; i++) + init_vaapi_pic(&dpb.va_pics[i]); + ++ if (use_gma500_workaround(h->s.avctx->hwaccel_context)) { ++ /* XXX: this is really wrong */ ++ for (list = 0; list < h->list_count; list++) ++ for (i = 0; i < (int)h->ref_count[list]; i++) { ++ Picture * const pic = &h->ref_list[list][i]; ++ if (pic->reference && dpb_add(&dpb, pic) < 0) ++ return -1; ++ } ++ return 0; ++ } ++ + for (i = 0; i < h->short_ref_count; i++) { + Picture * const pic = h->short_ref[i]; + if (pic && pic->reference && dpb_add(&dpb, pic) < 0) diff --git a/media-video/mplayer/files/vaapi/03-mplayer-vaapi-0.29.patch b/media-video/mplayer/files/vaapi/03-mplayer-vaapi-0.29.patch new file mode 100644 index 0000000..d2f7bba --- /dev/null +++ b/media-video/mplayer/files/vaapi/03-mplayer-vaapi-0.29.patch @@ -0,0 +1,675 @@ +commit ea392cb5fb1265c433b530535108ad8a441b61f6 +Author: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com> +Date: Fri Feb 12 11:03:00 2010 +0000 + + Add compatibility with original VA-API 0.29. + +diff --git a/configure b/configure +index 39fef26..f2f9f2e 100755 +--- a/configure ++++ b/configure +@@ -5109,20 +5109,35 @@ echores "$_glu" + echocheck "VA API" + if test "$_vaapi" = yes -o "$_vaapi" = auto; then + _vaapi=no ++ _vaapi_old=no + cat > $TMPC <<EOF + #include <va/va_x11.h> + int main(void) { (void) vaGetDisplay(0); return 0; } + EOF +- cc_check -lva-x11 && _vaapi=yes ++ cc_check -lva-x11 && _vaapi=yes || { ++ cat > $TMPC <<EOF ++#include <va_x11.h> ++int main(void) { (void) vaGetDisplay(0); return 0; } ++EOF ++ cc_check -lva && _vaapi=yes _vaapi_old=yes ++ } + fi + + if test "$_vaapi" = yes ; then + def_vaapi='#define CONFIG_VAAPI 1' +- libs_mencoder="$libs_mencoder -lva" +- libs_mplayer="$libs_mplayer -lva-x11" ++ if test "$_vaapi_old" = no ; then ++ def_vaapi_old='#define CONFIG_VAAPI_OLD 0' ++ libs_mencoder="$libs_mencoder -lva" ++ libs_mplayer="$libs_mplayer -lva-x11 -lva" ++ else ++ def_vaapi_old='#define CONFIG_VAAPI_OLD 1' ++ _mencoder="no" ++ libs_mplayer="$libs_mplayer -lva" ++ fi + _vomodules="vaapi $_vomodules" + else + def_vaapi='#define CONFIG_VAAPI 0' ++ def_vaapi_old='#define CONFIG_VAAPI_OLD 0' + _novomodules="vaapi $_novomodules" + _libavhwaccels=`echo $_libavhwaccels | sed -e "s/\(MPEG[124]\|H26[34]\|WMV3\|VC1\)_VAAPI_HWACCEL//g"` + fi +@@ -8759,6 +8774,7 @@ CONFIG_POSTPROC = yes + # Prevent building libavcodec/imgresample.c with conflicting symbols + CONFIG_SWSCALE=yes + CONFIG_VAAPI=$_vaapi ++CONFIG_VAAPI_OLD=$_vaapi_old + CONFIG_VDPAU=$_vdpau + CONFIG_XVMC=$_xvmc + CONFIG_ZLIB=$_zlib +@@ -9143,6 +9159,7 @@ $def_tdfxvid + $def_tga + $def_v4l2 + $def_vaapi ++$def_vaapi_old + $def_vaapi_glx + $def_vdpau + $def_vesa +diff --git a/libavcodec/vaapi_compat.h b/libavcodec/vaapi_compat.h +new file mode 100644 +index 0000000..f463118 +--- /dev/null ++++ b/libavcodec/vaapi_compat.h +@@ -0,0 +1,92 @@ ++/* ++ * Video Acceleration API (video decoding) ++ * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 ++ * ++ * Copyright (C) 2008-2009 Splitted-Desktop Systems ++ * ++ * This file is part of FFmpeg. ++ * ++ * FFmpeg is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * FFmpeg is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with FFmpeg; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#ifndef AVCODEC_VAAPI_COMPAT_H ++#define AVCODEC_VAAPI_COMPAT_H ++ ++/* Compatibility glue with original VA-API 0.29 */ ++#if CONFIG_VAAPI_OLD ++typedef struct _VASliceParameterBufferBase { ++ unsigned int slice_data_size; ++ unsigned int slice_data_offset; ++ unsigned int slice_data_flag; ++} VASliceParameterBufferBase; ++#endif ++ ++#ifndef VA_CHECK_VERSION ++#define VA_MAJOR_VERSION 0 ++#define VA_MINOR_VERSION 29 ++#define VA_CHECK_VERSION(major,minor,micro) \ ++ (VA_MAJOR_VERSION > (major) || \ ++ (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \ ++ (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro))) ++#endif ++ ++#ifndef VA_FOURCC ++#define VA_FOURCC(ch0, ch1, ch2, ch3) \ ++ ((uint32_t)(uint8_t)(ch0) | \ ++ ((uint32_t)(uint8_t)(ch1) << 8) | \ ++ ((uint32_t)(uint8_t)(ch2) << 16) | \ ++ ((uint32_t)(uint8_t)(ch3) << 24 )) ++#endif ++ ++#ifndef VA_INVALID_ID ++#define VA_INVALID_ID 0xffffffff ++#endif ++#ifndef VA_INVALID_SURFACE ++#define VA_INVALID_SURFACE VA_INVALID_ID ++#endif ++ ++/* Compatibility glue with VA-API >= 0.31 */ ++#if VA_CHECK_VERSION(0,31,0) ++#define vaSyncSurface(dpy, context, surface) (vaSyncSurface)((dpy), (surface)) ++#define vaPutImage2 vaPutImage ++#define vaAssociateSubpicture2 vaAssociateSubpicture ++#endif ++ ++/* Used in codec implementation to set up the right bit-fields */ ++#if CONFIG_VAAPI_OLD ++# define BFV(a, b) a ++# define BFM(a, b, c) c ++# define BFMP(p, a, b, c) p##_##c ++# define NEW(x) /* nothing */ ++#else ++# define BFV(a, b) a.b ++# define BFM(a, b, c) a.b.c ++# define BFMP(p, a, b, c) a.b.c ++# define NEW(x) x ++#endif ++ ++#if CONFIG_VAAPI_OLD ++# define V_raw_coding raw_coding_flag ++# define M_raw_coding raw_coding ++# define V_bitplane_present bitplane_present_flag ++# define M_bitplane_present bitplane_present ++#else ++# define V_raw_coding raw_coding ++# define M_raw_coding raw_coding ++# define V_bitplane_present bitplane_present ++# define M_bitplane_present bitplane_present ++#endif ++ ++#endif /* AVCODEC_VAAPI_COMPAT_H */ +diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c +index a365428..efe92b8 100644 +--- a/libavcodec/vaapi_h264.c ++++ b/libavcodec/vaapi_h264.c +@@ -123,8 +123,8 @@ static void fill_vaapi_pic(VAPictureH264 *va_pic, + if (pic_structure == 0) + pic_structure = pic->reference; + +- va_pic->picture_id = ff_vaapi_get_surface_id(pic); +- va_pic->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num; ++ va_pic->picture_id = ff_vaapi_get_surface_id(pic); ++ NEW(va_pic->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num); + + va_pic->flags = 0; + if (pic_structure != PICT_FRAME) +@@ -317,42 +317,42 @@ static int start_frame(AVCodecContext *avctx, + fill_vaapi_pic(&pic_param->CurrPic, s->current_picture_ptr, s->picture_structure); + if (fill_vaapi_ReferenceFrames(pic_param, h) < 0) + return -1; +- pic_param->picture_width_in_mbs_minus1 = s->mb_width - 1; +- pic_param->picture_height_in_mbs_minus1 = s->mb_height - 1; +- pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; +- pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; +- pic_param->num_ref_frames = h->sps.ref_frame_count; +- pic_param->seq_fields.value = 0; /* reset all bits */ +- pic_param->seq_fields.bits.chroma_format_idc = h->sps.chroma_format_idc; +- pic_param->seq_fields.bits.residual_colour_transform_flag = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */ +- pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag; +- pic_param->seq_fields.bits.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; +- pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = h->sps.mb_aff; +- pic_param->seq_fields.bits.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; +- pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = h->sps.level_idc >= 31; /* A.3.3.2 */ +- pic_param->seq_fields.bits.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4; +- pic_param->seq_fields.bits.pic_order_cnt_type = h->sps.poc_type; +- pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; +- pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; +- pic_param->num_slice_groups_minus1 = h->pps.slice_group_count - 1; +- pic_param->slice_group_map_type = h->pps.mb_slice_group_map_type; +- pic_param->slice_group_change_rate_minus1 = 0; /* XXX: unimplemented in FFmpeg */ +- pic_param->pic_init_qp_minus26 = h->pps.init_qp - 26; +- pic_param->pic_init_qs_minus26 = h->pps.init_qs - 26; +- pic_param->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; +- pic_param->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; +- pic_param->pic_fields.value = 0; /* reset all bits */ +- pic_param->pic_fields.bits.entropy_coding_mode_flag = h->pps.cabac; +- pic_param->pic_fields.bits.weighted_pred_flag = h->pps.weighted_pred; +- pic_param->pic_fields.bits.weighted_bipred_idc = h->pps.weighted_bipred_idc; +- pic_param->pic_fields.bits.transform_8x8_mode_flag = h->pps.transform_8x8_mode; +- pic_param->pic_fields.bits.field_pic_flag = s->picture_structure != PICT_FRAME; +- pic_param->pic_fields.bits.constrained_intra_pred_flag = h->pps.constrained_intra_pred; +- pic_param->pic_fields.bits.pic_order_present_flag = h->pps.pic_order_present; +- pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; +- pic_param->pic_fields.bits.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; +- pic_param->pic_fields.bits.reference_pic_flag = h->nal_ref_idc != 0; +- pic_param->frame_num = h->frame_num; ++ pic_param->picture_width_in_mbs_minus1 = s->mb_width - 1; ++ pic_param->picture_height_in_mbs_minus1 = s->mb_height - 1; ++ pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; ++ pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; ++ pic_param->num_ref_frames = h->sps.ref_frame_count; ++ pic_param->BFV(seq_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(seq_fields,bits,chroma_format_idc) = h->sps.chroma_format_idc; ++ pic_param->BFM(seq_fields,bits,residual_colour_transform_flag) = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */ ++ NEW(pic_param->BFM(seq_fields,bits,gaps_in_frame_num_value_allowed_flag) = h->sps.gaps_in_frame_num_allowed_flag); ++ pic_param->BFM(seq_fields,bits,frame_mbs_only_flag) = h->sps.frame_mbs_only_flag; ++ pic_param->BFM(seq_fields,bits,mb_adaptive_frame_field_flag) = h->sps.mb_aff; ++ pic_param->BFM(seq_fields,bits,direct_8x8_inference_flag) = h->sps.direct_8x8_inference_flag; ++ pic_param->BFM(seq_fields,bits,MinLumaBiPredSize8x8) = h->sps.level_idc >= 31; /* A.3.3.2 */ ++ NEW(pic_param->BFM(seq_fields,bits,log2_max_frame_num_minus4) = h->sps.log2_max_frame_num - 4); ++ NEW(pic_param->BFM(seq_fields,bits,pic_order_cnt_type) = h->sps.poc_type); ++ NEW(pic_param->BFM(seq_fields,bits,log2_max_pic_order_cnt_lsb_minus4) = h->sps.log2_max_poc_lsb - 4); ++ NEW(pic_param->BFM(seq_fields,bits,delta_pic_order_always_zero_flag) = h->sps.delta_pic_order_always_zero_flag); ++ pic_param->num_slice_groups_minus1 = h->pps.slice_group_count - 1; ++ pic_param->slice_group_map_type = h->pps.mb_slice_group_map_type; ++ NEW(pic_param->slice_group_change_rate_minus1 = 0); /* XXX: unimplemented in FFmpeg */ ++ pic_param->pic_init_qp_minus26 = h->pps.init_qp - 26; ++ NEW(pic_param->pic_init_qs_minus26 = h->pps.init_qs - 26); ++ pic_param->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; ++ pic_param->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; ++ pic_param->BFV(pic_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(pic_fields,bits,entropy_coding_mode_flag) = h->pps.cabac; ++ pic_param->BFM(pic_fields,bits,weighted_pred_flag) = h->pps.weighted_pred; ++ pic_param->BFM(pic_fields,bits,weighted_bipred_idc) = h->pps.weighted_bipred_idc; ++ pic_param->BFM(pic_fields,bits,transform_8x8_mode_flag) = h->pps.transform_8x8_mode; ++ pic_param->BFM(pic_fields,bits,field_pic_flag) = s->picture_structure != PICT_FRAME; ++ pic_param->BFM(pic_fields,bits,constrained_intra_pred_flag) = h->pps.constrained_intra_pred; ++ NEW(pic_param->BFM(pic_fields,bits,pic_order_present_flag) = h->pps.pic_order_present); ++ NEW(pic_param->BFM(pic_fields,bits,deblocking_filter_control_present_flag) = h->pps.deblocking_filter_parameters_present); ++ NEW(pic_param->BFM(pic_fields,bits,redundant_pic_cnt_present_flag) = h->pps.redundant_pic_cnt_present); ++ NEW(pic_param->BFM(pic_fields,bits,reference_pic_flag) = h->nal_ref_idc != 0); ++ pic_param->frame_num = h->frame_num; + + /* Fill in VAIQMatrixBufferH264. */ + iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferH264)); +diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h +index 2c0fdf9..ff83b96 100644 +--- a/libavcodec/vaapi_internal.h ++++ b/libavcodec/vaapi_internal.h +@@ -24,8 +24,14 @@ + #ifndef AVCODEC_VAAPI_INTERNAL_H + #define AVCODEC_VAAPI_INTERNAL_H + ++#include "config.h" ++#if CONFIG_VAAPI_OLD ++#include <va.h> ++#else + #include <va/va.h> ++#endif + #include "vaapi.h" ++#include "vaapi_compat.h" + #include "avcodec.h" + #include "mpegvideo.h" + +diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c +index 21bc778..8961e9e 100644 +--- a/libavcodec/vaapi_mpeg2.c ++++ b/libavcodec/vaapi_mpeg2.c +@@ -52,24 +52,24 @@ static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_ + pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG2)); + if (!pic_param) + return -1; +- pic_param->horizontal_size = s->width; +- pic_param->vertical_size = s->height; +- pic_param->forward_reference_picture = VA_INVALID_ID; +- pic_param->backward_reference_picture = VA_INVALID_ID; +- pic_param->picture_coding_type = s->pict_type; +- pic_param->f_code = mpeg2_get_f_code(s); +- pic_param->picture_coding_extension.value = 0; /* reset all bits */ +- pic_param->picture_coding_extension.bits.intra_dc_precision = s->intra_dc_precision; +- pic_param->picture_coding_extension.bits.picture_structure = s->picture_structure; +- pic_param->picture_coding_extension.bits.top_field_first = s->top_field_first; +- pic_param->picture_coding_extension.bits.frame_pred_frame_dct = s->frame_pred_frame_dct; +- pic_param->picture_coding_extension.bits.concealment_motion_vectors = s->concealment_motion_vectors; +- pic_param->picture_coding_extension.bits.q_scale_type = s->q_scale_type; +- pic_param->picture_coding_extension.bits.intra_vlc_format = s->intra_vlc_format; +- pic_param->picture_coding_extension.bits.alternate_scan = s->alternate_scan; +- pic_param->picture_coding_extension.bits.repeat_first_field = s->repeat_first_field; +- pic_param->picture_coding_extension.bits.progressive_frame = s->progressive_frame; +- pic_param->picture_coding_extension.bits.is_first_field = mpeg2_get_is_frame_start(s); ++ pic_param->horizontal_size = s->width; ++ pic_param->vertical_size = s->height; ++ pic_param->forward_reference_picture = VA_INVALID_ID; ++ pic_param->backward_reference_picture = VA_INVALID_ID; ++ pic_param->picture_coding_type = s->pict_type; ++ pic_param->f_code = mpeg2_get_f_code(s); ++ pic_param->BFV(picture_coding_extension,value) = 0; /* reset all bits */ ++ pic_param->BFM(picture_coding_extension,bits,intra_dc_precision) = s->intra_dc_precision; ++ pic_param->BFM(picture_coding_extension,bits,picture_structure) = s->picture_structure; ++ pic_param->BFM(picture_coding_extension,bits,top_field_first) = s->top_field_first; ++ pic_param->BFM(picture_coding_extension,bits,frame_pred_frame_dct) = s->frame_pred_frame_dct; ++ pic_param->BFM(picture_coding_extension,bits,concealment_motion_vectors) = s->concealment_motion_vectors; ++ pic_param->BFM(picture_coding_extension,bits,q_scale_type) = s->q_scale_type; ++ pic_param->BFM(picture_coding_extension,bits,intra_vlc_format) = s->intra_vlc_format; ++ pic_param->BFM(picture_coding_extension,bits,alternate_scan) = s->alternate_scan; ++ pic_param->BFM(picture_coding_extension,bits,repeat_first_field) = s->repeat_first_field; ++ pic_param->BFM(picture_coding_extension,bits,progressive_frame) = s->progressive_frame; ++ pic_param->BFM(picture_coding_extension,bits,is_first_field) = mpeg2_get_is_frame_start(s); + + switch (s->pict_type) { + case FF_B_TYPE: +@@ -131,7 +131,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer + if (!slice_param) + return -1; + slice_param->macroblock_offset = macroblock_offset; +- slice_param->slice_horizontal_position = s->mb_x; ++ NEW(slice_param->slice_horizontal_position = s->mb_x); + slice_param->slice_vertical_position = s->mb_y; + slice_param->quantiser_scale_code = quantiser_scale_code; + slice_param->intra_slice_flag = intra_slice_flag; +diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c +index 4e606f0..5a9a48e 100644 +--- a/libavcodec/vaapi_mpeg4.c ++++ b/libavcodec/vaapi_mpeg4.c +@@ -54,42 +54,42 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ + pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG4)); + if (!pic_param) + return -1; +- pic_param->vop_width = s->width; +- pic_param->vop_height = s->height; +- pic_param->forward_reference_picture = VA_INVALID_ID; +- pic_param->backward_reference_picture = VA_INVALID_ID; +- pic_param->vol_fields.value = 0; /* reset all bits */ +- pic_param->vol_fields.bits.short_video_header = avctx->codec->id == CODEC_ID_H263; +- pic_param->vol_fields.bits.chroma_format = CHROMA_420; +- pic_param->vol_fields.bits.interlaced = !s->progressive_sequence; +- pic_param->vol_fields.bits.obmc_disable = 1; +- pic_param->vol_fields.bits.sprite_enable = s->vol_sprite_usage; +- pic_param->vol_fields.bits.sprite_warping_accuracy = s->sprite_warping_accuracy; +- pic_param->vol_fields.bits.quant_type = s->mpeg_quant; +- pic_param->vol_fields.bits.quarter_sample = s->quarter_sample; +- pic_param->vol_fields.bits.data_partitioned = s->data_partitioning; +- pic_param->vol_fields.bits.reversible_vlc = s->rvlc; +- pic_param->vol_fields.bits.resync_marker_disable = !s->resync_marker; +- pic_param->no_of_sprite_warping_points = s->num_sprite_warping_points; ++ pic_param->vop_width = s->width; ++ pic_param->vop_height = s->height; ++ pic_param->forward_reference_picture = VA_INVALID_ID; ++ pic_param->backward_reference_picture = VA_INVALID_ID; ++ pic_param->BFV(vol_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(vol_fields,bits,short_video_header) = avctx->codec->id == CODEC_ID_H263; ++ pic_param->BFM(vol_fields,bits,chroma_format) = CHROMA_420; ++ pic_param->BFM(vol_fields,bits,interlaced) = !s->progressive_sequence; ++ pic_param->BFM(vol_fields,bits,obmc_disable) = 1; ++ pic_param->BFM(vol_fields,bits,sprite_enable) = s->vol_sprite_usage; ++ pic_param->BFM(vol_fields,bits,sprite_warping_accuracy) = s->sprite_warping_accuracy; ++ pic_param->BFM(vol_fields,bits,quant_type) = s->mpeg_quant; ++ pic_param->BFM(vol_fields,bits,quarter_sample) = s->quarter_sample; ++ pic_param->BFM(vol_fields,bits,data_partitioned) = s->data_partitioning; ++ pic_param->BFM(vol_fields,bits,reversible_vlc) = s->rvlc; ++ NEW(pic_param->BFM(vol_fields,bits,resync_marker_disable) = !s->resync_marker); ++ pic_param->no_of_sprite_warping_points = s->num_sprite_warping_points; + for (i = 0; i < s->num_sprite_warping_points && i < 3; i++) { +- pic_param->sprite_trajectory_du[i] = s->sprite_traj[i][0]; +- pic_param->sprite_trajectory_dv[i] = s->sprite_traj[i][1]; ++ pic_param->sprite_trajectory_du[i] = s->sprite_traj[i][0]; ++ pic_param->sprite_trajectory_dv[i] = s->sprite_traj[i][1]; + } +- pic_param->quant_precision = s->quant_precision; +- pic_param->vop_fields.value = 0; /* reset all bits */ +- pic_param->vop_fields.bits.vop_coding_type = s->pict_type - FF_I_TYPE; +- pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == FF_B_TYPE ? s->next_picture.pict_type - FF_I_TYPE : 0; +- pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding; +- pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(s); +- pic_param->vop_fields.bits.top_field_first = s->top_field_first; +- pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan; +- pic_param->vop_fcode_forward = s->f_code; +- pic_param->vop_fcode_backward = s->b_code; +- pic_param->vop_time_increment_resolution = avctx->time_base.den; +- pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); +- pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; +- pic_param->TRB = s->pb_time; +- pic_param->TRD = s->pp_time; ++ pic_param->quant_precision = s->quant_precision; ++ pic_param->BFV(vop_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(vop_fields,bits,vop_coding_type) = s->pict_type - FF_I_TYPE; ++ pic_param->BFM(vop_fields,bits,backward_reference_vop_coding_type) = s->pict_type == FF_B_TYPE ? s->next_picture.pict_type - FF_I_TYPE : 0; ++ pic_param->BFM(vop_fields,bits,vop_rounding_type) = s->no_rounding; ++ pic_param->BFM(vop_fields,bits,intra_dc_vlc_thr) = mpeg4_get_intra_dc_vlc_thr(s); ++ pic_param->BFM(vop_fields,bits,top_field_first) = s->top_field_first; ++ pic_param->BFM(vop_fields,bits,alternate_vertical_scan_flag) = s->alternate_scan; ++ pic_param->vop_fcode_forward = s->f_code; ++ pic_param->vop_fcode_backward = s->b_code; ++ NEW(pic_param->vop_time_increment_resolution = avctx->time_base.den); ++ pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); ++ pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; ++ pic_param->TRB = s->pb_time; ++ pic_param->TRD = s->pp_time; + + if (s->pict_type == FF_B_TYPE) + pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture); +@@ -98,7 +98,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ + + /* Fill in VAIQMatrixBufferMPEG4 */ + /* Only the first inverse quantisation method uses the weighthing matrices */ +- if (pic_param->vol_fields.bits.quant_type) { ++ if (pic_param->BFM(vol_fields,bits,quant_type)) { + iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4)); + if (!iq_matrix) + return -1; +diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c +index 50a4ba2..6e319fc 100644 +--- a/libavcodec/vaapi_vc1.c ++++ b/libavcodec/vaapi_vc1.c +@@ -146,100 +146,100 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t + pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1)); + if (!pic_param) + return -1; +- pic_param->forward_reference_picture = VA_INVALID_ID; +- pic_param->backward_reference_picture = VA_INVALID_ID; +- pic_param->inloop_decoded_picture = VA_INVALID_ID; +- pic_param->sequence_fields.value = 0; /* reset all bits */ +- pic_param->sequence_fields.bits.pulldown = v->broadcast; +- pic_param->sequence_fields.bits.interlace = v->interlace; +- pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag; +- pic_param->sequence_fields.bits.finterpflag = v->finterpflag; +- pic_param->sequence_fields.bits.psf = v->psf; +- pic_param->sequence_fields.bits.multires = v->multires; +- pic_param->sequence_fields.bits.overlap = v->overlap; +- pic_param->sequence_fields.bits.syncmarker = s->resync_marker; +- pic_param->sequence_fields.bits.rangered = v->rangered; +- pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames; +- pic_param->coded_width = s->avctx->coded_width; +- pic_param->coded_height = s->avctx->coded_height; +- pic_param->entrypoint_fields.value = 0; /* reset all bits */ +- pic_param->entrypoint_fields.bits.broken_link = v->broken_link; +- pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry; +- pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag; +- pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter; +- pic_param->conditional_overlap_flag = v->condover; +- pic_param->fast_uvmc_flag = v->fastuvmc; +- pic_param->range_mapping_fields.value = 0; /* reset all bits */ +- pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag; +- pic_param->range_mapping_fields.bits.luma = v->range_mapy; +- pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag; +- pic_param->range_mapping_fields.bits.chroma = v->range_mapuv; +- pic_param->b_picture_fraction = v->bfraction_lut_index; +- pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0; +- pic_param->mb_mode_table = 0; /* XXX: interlaced frame */ +- pic_param->range_reduction_frame = v->rangeredfrm; +- pic_param->rounding_control = v->rnd; +- pic_param->post_processing = v->postproc; +- pic_param->picture_resolution_index = v->respic; +- pic_param->luma_scale = v->lumscale; +- pic_param->luma_shift = v->lumshift; +- pic_param->picture_fields.value = 0; /* reset all bits */ +- pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v); +- pic_param->picture_fields.bits.frame_coding_mode = v->fcm; +- pic_param->picture_fields.bits.top_field_first = v->tff; +- pic_param->picture_fields.bits.is_first_field = v->fcm == 0; /* XXX: interlaced frame */ +- pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP; +- pic_param->raw_coding.value = 0; /* reset all bits */ +- pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw; +- pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw; +- pic_param->raw_coding.flags.skip_mb = v->skip_is_raw; +- pic_param->raw_coding.flags.field_tx = 0; /* XXX: interlaced frame */ +- pic_param->raw_coding.flags.forward_mb = 0; /* XXX: interlaced frame */ +- pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw; +- pic_param->raw_coding.flags.overflags = v->overflg_is_raw; +- pic_param->bitplane_present.value = 0; /* reset all bits */ +- pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v); +- pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v); +- pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v); +- pic_param->bitplane_present.flags.bp_field_tx = 0; /* XXX: interlaced frame */ +- pic_param->bitplane_present.flags.bp_forward_mb = 0; /* XXX: interlaced frame */ +- pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v); +- pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v); +- pic_param->reference_fields.value = 0; /* reset all bits */ +- pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag; +- pic_param->reference_fields.bits.reference_distance = 0; /* XXX: interlaced frame */ +- pic_param->reference_fields.bits.num_reference_pictures = 0; /* XXX: interlaced frame */ +- pic_param->reference_fields.bits.reference_field_pic_indicator = 0; /* XXX: interlaced frame */ +- pic_param->mv_fields.value = 0; /* reset all bits */ +- pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v); +- pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v); +- pic_param->mv_fields.bits.mv_table = s->mv_table_index; +- pic_param->mv_fields.bits.two_mv_block_pattern_table = 0; /* XXX: interlaced frame */ +- pic_param->mv_fields.bits.four_mv_switch = 0; /* XXX: interlaced frame */ +- pic_param->mv_fields.bits.four_mv_block_pattern_table = 0; /* XXX: interlaced frame */ +- pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv; +- pic_param->mv_fields.bits.extended_mv_range = v->mvrange; +- pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv; +- pic_param->mv_fields.bits.extended_dmv_range = 0; /* XXX: interlaced frame */ +- pic_param->pic_quantizer_fields.value = 0; /* reset all bits */ +- pic_param->pic_quantizer_fields.bits.dquant = v->dquant; +- pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode; +- pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq; +- pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq; +- pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer; +- pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm; +- pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile; +- pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0; +- pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0; +- pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel; +- pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq; +- pic_param->transform_fields.value = 0; /* reset all bits */ +- pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform; +- pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf; +- pic_param->transform_fields.bits.frame_level_transform_type = v->ttfrm; +- pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index; +- pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index; +- pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index; ++ pic_param->forward_reference_picture = VA_INVALID_ID; ++ pic_param->backward_reference_picture = VA_INVALID_ID; ++ pic_param->inloop_decoded_picture = VA_INVALID_ID; ++ pic_param->BFV(sequence_fields,value) = 0; /* reset all bits */ ++ NEW(pic_param->BFM(sequence_fields,bits,pulldown) = v->broadcast); ++ pic_param->BFM(sequence_fields,bits,interlace) = v->interlace; ++ NEW(pic_param->BFM(sequence_fields,bits,tfcntrflag) = v->tfcntrflag); ++ NEW(pic_param->BFM(sequence_fields,bits,finterpflag) = v->finterpflag); ++ NEW(pic_param->BFM(sequence_fields,bits,psf) = v->psf); ++ NEW(pic_param->BFM(sequence_fields,bits,multires) = v->multires); ++ pic_param->BFM(sequence_fields,bits,overlap) = v->overlap; ++ pic_param->BFM(sequence_fields,bits,syncmarker) = s->resync_marker; ++ NEW(pic_param->BFM(sequence_fields,bits,rangered) = v->rangered); ++ NEW(pic_param->BFM(sequence_fields,bits,max_b_frames) = s->avctx->max_b_frames); ++ pic_param->coded_width = s->avctx->coded_width; ++ pic_param->coded_height = s->avctx->coded_height; ++ NEW(pic_param->BFV(entrypoint_fields,value) = 0); /* reset all bits */ ++ pic_param->BFM(entrypoint_fields,bits,broken_link) = v->broken_link; ++ pic_param->BFM(entrypoint_fields,bits,closed_entry) = v->closed_entry; ++ NEW(pic_param->BFM(entrypoint_fields,bits,panscan_flag) = v->panscanflag); ++ pic_param->BFM(entrypoint_fields,bits,loopfilter) = s->loop_filter; ++ pic_param->conditional_overlap_flag = v->condover; ++ pic_param->fast_uvmc_flag = v->fastuvmc; ++ pic_param->BFV(range_mapping_fields,value) = 0; /* reset all bits */ ++ pic_param->BFMP(range_mapping,range_mapping_fields,bits,luma_flag) = v->range_mapy_flag; ++ pic_param->BFMP(range_mapping,range_mapping_fields,bits,luma) = v->range_mapy; ++ pic_param->BFMP(range_mapping,range_mapping_fields,bits,chroma_flag) = v->range_mapuv_flag; ++ pic_param->BFMP(range_mapping,range_mapping_fields,bits,chroma) = v->range_mapuv; ++ pic_param->b_picture_fraction = v->bfraction_lut_index; ++ pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0; ++ pic_param->mb_mode_table = 0; /* XXX: interlaced frame */ ++ pic_param->range_reduction_frame = v->rangeredfrm; ++ pic_param->rounding_control = v->rnd; ++ pic_param->post_processing = v->postproc; ++ pic_param->picture_resolution_index = v->respic; ++ pic_param->luma_scale = v->lumscale; ++ pic_param->luma_shift = v->lumshift; ++ pic_param->BFV(picture_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(picture_fields,bits,picture_type) = vc1_get_PTYPE(v); ++ pic_param->BFM(picture_fields,bits,frame_coding_mode) = v->fcm; ++ pic_param->BFM(picture_fields,bits,top_field_first) = v->tff; ++ pic_param->BFM(picture_fields,bits,is_first_field) = v->fcm == 0; /* XXX: interlaced frame */ ++ pic_param->BFM(picture_fields,bits,intensity_compensation) = v->mv_mode == MV_PMODE_INTENSITY_COMP; ++ pic_param->BFV(V_raw_coding,value) = 0; /* reset all bits */ ++ pic_param->BFM(M_raw_coding,flags,mv_type_mb) = v->mv_type_is_raw; ++ pic_param->BFM(M_raw_coding,flags,direct_mb) = v->dmb_is_raw; ++ pic_param->BFM(M_raw_coding,flags,skip_mb) = v->skip_is_raw; ++ pic_param->BFM(M_raw_coding,flags,field_tx) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(M_raw_coding,flags,forward_mb) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(M_raw_coding,flags,ac_pred) = v->acpred_is_raw; ++ pic_param->BFM(M_raw_coding,flags,overflags) = v->overflg_is_raw; ++ pic_param->BFV(V_bitplane_present,value) = 0; /* reset all bits */ ++ pic_param->BFM(M_bitplane_present,flags,bp_mv_type_mb) = vc1_has_MVTYPEMB_bitplane(v); ++ pic_param->BFM(M_bitplane_present,flags,bp_direct_mb) = vc1_has_DIRECTMB_bitplane(v); ++ pic_param->BFM(M_bitplane_present,flags,bp_skip_mb) = vc1_has_SKIPMB_bitplane(v); ++ pic_param->BFM(M_bitplane_present,flags,bp_field_tx) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(M_bitplane_present,flags,bp_forward_mb) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(M_bitplane_present,flags,bp_ac_pred) = vc1_has_ACPRED_bitplane(v); ++ pic_param->BFM(M_bitplane_present,flags,bp_overflags) = vc1_has_OVERFLAGS_bitplane(v); ++ pic_param->BFV(reference_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(reference_fields,bits,reference_distance_flag) = v->refdist_flag; ++ pic_param->BFM(reference_fields,bits,reference_distance) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(reference_fields,bits,num_reference_pictures) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(reference_fields,bits,reference_field_pic_indicator) = 0; /* XXX: interlaced frame */ ++ pic_param->BFV(mv_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(mv_fields,bits,mv_mode) = vc1_get_MVMODE(v); ++ pic_param->BFM(mv_fields,bits,mv_mode2) = vc1_get_MVMODE2(v); ++ pic_param->BFM(mv_fields,bits,mv_table) = s->mv_table_index; ++ pic_param->BFM(mv_fields,bits,two_mv_block_pattern_table) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(mv_fields,bits,four_mv_switch) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(mv_fields,bits,four_mv_block_pattern_table) = 0; /* XXX: interlaced frame */ ++ pic_param->BFM(mv_fields,bits,extended_mv_flag) = v->extended_mv; ++ pic_param->BFM(mv_fields,bits,extended_mv_range) = v->mvrange; ++ pic_param->BFM(mv_fields,bits,extended_dmv_flag) = v->extended_dmv; ++ pic_param->BFM(mv_fields,bits,extended_dmv_range) = 0; /* XXX: interlaced frame */ ++ pic_param->BFV(pic_quantizer_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(pic_quantizer_fields,bits,dquant) = v->dquant; ++ pic_param->BFM(pic_quantizer_fields,bits,quantizer) = v->quantizer_mode; ++ pic_param->BFM(pic_quantizer_fields,bits,half_qp) = v->halfpq; ++ pic_param->BFM(pic_quantizer_fields,bits,pic_quantizer_scale) = v->pq; ++ pic_param->BFM(pic_quantizer_fields,bits,pic_quantizer_type) = v->pquantizer; ++ pic_param->BFM(pic_quantizer_fields,bits,dq_frame) = v->dquantfrm; ++ pic_param->BFM(pic_quantizer_fields,bits,dq_profile) = v->dqprofile; ++ pic_param->BFM(pic_quantizer_fields,bits,dq_sb_edge) = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0; ++ pic_param->BFM(pic_quantizer_fields,bits,dq_db_edge) = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0; ++ pic_param->BFM(pic_quantizer_fields,bits,dq_binary_level) = v->dqbilevel; ++ pic_param->BFM(pic_quantizer_fields,bits,alt_pic_quantizer) = v->altpq; ++ pic_param->BFV(transform_fields,value) = 0; /* reset all bits */ ++ pic_param->BFM(transform_fields,bits,variable_sized_transform_flag) = v->vstransform; ++ pic_param->BFM(transform_fields,bits,mb_level_transform_type_flag) = v->ttmbf; ++ pic_param->BFM(transform_fields,bits,frame_level_transform_type) = v->ttfrm; ++ pic_param->BFM(transform_fields,bits,transform_ac_codingset_idx1) = v->c_ac_table_index; ++ pic_param->BFM(transform_fields,bits,transform_ac_codingset_idx2) = v->y_ac_table_index; ++ pic_param->BFM(transform_fields,bits,intra_transform_dc_table) = v->s.dc_table_index; + + switch (s->pict_type) { + case FF_B_TYPE: +@@ -250,29 +250,29 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t + break; + } + +- if (pic_param->bitplane_present.value) { ++ if (pic_param->BFV(V_bitplane_present,value)) { + uint8_t *bitplane; + const uint8_t *ff_bp[3]; + int x, y, n; + + switch (s->pict_type) { + case FF_P_TYPE: +- ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; +- ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; +- ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL; ++ ff_bp[0] = pic_param->BFM(M_bitplane_present,flags,bp_direct_mb) ? v->direct_mb_plane : NULL; ++ ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_skip_mb) ? s->mbskip_table : NULL; ++ ff_bp[2] = pic_param->BFM(M_bitplane_present,flags,bp_mv_type_mb) ? v->mv_type_mb_plane : NULL; + break; + case FF_B_TYPE: + if (!v->bi_type) { +- ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; +- ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; ++ ff_bp[0] = pic_param->BFM(M_bitplane_present,flags,bp_direct_mb) ? v->direct_mb_plane : NULL; ++ ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_skip_mb) ? s->mbskip_table : NULL; + ff_bp[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */ + break; + } + /* fall-through (BI-type) */ + case FF_I_TYPE: + ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */ +- ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL; +- ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL; ++ ff_bp[1] = pic_param->BFM(M_bitplane_present,flags,bp_ac_pred) ? v->acpred_plane : NULL; ++ ff_bp[2] = pic_param->BFM(M_bitplane_present,flags,bp_overflags) ? v->over_flags_plane : NULL; + break; + default: + ff_bp[0] = NULL; +diff --git a/libvo/vo_vaapi.c b/libvo/vo_vaapi.c +index 3fe563a..d653b53 100644 +--- a/libvo/vo_vaapi.c ++++ b/libvo/vo_vaapi.c +@@ -45,7 +45,11 @@ + #include <assert.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> ++#if CONFIG_VAAPI_OLD ++#include <va_x11.h> ++#else + #include <va/va_x11.h> ++#endif + #if CONFIG_VAAPI_GLX + #include <va/va_glx.h> + #endif diff --git a/media-video/mplayer/files/vaapi/04-mplayer-vdpau.patch b/media-video/mplayer/files/vaapi/04-mplayer-vdpau.patch new file mode 100644 index 0000000..c721609 --- /dev/null +++ b/media-video/mplayer/files/vaapi/04-mplayer-vdpau.patch @@ -0,0 +1,1199 @@ +diff --git a/configure b/configure +index 39fef26..3a97c6e 100755 +--- a/configure ++++ b/configure +@@ -549,7 +549,7 @@ _libopencore_amrnb=auto + _libavbsfs_all=$(sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]') + _libavbsfs=$_libavbsfs_all + _libavhwaccels_all=$(sed -n 's/^[^#]*HWACCEL.*(.*, *\(.*\)).*/\1_hwaccel/p' libavcodec/allcodecs.c | tr '[a-z]' '[A-Z]') +-_libavhwaccels=$(for h in $_libavhwaccels_all; do case $h in (*_VAAPI_HWACCEL) echo $h;; esac; done) ++_libavhwaccels=$(for h in $_libavhwaccels_all; do case $h in (*_VDPAU_HWACCEL|*_VAAPI_HWACCEL) echo $h;; esac; done) + _libavdemuxers_all=$(sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]') + _libavdemuxers=$(echo $_libavdemuxers_all | sed -e 's/ LIB[A-Z0-9_]*_DEMUXER//g' -e s/REDIR_DEMUXER// -e s/AVISYNTH_DEMUXER//) + _libavmuxers_all=$(sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' libavformat/allformats.c | tr '[a-z]' '[A-Z]') +@@ -4500,7 +4500,7 @@ if test "$_vdpau" = yes ; then + else + def_vdpau='#define CONFIG_VDPAU 0' + _novomodules="vdpau $_novomodules" +- _libavdecoders=$(echo $_libavdecoders | sed -e "s/\(MPEG\|MPEG[124]\|H26[34]\|WMV3\|VC1\)_VDPAU_DECODER//g") ++ _libavhwaccels=$(echo $_libavhwaccels | sed -e "s/\(MPEG[124]\|H26[34]\|WMV3\|VC1\)_VDPAU_HWACCEL//g") + fi + echores "$_vdpau" + +diff --git a/etc/codecs.conf b/etc/codecs.conf +index 15c6e8d..8f6a122 100644 +--- a/etc/codecs.conf ++++ b/etc/codecs.conf +@@ -146,6 +146,7 @@ videocodec ffmpeg1 + fourcc m1v1 + driver ffmpeg + dll "mpeg1video" ++ out VDPAU_MPEG1 + out YV12,I420,IYUV + + videocodec ffmpeg2 +@@ -182,6 +183,7 @@ videocodec ffmpeg2 + driver ffmpeg + dll "mpeg2video" + out VAAPI_MPEG2 ++ out VDPAU_MPEG2 + out YV12,I420,IYUV + out 422P,444P + +@@ -221,6 +223,7 @@ videocodec ffmpeg12 + fourcc slif ; SoftLab MPEG-2 I-frames Codec + driver ffmpeg + dll "mpegvideo" ++ out VDPAU_MPEG1,VDPAU_MPEG2 + out YV12,I420,IYUV + out 422P,444P + +@@ -307,44 +310,6 @@ videocodec ffmpeg12mc + out IDCT_MPEG2 + out MOCO_MPEG2 + +-videocodec ffmpeg12vdpau +- info "FFmpeg MPEG-1/2 (VDPAU)" +- status working +- format 0x10000001 ; MPEG-1 +- format 0x10000002 ; MPEG-2 +- fourcc mpg1,mpg2,MPG2 +- fourcc PIM1 ; Pinnacle hardware-MPEG-1 +- fourcc PIM2 ; Pinnacle hardware-MPEG-2 +- fourcc "DVR " +- fourcc hdv2 +- fourcc MPEG +- fourcc hdv1 +- fourcc hdv3 ; HDV 1080i50 +- fourcc hdv5 ; HDV 720p25 +- fourcc mx5p ; MPEG IMX 625/50 (50 Mb/s) +- fourcc MMES,mmes ; matrox mpeg2 in avi +- fourcc hdv6,hdv7,hdv8 +- fourcc xdv1,xdv2,xdv3 +- fourcc xdv4,xdv5,xdv6 +- fourcc xdv7,xdv8,xdv9 +- fourcc xdva,xdvb,xdvc +- fourcc xdvd,xdve,xdvf +- fourcc xd5a,xd5b,xd5c +- fourcc xd5d,xd5e,xd5f +- fourcc xd59 +- fourcc mx5n,mx4n,mx4p +- fourcc mx3n,mx3p +- fourcc AVmp +- fourcc mp2v,mpgv +- fourcc LMP2 ; Lead mpeg2 in avi +- fourcc m2v1,m1v1 +- driver ffmpeg +- dll "mpegvideo_vdpau" +- out VDPAU_MPEG1 +- out VDPAU_MPEG2 +- +-; we have only native open source codecs for these: +- + videocodec ffnuv + info "NuppelVideo" + status working +@@ -883,15 +849,8 @@ videocodec ffwmv3 + driver ffmpeg + dll wmv3 + out VAAPI_WMV3 +- out YV12,I420,IYUV +- +-videocodec ffwmv3vdpau +- info "FFmpeg WMV3/WMV9 (VDPAU)" +- status buggy +- fourcc WMV3,wmv3 +- driver ffmpeg +- dll wmv3_vdpau + out VDPAU_WMV3 ++ out YV12,I420,IYUV + + videocodec ffvc1 + info "FFmpeg WVC1" +@@ -901,16 +860,8 @@ videocodec ffvc1 + driver ffmpeg + dll vc1 + out VAAPI_VC1 +- out YV12,I420,IYUV +- +-videocodec ffvc1vdpau +- info "FFmpeg WVC1 (VDPAU)" +- status buggy +- fourcc WVC1,wvc1,WMVA +- fourcc vc-1,VC-1 +- driver ffmpeg +- dll vc1_vdpau + out VDPAU_VC1 ++ out YV12,I420,IYUV + + videocodec ffh264 + info "FFmpeg H.264" +@@ -923,19 +874,8 @@ videocodec ffh264 + driver ffmpeg + dll h264 + out VAAPI_H264 +- out YV12,I420,IYUV +- +-videocodec ffh264vdpau +- info "FFmpeg H.264 (VDPAU)" +- status working +- fourcc H264,h264 +- fourcc X264,x264 +- fourcc avc1,AVC1 +- fourcc davc,DAVC +- format 0x10000005 +- driver ffmpeg +- dll h264_vdpau + out VDPAU_H264 ++ out YV12,I420,IYUV + + videocodec coreavcwindows + info "CoreAVC H.264 for x86 - http://corecodec.org/" +@@ -994,39 +933,8 @@ videocodec ffodivx + driver ffmpeg + dll mpeg4 ;opendivx + out VAAPI_MPEG4 +- out YV12,I420,IYUV +- +-videocodec ffodivxvdpau +- info "FFmpeg MPEG-4,DIVX-4/5 (VDPAU)" +- status working +- fourcc FMP4,fmp4 +- fourcc DIVX,divx +- fourcc DIV1,div1 divx +- fourcc MP4S,mp4s ; ISO MPEG-4 Video V1 +- fourcc M4S2,m4s2 +- fourcc xvid,XVID,XviD,XVIX +- fourcc DX50,dx50,BLZ0 DX50 +- fourcc mp4v,MP4V +- format 0x4 +- fourcc UMP4 +- fourcc RMP4 +- fourcc 3IV2,3iv2 ; 3ivx Delta 4 +- fourcc DXGM +- fourcc SEDG ; diskless camcorder Samsung Miniket VP-M110 +- fourcc SMP4,smp4 ; Samsung SMP4 video codec +- fourcc VIDM ; vidm 4.01 codec +- format 0x10000004 ; mpeg 4 es +- fourcc m4cc,M4CC +- fourcc hdx4,HDX4 +- fourcc FVFW,fvfw +- fourcc FFDS +- fourcc DCOD,MVXM,EM4A,PM4V +- fourcc M4T3,DMK2,DIGI,INMC +- fourcc EPHV,SN40 +- fourcc uldx,ULDX,VSPX +- driver ffmpeg +- dll mpeg4_vdpau + out VDPAU_MPEG4 ++ out YV12,I420,IYUV + + videocodec ffwv1f + info "WV1F MPEG-4" +diff --git a/fmt-conversion.c b/fmt-conversion.c +index a9ba43d..cf5566d 100644 +--- a/fmt-conversion.c ++++ b/fmt-conversion.c +@@ -81,12 +81,6 @@ static const struct { + + {IMGFMT_XVMC_MOCO_MPEG2, PIX_FMT_XVMC_MPEG2_MC}, + {IMGFMT_XVMC_IDCT_MPEG2, PIX_FMT_XVMC_MPEG2_IDCT}, +- {IMGFMT_VDPAU_MPEG1, PIX_FMT_VDPAU_MPEG1}, +- {IMGFMT_VDPAU_MPEG2, PIX_FMT_VDPAU_MPEG2}, +- {IMGFMT_VDPAU_H264, PIX_FMT_VDPAU_H264}, +- {IMGFMT_VDPAU_WMV3, PIX_FMT_VDPAU_WMV3}, +- {IMGFMT_VDPAU_VC1, PIX_FMT_VDPAU_VC1}, +- {IMGFMT_VDPAU_MPEG4, PIX_FMT_VDPAU_MPEG4}, + + /* VA API formats */ + {IMGFMT_VAAPI_MPEG2, PIX_FMT_VAAPI_VLD, CODEC_ID_MPEG2VIDEO}, +@@ -98,6 +92,14 @@ static const struct { + {IMGFMT_VAAPI_WMV3, PIX_FMT_VAAPI_VLD, CODEC_ID_WMV3}, + {IMGFMT_VAAPI_VC1, PIX_FMT_VAAPI_VLD, CODEC_ID_VC1}, + ++ /* VDPAU formats */ ++ {IMGFMT_VDPAU_MPEG1, PIX_FMT_VDPAU, CODEC_ID_MPEG1VIDEO}, ++ {IMGFMT_VDPAU_MPEG2, PIX_FMT_VDPAU, CODEC_ID_MPEG2VIDEO}, ++ {IMGFMT_VDPAU_MPEG4, PIX_FMT_VDPAU, CODEC_ID_MPEG4}, ++ {IMGFMT_VDPAU_H264, PIX_FMT_VDPAU, CODEC_ID_H264}, ++ {IMGFMT_VDPAU_WMV3, PIX_FMT_VDPAU, CODEC_ID_WMV3}, ++ {IMGFMT_VDPAU_VC1, PIX_FMT_VDPAU, CODEC_ID_VC1}, ++ + {0, PIX_FMT_NONE} + }; + +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index 43e49d1..646c590 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -61,6 +61,13 @@ void avcodec_register_all(void) + REGISTER_HWACCEL (VC1_VAAPI, vc1_vaapi); + REGISTER_HWACCEL (WMV3_VAAPI, wmv3_vaapi); + ++ REGISTER_HWACCEL (H264_VDPAU, h264_vdpau); ++ REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau); ++ REGISTER_HWACCEL (MPEG2_VDPAU, mpeg2_vdpau); ++ REGISTER_HWACCEL (MPEG4_VDPAU, mpeg4_vdpau); ++ REGISTER_HWACCEL (VC1_VDPAU, vc1_vdpau); ++ REGISTER_HWACCEL (WMV3_VDPAU, wmv3_vdpau); ++ + /* video codecs */ + REGISTER_DECODER (AASC, aasc); + REGISTER_DECODER (AMV, amv); +@@ -108,7 +115,6 @@ void avcodec_register_all(void) + REGISTER_DECODER (H263I, h263i); + REGISTER_ENCODER (H263P, h263p); + REGISTER_DECODER (H264, h264); +- REGISTER_DECODER (H264_VDPAU, h264_vdpau); + REGISTER_ENCDEC (HUFFYUV, huffyuv); + REGISTER_DECODER (IDCIN, idcin); + REGISTER_DECODER (INDEO2, indeo2); +@@ -128,10 +134,7 @@ void avcodec_register_all(void) + REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); + REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); + REGISTER_ENCDEC (MPEG4, mpeg4); +- REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau); + REGISTER_DECODER (MPEGVIDEO, mpegvideo); +- REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau); +- REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau); + REGISTER_ENCDEC (MSMPEG4V1, msmpeg4v1); + REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); + REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); +@@ -182,7 +185,6 @@ void avcodec_register_all(void) + REGISTER_DECODER (V210X, v210x); + REGISTER_DECODER (VB, vb); + REGISTER_DECODER (VC1, vc1); +- REGISTER_DECODER (VC1_VDPAU, vc1_vdpau); + REGISTER_DECODER (VCR1, vcr1); + REGISTER_DECODER (VMDVIDEO, vmdvideo); + REGISTER_DECODER (VMNC, vmnc); +@@ -195,7 +197,6 @@ void avcodec_register_all(void) + REGISTER_ENCDEC (WMV1, wmv1); + REGISTER_ENCDEC (WMV2, wmv2); + REGISTER_DECODER (WMV3, wmv3); +- REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau); + REGISTER_DECODER (WNV1, wnv1); + REGISTER_DECODER (XAN_WC3, xan_wc3); + REGISTER_DECODER (XL, xl); +diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h +index 81f9d98..d63f5f3 100644 +--- a/libavcodec/avcodec.h ++++ b/libavcodec/avcodec.h +@@ -614,10 +614,6 @@ typedef struct RcOverride{ + */ + #define CODEC_CAP_SMALL_LAST_FRAME 0x0040 + /** +- * Codec can export data for HW decoding (VDPAU). +- */ +-#define CODEC_CAP_HWACCEL_VDPAU 0x0080 +-/** + * Codec can output multiple frames per AVPacket + */ + #define CODEC_CAP_SUBFRAMES 0x0100 +diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c +index 8c6ac9d..2f08ddb 100644 +--- a/libavcodec/error_resilience.c ++++ b/libavcodec/error_resilience.c +@@ -684,7 +684,6 @@ void ff_er_frame_end(MpegEncContext *s){ + + if(!s->error_recognition || s->error_count==0 || s->avctx->lowres || + s->avctx->hwaccel || +- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU || + s->picture_structure != PICT_FRAME || // we dont support ER of field pictures yet, though it should not crash if enabled + s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return; + +diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c +index a4d9532..d35bd26 100644 +--- a/libavcodec/h263dec.c ++++ b/libavcodec/h263dec.c +@@ -33,7 +33,6 @@ + #include "h263_parser.h" + #include "mpeg4video_parser.h" + #include "msmpeg4.h" +-#include "vdpau_internal.h" + #include "flv.h" + #include "mpeg4video.h" + +@@ -617,11 +616,6 @@ retry: + if(MPV_frame_start(s, avctx) < 0) + return -1; + +- if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) { +- ff_vdpau_mpeg4_decode_picture(s, buf, buf_size); +- goto frame_end; +- } +- + if (avctx->hwaccel) { + if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) + return -1; +diff --git a/libavcodec/h264.c b/libavcodec/h264.c +index 6056497..493bdf5 100644 +--- a/libavcodec/h264.c ++++ b/libavcodec/h264.c +@@ -36,7 +36,6 @@ + #include "golomb.h" + #include "mathops.h" + #include "rectangle.h" +-#include "vdpau_internal.h" + + #include "cabac.h" + #if ARCH_X86 +@@ -1626,9 +1625,6 @@ static void field_end(H264Context *h){ + s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264; + s->current_picture_ptr->pict_type= s->pict_type; + +- if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) +- ff_vdpau_h264_set_reference_frames(s); +- + if(!s->dropable) { + ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); + h->prev_poc_msb= h->poc_msb; +@@ -1642,9 +1638,6 @@ static void field_end(H264Context *h){ + av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n"); + } + +- if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) +- ff_vdpau_h264_picture_complete(s); +- + /* + * FIXME: Error handling code does not seem to support interlaced + * when slices span multiple rows +@@ -2355,8 +2348,6 @@ static void execute_decode_slices(H264Context *h, int context_count){ + + if (s->avctx->hwaccel) + return; +- if(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) +- return; + if(context_count == 1) { + decode_slice(avctx, &h); + } else { +@@ -2499,11 +2490,6 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ + if (avctx->hwaccel->decode_slice(avctx, &buf[buf_index - consumed], consumed) < 0) + return -1; + }else +- if(CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ +- static const uint8_t start_code[] = {0x00, 0x00, 0x01}; +- ff_vdpau_add_data_chunk(s, start_code, sizeof(start_code)); +- ff_vdpau_add_data_chunk(s, &buf[buf_index - consumed], consumed ); +- }else + context_count++; + } + break; +@@ -3080,20 +3066,3 @@ AVCodec h264_decoder = { + .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + .pix_fmts= ff_hwaccel_pixfmt_list_420, + }; +- +-#if CONFIG_H264_VDPAU_DECODER +-AVCodec h264_vdpau_decoder = { +- "h264_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_H264, +- sizeof(H264Context), +- ff_h264_decode_init, +- NULL, +- ff_h264_decode_end, +- decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, +- .flush= flush_dpb, +- .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"), +- .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE}, +-}; +-#endif +diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c +index 636ae06..be32e8d 100644 +--- a/libavcodec/mpeg12.c ++++ b/libavcodec/mpeg12.c +@@ -35,7 +35,6 @@ + #include "mpeg12data.h" + #include "mpeg12decdata.h" + #include "bytestream.h" +-#include "vdpau_internal.h" + #include "xvmc_internal.h" + + //#undef NDEBUG +@@ -1226,12 +1225,7 @@ static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){ + + if(avctx->xvmc_acceleration) + return avctx->get_format(avctx,pixfmt_xvmc_mpg2_420); +- else if(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ +- if(avctx->codec_id == CODEC_ID_MPEG1VIDEO) +- return PIX_FMT_VDPAU_MPEG1; +- else +- return PIX_FMT_VDPAU_MPEG2; +- }else{ ++ else{ + if(s->chroma_format < 2) + return avctx->get_format(avctx,ff_hwaccel_pixfmt_list_420); + else if(s->chroma_format == 2) +@@ -1324,9 +1318,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){ + avctx->pix_fmt = mpeg_get_pixelformat(avctx); + avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); + //until then pix_fmt may be changed right after codec init +- if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || +- avctx->hwaccel || +- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ) ++ if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ) + if( avctx->idct_algo == FF_IDCT_AUTO ) + avctx->idct_algo = FF_IDCT_SIMPLE; + +@@ -2063,8 +2055,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) + avctx->pix_fmt = mpeg_get_pixelformat(avctx); + avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); + +- if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel || +- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ) ++ if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel ) + if( avctx->idct_algo == FF_IDCT_AUTO ) + avctx->idct_algo = FF_IDCT_SIMPLE; + +@@ -2292,9 +2283,6 @@ static int decode_chunks(AVCodecContext *avctx, + s2->error_count += s2->thread_context[i]->error_count; + } + +- if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) +- ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); +- + if (slice_end(avctx, picture)) { + if(s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice + *data_size = sizeof(AVPicture); +@@ -2441,11 +2429,6 @@ static int decode_chunks(AVCodecContext *avctx, + return -1; + } + +- if (avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { +- s->slice_count++; +- break; +- } +- + if(avctx->thread_count > 1){ + int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count; + if(threshold <= mb_y){ +@@ -2570,36 +2553,3 @@ AVCodec mpeg_xvmc_decoder = { + }; + + #endif +- +-#if CONFIG_MPEG_VDPAU_DECODER +-AVCodec mpeg_vdpau_decoder = { +- "mpegvideo_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MPEG2VIDEO, +- sizeof(Mpeg1Context), +- mpeg_decode_init, +- NULL, +- mpeg_decode_end, +- mpeg_decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, +- .flush= flush, +- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"), +-}; +-#endif +- +-#if CONFIG_MPEG1_VDPAU_DECODER +-AVCodec mpeg1_vdpau_decoder = { +- "mpeg1video_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MPEG1VIDEO, +- sizeof(Mpeg1Context), +- mpeg_decode_init, +- NULL, +- mpeg_decode_end, +- mpeg_decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY, +- .flush= flush, +- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"), +-}; +-#endif +- +diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c +index a1786e8..757df3d 100644 +--- a/libavcodec/mpeg4videodec.c ++++ b/libavcodec/mpeg4videodec.c +@@ -2243,20 +2243,3 @@ AVCodec mpeg4_decoder = { + .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), + .pix_fmts= ff_hwaccel_pixfmt_list_420, + }; +- +- +-#if CONFIG_MPEG4_VDPAU_DECODER +-AVCodec mpeg4_vdpau_decoder = { +- "mpeg4_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MPEG4, +- sizeof(MpegEncContext), +- decode_init, +- NULL, +- ff_h263_decode_end, +- ff_h263_decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, +- .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"), +- .pix_fmts= (const enum PixelFormat[]){PIX_FMT_VDPAU_MPEG4, PIX_FMT_NONE}, +-}; +-#endif +diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c +index ea96cbe..8dd5ac1 100644 +--- a/libavcodec/mpegvideo.c ++++ b/libavcodec/mpegvideo.c +@@ -82,6 +82,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = { + + const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { + PIX_FMT_VAAPI_VLD, ++ PIX_FMT_VDPAU, + PIX_FMT_YUV420P, + PIX_FMT_NONE + }; +@@ -1018,7 +1019,6 @@ void MPV_frame_end(MpegEncContext *s) + if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){ + ff_xvmc_field_end(s); + }else if(!s->avctx->hwaccel +- && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + && s->unrestricted_mv + && s->current_picture.reference + && !s->intra_only +diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c +index d2a50a3..8770756 100644 +--- a/libavcodec/vc1dec.c ++++ b/libavcodec/vc1dec.c +@@ -36,7 +36,6 @@ + #include "unary.h" + #include "simple_idct.h" + #include "mathops.h" +-#include "vdpau_internal.h" + + #undef NDEBUG + #include <assert.h> +@@ -3140,13 +3139,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, + s->current_picture_ptr= &s->picture[i]; + } + +- if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ +- if (v->profile < PROFILE_ADVANCED) +- avctx->pix_fmt = PIX_FMT_VDPAU_WMV3; +- else +- avctx->pix_fmt = PIX_FMT_VDPAU_VC1; +- } +- + //for advanced profile we may need to parse and unescape data + if (avctx->codec_id == CODEC_ID_VC1) { + int buf_size2 = 0; +@@ -3163,8 +3155,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, + if(size <= 0) continue; + switch(AV_RB32(start)){ + case VC1_CODE_FRAME: +- if (avctx->hwaccel || +- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) ++ if (avctx->hwaccel) + buf_start = start; + buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); + break; +@@ -3256,10 +3247,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, + s->me.qpel_put= s->dsp.put_qpel_pixels_tab; + s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; + +- if ((CONFIG_VC1_VDPAU_DECODER) +- &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) +- ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start); +- else if (avctx->hwaccel) { ++ if (avctx->hwaccel) { + if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) + return -1; + if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0) +@@ -3349,37 +3337,3 @@ AVCodec wmv3_decoder = { + .pix_fmts = ff_hwaccel_pixfmt_list_420 + }; + #endif +- +-#if CONFIG_WMV3_VDPAU_DECODER +-AVCodec wmv3_vdpau_decoder = { +- "wmv3_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_WMV3, +- sizeof(VC1Context), +- vc1_decode_init, +- NULL, +- vc1_decode_end, +- vc1_decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, +- NULL, +- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"), +- .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE} +-}; +-#endif +- +-#if CONFIG_VC1_VDPAU_DECODER +-AVCodec vc1_vdpau_decoder = { +- "vc1_vdpau", +- CODEC_TYPE_VIDEO, +- CODEC_ID_VC1, +- sizeof(VC1Context), +- vc1_decode_init, +- NULL, +- vc1_decode_end, +- vc1_decode_frame, +- CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, +- NULL, +- .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"), +- .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE} +-}; +-#endif +diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c +index 7cc8ad1..c60b1e7 100644 +--- a/libavcodec/vdpau.c ++++ b/libavcodec/vdpau.c +@@ -30,7 +30,6 @@ + #include <assert.h> + + #include "vdpau.h" +-#include "vdpau_internal.h" + + /** + * \addtogroup VDPAU_Decoding +@@ -38,15 +37,57 @@ + * @{ + */ + +-void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) ++static void vdpau_h264_fill_field_order_cnt(int32_t field_order_cnt[2], Picture *pic, int pic_structure) + { +- H264Context *h = s->avctx->priv_data; ++ int i; ++ for (i = 0; i < 2; i++) { ++ const int poc = pic->field_poc[i]; ++ field_order_cnt[i] = poc != INT_MAX ? poc : 0; ++ } ++} ++ ++static void vdpau_h264_init_picture(VdpReferenceFrameH264 *rf) ++{ ++ rf->surface = VDP_INVALID_HANDLE; ++ rf->is_long_term = 0; ++ rf->top_is_reference = 0; ++ rf->bottom_is_reference = 0; ++ rf->field_order_cnt[0] = 0; ++ rf->field_order_cnt[1] = 0; ++ rf->frame_idx = 0; ++} ++ ++static void vdpau_h264_fill_picture(VdpReferenceFrameH264 *rf, Picture *pic, int pic_structure) ++{ ++ struct vdpau_render_state *render; ++ ++ assert(rf); ++ assert(pic); ++ ++ if (pic_structure == 0) ++ pic_structure = pic->reference; ++ ++ render = (struct vdpau_render_state *)pic->data[3]; ++ assert(render); ++ ++ rf->surface = render->surface; ++ rf->is_long_term = pic->reference && pic->long_ref; ++ rf->top_is_reference = (pic_structure & PICT_TOP_FIELD) != 0; ++ rf->bottom_is_reference = (pic_structure & PICT_BOTTOM_FIELD) != 0; ++ rf->frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num; ++ ++ vdpau_h264_fill_field_order_cnt(rf->field_order_cnt, pic, pic_structure); ++} ++ ++static void vdpau_h264_set_reference_frames(H264Context *h) ++{ ++ MpegEncContext * const s = &h->s; + struct vdpau_render_state *render, *render_ref; + VdpReferenceFrameH264 *rf, *rf2; + Picture *pic; + int i, list, pic_frame_idx; + +- render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; + assert(render); + + rf = &render->info.h264.referenceFrames[0]; +@@ -62,7 +103,7 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) + continue; + pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num; + +- render_ref = (struct vdpau_render_state *)pic->data[0]; ++ render_ref = (struct vdpau_render_state *)pic->data[3]; + assert(render_ref); + + rf2 = &render->info.h264.referenceFrames[0]; +@@ -84,70 +125,92 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s) + if (rf >= &render->info.h264.referenceFrames[H264_RF_COUNT]) + continue; + +- rf->surface = render_ref->surface; +- rf->is_long_term = pic->long_ref; +- rf->top_is_reference = (pic->reference & PICT_TOP_FIELD) ? VDP_TRUE : VDP_FALSE; +- rf->bottom_is_reference = (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE; +- rf->field_order_cnt[0] = pic->field_poc[0]; +- rf->field_order_cnt[1] = pic->field_poc[1]; +- rf->frame_idx = pic_frame_idx; ++ vdpau_h264_fill_picture(rf, pic, pic->reference); + + ++rf; + } + } + +- for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf) { +- rf->surface = VDP_INVALID_HANDLE; +- rf->is_long_term = 0; +- rf->top_is_reference = 0; +- rf->bottom_is_reference = 0; +- rf->field_order_cnt[0] = 0; +- rf->field_order_cnt[1] = 0; +- rf->frame_idx = 0; +- } ++ for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf) ++ vdpau_h264_init_picture(rf); + } + +-void ff_vdpau_add_data_chunk(MpegEncContext *s, +- const uint8_t *buf, int buf_size) ++static int vdpau_ensure_bitstream_buffers(struct vdpau_render_state *render) + { +- struct vdpau_render_state *render; +- +- render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; +- assert(render); +- + render->bitstream_buffers= av_fast_realloc( + render->bitstream_buffers, + &render->bitstream_buffers_allocated, + sizeof(*render->bitstream_buffers)*(render->bitstream_buffers_used + 1) + ); + ++ if (!render->bitstream_buffers) ++ return -1; ++ ++ return 0; ++} ++ ++static int vdpau_common_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) ++{ ++ MpegEncContext * const s = avctx->priv_data; ++ struct vdpau_render_state *render; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ render->bitstream_buffers_used = 0; ++ return 0; ++} ++ ++static int vdpau_common_end_frame(AVCodecContext *avctx) ++{ ++ MpegEncContext * const s = avctx->priv_data; ++ struct vdpau_render_state *render; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ if (render->bitstream_buffers_used) { ++ ff_draw_horiz_band(s, 0, s->avctx->height); ++ render->bitstream_buffers_used = 0; ++ } ++ return 0; ++} ++ ++static int vdpau_common_decode_slice(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) ++{ ++ MpegEncContext * const s = avctx->priv_data; ++ struct vdpau_render_state *render; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ if (vdpau_ensure_bitstream_buffers(render) < 0) ++ return -1; ++ + render->bitstream_buffers[render->bitstream_buffers_used].struct_version = VDP_BITSTREAM_BUFFER_VERSION; + render->bitstream_buffers[render->bitstream_buffers_used].bitstream = buf; + render->bitstream_buffers[render->bitstream_buffers_used].bitstream_bytes = buf_size; + render->bitstream_buffers_used++; ++ return 0; + } + +-void ff_vdpau_h264_picture_complete(MpegEncContext *s) ++static int vdpau_h264_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) + { +- H264Context *h = s->avctx->priv_data; ++ H264Context * const h = avctx->priv_data; ++ MpegEncContext * const s = &h->s; + struct vdpau_render_state *render; +- int i; + +- render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; + assert(render); + +- render->info.h264.slice_count = h->slice_num; +- if (render->info.h264.slice_count < 1) +- return; ++ vdpau_h264_set_reference_frames(h); + +- for (i = 0; i < 2; ++i) { +- int foc = s->current_picture_ptr->field_poc[i]; +- if (foc == INT_MAX) +- foc = 0; +- render->info.h264.field_order_cnt[i] = foc; +- } ++ vdpau_h264_fill_field_order_cnt(render->info.h264.field_order_cnt, ++ s->current_picture_ptr, ++ s->picture_structure); + +- render->info.h264.is_reference = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE; ++ /* fill VdpPictureInfoH264 struct */ ++ render->info.h264.is_reference = h->nal_ref_idc != 0; + render->info.h264.frame_num = h->frame_num; + render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME; + render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD; +@@ -175,19 +238,44 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s) + memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4)); + memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8)); + +- ff_draw_horiz_band(s, 0, s->avctx->height); +- render->bitstream_buffers_used = 0; ++ render->info.h264.slice_count = 0; ++ ++ return vdpau_common_start_frame(avctx, buffer, size); ++} ++ ++static int vdpau_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) ++{ ++ MpegEncContext * const s = avctx->priv_data; ++ struct vdpau_render_state *render; ++ static const uint8_t start_code_prefix_one_3byte[3] = { 0x00, 0x00, 0x01 }; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ if (vdpau_ensure_bitstream_buffers(render) < 0) ++ return -1; ++ ++ render->bitstream_buffers[render->bitstream_buffers_used].struct_version = VDP_BITSTREAM_BUFFER_VERSION; ++ render->bitstream_buffers[render->bitstream_buffers_used].bitstream = start_code_prefix_one_3byte; ++ render->bitstream_buffers[render->bitstream_buffers_used].bitstream_bytes = sizeof(start_code_prefix_one_3byte); ++ render->bitstream_buffers_used++; ++ ++ if (vdpau_common_decode_slice(avctx, buffer, size) < 0) ++ return -1; ++ ++ ++render->info.h264.slice_count; ++ return 0; + } + +-void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, +- int buf_size, int slice_count) ++static int vdpau_mpeg2_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) + { ++ MpegEncContext * const s = avctx->priv_data; + struct vdpau_render_state *render, *last, *next; + int i; + +- if (!s->current_picture_ptr) return; ++ if (!s->current_picture_ptr) return 0; + +- render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; + assert(render); + + /* fill VdpPictureInfoMPEG1Or2 struct */ +@@ -216,36 +304,47 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf, + + switch(s->pict_type){ + case FF_B_TYPE: +- next = (struct vdpau_render_state *)s->next_picture.data[0]; ++ next = (struct vdpau_render_state *)s->next_picture.data[3]; + assert(next); + render->info.mpeg.backward_reference = next->surface; + // no return here, going to set forward prediction + case FF_P_TYPE: +- last = (struct vdpau_render_state *)s->last_picture.data[0]; ++ last = (struct vdpau_render_state *)s->last_picture.data[3]; + if (!last) // FIXME: Does this test make sense? + last = render; // predict second field from the first + render->info.mpeg.forward_reference = last->surface; + } + +- ff_vdpau_add_data_chunk(s, buf, buf_size); ++ render->info.mpeg.slice_count = 0; + +- render->info.mpeg.slice_count = slice_count; ++ return vdpau_common_start_frame(avctx, buffer, size); ++} + +- if (slice_count) +- ff_draw_horiz_band(s, 0, s->avctx->height); +- render->bitstream_buffers_used = 0; ++static int vdpau_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) ++{ ++ MpegEncContext * const s = avctx->priv_data; ++ struct vdpau_render_state *render; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ if (vdpau_common_decode_slice(avctx, buffer, size) < 0) ++ return -1; ++ ++ ++render->info.mpeg.slice_count; ++ return 0; + } + +-void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, +- int buf_size) ++static int vdpau_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) + { +- VC1Context *v = s->avctx->priv_data; ++ VC1Context * const v = avctx->priv_data; ++ MpegEncContext * const s = &v->s; + struct vdpau_render_state *render, *last, *next; + +- render = (struct vdpau_render_state *)s->current_picture.data[0]; ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; + assert(render); + +- /* fill LvPictureInfoVC1 struct */ ++ /* fill VdpPictureInfoVC1 struct */ + render->info.vc1.frame_coding_mode = v->fcm; + render->info.vc1.postprocflag = v->postprocflag; + render->info.vc1.pulldown = v->broadcast; +@@ -286,34 +385,47 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, + + switch(s->pict_type){ + case FF_B_TYPE: +- next = (struct vdpau_render_state *)s->next_picture.data[0]; ++ next = (struct vdpau_render_state *)s->next_picture.data[3]; + assert(next); + render->info.vc1.backward_reference = next->surface; + // no break here, going to set forward prediction + case FF_P_TYPE: +- last = (struct vdpau_render_state *)s->last_picture.data[0]; ++ last = (struct vdpau_render_state *)s->last_picture.data[3]; + if (!last) // FIXME: Does this test make sense? + last = render; // predict second field from the first + render->info.vc1.forward_reference = last->surface; + } + +- ff_vdpau_add_data_chunk(s, buf, buf_size); ++ render->info.vc1.slice_count = 0; + +- render->info.vc1.slice_count = 1; ++ return vdpau_common_start_frame(avctx, buffer, size); ++} + +- ff_draw_horiz_band(s, 0, s->avctx->height); +- render->bitstream_buffers_used = 0; ++static int vdpau_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) ++{ ++ VC1Context * const v = avctx->priv_data; ++ MpegEncContext * const s = &v->s; ++ struct vdpau_render_state *render; ++ ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; ++ assert(render); ++ ++ if (vdpau_common_decode_slice(avctx, buffer, size) < 0) ++ return -1; ++ ++ ++render->info.vc1.slice_count; ++ return 0; + } + +-void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, +- int buf_size) ++static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) + { ++ MpegEncContext * const s = avctx->priv_data; + struct vdpau_render_state *render, *last, *next; + int i; + +- if (!s->current_picture_ptr) return; ++ if (!s->current_picture_ptr) return 0; + +- render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; ++ render = (struct vdpau_render_state *)s->current_picture_ptr->data[3]; + assert(render); + + /* fill VdpPictureInfoMPEG4Part2 struct */ +@@ -338,21 +450,104 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, + + switch (s->pict_type) { + case FF_B_TYPE: +- next = (struct vdpau_render_state *)s->next_picture.data[0]; ++ next = (struct vdpau_render_state *)s->next_picture.data[3]; + assert(next); + render->info.mpeg4.backward_reference = next->surface; + render->info.mpeg4.vop_coding_type = 2; + // no break here, going to set forward prediction + case FF_P_TYPE: +- last = (struct vdpau_render_state *)s->last_picture.data[0]; ++ last = (struct vdpau_render_state *)s->last_picture.data[3]; + assert(last); + render->info.mpeg4.forward_reference = last->surface; + } + +- ff_vdpau_add_data_chunk(s, buf, buf_size); ++ if (vdpau_common_start_frame(avctx, buffer, size) < 0) ++ return -1; + +- ff_draw_horiz_band(s, 0, s->avctx->height); +- render->bitstream_buffers_used = 0; ++ return vdpau_common_decode_slice(avctx, buffer, size); + } + ++static int vdpau_mpeg4_decode_slice(av_unused AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) ++{ ++ return 0; ++} ++ ++#if CONFIG_MPEG1_VDPAU_HWACCEL ++AVHWAccel mpeg1_vdpau_hwaccel = { ++ .name = "mpeg1_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_MPEG1VIDEO, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_mpeg2_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_mpeg2_decode_slice, ++}; ++#endif ++ ++#if CONFIG_MPEG2_VDPAU_HWACCEL ++AVHWAccel mpeg2_vdpau_hwaccel = { ++ .name = "mpeg2_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_MPEG2VIDEO, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_mpeg2_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_mpeg2_decode_slice, ++}; ++#endif ++ ++#if CONFIG_H264_VDPAU_HWACCEL ++AVHWAccel h264_vdpau_hwaccel = { ++ .name = "h264_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_H264, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_h264_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_h264_decode_slice, ++}; ++#endif ++ ++#if CONFIG_WMV3_VDPAU_HWACCEL ++AVHWAccel wmv3_vdpau_hwaccel = { ++ .name = "wmv3_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_WMV3, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_vc1_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_vc1_decode_slice, ++}; ++#endif ++ ++#if CONFIG_VC1_VDPAU_HWACCEL ++AVHWAccel vc1_vdpau_hwaccel = { ++ .name = "vc1_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_VC1, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_vc1_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_vc1_decode_slice, ++}; ++#endif ++ ++#if CONFIG_MPEG4_VDPAU_HWACCEL ++AVHWAccel mpeg4_vdpau_hwaccel = { ++ .name = "mpeg4_vdpau", ++ .type = CODEC_TYPE_VIDEO, ++ .id = CODEC_ID_MPEG4, ++ .pix_fmt = PIX_FMT_VDPAU, ++ .capabilities = 0, ++ .start_frame = vdpau_mpeg4_start_frame, ++ .end_frame = vdpau_common_end_frame, ++ .decode_slice = vdpau_mpeg4_decode_slice, ++}; ++#endif ++ + /* @}*/ +diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c +index b689519..217c49f 100644 +--- a/libavutil/pixdesc.c ++++ b/libavutil/pixdesc.c +@@ -646,6 +646,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { + }, + .flags = PIX_FMT_BE, + }, ++ [PIX_FMT_VDPAU] = { ++ .name = "vdpau", ++ .log2_chroma_w = 1, ++ .log2_chroma_h = 1, ++ .flags = PIX_FMT_HWACCEL, ++ }, + }; + + int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc) +diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h +index ddd17fb..1f17073 100644 +--- a/libavutil/pixfmt.h ++++ b/libavutil/pixfmt.h +@@ -127,6 +127,7 @@ enum PixelFormat { + PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer ++ PIX_FMT_VDPAU, ///< HW decoding with VDPAU, Picture.data[3] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + }; + +diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c +index 1e8e71f..d49d009 100644 +--- a/libmpcodecs/vd_ffmpeg.c ++++ b/libmpcodecs/vd_ffmpeg.c +@@ -275,7 +275,7 @@ static int init(sh_video_t *sh){ + } + #endif /* CONFIG_VAAPI */ + #if CONFIG_VDPAU +- if(lavc_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU){ ++ if(get_video_hwaccel() == HWACCEL_VDPAU){ + avctx->get_format = get_format; + } + #endif /* CONFIG_VDPAU */ +diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c +index 2ee7ccc..e728aff 100644 +--- a/libvo/vo_vdpau.c ++++ b/libvo/vo_vdpau.c +@@ -977,7 +977,7 @@ static int draw_slice(uint8_t *image[], int stride[], int w, int h, + int x, int y) + { + VdpStatus vdp_st; +- struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[0]; ++ struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[3]; + int max_refs = image_format == IMGFMT_VDPAU_H264 ? rndr->info.h264.num_ref_frames : 2; + + if (handle_preemption() < 0) +@@ -1080,10 +1080,10 @@ static uint32_t get_image(mp_image_t *mpi) + return VO_FALSE; + } + mpi->flags |= MP_IMGFLAG_DIRECT; +- mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = 0; +- mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = NULL; ++ mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = mpi->stride[3] = 0; ++ mpi->planes[0] = mpi->planes[1] = mpi->planes[2] = mpi->planes[3] = NULL; + // hack to get around a check and to avoid a special-case in vd_ffmpeg.c +- mpi->planes[0] = (void *)rndr; ++ mpi->planes[0] = mpi->planes[3] = (void *)rndr; + mpi->num_planes = 1; + mpi->priv = rndr; + return VO_TRUE; diff --git a/media-video/mplayer/metadata.xml b/media-video/mplayer/metadata.xml new file mode 100644 index 0000000..a9f41f0 --- /dev/null +++ b/media-video/mplayer/metadata.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <herd>video</herd> + <maintainer> + <email>media-video@gentoo.org</email> + </maintainer> + <use> + <flag name="3dnowext">Enable 3dnowext cpu instructions</flag> + <flag name="ass">Internal SRT/SSA/ASS (SubRip / SubStation Alpha) subtitle support</flag> + <flag name="bl">Blinkenlights video output</flag> + <flag name="bs2b">Enable Bauer stereophonic-to-binaural headphone filter</flag> + <flag name="cdio">Use libcdio for CD support (instead of cdparanoia)</flag> + <flag name="cpudetection">Enables runtime cpudetection (useful for bindist, compatability on other CPUs)</flag> + <flag name="custom-cpuopts">Fine-tune custom CPU optimizations (UNSUPPORTED)</flag> + <flag name="dirac">Enable Dirac video support (an advanced royalty-free video compression format) via the reference library: dirac.</flag> + <flag name="dvdnav">Use forked libdvdnav, navigate menus in GUIs</flag> + <flag name="dxr3">Enable DXR3/H+ video output</flag> + <flag name="enca">Enables support for charset discovery and conversion</flag> + <flag name="external-ffmpeg">Use shared FFmpeg libraries instead of static bundled ones. Discouraged by upstream.</flag> + <flag name="faac">Use external faac library for AAC encoding</flag> + <flag name="faad">Use external faad library for AAC decoding</flag> + <flag name="gmplayer">Build gmplayer, a GTK+ MPlayer gui (UNSUPPORTED)</flag> + <flag name="live">Enables live.com streaming media support</flag> + <flag name="md5sum">Enables md5sum video output</flag> + <flag name="mmxext">Enables mmx2 support</flag> + <flag name="mng">MNG input support</flag> + <flag name="network">Enables network streaming support</flag> + <flag name="nut">Enables support for the NUT container format</flag> + <flag name="opencore-amr">Enables Adaptive Multi-Rate format support</flag> + <flag name="osdmenu">Enables support for on-screen display (OSD) menus</flag> + <flag name="pnm">Add PNM video output option, to create PPM/PGM/PGMYUV images</flag> + <flag name="pvr">Enable Video4Linux2 MPEG PVR</flag> + <flag name="radio">Enable V4L2 radio interface and support</flag> + <flag name="rar">Enable Unique RAR File Library</flag> + <flag name="real">Adds real audo/video support</flag> + <flag name="rtc">Enables usage of the linux real time clock. The alternative is software emulation of rtc</flag> + <flag name="schroedinger">Enable Dirac video support (an advanced royalty-free video compression format) via libschroedinger (high-speed implementation in C of the Dirac codec).</flag> + <flag name="shm">Enable support for shm</flag> + <flag name="ssse3">faster floating point optimization for SSSE3 capable chips (Intel Core 2 and later chips)</flag> + <flag name="teletext">Support for TV teletext interface</flag> + <flag name="tga">Enables Targa video output</flag> + <flag name="toolame">Enable toolame MPEG-2 encoding</flag> + <flag name="tremor">Enable internal support for Vorbis</flag> + <flag name="twolame">Enable twolame MPEG-2 encoding</flag> + <flag name="vdpau">Enables experimental VDPAU support (requires nVidia video cards) to offload MPEG2/MPEG4/VC1/WMV CPU processing to video card</flag> + <flag name="vidix">Support for vidix video output</flag> + <flag name="xanim">Enables support for xanim based codecs</flag> + <flag name="xvmc">Enables X-Video Motion Compensation support</flag> + <flag name="zoran">Enables ZR360[56]7/ZR36060 video output</flag> + </use> +</pkgmetadata> diff --git a/media-video/mplayer/mplayer-1.0_rc4_p20100213-r50.ebuild b/media-video/mplayer/mplayer-1.0_rc4_p20100213-r50.ebuild new file mode 100644 index 0000000..1085db2 --- /dev/null +++ b/media-video/mplayer/mplayer-1.0_rc4_p20100213-r50.ebuild @@ -0,0 +1,743 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/media-video/mplayer/mplayer-1.0_rc4_p20100213-r1.ebuild,v 1.9 2010/04/23 13:04:43 ssuominen Exp $ + +EAPI="2" + +ESVN_REPO_URI="svn://svn.mplayerhq.hu/mplayer/trunk" +[[ ${PV} = *9999* ]] && SVN_ECLASS="subversion" || SVN_ECLASS="" + +inherit eutils flag-o-matic multilib base ${SVN_ECLASS} + +[[ ${PV} != *9999* ]] && MPLAYER_REVISION=SVN-r30554 + +IUSE="3dnow 3dnowext +a52 +aac aalib +alsa altivec +ass bidi bindist bl bs2b ++cddb +cdio cdparanoia cpudetection custom-cpuopts debug dga +dirac directfb +doc +dts +dv dvb +dvd +dvdnav dxr3 +enca +encode esd +faac +faad fbcon ftp +gif ggi -gmplayer +iconv ipv6 jack joystick jpeg jpeg2k kernel_linux ladspa +libcaca lirc +live lzo mad md5sum +mmx mmxext mng +mp3 nas +network nut openal +amr +opengl +osdmenu oss png pnm pulseaudio pvr +quicktime radio +rar +real +rtc +samba +shm +schroedinger sdl +speex sse sse2 ssse3 svga tga +theora +tremor ++truetype +toolame +twolame +unicode v4l v4l2 vaapi vdpau vidix +vorbis win32codecs ++X +x264 xanim xinerama +xscreensaver +xv +xvid xvmc zoran" +[[ ${PV} == *9999* ]] && IUSE+=" external-ffmpeg" + +VIDEO_CARDS="s3virge mga tdfx nvidia vesa" +for x in ${VIDEO_CARDS}; do + IUSE+=" video_cards_${x}" +done + +BLUV="1.7" +SVGV="1.9.17" +AMR_URI="http://www.3gpp.org/ftp/Specs/archive" +FONT_URI=" + mirror://mplayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 + mirror://mplayer/releases/fonts/font-arial-iso-8859-2.tar.bz2 + mirror://mplayer/releases/fonts/font-arial-cp1250.tar.bz2 +" +if [[ ${PV} == *9999* ]]; then + RELEASE_URI="" +else + RELEASE_URI="mirror://gentoo/${P}.tbz2" +fi +SRC_URI="${RELEASE_URI} + !truetype? ( ${FONT_URI} ) + gmplayer? ( mirror://mplayer/skins/Blue-${BLUV}.tar.bz2 ) + svga? ( mirror://gentoo/svgalib_helper-${SVGV}-mplayer.tar.gz )" +# svga? ( http://mplayerhq.hu/~alex/svgalib_helper-${SVGV}-mplayer.tar.bz2 ) + +DESCRIPTION="Media Player for Linux" +HOMEPAGE="http://www.mplayerhq.hu/" + +FONT_RDEPS=" + virtual/ttf-fonts + media-libs/fontconfig + media-libs/freetype:2 +" +X_RDEPS=" + x11-libs/libXext + x11-libs/libXxf86vm +" +[[ ${PV} == *9999* ]] && RDEPEND+=" external-ffmpeg? ( media-video/ffmpeg )" +# Rar: althrought -gpl version is nice, it cant do most functions normal rars can +# nemesi? ( net-libs/libnemesi ) +RDEPEND+=" + sys-libs/ncurses + !bindist? ( + x86? ( + win32codecs? ( media-libs/win32codecs ) + ) + ) + X? ( + ${X_RDEPS} + ass? ( ${FONT_RDEPS} ) + dga? ( x11-libs/libXxf86dga ) + ggi? ( + media-libs/libggi + media-libs/libggiwmh + ) + gmplayer? ( + media-libs/libpng + x11-libs/gtk+:2 + x11-libs/libXi + ) + opengl? ( virtual/opengl ) + truetype? ( ${FONT_RDEPS} ) + video_cards_nvidia? ( + vdpau? ( >=x11-drivers/nvidia-drivers-180.60 ) + ) + xinerama? ( x11-libs/libXinerama ) + xscreensaver? ( x11-libs/libXScrnSaver ) + xv? ( + x11-libs/libXv + xvmc? ( x11-libs/libXvMC ) + ) + ) + aalib? ( media-libs/aalib ) + alsa? ( media-libs/alsa-lib ) + bidi? ( dev-libs/fribidi ) + bs2b? ( media-libs/libbs2b ) + cdio? ( dev-libs/libcdio ) + cdparanoia? ( media-sound/cdparanoia ) + dirac? ( media-video/dirac ) + directfb? ( dev-libs/DirectFB ) + dts? ( media-libs/libdca ) + dv? ( media-libs/libdv ) + dvb? ( media-tv/linuxtv-dvb-headers ) + encode? ( + !twolame? ( toolame? ( media-sound/toolame ) ) + twolame? ( media-sound/twolame ) + faac? ( media-libs/faac ) + mp3? ( media-sound/lame ) + x264? ( >=media-libs/x264-0.0.20091124 ) + xvid? ( media-libs/xvid ) + ) + esd? ( media-sound/esound ) + enca? ( app-i18n/enca ) + faad? ( !aac? ( media-libs/faad2 ) ) + gif? ( media-libs/giflib ) + jack? ( media-sound/jack-audio-connection-kit ) + jpeg? ( media-libs/jpeg ) + ladspa? ( media-libs/ladspa-sdk ) + libcaca? ( media-libs/libcaca ) + lirc? ( app-misc/lirc ) + live? ( media-plugins/live ) + lzo? ( >=dev-libs/lzo-2 ) + mad? ( media-libs/libmad ) + mng? ( media-libs/libmng ) + nas? ( media-libs/nas ) + nut? ( >=media-libs/libnut-661 ) + openal? ( media-libs/openal ) + amr? ( media-libs/opencore-amr ) + jpeg2k? ( media-libs/openjpeg ) + png? ( media-libs/libpng ) + pnm? ( media-libs/netpbm ) + pulseaudio? ( media-sound/pulseaudio ) + rar? ( + || ( + app-arch/unrar + app-arch/rar + ) + ) + samba? ( net-fs/samba ) + schroedinger? ( media-libs/schroedinger ) + sdl? ( media-libs/libsdl ) + speex? ( media-libs/speex ) + svga? ( media-libs/svgalib ) + theora? ( media-libs/libtheora ) + vaapi? ( x11-libs/libva ) + vorbis? ( media-libs/libvorbis ) + xanim? ( media-video/xanim ) +" + +X_DEPS=" + x11-proto/videoproto + x11-proto/xf86vidmodeproto +" +ASM_DEP="dev-lang/yasm" +DEPEND="${RDEPEND} + dev-util/pkgconfig + X? ( + ${X_DEPS} + dga? ( x11-proto/xf86dgaproto ) + dxr3? ( media-video/em8300-libraries ) + gmplayer? ( x11-proto/xextproto ) + xinerama? ( x11-proto/xineramaproto ) + xscreensaver? ( x11-proto/scrnsaverproto ) + ) + amd64? ( ${ASM_DEP} ) + doc? ( dev-libs/libxslt ) + iconv? ( virtual/libiconv ) + x86? ( ${ASM_DEP} ) + x86-fbsd? ( ${ASM_DEP} ) +" + +SLOT="0" +LICENSE="GPL-2" +if [[ ${PV} != *9999* ]]; then + KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd" +else + KEYWORDS="" +fi + +PATCHES=( "${FILESDIR}"/vaapi/*.patch ) + +pkg_setup() { + if [[ ${PV} == *9999* ]]; then + elog "" + elog "This is a live ebuild which installs the latest from upstream's" + elog "subversion repository, and is unsupported by Gentoo." + elog "Everything but bugs in the ebuild itself will be ignored." + elog "" + fi + + if use gmplayer; then + ewarn "" + ewarn "GMPlayer is no longer actively developed upstream" + ewarn "and is not supported by Gentoo. There are alternatives" + ewarn "for a GUI frontend: smplayer, gnome-mplayer or kmplayer." + fi + + if use cpudetection; then + ewarn "" + ewarn "You've enabled the cpudetection flag. This feature is" + ewarn "included mainly for people who want to use the same" + ewarn "binary on another system with a different CPU architecture." + ewarn "MPlayer will already detect your CPU settings by default at" + ewarn "buildtime; this flag is used for runtime detection." + ewarn "You won't need this turned on if you are only building" + ewarn "mplayer for this system. Also, if your compile fails, try" + ewarn "disabling this use flag." + fi + + if use custom-cpuopts; then + ewarn "" + ewarn "You are using the custom-cpuopts flag which will" + ewarn "specifically allow you to enable / disable certain" + ewarn "CPU optimizations." + ewarn "" + ewarn "Most desktop users won't need this functionality, but it" + ewarn "is included for corner cases like cross-compiling and" + ewarn "certain profiles. If unsure, disable this flag and MPlayer" + ewarn "will automatically detect and use your available CPU" + ewarn "optimizations." + ewarn "" + ewarn "Using this flag means your build is unsupported, so" + ewarn "please make sure your CPU optimization use flags (3dnow" + ewarn "3dnowext mmx mmxext sse sse2 ssse3) are properly set." + fi +} + +src_unpack() { + [[ ${PV} = *9999* ]] && subversion_src_unpack || unpack ${A} + + if ! use truetype; then + unpack font-arial-iso-8859-1.tar.bz2 \ + font-arial-iso-8859-2.tar.bz2 \ + font-arial-cp1250.tar.bz2 + fi + + use gmplayer && unpack "Blue-${BLUV}.tar.bz2" + use svga && unpack "svgalib_helper-${SVGV}-mplayer.tar.gz" +} + +src_prepare() { + if [[ ${PV} = *9999* ]]; then + # Set SVN version manually + subversion_wc_info + sed -i s/UNKNOWN/${ESVN_WC_REVISION}/ "${S}/version.sh" + else + # Set version # + sed -i s/UNKNOWN/${MPLAYER_REVISION}/ "${S}/version.sh" + fi + + if use svga; then + echo + einfo "Enabling vidix non-root mode." + einfo "(You need a proper svgalib_helper.o module for your kernel" + einfo "to actually use this)" + echo + + mv "${WORKDIR}/svgalib_helper" "${S}/libdha" + fi + + base_src_prepare +} + +src_configure() { + local myconf="" + local uses i + + # set LINGUAS + [[ -n $LINGUAS ]] && LINGUAS="${LINGUAS/da/dk}" + + # mplayer ebuild uses "use foo || --disable-foo" to forcibly disable + # compilation in almost every situation. The reason for this is + # because if --enable is used, it will force the build of that option, + # regardless of whether the dependency is available or not. + + ################### + #Optional features# + ################### + myconf+=" + --disable-arts + --disable-kai + $(use_enable network) + $(use_enable joystick) + " + uses="bl enca ftp rtc" # nemesi <- not working with in-tree ebuild + myconf+=" --disable-nemesi" # nemesi automagic disable + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use ass || myconf+=" --disable-ass --disable-ass-internal" + use bidi || myconf+=" --disable-fribidi" + use encode || myconf+=" --disable-mencoder" + use ipv6 || myconf+=" --disable-inet6" + use nut || myconf+=" --disable-libnut" + use rar || myconf+=" --disable-unrarexec" + use samba || myconf+=" --disable-smb" + if ! use lirc; then + myconf+=" + --disable-lirc + --disable-lircc + --disable-apple-ir + " + fi + + # libcdio support: prefer libcdio over cdparanoia + # don't check for cddb w/cdio + if use cdio; then + myconf+=" --disable-cdparanoia" + else + myconf+=" --disable-libcdio" + use cdparanoia || myconf+=" --disable-cdparanoia" + use cddb || myconf+=" --disable-cddb" + fi + + ################################ + # DVD read, navigation support # + ################################ + # + # dvdread - accessing a DVD + # dvdnav - navigation of menus + # + # internal dvdread and dvdnav use flags enable internal + # versions of the libraries, which are snapshots of the fork. + # + # Only check for disabled a52 use flag inside the DVD check, + # since many users were getting confused why there was no + # audio stream. + + if use dvd; then + use dvdnav || myconf+=" --disable-dvdnav" + else + myconf+=" + --disable-dvdnav + --disable-dvdread + --disable-dvdread-internal + --disable-libdvdcss-internal + " + use a52 || myconf+=" --disable-liba52-internal" + fi + + ############# + # Subtitles # + ############# + # + # SRT/ASS/SSA (subtitles) requires freetype support + # freetype support requires iconv + # iconv optionally can use unicode + + if ! use ass; then + if ! use truetype; then + myconf+=" --disable-freetype" + if ! use iconv; then + myconf+=" + --disable-iconv + --charset=noconv + " + fi + fi + fi + use iconv && use unicode && myconf+=" --charset=UTF-8" + + ##################################### + # DVB / Video4Linux / Radio support # + ##################################### + myconf+=" --disable-tv-bsdbt848" + # broken upstream, won't work with recent kernels + myconf+=" --disable-ivtv" + if { use dvb || use v4l || use v4l2 || use pvr || use radio; }; then + use dvb || myconf+=" --disable-dvb --disable-dvbhead" + use pvr || myconf+=" --disable-pvr" + use v4l || myconf+=" --disable-tv-v4l1" + use v4l2 || myconf+=" --disable-tv-v4l2" + if use radio && { use dvb || use v4l || use v4l2; }; then + myconf+=" + --enable-radio + $(use_enable encode radio-capture) + " + else + myconf+=" + --disable-radio-v4l2 + --disable-radio-bsdbt848 + " + fi + else + myconf+=" + --disable-tv + --disable-tv-v4l1 + --disable-tv-v4l2 + --disable-radio + --disable-radio-v4l2 + --disable-radio-bsdbt848 + --disable-dvb + --disable-dvbhead + --disable-v4l2 + --disable-pvr" + fi + + ########## + # Codecs # + ########## + # Won't work with external liba52 + myconf+=" --disable-liba52" + # Use internal musepack codecs for SV7 and SV8 support + myconf+=" --disable-musepack" + + use aac || myconf+=" --disable-faad-internal" + use dirac || myconf+=" --disable-libdirac-lavc" + use dts || myconf+=" --disable-libdca" + use dv || myconf+=" --disable-libdv" + use faad || myconf+=" --disable-faad" + use lzo || myconf+=" --disable-liblzo" + if ! use mp3; then + myconf+=" + --disable-mp3lame + --disable-mp3lame-lavc + --disable-mp3lib + " + fi + use bs2b || myconf+=" --disable-libbs2b" + use schroedinger || myconf+=" --disable-libschroedinger-lavc" + use xanim && myconf+=" --xanimcodecsdir=/usr/lib/xanim/mods" + if ! use png && ! use gmplayer; then + myconf+=" --disable-png" + fi + + uses="gif jpeg live mad mng pnm speex tga theora xanim" + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use jpeg2k || myconf+=" --disable-libopenjpeg" + if use vorbis || use tremor; then + use tremor || myconf+=" --disable-tremor-internal" + use vorbis || myconf+=" --disable-libvorbis" + else + myconf+=" + --disable-tremor-internal + --disable-tremor + --disable-libvorbis + " + fi + # Encoding + if use encode; then + uses="faac x264 xvid toolame twolame" + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use aac || myconf+=" --disable-faac-lavc" + else + myconf+=" + --disable-faac-lavc + --disable-faac + --disable-x264 + --disable-xvid + --disable-x264-lavc + --disable-xvid-lavc + --disable-twolame + --disable-toolame + " + uses="aac faac x264 xvid toolame twolame" + for i in ${uses}; do + use ${i} && elog "Useflag \"${i}\" require \"encode\" useflag enabled to work." + done + fi + + ################# + # Binary codecs # + ################# + # bug 213836 + if ! use x86 || ! use win32codecs; then + use quicktime || myconf+=" --disable-qtx" + fi + + ###################### + # RealPlayer support # + ###################### + # Realplayer support shows up in four places: + # - libavcodec (internal) + # - win32codecs + # - realcodecs (win32codecs libs) + # - realcodecs (realplayer libs) + + # internal + use real || myconf+=" --disable-real" + + # Real binary codec support only available on x86, amd64 + if use real; then + use x86 && myconf+=" --realcodecsdir=/opt/RealPlayer/codecs" + use amd64 && myconf+=" --realcodecsdir=/usr/$(get_libdir)/codecs" + elif ! use bindist; then + myconf+=" $(use_enable win32codecs win32dll)" + fi + + ################ + # Video Output # + ################ + uses="directfb md5sum sdl" + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use aalib || myconf+=" --disable-aa" + use fbcon || myconf+=" --disable-fbdev" + use fbcon && use video_cards_s3virge && myconf+=" --enable-s3fb" + use libcaca || myconf+=" --disable-caca" + use zoran || myconf+=" --disable-zr" + + if ! use kernel_linux && ! use video_cards_mga; then + myconf+=" --disable-mga --disable-xmga" + fi + + if use video_cards_tdfx; then + myconf+=" + $(use_enable video_cards_tdfx tdfxvid) + $(use_enable fbcon tdfxfb) + " + else + myconf+=" + --disable-3dfx + --disable-tdfxvid + --disable-tdfxfb + " + fi + + ################ + # Audio Output # + ################ + uses="alsa esd jack ladspa nas openal" + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use pulseaudio || myconf+=" --disable-pulse" + if ! use radio; then + use oss || myconf+=" --disable-ossaudio" + fi + + #################### + # Advanced Options # + #################### + # Platform specific flags, hardcoded on amd64 (see below) + if use cpudetection; then + myconf+=" --enable-runtime-cpudetection" + fi + + # Turning off CPU optimizations usually will break the build. + # However, this use flag, if enabled, will allow users to completely + # specify which ones to use. If disabled, mplayer will automatically + # enable all CPU optimizations that the host build supports. + if use custom-cpuopts; then + uses="3dnow 3dnowext altivec mmx mmxext shm sse sse2 ssse3" + for i in ${uses}; do + myconf+=" $(use_enable ${i})" + done + fi + + use debug && myconf+=" --enable-debug=3" + + if use x86; then + filter-flags -fPIC -fPIE + append-ldflags -nopie + fi + + append-flags -D__STDC_LIMIT_MACROS + is-flag -O? || append-flags -O2 + if use x86 || use x86-fbsd; then + use debug || append-flags -fomit-frame-pointer + fi + + ########################### + # X enabled configuration # + ########################### + if use X; then + uses="dxr3 ggi xinerama" + for i in ${uses}; do + use ${i} || myconf+=" --disable-${i}" + done + use dga || myconf+=" --disable-dga1 --disable-dga2" + use opengl || myconf+=" --disable-gl" + use osdmenu && myconf+=" --enable-menu" + use video_cards_nvidia && use vdpau || myconf+=" --disable-vdpau" + use video_cards_vesa || myconf+=" --disable-vesa" + use vidix || myconf+=" --disable-vidix --disable-vidix-pcidb" + use xscreensaver || myconf+=" --disable-xss" + use vaapi && myconf+=" --enable-vaapi" + + # GTK gmplayer gui + # Unsupported by Gentoo, upstream has dropped development + myconf+=" $(use_enable gmplayer gui)" + + if use xv; then + if use xvmc; then + myconf+=" --enable-xvmc --with-xvmclib=XvMCW" + else + myconf+=" --disable-xvmc" + fi + else + myconf+=" + --disable-xv + --disable-xvmc + " + use xvmc && elog "Disabling xvmc because it requires \"xv\" useflag enabled." + fi + else + myconf+=" + --disable-dga1 + --disable-dga2 + --disable-dxr3 + --disable-ggi + --disable-gl + --disable-vdpau + --disable-vidix + --disable-vidix-pcidb + --disable-xinerama + --disable-xss + --disable-xv + --disable-xvmc + " + uses="dga dxr3 ggi opengl osdmenu vdpau vidix xinerama xscreensaver xv" + for i in ${uses}; do + use ${i} && elog "Useflag \"${i}\" require \"X\" useflag enabled to work." + done + fi + + if [[ ${PV} == *9999* ]]; then + ################### + # External FFmpeg # + ################### + use external-ffmpeg && myconf+=" --disable-libavutil_a --disable-libavcodec_a --disable-libavformat_a --disable-libpostproc_a --disable-libswscale_a" + fi + + myconf="--cc=$(tc-getCC) \ + --host-cc=$(tc-getBUILD_CC) \ + --prefix=/usr \ + --confdir=/etc/mplayer \ + --datadir=/usr/share/mplayer \ + --libdir=/usr/$(get_libdir) \ + ${myconf}" + + CFLAGS="${CFLAGS}" ./configure ${myconf} || die "configure died" +} + +src_compile() { + base_src_compile + emake || die "Failed to build MPlayer!" + use doc && make -C DOCS/xml html-chunked +} + +src_install() { + local i + + emake prefix="${D}/usr" \ + BINDIR="${D}/usr/bin" \ + LIBDIR="${D}/usr/$(get_libdir)" \ + CONFDIR="${D}/etc/mplayer" \ + DATADIR="${D}/usr/share/mplayer" \ + MANDIR="${D}/usr/share/man" \ + INSTALLSTRIP="" \ + install || die "emake install failed" + + dodoc AUTHORS Changelog Copyright README etc/codecs.conf || die + + docinto tech/ + dodoc DOCS/tech/{*.txt,MAINTAINERS,mpsub.sub,playtree,TODO,wishlist} || die + docinto TOOLS/ + dodoc TOOLS/* || die + if use real; then + docinto tech/realcodecs/ + dodoc DOCS/tech/realcodecs/* || die + docinto TOOLS/realcodecs/ + dodoc TOOLS/realcodecs/* || die + fi + docinto tech/mirrors/ + dodoc DOCS/tech/mirrors/* || die + + if use doc; then + dohtml -r "${S}"/DOCS/HTML/* || die + fi + + # Install the default Skin and Gnome menu entry + if use gmplayer; then + dodir /usr/share/mplayer/skins + cp -r "${WORKDIR}/Blue" \ + "${D}/usr/share/mplayer/skins/default" || die "cp skins died" + + # Fix the symlink + rm -rf "${D}/usr/bin/gmplayer" + dosym mplayer /usr/bin/gmplayer + fi + + if ! use ass && ! use truetype; then + dodir /usr/share/mplayer/fonts + # Do this generic, as the mplayer people like to change the structure + # of their zips ... + for i in $(find "${WORKDIR}/" -type d -name 'font-arial-*'); do + cp -pPR "${i}" "${D}/usr/share/mplayer/fonts" + done + # Fix the font symlink ... + rm -rf "${D}/usr/share/mplayer/font" + dosym fonts/font-arial-14-iso-8859-1 /usr/share/mplayer/font + fi + + insinto /etc/mplayer + newins "${S}/etc/example.conf" mplayer.conf || die + doins "${S}/etc/input.conf" || die + if use osdmenu; then + doins "${S}/etc/menu.conf" || die + fi + + if use ass || use truetype; then + cat >> "${D}/etc/mplayer/mplayer.conf" << _EOF_ +fontconfig=1 +subfont-osd-scale=4 +subfont-text-scale=3 +_EOF_ + fi + + # bug 256203 + if use rar; then + cat >> "${D}/etc/mplayer/mplayer.conf" << _EOF_ +unrarexec=/usr/bin/unrar +_EOF_ + fi + + dosym ../../../etc/mplayer/mplayer.conf /usr/share/mplayer/mplayer.conf + newbin "${S}/TOOLS/midentify.sh" midentify || die +} + +pkg_preinst() { + [[ -d ${ROOT}/usr/share/mplayer/Skin/default ]] && \ + rm -rf "${ROOT}/usr/share/mplayer/Skin/default" +} + +pkg_postrm() { + # Cleanup stale symlinks + [ -L "${ROOT}/usr/share/mplayer/font" -a \ + ! -e "${ROOT}/usr/share/mplayer/font" ] && \ + rm -f "${ROOT}/usr/share/mplayer/font" + + [ -L "${ROOT}/usr/share/mplayer/subfont.ttf" -a \ + ! -e "${ROOT}/usr/share/mplayer/subfont.ttf" ] && \ + rm -f "${ROOT}/usr/share/mplayer/subfont.ttf" +} diff --git a/net-misc/mimms/Manifest b/net-misc/mimms/Manifest new file mode 100644 index 0000000..83f7ebf --- /dev/null +++ b/net-misc/mimms/Manifest @@ -0,0 +1,2 @@ +DIST mimms-3.2.1.tar.bz2 18224 RMD160 669d5d80ae9bd318bf98c032197fa6980622182e SHA1 279eee76dd4032cd2c1dddf1d49292a952c57b80 SHA256 92cd3e1800d8bd637268274196f6baec0d95aa8e709714093dd96ba8893c2354 +EBUILD mimms-3.2.1.ebuild 560 RMD160 cc60c30e0eccb128a9b8029cdc0680eee0084bfa SHA1 dc55dde5b493c3b9895b0fd373938c20b40fd7e6 SHA256 8abb64c05636a2c6c1884a4d3838ed8b89d7e4496026209db5d134157927d4e8 diff --git a/net-misc/mimms/mimms-3.2.1.ebuild b/net-misc/mimms/mimms-3.2.1.ebuild new file mode 100644 index 0000000..b54f45a --- /dev/null +++ b/net-misc/mimms/mimms-3.2.1.ebuild @@ -0,0 +1,25 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" +SUPPORT_PYTHON_ABIS="1" + +NEED_PYTHON="2.5" +inherit distutils + +DESCRIPTION="mms stream downloader that uses libmms" +HOMEPAGE="http://savannah.nongnu.org/projects/mimms/" +SRC_URI="http://savannah.nongnu.org/download/${PN}/${P}.tar.bz2" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +DEPEND="media-libs/libmms <dev-lang/python-3" +RDEPEND="${DEPEND}" + +RESTRICT_PYTHON_ABIS="3*" + +DOCS="AUTHORS NEWS README teststreams.list" diff --git a/net-misc/ndisc6/Manifest b/net-misc/ndisc6/Manifest new file mode 100644 index 0000000..be80868 --- /dev/null +++ b/net-misc/ndisc6/Manifest @@ -0,0 +1,2 @@ +DIST ndisc6-0.9.9.tar.bz2 233493 RMD160 19f9f9dbd5f072a57ccffe8acad2f3fb8a06eb87 SHA1 9abca715b07b5aab6aa95335aad1bffa4edc6916 SHA256 fbc5909f9509082bf235c040071b3c2ff9f58af48b4e39c4c6bf706690c9cc44 +EBUILD ndisc6-0.9.9.ebuild 710 RMD160 d57f6e4e2b0bbfd9449f4d0d33d5e3e181c2af74 SHA1 d48e417f421ca395a226eba62cfb0da1fc54f688 SHA256 a2b2642c46dddf0f554f94602158d33152f23af98a9edd2b929f2441ce8c2881 diff --git a/net-misc/ndisc6/ndisc6-0.9.9.ebuild b/net-misc/ndisc6/ndisc6-0.9.9.ebuild new file mode 100644 index 0000000..fd7a486 --- /dev/null +++ b/net-misc/ndisc6/ndisc6-0.9.9.ebuild @@ -0,0 +1,27 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header$ + +DESCRIPTION="Tools for IPv6 networking" +HOMEPAGE="http://www.remlab.net/ndisc6/" +SRC_URI="http://www.remlab.net/files/ndisc6/${P}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +DEPEND="dev-lang/perl sys-devel/gettext" + +src_compile() { + econf --localstatedir=/var || die "econf failed" + emake || die "emake failed" +} + +src_install() { + make DESTDIR="${D}" install || die "make install failed" + dodoc README ChangeLog NEWS AUTHORS INSTALL +# newinitd "${FILESDIR}"/rdnssd.rc rdnssd +# newconfd "${FILESDIR}"/rdnssd.conf rdnssd +# exeinto /etc/rdnssd +# doexe "${FILESDIR}"/resolvconf +} diff --git a/profiles/repo_name b/profiles/repo_name new file mode 100644 index 0000000..d125f84 --- /dev/null +++ b/profiles/repo_name @@ -0,0 +1 @@ +xhub diff --git a/sys-apps/v86d/Manifest b/sys-apps/v86d/Manifest new file mode 100644 index 0000000..b56bd4f --- /dev/null +++ b/sys-apps/v86d/Manifest @@ -0,0 +1,4 @@ +AUX v86d-0.1.9-915resolution.patch 27936 RMD160 69114c1f02a7fe98744df4361fc4f8850c766f7e SHA1 7df9358d5db2d2739b40026d765988d441673d8f SHA256 b08df989846d6647ad6040594c9891be38ca3c170e7229f37293e7415d5a2417 +AUX v86d-0.1.9-prot_write.patch 1020 RMD160 5cd1a337dbd5316e6ef1e7cb14c024f051bb3272 SHA1 fe63622120c164e5b95d37f347d234bfb5ed28a9 SHA256 faaf65c087887e1c78f6c8c92eed6fa89d87128d5cdff462fbb00081f0a3e4fb +DIST v86d-0.1.9.tar.bz2 69752 RMD160 e2d9cda4e8b40a5002c8448d1954a06c5fddb3bf SHA1 ca16ae61329847955ca65da3222131866703a02a SHA256 8167dec4ff919cfd73f854bbd3244f05c2b867e014fa8298044ea7cfd66d18a8 +EBUILD v86d-0.1.9.ebuild 1595 RMD160 98250c756f07939a6060648a1bec833179b6fd62 SHA1 f4b72891c046c9c939795dd3b2b6f402aa886f70 SHA256 5b1157c607b0f7d60afbde75339e7791b351522457e52020ec4b5d080236eedf diff --git a/sys-apps/v86d/files/v86d-0.1.9-915resolution.patch b/sys-apps/v86d/files/v86d-0.1.9-915resolution.patch new file mode 100644 index 0000000..9f8c16b --- /dev/null +++ b/sys-apps/v86d/files/v86d-0.1.9-915resolution.patch @@ -0,0 +1,1005 @@ +diff -Naur v86d-0.1.9.orig/915resolution.c v86d-0.1.9/915resolution.c +--- v86d-0.1.9.orig/915resolution.c 1970-01-01 01:00:00.000000000 +0100 ++++ v86d-0.1.9/915resolution.c 2008-10-04 15:53:23.155038024 +0200 +@@ -0,0 +1,964 @@ ++/* 915 resolution by steve tomljenovic ++ * ++ * This was tested only on Sony VGN-FS550. Use at your own risk ++ * ++ * This code is based on the techniques used in : ++ * ++ * - 855patch. Many thanks to Christian Zietz (czietz gmx net) ++ * for demonstrating how to shadow the VBIOS into system RAM ++ * and then modify it. ++ * ++ * - 1280patch by Andrew Tipton (andrewtipton null li). ++ * ++ * - 855resolution by Alain Poirier ++ * ++ * This source code is into the public domain. ++ */ ++ ++#include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> ++#define __USE_GNU ++#include <string.h> ++#include <sys/mman.h> ++#include <fcntl.h> ++ ++#if defined(__NetBSD__) ++#include <sys/types.h> ++#include <machine/sysarch.h> ++#include "bsd_io.h" ++#elif defined(__FreeBSD__) ++#include "bsd_io.h" ++#elif defined(linux) ++#include <sys/io.h> ++#endif ++ ++#include <unistd.h> ++#include <assert.h> ++ ++ ++ ++#define NEW(a) ((a *)(calloc(1, sizeof(a)))) ++#define FREE(a) (free(a)) ++ ++#define VBIOS_START 0xc0000 ++#define VBIOS_SIZE 0x10000 ++ ++#define VBIOS_FILE "/dev/mem" ++ ++#define FALSE 0 ++#define TRUE 1 ++ ++#define MODE_TABLE_OFFSET_845G 617 ++ ++#define VERSION "0.5.3" ++ ++#define ATI_SIGNATURE1 "ATI MOBILITY RADEON" ++#define ATI_SIGNATURE2 "ATI Technologies Inc" ++#define NVIDIA_SIGNATURE "NVIDIA Corp" ++#define INTEL_SIGNATURE "Intel Corp" ++ ++typedef unsigned char * address; ++typedef unsigned char byte; ++typedef unsigned short word; ++typedef unsigned char boolean; ++typedef unsigned int cardinal; ++ ++typedef enum { ++ CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, CT_915G, CT_915GM, CT_945G, CT_945GM, ++ CT_946GZ, CT_G965, CT_Q965, CT_965GM ++} chipset_type; ++ ++char * chipset_type_names[] = { ++ "UNKNOWN", "830", "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM", ++ "946GZ", "G965", "Q965", "965GM" ++}; ++ ++typedef enum { ++ BT_UNKWN, BT_1, BT_2, BT_3 ++} bios_type; ++ ++char * bios_type_names[] = {"UNKNOWN", "TYPE 1", "TYPE 2", "TYPE 3"}; ++ ++int freqs[] = { 60, 75, 85 }; ++ ++typedef struct { ++ byte mode; ++ byte bits_per_pixel; ++ word resolution; ++ byte unknown; ++} __attribute__((packed)) vbios_mode; ++ ++typedef struct { ++ byte unknow1[2]; ++ byte x1; ++ byte x_total; ++ byte x2; ++ byte y1; ++ byte y_total; ++ byte y2; ++} __attribute__((packed)) vbios_resolution_type1; ++ ++typedef struct { ++ unsigned long clock; ++ ++ word x1; ++ word htotal; ++ word x2; ++ word hblank; ++ word hsyncstart; ++ word hsyncend; ++ ++ word y1; ++ word vtotal; ++ word y2; ++ word vblank; ++ word vsyncstart; ++ word vsyncend; ++} __attribute__((packed)) vbios_modeline_type2; ++ ++typedef struct { ++ byte xchars; ++ byte ychars; ++ byte unknown[4]; ++ ++ vbios_modeline_type2 modelines[]; ++} __attribute__((packed)) vbios_resolution_type2; ++ ++typedef struct { ++ unsigned long clock; ++ ++ word x1; ++ word htotal; ++ word x2; ++ word hblank; ++ word hsyncstart; ++ word hsyncend; ++ ++ word y1; ++ word vtotal; ++ word y2; ++ word vblank; ++ word vsyncstart; ++ word vsyncend; ++ ++ word timing_h; ++ word timing_v; ++ ++ byte unknown[6]; ++} __attribute__((packed)) vbios_modeline_type3; ++ ++typedef struct { ++ unsigned char unknown[6]; ++ ++ vbios_modeline_type3 modelines[]; ++} __attribute__((packed)) vbios_resolution_type3; ++ ++ ++typedef struct { ++ cardinal chipset_id; ++ chipset_type chipset; ++ bios_type bios; ++ ++ int bios_fd; ++ address bios_ptr; ++ ++ vbios_mode * mode_table; ++ cardinal mode_table_size; ++ ++ byte b1, b2; ++ ++ boolean unlocked; ++} vbios_map; ++ ++ ++void initialize_system(char * filename) { ++ if (!filename) { ++#if defined(__FreeBSD__) ++ int iofd = open("/dev/io", O_RDONLY); ++ if (iofd == -1) { ++ perror("Unable to obtain the proper IO permissions"); ++ exit(2); ++ } ++#elif defined(__NetBSD__) ++ if (i386_iopl(3) < 0) { ++ perror("Unable to obtain the proper IO permissions"); ++ exit(2); ++ } ++#elif defined(linux) ++ if (iopl(3) < 0) { ++ perror("Unable to obtain the proper IO permissions"); ++ exit(2); ++ } ++#else ++#error Not ported to this operating system ++#endif ++ } ++} ++ ++cardinal get_chipset_id(void) { ++ outl(0x80000000, 0xcf8); ++ return inl(0xcfc); ++} ++ ++chipset_type get_chipset(cardinal id) { ++ chipset_type type; ++ ++ switch (id) { ++ case 0x35758086: ++ type = CT_830; ++ break; ++ ++ case 0x25608086: ++ type = CT_845G; ++ break; ++ ++ case 0x35808086: ++ type = CT_855GM; ++ break; ++ ++ case 0x25708086: ++ type = CT_865G; ++ break; ++ ++ case 0x25808086: ++ type = CT_915G; ++ break; ++ ++ case 0x25908086: ++ type = CT_915GM; ++ break; ++ ++ case 0x27708086: ++ type = CT_945G; ++ break; ++ ++ case 0x27a08086: ++ type = CT_945GM; ++ break; ++ ++ case 0x29708086: ++ type = CT_946GZ; ++ break; ++ ++ case 0x29a08086: ++ type = CT_G965; ++ break; ++ ++ case 0x29908086: ++ type = CT_Q965; ++ break; ++ ++ case 0x2a008086: ++ type = CT_965GM; ++ break; ++ ++ default: ++ type = CT_UNKWN; ++ break; ++ } ++ ++ return type; ++} ++ ++ ++vbios_resolution_type1 * map_type1_resolution(vbios_map * map, word res) { ++ vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); ++ return ptr; ++} ++ ++vbios_resolution_type2 * map_type2_resolution(vbios_map * map, word res) { ++ vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); ++ return ptr; ++} ++ ++vbios_resolution_type3 * map_type3_resolution(vbios_map * map, word res) { ++ vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); ++ return ptr; ++} ++ ++ ++boolean detect_bios_type(vbios_map * map, boolean modeline, int entry_size) { ++ int i; ++ short int r1, r2; ++ float f; ++ ++ r1 = r2 = 32000; ++ ++ for (i=0; i < map->mode_table_size; i++) { ++ if (map->mode_table[i].resolution <= r1) { ++ r1 = map->mode_table[i].resolution; ++ } ++ else { ++ if (map->mode_table[i].resolution <= r2) { ++ r2 = map->mode_table[i].resolution; ++ } ++ } ++ ++ /*printf("r1 = %d r2 = %d\n", r1, r2);*/ ++ } ++ ++ ++ f = ((float) (r2-r1-6)) / entry_size; ++ ++ return f == (int) f; ++} ++ ++ ++void close_vbios(vbios_map * map); ++ ++ ++vbios_map * open_vbios(char * filename, chipset_type forced_chipset) { ++ vbios_map * map = NEW(vbios_map); ++ ++ /* ++ * Determine chipset ++ */ ++ ++ if (!filename && forced_chipset == CT_UNKWN) { ++ map->chipset_id = get_chipset_id(); ++ ++ map->chipset = get_chipset(map->chipset_id); ++ } ++ else if (forced_chipset != CT_UNKWN) { ++ map->chipset = forced_chipset; ++ } ++ else { ++ map->chipset = CT_915GM; ++ } ++ ++ /* ++ * Map the video bios to memory ++ */ ++ ++ if (!filename) { ++ map->bios_fd = open(VBIOS_FILE, O_RDWR); ++ if(map->bios_fd < 0) { ++ if (map->chipset == CT_UNKWN) { ++ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id); ++ } ++ perror("Unable to open the BIOS file"); ++ exit(2); ++ } ++ ++ map->bios_ptr = mmap(0, VBIOS_SIZE, ++ PROT_READ | PROT_WRITE, MAP_SHARED, ++ map->bios_fd, VBIOS_START); ++ ++ if (map->bios_ptr == MAP_FAILED) { ++ if (map->chipset == CT_UNKWN) { ++ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id); ++ } ++ perror("Cannot mmap() the video BIOS\n"); ++ close(map->bios_fd); ++ exit(2); ++ } ++ } ++ else { ++ map->bios_fd = open(filename, O_RDWR); ++ if(map->bios_fd < 0) { ++ if (map->chipset == CT_UNKWN) { ++ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id); ++ } ++ perror("Unable to open the BIOS file"); ++ exit(2); ++ } ++ ++ map->bios_ptr = mmap(0, VBIOS_SIZE, ++ PROT_READ | PROT_WRITE, MAP_SHARED, ++ map->bios_fd, 0); ++ ++ if (map->bios_ptr == MAP_FAILED) { ++ if (map->chipset == CT_UNKWN) { ++ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id); ++ } ++ perror("Cannot mmap() the BIOS file\n"); ++ close(map->bios_fd); ++ exit(2); ++ } ++ } ++ ++ /* ++ * check if we have ATI Radeon ++ */ ++ ++ if (memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE1, strlen(ATI_SIGNATURE1)) || ++ memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE2, strlen(ATI_SIGNATURE2)) ) { ++ fprintf(stderr, "ATI chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n"); ++ close(map->bios_fd); ++ exit(2); ++ } ++ ++ /* ++ * check if we have NVIDIA ++ */ ++ ++ if (memmem(map->bios_ptr, VBIOS_SIZE, NVIDIA_SIGNATURE, strlen(NVIDIA_SIGNATURE))) { ++ fprintf(stderr, "NVIDIA chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n"); ++ close(map->bios_fd); ++ exit(2); ++ } ++ ++ /* ++ * check if we have Intel ++ */ ++ ++ if (map->chipset == CT_UNKWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) { ++ fprintf(stderr, "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n"); ++ ++ fprintf(stderr, "Chipset Id: %x\n", map->chipset_id); ++ ++ fprintf(stderr, "Please report this problem to stomljen@yahoo.com\n"); ++ ++ close_vbios(map); ++ exit(2); ++ } ++ ++ /* ++ * check for others ++ */ ++ ++ if (map->chipset == CT_UNKWN) { ++ fprintf(stderr, "Unknown chipset type and unrecognized bios.\n"); ++ fprintf(stderr, "915resolution only works with Intel 800/900 series graphic chipsets.\n"); ++ ++ fprintf(stderr, "Chipset Id: %x\n", map->chipset_id); ++ close_vbios(map); ++ exit(2); ++ } ++ ++ /* ++ * Figure out where the mode table is ++ */ ++ ++ { ++ address p = map->bios_ptr + 16; ++ address limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode)); ++ ++ while (p < limit && map->mode_table == 0) { ++ vbios_mode * mode_ptr = (vbios_mode *) p; ++ ++ if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) && ++ ((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30)) { ++ ++ map->mode_table = mode_ptr; ++ } ++ ++ p++; ++ } ++ ++ if (map->mode_table == 0) { ++ fprintf(stderr, "Unable to locate the mode table.\n"); ++ fprintf(stderr, "Please run the program 'dump_bios' as root and\n"); ++ fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n"); ++ ++ fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]); ++ close_vbios(map); ++ exit(2); ++ } ++ } ++ ++ /* ++ * Determine size of mode table ++ */ ++ ++ { ++ vbios_mode * mode_ptr = map->mode_table; ++ ++ while (mode_ptr->mode != 0xff) { ++ map->mode_table_size++; ++ mode_ptr++; ++ } ++ } ++ ++ /* ++ * Figure out what type of bios we have ++ * order of detection is important ++ */ ++ ++ if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) { ++ map->bios = BT_3; ++ } ++ else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) { ++ map->bios = BT_2; ++ } ++ else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) { ++ map->bios = BT_1; ++ } ++ else { ++ fprintf(stderr, "Unable to determine bios type.\n"); ++ fprintf(stderr, "Please run the program 'dump_bios' as root and\n"); ++ fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n"); ++ ++ fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]); ++ fprintf(stderr, "Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr)); ++ fprintf(stderr, "Mode Table Entries: %u\n", map->mode_table_size); ++ exit(2); ++ } ++ ++ return map; ++} ++ ++void close_vbios(vbios_map * map) { ++ assert(!map->unlocked); ++ ++ if(map->bios_ptr == MAP_FAILED) { ++ fprintf(stderr, "BIOS should be open already!\n"); ++ exit(2); ++ } ++ ++ munmap(map->bios_ptr, VBIOS_SIZE); ++ close(map->bios_fd); ++ ++ FREE(map); ++} ++ ++void unlock_vbios(vbios_map * map) { ++ ++ assert(!map->unlocked); ++ ++ map->unlocked = TRUE; ++ ++ switch (map->chipset) { ++ case CT_UNKWN: ++ break; ++ case CT_830: ++ case CT_855GM: ++ outl(0x8000005a, 0xcf8); ++ map->b1 = inb(0xcfe); ++ ++ outl(0x8000005a, 0xcf8); ++ outb(0x33, 0xcfe); ++ break; ++ case CT_845G: ++ case CT_865G: ++ case CT_915G: ++ case CT_915GM: ++ case CT_945G: ++ case CT_945GM: ++ case CT_946GZ: ++ case CT_G965: ++ case CT_Q965: ++ case CT_965GM: ++ outl(0x80000090, 0xcf8); ++ map->b1 = inb(0xcfd); ++ map->b2 = inb(0xcfe); ++ ++ outl(0x80000090, 0xcf8); ++ outb(0x33, 0xcfd); ++ outb(0x33, 0xcfe); ++ break; ++ } ++ ++#if DEBUG ++ { ++ cardinal t = inl(0xcfc); ++ printf("unlock PAM: (0x%08x)\n", t); ++ } ++#endif ++} ++ ++void relock_vbios(vbios_map * map) { ++ ++ assert(map->unlocked); ++ map->unlocked = FALSE; ++ ++ switch (map->chipset) { ++ case CT_UNKWN: ++ break; ++ case CT_830: ++ case CT_855GM: ++ outl(0x8000005a, 0xcf8); ++ outb(map->b1, 0xcfe); ++ break; ++ case CT_845G: ++ case CT_865G: ++ case CT_915G: ++ case CT_915GM: ++ case CT_945G: ++ case CT_945GM: ++ case CT_946GZ: ++ case CT_G965: ++ case CT_Q965: ++ case CT_965GM: ++ outl(0x80000090, 0xcf8); ++ outb(map->b1, 0xcfd); ++ outb(map->b2, 0xcfe); ++ break; ++ } ++ ++#if DEBUG ++ { ++ cardinal t = inl(0xcfc); ++ printf("relock PAM: (0x%08x)\n", t); ++ } ++#endif ++} ++ ++ ++void list_modes(vbios_map *map, cardinal raw) { ++ cardinal i, x, y; ++ ++ for (i=0; i < map->mode_table_size; i++) { ++ switch(map->bios) { ++ case BT_1: ++ { ++ vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution); ++ ++ x = ((((cardinal) res->x2) & 0xf0) << 4) | res->x1; ++ y = ((((cardinal) res->y2) & 0xf0) << 4) | res->y1; ++ ++ if (x != 0 && y != 0) { ++ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); ++ } ++ ++ if (raw) ++ { ++ printf("Mode %02x (raw) :\n\t%02x %02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n", map->mode_table[i].mode, res->unknow1[0],res->unknow1[1], res->x1,res->x_total,res->x2,res->y1,res->y_total,res->y2); ++ } ++ ++ } ++ break; ++ case BT_2: ++ { ++ vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution); ++ ++ x = res->modelines[0].x1+1; ++ y = res->modelines[0].y1+1; ++ ++ if (x != 0 && y != 0) { ++ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); ++ } ++ } ++ break; ++ case BT_3: ++ { ++ vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution); ++ ++ x = res->modelines[0].x1+1; ++ y = res->modelines[0].y1+1; ++ ++ if (x != 0 && y != 0) { ++ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel); ++ } ++ } ++ break; ++ case BT_UNKWN: ++ break; ++ } ++ } ++} ++ ++static void gtf_timings(int x, int y, int freq, ++ unsigned long *clock, ++ word *hsyncstart, word *hsyncend, word *hblank, ++ word *vsyncstart, word *vsyncend, word *vblank) ++{ ++ int hbl, vbl, vfreq; ++ ++ vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5; ++ vfreq = vbl * freq; ++ hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) / ++ (70.0 + 300000.0 / vfreq) / 16.0 + 0.5); ++ ++ *vsyncstart = y; ++ *vsyncend = y + 3; ++ *vblank = vbl - 1; ++ *hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1; ++ *hsyncend = x + hbl / 2 - 1; ++ *hblank = x + hbl - 1; ++ *clock = (x + hbl) * vfreq / 1000; ++} ++ ++void set_mode(vbios_map * map, cardinal mode, cardinal x, cardinal y, cardinal bp, cardinal htotal, cardinal vtotal) { ++ int xprev, yprev; ++ cardinal i, j; ++ ++ for (i=0; i < map->mode_table_size; i++) { ++ if (map->mode_table[i].mode == mode) { ++ switch(map->bios) { ++ case BT_1: ++ { ++ vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution); ++ ++ if (bp) { ++ map->mode_table[i].bits_per_pixel = bp; ++ } ++ ++ res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0); ++ res->x1 = (x & 0xff); ++ ++ res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0); ++ res->y1 = (y & 0xff); ++ if (htotal) ++ res->x_total = ((htotal-x) & 0xff); ++ ++ if (vtotal) ++ res->y_total = ((vtotal-y) & 0xff); ++ } ++ break; ++ case BT_2: ++ { ++ vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution); ++ ++ res->xchars = x / 8; ++ res->ychars = y / 16 - 1; ++ xprev = res->modelines[0].x1; ++ yprev = res->modelines[0].y1; ++ ++ for(j=0; j < 3; j++) { ++ vbios_modeline_type2 * modeline = &res->modelines[j]; ++ ++ if (modeline->x1 == xprev && modeline->y1 == yprev) { ++ modeline->x1 = modeline->x2 = x-1; ++ modeline->y1 = modeline->y2 = y-1; ++ ++ gtf_timings(x, y, freqs[j], &modeline->clock, ++ &modeline->hsyncstart, &modeline->hsyncend, ++ &modeline->hblank, &modeline->vsyncstart, ++ &modeline->vsyncend, &modeline->vblank); ++ ++ if (htotal) ++ modeline->htotal = htotal; ++ else ++ modeline->htotal = modeline->hblank; ++ ++ if (vtotal) ++ modeline->vtotal = vtotal; ++ else ++ modeline->vtotal = modeline->vblank; ++ } ++ } ++ } ++ break; ++ case BT_3: ++ { ++ vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution); ++ ++ xprev = res->modelines[0].x1; ++ yprev = res->modelines[0].y1; ++ ++ for (j=0; j < 3; j++) { ++ vbios_modeline_type3 * modeline = &res->modelines[j]; ++ ++ if (modeline->x1 == xprev && modeline->y1 == yprev) { ++ modeline->x1 = modeline->x2 = x-1; ++ modeline->y1 = modeline->y2 = y-1; ++ ++ gtf_timings(x, y, freqs[j], &modeline->clock, ++ &modeline->hsyncstart, &modeline->hsyncend, ++ &modeline->hblank, &modeline->vsyncstart, ++ &modeline->vsyncend, &modeline->vblank); ++ if (htotal) ++ modeline->htotal = htotal; ++ else ++ modeline->htotal = modeline->hblank; ++ if (vtotal) ++ modeline->vtotal = vtotal; ++ else ++ modeline->vtotal = modeline->vblank; ++ ++ modeline->timing_h = y-1; ++ modeline->timing_v = x-1; ++ } ++ } ++ } ++ break; ++ case BT_UNKWN: ++ break; ++ } ++ } ++ } ++} ++ ++void display_map_info(vbios_map * map) { ++ printf("Chipset: %s\n", chipset_type_names[map->chipset]); ++ printf("BIOS: %s\n", bios_type_names[map->bios]); ++ ++ printf("Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr)); ++ printf("Mode Table Entries: %u\n", map->mode_table_size); ++} ++ ++ ++int parse_args(int argc, char *argv[], char ** filename, chipset_type *forced_chipset, cardinal *list, cardinal *mode, cardinal *x, cardinal *y, cardinal *bp, cardinal *raw, cardinal *htotal, cardinal *vtotal) { ++ cardinal index = 1; ++ ++ *list = *mode = *x = *y = *raw = *htotal = *vtotal = 0; ++ ++ *forced_chipset = CT_UNKWN; ++ ++ *filename = NULL; ++ ++ if ((argc > index) && !strcmp(argv[index], "-f")) { ++ index++; ++ ++ if(argc<=index) { ++ return 0; ++ } ++ ++ *filename = argv[index]; ++ ++ index++; ++ ++ if(argc<=index) { ++ return 0; ++ } ++ } ++ ++ if ((argc > index) && !strcmp(argv[index], "-c")) { ++ index++; ++ ++ if(argc<=index) { ++ return 0; ++ } ++ ++ if (!strcmp(argv[index], "845")) { ++ *forced_chipset = CT_845G; ++ } ++ else if (!strcmp(argv[index], "855")) { ++ *forced_chipset = CT_855GM; ++ } ++ else if (!strcmp(argv[index], "865")) { ++ *forced_chipset = CT_865G; ++ } ++ else if (!strcmp(argv[index], "915G")) { ++ *forced_chipset = CT_915G; ++ } ++ else if (!strcmp(argv[index], "915GM")) { ++ *forced_chipset = CT_915GM; ++ } ++ else if (!strcmp(argv[index], "945G")) { ++ *forced_chipset = CT_945G; ++ } ++ else if (!strcmp(argv[index], "945GM")) { ++ *forced_chipset = CT_945GM; ++ } ++ else if (!strcmp(argv[index], "946GZ")) { ++ *forced_chipset = CT_946GZ; ++ } ++ else if (!strcmp(argv[index], "G965")) { ++ *forced_chipset = CT_G965; ++ } ++ else if (!strcmp(argv[index], "965GM")) { ++ *forced_chipset = CT_965GM; ++ } ++ else if (!strcmp(argv[index], "Q965")) { ++ *forced_chipset = CT_Q965; ++ } ++ else { ++ *forced_chipset = CT_UNKWN; ++ } ++ ++ index++; ++ ++ if (argc<=index) { ++ return 0; ++ } ++ } ++ ++ if ((argc > index) && !strcmp(argv[index], "-l")) { ++ *list = 1; ++ index++; ++ ++ if(argc<=index) { ++ return 0; ++ } ++ } ++ ++ if ((argc > index) && !strcmp(argv[index], "-r")) { ++ *raw = 1; ++ index++; ++ ++ if(argc<=index) { ++ return 0; ++ } ++ } ++ ++ if (argc-index < 3 || argc-index > 6) { ++ return -1; ++ } ++ ++ *mode = (cardinal) strtol(argv[index], NULL, 16); ++ *x = (cardinal)atoi(argv[index+1]); ++ *y = (cardinal)atoi(argv[index+2]); ++ ++ ++ if (argc-index > 3) { ++ *bp = (cardinal)atoi(argv[index+3]); ++ } ++ else { ++ *bp = 0; ++ } ++ ++ if (argc-index > 4) { ++ *htotal = (cardinal)atoi(argv[index+4]); ++ } ++ else { ++ *htotal = 0; ++ } ++ ++ if (argc-index > 5) { ++ *vtotal = (cardinal)atoi(argv[index+5]); ++ } ++ else { ++ *vtotal = 0; ++ } ++ ++ return 0; ++} ++ ++void usage(char *name) { ++ printf("Usage: %s [-f file] [-c chipset] [-l] [mode X Y] [bits/pixel] [htotal] [vtotal]\n", name); ++ printf(" Set the resolution to XxY for a video mode\n"); ++ printf(" Bits per pixel are optional. htotal/vtotal settings are additionally optional.\n"); ++ printf(" Options:\n"); ++ printf(" -f use an alternate file (THIS IS USED FOR DEBUG PURPOSES)\n"); ++ printf(" -c force chipset type (THIS IS USED FOR DEBUG PURPOSES)\n"); ++ printf(" -l display the modes found in the video BIOS\n"); ++ printf(" -r display the modes found in the video BIOS in raw mode (THIS IS USED FOR DEBUG PURPOSES)\n"); ++} ++ ++int main_915 (int argc, char *argv[]) { ++ vbios_map * map; ++ cardinal list, mode, x, y, bp, raw, htotal, vtotal; ++ char * filename; ++ chipset_type forced_chipset; ++ ++ printf("Intel 800/900 Series VBIOS Hack : version %s\n\n", VERSION); ++ ++ if (parse_args(argc, argv, &filename, &forced_chipset, &list, &mode, &x, &y, &bp, &raw, &htotal, &vtotal) == -1) { ++ usage(argv[0]); ++ return 2; ++ } ++ ++ initialize_system(filename); ++ ++ map = open_vbios(filename, forced_chipset); ++ display_map_info(map); ++ ++ printf("\n"); ++ ++ if (list) { ++ list_modes(map, raw); ++ } ++ ++ if (mode!=0 && x!=0 && y!=0) { ++ if (!filename) ++ unlock_vbios(map); ++ ++ set_mode(map, mode, x, y, bp, htotal, vtotal); ++ ++ if (!filename) ++ relock_vbios(map); ++ ++ printf("Patch mode %02x to resolution %dx%d complete\n", mode, x, y); ++ ++ if (list) { ++ list_modes(map, raw); ++ } ++ } ++ ++ close_vbios(map); ++ ++ return 0; ++} +diff -Naur v86d-0.1.9.orig/Makefile v86d-0.1.9/Makefile +--- v86d-0.1.9.orig/Makefile 2008-10-04 02:08:30.000000000 +0200 ++++ v86d-0.1.9/Makefile 2008-10-04 15:54:43.643008353 +0200 +@@ -16,7 +16,7 @@ + CFLAGS += -Ilibs/x86emu + LDFLAGS += -Llibs/x86emu + LDLIBS += -lx86emu +- V86OBJS = v86_x86emu.o v86_mem.o v86_common.o ++ V86OBJS = v86_x86emu.o v86_mem.o v86_common.o 915resolution.o + V86LIB = x86emu + else + CFLAGS += -Ilibs/lrmi-0.10 +diff -Naur v86d-0.1.9.orig/v86.c v86d-0.1.9/v86.c +--- v86d-0.1.9.orig/v86.c 2008-10-04 02:08:30.000000000 +0200 ++++ v86d-0.1.9/v86.c 2008-10-04 15:53:23.156037592 +0200 +@@ -63,6 +63,8 @@ + } + + ++int main_915(int argc, char *argv[]); ++ + int main(int argc, char *argv[]) + { + char buf[CONNECTOR_MAX_MSG_SIZE]; +@@ -71,6 +73,12 @@ + struct sockaddr_nl l_local; + struct cn_msg *data; + struct pollfd pfd; ++ char *args_915_1280[] = {"915resolution", "5a", "1280", "800", "32", 0}; ++ char *args_915_1440[] = {"915resolution", "5c", "1440", "900", "32", 0}; ++ ++ /* Hacking i915 bios */ ++ main_915(5, args_915_1280); ++ main_915(5, args_915_1440); + + s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); + if (s == -1) { diff --git a/sys-apps/v86d/files/v86d-0.1.9-prot_write.patch b/sys-apps/v86d/files/v86d-0.1.9-prot_write.patch new file mode 100644 index 0000000..109c1c7 --- /dev/null +++ b/sys-apps/v86d/files/v86d-0.1.9-prot_write.patch @@ -0,0 +1,28 @@ +diff --git a/v86_mem.c b/v86_mem.c +index 4cedbbe..23eb7c0 100644 +--- a/v86_mem.c ++++ b/v86_mem.c +@@ -293,7 +293,13 @@ int v86_mem_init(void) + } + vbios_size = tmp[2] * 0x200; + ulog(LOG_DEBUG, "VBIOS at %5x-%5x\n", VBIOS_BASE, VBIOS_BASE + vbios_size - 1); +- mem_vbios = map_file(NULL, vbios_size, PROT_READ, ++ ++ /* ++ * The Video BIOS and the System BIOS have to be mapped with PROT_WRITE. ++ * There is at least one case where mapping them without this flag causes ++ * a segfault during the emulation: https://bugs.gentoo.org/show_bug.cgi?id=245254 ++ */ ++ mem_vbios = map_file(NULL, vbios_size, PROT_READ | PROT_WRITE, + MAP_SHARED, "/dev/mem", VBIOS_BASE); + + if (!mem_vbios) { +@@ -303,7 +309,7 @@ int v86_mem_init(void) + } + + /* Map the system BIOS */ +- mem_sbios = map_file(NULL, SBIOS_SIZE, PROT_READ, ++ mem_sbios = map_file(NULL, SBIOS_SIZE, PROT_READ | PROT_WRITE, + MAP_SHARED, "/dev/mem", SBIOS_BASE); + if (!mem_sbios) { + ulog(LOG_ERR, "Failed to mmap the System BIOS as %5x.", SBIOS_BASE); diff --git a/sys-apps/v86d/v86d-0.1.9.ebuild b/sys-apps/v86d/v86d-0.1.9.ebuild new file mode 100644 index 0000000..c9c0299 --- /dev/null +++ b/sys-apps/v86d/v86d-0.1.9.ebuild @@ -0,0 +1,59 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/v86d/v86d-0.1.9.ebuild,v 1.4 2008/11/05 19:58:27 maekke Exp $ + +inherit eutils linux-info multilib + +DESCRIPTION="A daemon to run x86 code in an emulated environment." +HOMEPAGE="http://dev.gentoo.org/~spock/projects/uvesafb/" +SRC_URI="http://dev.gentoo.org/~spock/projects/uvesafb/archive/${P/_/-}.tar.bz2" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="debug x86emu 915resolution_hack" + +DEPEND="dev-libs/klibc" +RDEPEND="" + +S="${WORKDIR}/${P//_*/}" + +pkg_setup() { + if [ -z "$(grep V86D /usr/$(get_libdir)/klibc/include/linux/connector.h)" ]; then + eerror "You need to compile klibc against a kernel tree patched with uvesafb" + eerror "prior to merging this package." + die "Kernel not patched with uvesafb." + fi + linux-info_pkg_setup +} + +src_unpack() { + unpack ${A} + cd "${S}" + epatch "${FILESDIR}/${P}-prot_write.patch" + + # Dirty 915resolution hack if needed + # You may want to modify the patch to adapt it to your needs + if use 915resolution_hack; then + epatch ${FILESDIR}/${P}-915resolution.patch + fi +} + +src_compile() { + ./configure --with-klibc $(use_with debug) $(use_with x86emu) || die + emake KDIR="${KV_DIR}" || die +} + +src_install() { + emake DESTDIR="${D}" install || die + + dodoc README ChangeLog + + insinto /usr/share/${PN} + doins misc/initramfs +} + +pkg_postinst() { + elog "If you wish to place v86d into an initramfs image, you might want to use" + elog "'/usr/share/${PN}/initramfs' in your kernel's CONFIG_INITRAMFS_SOURCE." +} diff --git a/x11-libs/libva/Manifest b/x11-libs/libva/Manifest new file mode 100644 index 0000000..38a68c9 --- /dev/null +++ b/x11-libs/libva/Manifest @@ -0,0 +1,3 @@ +AUX libva-dont-install-tests.patch 1788 RMD160 809e40dfe12a44d5275d03a5c05219184883eede SHA1 9c6f3ceb678bfb5429977223611ab03db72f22fc SHA256 f12d72a4007b2c7eb6f18be852eda7f4ebfbcb320317281b35bf5473336f5973 +DIST libva_0.31.0-1+sds12.tar.gz 598771 RMD160 0dd0f9867de0f7f33cec987af867e9a80862a54c SHA1 8a74ebb1e46e3c42166cfb96cfb82ea1e3b9667c SHA256 7ebc2064a0ab5f369ef136d8a379136a65256169c99dc4122ebe7d88c1d24637 +EBUILD libva-0.31.0_p12.ebuild 1334 RMD160 3a2548bb3ac1f009b4e414b84e43ff1bf87e49f7 SHA1 9c67081bd9833034ede12c1cc20a856546b65059 SHA256 9dc5c78ba7f66e47ebbd0fb6d6ae332f9bb7fde5919da5d5e0323147f40acb9c diff --git a/x11-libs/libva/files/libva-dont-install-tests.patch b/x11-libs/libva/files/libva-dont-install-tests.patch new file mode 100644 index 0000000..43e4cba --- /dev/null +++ b/x11-libs/libva/files/libva-dont-install-tests.patch @@ -0,0 +1,47 @@ +Don't install some useeless tests programs + + +--- test/basic/Makefile.am~ 2010-02-12 09:42:10.000000000 -0500 ++++ test/basic/Makefile.am 2010-03-10 13:36:50.449834525 -0500 +@@ -20,7 +20,7 @@ + # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-bin_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \ ++check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \ + test_07 test_08 test_09 test_10 test_11 + + AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA +--- test/decode/Makefile.am~ 2010-02-12 09:42:10.000000000 -0500 ++++ test/decode/Makefile.am 2010-03-10 13:37:09.636843464 -0500 +@@ -20,7 +20,7 @@ + # 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 ++check_PROGRAMS = mpeg2vldemo + + AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + +--- test/encode/Makefile.am~ 2010-02-12 09:42:10.000000000 -0500 ++++ test/encode/Makefile.am 2010-03-10 13:37:26.701846294 -0500 +@@ -20,7 +20,7 @@ + # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-bin_PROGRAMS = h264encode ++check_PROGRAMS = h264encode + + AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + +--- test/putsurface/Makefile.am~ 2010-03-10 13:18:55.270697040 -0500 ++++ test/putsurface/Makefile.am 2010-03-10 13:38:08.106713556 -0500 +@@ -20,7 +20,7 @@ + # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-bin_PROGRAMS = putsurface ++check_PROGRAMS = putsurface + + AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + diff --git a/x11-libs/libva/libva-0.31.0_p12.ebuild b/x11-libs/libva/libva-0.31.0_p12.ebuild new file mode 100644 index 0000000..b0b6c17 --- /dev/null +++ b/x11-libs/libva/libva-0.31.0_p12.ebuild @@ -0,0 +1,62 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI="2" +inherit eutils autotools + +PLEVEL=${PV##*_p} +MY_PV=${PV/_p*} +MY_P=${PN}-${MY_PV} + +DESCRIPTION="Video Acceleration (VA) API for Linux" +HOMEPAGE="http://www.splitted-desktop.com/~gbeauchesne/libva/" +SRC_URI="http://www.splitted-desktop.com/~gbeauchesne/${PN}/${PN}_${MY_PV}-1+sds${PLEVEL}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" +IUSE="opengl" + +VIDEO_CARDS="intel dummy" +for x in ${VIDEO_CARDS}; do + IUSE+=" video_cards_${x}" +done + +DEPEND=">=x11-libs/libdrm-2.4 +x11-libs/libX11 +x11-libs/libXext +x11-libs/libXfixes +opengl? ( + virtual/opengl + x11-libs/libXdamage + x11-libs/libXxf86vm + ) +x11-libs/libXau +x11-libs/libXdmcp +x11-libs/libxcb" + +RDEPEND="$DEPEND +video_cards_intel? ( x11-drivers/xf86-video-intel )" + +S=${WORKDIR}/${MY_P} + +#RESTRICT="test" + +src_prepare() { + EPATCH_SOURCE="${S}/debian/patches" EPATCH_SUFFIX="patch" \ + EPATCH_FORCE="yes" EPATCH_OPTS="-g0 -E --no-backup-if-mismatch -p1" epatch + epatch "${FILESDIR}"/libva-dont-install-tests.patch + eautoreconf +} + +src_configure() { + econf \ + $(use_enable video_cards_dummy dummy-driver) \ + $(use_enable video_cards_intel i965-driver) \ + $(use_enable opengl glx) +} + +src_install() { + emake DESTDIR="${D}" install || die "make install failed" +} |